From 4713ff66ff81a9da50324081d74a8edd6d402952 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 30 Apr 2004 17:52:19 +0000 Subject: If the row the cursor is hovering over has children and is not expanded 2004-04-30 Jeffrey Stedfast * em-folder-tree.c (tree_drag_motion): If the row the cursor is hovering over has children and is not expanded already, setup a timer to auto-expand it if the user hovers there long enough. (tree_autoexpand): Callback to expand the row. (tree_drag_leave): Disconnect the timer. (tree_drag_drop): Same. (em_folder_tree_destroy): Same. svn path=/trunk/; revision=25718 --- mail/ChangeLog | 10 ++++++++ mail/em-folder-tree.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index bbb3bb1fcd..823be6a2bd 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,13 @@ +2004-04-30 Jeffrey Stedfast + + * em-folder-tree.c (tree_drag_motion): If the row the cursor is + hovering over has children and is not expanded already, setup a + timer to auto-expand it if the user hovers there long enough. + (tree_autoexpand): Callback to expand the row. + (tree_drag_leave): Disconnect the timer. + (tree_drag_drop): Same. + (em_folder_tree_destroy): Same. + 2004-04-30 Enver ALTIN * evolution-mail.schemas.in.in: Fixed a type-o. diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 56d457a725..714329327e 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -88,6 +88,8 @@ struct _EMFolderTreePrivate { guint save_state_id; guint autoscroll_id; + guint autoexpand_id; + GtkTreeRowReference *autoexpand_row; guint loading_row_id; guint loaded_row_id; @@ -400,6 +402,14 @@ em_folder_tree_destroy (GtkObject *obj) priv->autoscroll_id = 0; } + if (priv->autoexpand_id != 0) { + gtk_tree_row_reference_free (priv->autoexpand_row); + priv->autoexpand_row = NULL; + + g_source_remove (priv->autoexpand_id); + priv->autoexpand_id = 0; + } + priv->treeview = NULL; priv->model = NULL; @@ -1286,6 +1296,14 @@ tree_drag_drop (GtkWidget *widget, GdkDragContext *context, int x, int y, guint priv->autoscroll_id = 0; } + if (priv->autoexpand_id != 0) { + gtk_tree_row_reference_free (priv->autoexpand_row); + priv->autoexpand_row = NULL; + + g_source_remove (priv->autoexpand_id); + priv->autoexpand_id = 0; + } + if (!gtk_tree_view_get_path_at_pos (priv->treeview, x, y, &path, &column, &cell_x, &cell_y)) return FALSE; @@ -1320,6 +1338,14 @@ tree_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, EMFolde priv->autoscroll_id = 0; } + if (priv->autoexpand_id != 0) { + gtk_tree_row_reference_free (priv->autoexpand_row); + priv->autoexpand_row = NULL; + + g_source_remove (priv->autoexpand_id); + priv->autoexpand_id = 0; + } + gtk_tree_view_set_drag_dest_row(emft->priv->treeview, NULL, GTK_TREE_VIEW_DROP_BEFORE); } @@ -1361,6 +1387,19 @@ tree_autoscroll (EMFolderTree *emft) return TRUE; } +static gboolean +tree_autoexpand (EMFolderTree *emft) +{ + struct _EMFolderTreePrivate *priv = emft->priv; + GtkTreePath *path; + + path = gtk_tree_row_reference_get_path (priv->autoexpand_row); + gtk_tree_view_expand_row (priv->treeview, path, FALSE); + gtk_tree_path_free (path); + + return TRUE; +} + static gboolean tree_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y, guint time, EMFolderTree *emft) { @@ -1368,6 +1407,7 @@ tree_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y, guin GtkTreeViewDropPosition pos; GdkDragAction action = 0; GtkTreePath *path; + GtkTreeIter iter; GdkAtom target; int i; @@ -1377,6 +1417,34 @@ tree_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y, guin if (priv->autoscroll_id == 0) priv->autoscroll_id = g_timeout_add (150, (GSourceFunc) tree_autoscroll, emft); + gtk_tree_model_get_iter (priv->model, &iter, path); + + if (gtk_tree_model_iter_has_child (priv->model, &iter) && !gtk_tree_view_row_expanded (priv->treeview, path)) { + if (priv->autoexpand_id != 0) { + GtkTreePath *autoexpand_path; + + autoexpand_path = gtk_tree_row_reference_get_path (priv->autoexpand_row); + if (gtk_tree_path_compare (autoexpand_path, path) != 0) { + /* row changed, restart timer */ + gtk_tree_row_reference_free (priv->autoexpand_row); + priv->autoexpand_row = gtk_tree_row_reference_new (priv->model, path); + g_source_remove (priv->autoexpand_id); + priv->autoexpand_id = g_timeout_add (600, (GSourceFunc) tree_autoexpand, emft); + } + + gtk_tree_path_free (autoexpand_path); + } else { + priv->autoexpand_id = g_timeout_add (600, (GSourceFunc) tree_autoexpand, emft); + priv->autoexpand_row = gtk_tree_row_reference_new (priv->model, path); + } + } else if (priv->autoexpand_id != 0) { + gtk_tree_row_reference_free (priv->autoexpand_row); + priv->autoexpand_row = NULL; + + g_source_remove (priv->autoexpand_id); + priv->autoexpand_id = 0; + } + target = emft_drop_target(emft, context, path); if (target != GDK_NONE) { for (i=0; i