[easytag] Propagate double-click events on tree view headers



commit 3fbdffab187351818ec81cf7b7853b1b8f66c741
Author: David King <amigadave amigadave com>
Date:   Mon Oct 20 08:31:59 2014 +0100

    Propagate double-click events on tree view headers
    
    Receiving a double-click event on a tree view is not a good indicator of
    whether to change the selection, as the event could have occurred on the
    column headers, resulting in the header resizing and the selection
    changing simultaneously. Avoid the problem by checking that the
    double-click event is in the bin window, and ignoring (and propagating)
    it otherwise.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738830

 src/browser.c     |   17 ++++++++++++++++-
 src/cddb_dialog.c |   19 +++++++++++++++++--
 2 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/src/browser.c b/src/browser.c
index 9fe9c08..1d71e2f 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -2944,13 +2944,25 @@ on_file_tree_button_press_event (GtkWidget *widget,
     {
         /* Double left mouse click. Select files of the same directory (useful
          * when browsing sub-directories). */
+        GdkWindow *bin_window;
         GList *l;
         gchar *path_ref = NULL;
         gchar *patch_check = NULL;
         GtkTreePath *currentPath = NULL;
 
         if (!ETCore->ETFileDisplayed)
-            return FALSE;
+        {
+            return GDK_EVENT_PROPAGATE;
+        }
+
+        bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
+
+        if (bin_window != event->window)
+        {
+            /* If the double-click is not on a tree view row, for example when
+             * resizing a header column, ignore it. */
+            return GDK_EVENT_PROPAGATE;
+        }
 
         /* File taken as reference. */
         path_ref = g_path_get_dirname (((File_Name *)ETCore->ETFileDisplayed->FileNameCur->data)->value);
@@ -2982,6 +2994,8 @@ on_file_tree_button_press_event (GtkWidget *widget,
         {
             gtk_tree_path_free (currentPath);
         }
+
+        return GDK_EVENT_STOP;
     }
     else if (event->type == GDK_3BUTTON_PRESS
              && event->button == GDK_BUTTON_PRIMARY)
@@ -2989,6 +3003,7 @@ on_file_tree_button_press_event (GtkWidget *widget,
         /* Triple left mouse click, select all files of the list. */
         g_action_group_activate_action (G_ACTION_GROUP (MainWindow),
                                         "select-all", NULL);
+        return GDK_EVENT_STOP;
     }
 
     return GDK_EVENT_PROPAGATE;
diff --git a/src/cddb_dialog.c b/src/cddb_dialog.c
index 78e4ce3..31446d7 100644
--- a/src/cddb_dialog.c
+++ b/src/cddb_dialog.c
@@ -2620,16 +2620,31 @@ track_list_select_all (EtCDDBDialog *self)
 }
 
 static gboolean
-on_track_list_button_press_event (EtCDDBDialog *self, GdkEventButton *event)
+on_track_list_button_press_event (EtCDDBDialog *self,
+                                  GdkEventButton *event,
+                                  GtkTreeView *track_list_view)
 {
     if (event->type == GDK_2BUTTON_PRESS
         && event->button == GDK_BUTTON_PRIMARY)
     {
+        GdkWindow *bin_window;
+
+        bin_window = gtk_tree_view_get_bin_window (track_list_view);
+
+        if (bin_window != event->window)
+        {
+            /* Ignore the event if it is on the header (which is not the bin
+             * window. */
+            return GDK_EVENT_PROPAGATE;
+        }
+
         /* Double left mouse click */
         track_list_select_all (self);
+
+        return GDK_EVENT_STOP;
     }
 
-    return FALSE;
+    return GDK_EVENT_PROPAGATE;
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]