Author: colossus Date: 2007-10-20 17:22:23 +0000 (Sat, 20 Oct 2007) New Revision: 26156
Modified: xarchiver/trunk/src/archive.c xarchiver/trunk/src/archive.h xarchiver/trunk/src/interface.c xarchiver/trunk/src/window.c Log: Fixed behaviour of up and home buttons. Modified: xarchiver/trunk/src/archive.c =================================================================== --- xarchiver/trunk/src/archive.c 2007-10-20 16:47:57 UTC (rev 26155) +++ xarchiver/trunk/src/archive.c 2007-10-20 17:22:23 UTC (rev 26156) @@ -450,6 +450,8 @@ { entry = archive->root_entry->child; gtk_entry_set_text(GTK_ENTRY(location_entry),"\0"); + gtk_widget_set_sensitive(up_button,FALSE); + gtk_widget_set_sensitive(home_button,FALSE); } else if (entry->child == NULL) return; @@ -508,6 +510,23 @@ } } +XEntry* xa_find_entry_from_path (XEntry *root_entry,const gchar *fullpathname) +{ + gchar **components = NULL; + unsigned short int x = 0; + XEntry *new_entry = NULL; + + components = g_strsplit(fullpathname,"/",-1); + while (components[x] && strlen(components[x]) > 0) + { + new_entry = xa_find_child_entry(root_entry->child,components[x]); + root_entry = new_entry; + x++; + } + g_strfreev(components); + return new_entry; +} + gchar *xa_build_full_path_name_from_entry(XEntry *entry) { GString *dummy = g_string_new('\0'); Modified: xarchiver/trunk/src/archive.h =================================================================== --- xarchiver/trunk/src/archive.h 2007-10-20 16:47:57 UTC (rev 26155) +++ xarchiver/trunk/src/archive.h 2007-10-20 17:22:23 UTC (rev 26156) @@ -130,6 +130,7 @@ XEntry *xa_set_archive_entries_for_each_row (XArchive *archive,gchar *filename,gboolean encrypted,gpointer *items); gpointer *xa_fill_archive_entry_columns_for_each_row (XArchive *archive,XEntry *entry,gpointer *items); void xa_update_window_with_archive_entries (XArchive *archive,XEntry *entry); +XEntry* xa_find_entry_from_path (XEntry *root_entry,const gchar *fullpathname); gchar *xa_build_full_path_name_from_entry(XEntry *entry); void xa_entries_to_filelist(XEntry *, GSList **, gchar *); void xa_destroy_filelist(GSList *file_list); Modified: xarchiver/trunk/src/interface.c =================================================================== --- xarchiver/trunk/src/interface.c 2007-10-20 16:47:57 UTC (rev 26155) +++ xarchiver/trunk/src/interface.c 2007-10-20 17:22:23 UTC (rev 26156) @@ -296,7 +296,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,TRUE); + 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); @@ -902,13 +902,10 @@ unsigned short int bp = GPOINTER_TO_UINT(user_data); gint current_page; gint idx; - gchar **components = NULL; - unsigned short int x = 0; XEntry *new_entry = NULL; current_page = gtk_notebook_get_current_page (notebook); idx = xa_find_archive_index (current_page); - XEntry *last_entry = archive[idx]->root_entry; switch (bp) { @@ -919,20 +916,12 @@ g_free(archive[idx]->location_entry_path); archive[idx]->location_entry_path = NULL; } - archive[idx]->location_entry_path = NULL; xa_update_window_with_archive_entries(archive[idx],NULL); break; /* Up */ case 2: - components = g_strsplit(gtk_entry_get_text(GTK_ENTRY(location_entry)),"/",-1); - while (components[x] && strlen(components[x]) > 0) - { - new_entry = xa_find_child_entry(last_entry->child,components[x]); - last_entry = new_entry; - x++; - } - g_strfreev(components); + new_entry = xa_find_entry_from_path(archive[idx]->root_entry,gtk_entry_get_text(GTK_ENTRY(location_entry))); if (new_entry->prev->prev == NULL) { xa_update_window_with_archive_entries(archive[idx],NULL); Modified: xarchiver/trunk/src/window.c =================================================================== --- xarchiver/trunk/src/window.c 2007-10-20 16:47:57 UTC (rev 26155) +++ xarchiver/trunk/src/window.c 2007-10-20 17:22:23 UTC (rev 26156) @@ -176,7 +176,6 @@ gtk_widget_set_sensitive ( password_entry , TRUE); } xa_set_button_state (1,1,1,archive->can_add,archive->can_extract,archive->has_sfx,archive->has_test,archive->has_properties); - gtk_widget_set_sensitive(home_button,TRUE); Update_StatusBar ( _("Operation completed.")); if (archive->status == XA_ARCHIVESTATUS_TEST) @@ -2021,16 +2020,19 @@ void xa_location_entry_activated (GtkEntry *entry, gpointer user_data) { - gchar *parent = NULL; + XEntry *new_entry = NULL; gint current_page; gint idx; - parent = xa_get_parent_dir (gtk_entry_get_text(entry)); - current_page = gtk_notebook_get_current_page(notebook); + current_page = gtk_notebook_get_current_page (notebook); idx = xa_find_archive_index (current_page); - g_print ("parent: %s\t loc.entry: %s\n",parent,archive[idx]->location_entry_path); - //xa_update_window_with_archive_entries(archive[idx],parent); - g_free (parent); + new_entry = xa_find_entry_from_path(archive[idx]->root_entry,gtk_entry_get_text(GTK_ENTRY(location_entry))); + xa_update_window_with_archive_entries(archive[idx],new_entry); + if (new_entry != NULL && new_entry->prev != NULL) + { + gtk_widget_set_sensitive(up_button,TRUE); + gtk_widget_set_sensitive(home_button,TRUE); + } } void xa_treeview_row_activated(GtkTreeView *tree_view,GtkTreePath *path,GtkTreeViewColumn *column,gpointer user_data) @@ -2047,5 +2049,10 @@ return; gtk_tree_model_get (GTK_TREE_MODEL (archive[idx]->liststore),&iter,archive[idx]->nc+1,&entry, -1); + if (entry->is_dir) + { + gtk_widget_set_sensitive(up_button,TRUE); + gtk_widget_set_sensitive(home_button,TRUE); + } xa_update_window_with_archive_entries(archive[idx],entry); } _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits