From dfc790ac4e03f0e56918cab67d24f7439d51f484 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Mon, 13 Sep 1999 23:27:18 +0000 Subject: [PATCH] 1999-09-13 Federico Mena Quintero * gtkdtree.c (scan_subtree): Do not set the current path here, just load the subtree. (gtk_dtree_get_row_path): Removed the column argument, since it was never used. (scan_subtree): Added a path argument that can be calculated upstream. (gtk_dtree_expand): Compute the path for scan_subtree(). (gtk_dtree_select_row): Compute the path for scan_subtree(), and set the tree's current path here. This is the right thing; setting the current path is completely orthogonal from scanning a subtree. --- gnome/ChangeLog | 12 +++++++++++ gnome/gscreen.c | 4 ++-- gnome/gtkdtree.c | 54 ++++++++++++++++++++++++++++++------------------ gnome/gtkdtree.h | 4 +--- 4 files changed, 49 insertions(+), 25 deletions(-) diff --git a/gnome/ChangeLog b/gnome/ChangeLog index d1bebdea8..68656e961 100644 --- a/gnome/ChangeLog +++ b/gnome/ChangeLog @@ -1,5 +1,17 @@ 1999-09-13 Federico Mena Quintero + * gtkdtree.c (scan_subtree): Do not set the current path here, + just load the subtree. + (gtk_dtree_get_row_path): Removed the column argument, since it + was never used. + (scan_subtree): Added a path argument that can be calculated + upstream. + (gtk_dtree_expand): Compute the path for scan_subtree(). + (gtk_dtree_select_row): Compute the path for scan_subtree(), and + set the tree's current path here. This is the right thing; + setting the current path is completely orthogonal from scanning a + subtree. + * gtkdtree.c (gtk_dtree_class_init): Sigh. Create a new signal, called "possibly_ungrab", used to request the client to ungrab the mouse at the proper time. This is required because the stupid diff --git a/gnome/gscreen.c b/gnome/gscreen.c index b7a708b26..01f2ed061 100644 --- a/gnome/gscreen.c +++ b/gnome/gscreen.c @@ -893,7 +893,7 @@ panel_tree_drag_data_received (GtkWidget *widget, if (!node) return; - path = gtk_dtree_get_row_path (dtree, node, 0); + path = gtk_dtree_get_row_path (dtree, node); fe = file_entry_from_file (path); if (!fe) { g_free (path); @@ -2044,7 +2044,7 @@ panel_tree_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y if (on_row) { node = gtk_ctree_node_nth (GTK_CTREE (dtree), row); - row_path = gtk_dtree_get_row_path (dtree, node, 0); + row_path = gtk_dtree_get_row_path (dtree, node); if (row != panel->drag_tree_row) { /* Highlight the row by selecting it */ diff --git a/gnome/gtkdtree.c b/gnome/gtkdtree.c index dd7533d42..135c083c5 100644 --- a/gnome/gtkdtree.c +++ b/gnome/gtkdtree.c @@ -20,6 +20,8 @@ #include "gtkdtree.h" #include "../vfs/vfs.h" +#define FREEZE + #ifdef HACK # define mc_opendir opendir # define mc_closedir closedir @@ -42,7 +44,7 @@ enum { static guint gtk_dtree_signals[LAST_SIGNAL] = { 0 }; char * -gtk_dtree_get_row_path (GtkDTree *dtree, GtkCTreeNode *row, gint column) +gtk_dtree_get_row_path (GtkDTree *dtree, GtkCTreeNode *row) { char *node_text, *path; @@ -56,7 +58,7 @@ gtk_dtree_get_row_path (GtkDTree *dtree, GtkCTreeNode *row, gint column) int val; val = gtk_ctree_node_get_pixtext ( - GTK_CTREE (dtree), row, column, + GTK_CTREE (dtree), row, 0, &node_text, NULL, NULL, NULL); if (!val) @@ -191,7 +193,9 @@ static void scan_begin (GtkDTree *dtree) { if (++dtree->scan_level == 1) { +#ifdef FREEZE gtk_clist_freeze (GTK_CLIST (dtree)); +#endif gtk_signal_emit (GTK_OBJECT (dtree), gtk_dtree_signals[SCAN_BEGIN]); } } @@ -203,36 +207,30 @@ scan_end (GtkDTree *dtree) if (--dtree->scan_level == 0) { gtk_signal_emit (GTK_OBJECT (dtree), gtk_dtree_signals[SCAN_END]); +#ifdef FREEZE gtk_clist_thaw (GTK_CLIST (dtree)); +#endif } } /* Scans a subdirectory in the tree */ static void -scan_subtree (GtkDTree *dtree, GtkCTreeNode *row) +scan_subtree (GtkDTree *dtree, GtkCTreeNode *row, char *path) { - char *path; - dtree->loading_dir++; - scan_begin (dtree); - path = gtk_dtree_get_row_path (dtree, row, 0); - - if (dtree->current_path) - g_free (dtree->current_path); - - dtree->current_path = path; gtk_dtree_load_path (dtree, path, row, 1); - dtree->loading_dir--; scan_end (dtree); + dtree->loading_dir--; } static void gtk_dtree_select_row (GtkCTree *ctree, GtkCTreeNode *row, gint column) { GtkDTree *dtree; + char *path; dtree = GTK_DTREE (ctree); @@ -241,7 +239,8 @@ gtk_dtree_select_row (GtkCTree *ctree, GtkCTreeNode *row, gint column) /* Ask for someone to ungrab the mouse, as the stupid clist grabs it on * button press. We cannot do it unconditionally because we don't want - * to knock off a DnD grab. + * to knock off a DnD grab. We cannot do it in a button_press handler, + * either, because the row is selected *inside* the default handler. */ gtk_signal_emit (GTK_OBJECT (dtree), gtk_dtree_signals[POSSIBLY_UNGRAB], NULL); @@ -256,11 +255,19 @@ gtk_dtree_select_row (GtkCTree *ctree, GtkCTreeNode *row, gint column) dtree->last_node = row; - scan_subtree (dtree, row); + /* Set the new current path */ + + path = gtk_dtree_get_row_path (dtree, row); + + if (dtree->current_path) + g_free (dtree->current_path); + + dtree->current_path = path; + + scan_subtree (dtree, row, path); if (!dtree->internal) - gtk_signal_emit (GTK_OBJECT (dtree), gtk_dtree_signals[DIRECTORY_CHANGED], - dtree->current_path); + gtk_signal_emit (GTK_OBJECT (dtree), gtk_dtree_signals[DIRECTORY_CHANGED], path); scan_end (dtree); } @@ -306,7 +313,7 @@ gtk_dtree_do_select_dir (GtkDTree *dtree, char *path) if (dtree->current_path && (strcmp (path, dtree->current_path) == 0)) return TRUE; - s = alloca (strlen (path)+1); + s = alloca (strlen (path) + 1); strcpy (s, path); current_node = dtree->root_node; @@ -429,12 +436,18 @@ static void gtk_dtree_expand (GtkCTree *ctree, GtkCTreeNode *node) { GtkDTree *dtree; + char *path; dtree = GTK_DTREE (ctree); scan_begin (dtree); + (* parent_class->tree_expand) (ctree, node); - scan_subtree (dtree, node); + + path = gtk_dtree_get_row_path (dtree, node); + scan_subtree (dtree, node, path); + g_free (path); + scan_end (dtree); } @@ -548,10 +561,12 @@ tree_set_freeze (int state, void *data) { GtkDTree *dtree = GTK_DTREE (data); +#ifdef FREEZE if (state) gtk_clist_freeze (GTK_CLIST (dtree)); else gtk_clist_thaw (GTK_CLIST (dtree)); +#endif } static void @@ -660,7 +675,6 @@ gtk_dtree_load_root_tree (GtkDTree *dtree) /* Select root node */ gtk_ctree_select (GTK_CTREE (dtree), dtree->root_node); - gtk_clist_thaw (GTK_CLIST (dtree)); } diff --git a/gnome/gtkdtree.h b/gnome/gtkdtree.h index 2bc993e14..9cef9e18f 100644 --- a/gnome/gtkdtree.h +++ b/gnome/gtkdtree.h @@ -51,9 +51,7 @@ guint gtk_dtree_get_type (void); GtkWidget *gtk_dtree_new (void); gboolean gtk_dtree_select_dir (GtkDTree *dtree, char *directory); -char *gtk_dtree_get_row_path (GtkDTree *ctree, - GtkCTreeNode *row, - gint column); +char *gtk_dtree_get_row_path (GtkDTree *ctree, GtkCTreeNode *row); void gtk_dtree_construct (GtkDTree *dtree); gboolean gtk_dtree_is_ancestor (GtkDTree *dtree, GtkCTreeNode *node, GtkCTreeNode *child);