Author: colossus
Date: 2007-02-09 14:38:53 +0000 (Fri, 09 Feb 2007)
New Revision: 24939
Modified:
xarchiver/trunk/src/archive.c
xarchiver/trunk/src/archive.h
xarchiver/trunk/src/interface.c
xarchiver/trunk/src/string_utils.c
xarchiver/trunk/src/string_utils.h
Log:
Implemented up navigation button in the toolbar.
Modified: xarchiver/trunk/src/archive.c
===================================================================
--- xarchiver/trunk/src/archive.c 2007-02-09 09:49:36 UTC (rev 24938)
+++ xarchiver/trunk/src/archive.c 2007-02-09 14:38:53 UTC (rev 24939)
@@ -378,7 +378,6 @@
{
GList *s = NULL;
XEntry *entry = NULL;
- gchar *location_path = NULL;
GtkTreeIter iter;
unsigned short int i;
gpointer current_column;
@@ -412,7 +411,8 @@
}
}
}
- gtk_entry_set_text(GTK_ENTRY(location_entry),"");
+ if (archive->location_entry_path == NULL)
+ gtk_entry_set_text(GTK_ENTRY(location_entry),"");
return;
}
else
@@ -421,10 +421,14 @@
if (entry == NULL || entry->child == NULL)
return;
- location_path = g_strconcat
(gtk_entry_get_text(GTK_ENTRY(location_entry)), entry->filename, "/", NULL);
- gtk_entry_set_text(GTK_ENTRY(location_entry),location_path);
- g_free (location_path);
+ gtk_widget_set_sensitive(up_button,TRUE);
+ if (archive->location_entry_path == NULL)
+ archive->location_entry_path = g_strconcat
(gtk_entry_get_text(GTK_ENTRY(location_entry)), entry->filename, "/", NULL);
+
gtk_entry_set_text(GTK_ENTRY(location_entry),archive->location_entry_path);
+ g_free (archive->location_entry_path);
+ archive->location_entry_path = NULL;
+
entry = entry->child;
}
gtk_list_store_clear(archive->liststore);
Modified: xarchiver/trunk/src/archive.h
===================================================================
--- xarchiver/trunk/src/archive.h 2007-02-09 09:49:36 UTC (rev 24938)
+++ xarchiver/trunk/src/archive.h 2007-02-09 14:38:53 UTC (rev 24939)
@@ -75,6 +75,7 @@
gchar *format;
gchar *extraction_path;
gchar *passwd;
+ gchar *location_entry_path;
GtkTreeModel *model;
GtkListStore *liststore;
GtkWidget *treeview;
Modified: xarchiver/trunk/src/interface.c
===================================================================
--- xarchiver/trunk/src/interface.c 2007-02-09 09:49:36 UTC (rev 24938)
+++ xarchiver/trunk/src/interface.c 2007-02-09 14:38:53 UTC (rev 24939)
@@ -309,6 +309,7 @@
tmp_image = gtk_image_new_from_stock ("gtk-go-up",
tmp_toolbar_icon_size);
gtk_widget_show (tmp_image);
up_button = (GtkWidget*) gtk_tool_button_new (tmp_image, _("Up"));
+ gtk_widget_set_sensitive(up_button,FALSE);
gtk_widget_show (up_button);
gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (up_button), FALSE);
gtk_container_add (GTK_CONTAINER (toolbar1), up_button);
@@ -916,6 +917,8 @@
gint current_page;
gint idx;
gchar *up = NULL;
+ gchar *path = NULL;
+ gchar *_path = NULL;
current_page = gtk_notebook_get_current_page (notebook);
idx = xa_find_archive_index (current_page);
@@ -924,13 +927,25 @@
{
/* Root */
case 0:
+ gtk_widget_set_sensitive (up_button,FALSE);
+ archive[idx]->location_entry_path = NULL;
xa_update_window_with_archive_entries(archive[idx],"/");
break;
/* Up */
case 2:
- //up = get_parent_dir
(gtk_entry_get_text(GTK_ENTRY(location_entry)) );
- g_message (up);
+ path =
g_strndup((gchar*)gtk_entry_get_text(GTK_ENTRY(location_entry)),
+
strlen(gtk_entry_get_text(GTK_ENTRY(location_entry)))-1);
+ up = xa_get_parent_dir (path);
+ if (*up == '/')
+ archive[idx]->location_entry_path = NULL;
+ else
+ {
+ _path = remove_level_from_path(path);
+ archive[idx]->location_entry_path = g_strconcat
(_path,"/",NULL);
+ }
+ g_free (_path);
+ g_free (path);
xa_update_window_with_archive_entries(archive[idx],up);
g_free (up);
break;
Modified: xarchiver/trunk/src/string_utils.c
===================================================================
--- xarchiver/trunk/src/string_utils.c 2007-02-09 09:49:36 UTC (rev 24938)
+++ xarchiver/trunk/src/string_utils.c 2007-02-09 14:38:53 UTC (rev 24939)
@@ -176,19 +176,21 @@
static int count_chars_to_escape (const char *str, const char *meta_chars)
{
- int meta_chars_n = strlen (meta_chars);
- const char *s;
- int n = 0;
+ int meta_chars_n = strlen (meta_chars);
+ const char *s;
+ int n = 0;
- for (s = str; *s != 0; s++) {
- int i;
- for (i = 0; i < meta_chars_n; i++)
- if (*s == meta_chars[i]) {
- n++;
- break;
- }
- }
- return n;
+ for (s = str; *s != 0; s++)
+ {
+ int i;
+ for (i = 0; i < meta_chars_n; i++)
+ if (*s == meta_chars[i])
+ {
+ n++;
+ break;
+ }
+ }
+ return n;
}
char *escape_str_common (const char *str, const char *meta_chars, const char
prefix, const char postfix)
{
@@ -272,6 +274,37 @@
return local_escaped_path;
}
+gchar *xa_get_parent_dir (gchar *current_dir)
+{
+ gchar *first_slash = NULL;
+ gchar *second_slash = NULL;
+ gchar *reverse = NULL;
+ gchar *retval = NULL;
+
+ reverse = g_strdup (current_dir);
+ g_strreverse (reverse);
+
+ first_slash = strchr(reverse,'/');
+ if (first_slash == NULL)
+ {
+ retval = g_strdup("/");
+ goto here;
+ }
+ first_slash++;
+ second_slash = strchr(first_slash,'/');
+
+ if (second_slash == NULL)
+ retval = g_strdup(first_slash);
+ else
+ retval = g_strndup(first_slash, (second_slash - first_slash) );
+
+ g_free (reverse);
+ g_strreverse(retval);
+
+here:
+ return retval;
+}
+
void xa_set_window_title ( GtkWidget *window , gchar *title)
{
gchar *x = NULL;
Modified: xarchiver/trunk/src/string_utils.h
===================================================================
--- xarchiver/trunk/src/string_utils.h 2007-02-09 09:49:36 UTC (rev 24938)
+++ xarchiver/trunk/src/string_utils.h 2007-02-09 14:38:53 UTC (rev 24939)
@@ -37,6 +37,7 @@
char **split_line (char *line,int n_fields);
char *escape_str_common (const char *str, const char *meta_chars, const char
prefix, const char postfix);
char *eat_spaces (char *line);
+gchar *xa_get_parent_dir (gchar *current_dir);
gchar *remove_level_from_path (const gchar *path);
gboolean file_extension_is (const char *filename, const char *ext);
gchar *extract_local_path (gchar *path);
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits