[nautilus/gnome-3-26] list-view: Fix middle-click behaviour



commit 455367f3b7927b12582a0759d616e34f969d4052
Author: George Mocanu <mocanu geo98 gmail com>
Date:   Sun Jun 3 15:31:12 2018 +0200

    list-view: Fix middle-click behaviour
    
    Currently, for double-click mode, middle-clicking a folder in
    List View fails to open a new tab, but only highlights the
    selection instead. Middle-clicking the folder again opens it
    in a new tab.
    
    For double-click mode, middle-clicking a folder should open it
    in a new tab. Also, middle-clicking a file should open it.
    
    This patch fixes this behaviour.
    
    Fixes https://gitlab.gnome.org/GNOME/nautilus/issues/453

 src/nautilus-list-view.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 9c168f97e..2a0dfcdbf 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -592,16 +592,9 @@ button_press_callback (GtkWidget      *widget,
                     nautilus_file_unref (file);
                 }
             }
-            else
+            else if ((event->button == GDK_BUTTON_PRIMARY || event->button == GDK_BUTTON_SECONDARY))
             {
-                if ((event->button == 1 || event->button == 3))
-                {
-                    activate_selected_items (view);
-                }
-                else if (event->button == 2)
-                {
-                    activate_selected_items_alternate (view, NULL, TRUE);
-                }
+                activate_selected_items (view);
             }
         }
         else
@@ -695,6 +688,19 @@ button_press_callback (GtkWidget      *widget,
         {
             do_popup_menu (widget, view, event);
         }
+
+        /* Don't open a new tab if we are in single click mode (this would open 2 tabs),
+         * or if CTRL or SHIFT is pressed.
+         */
+        if (event->button == GDK_BUTTON_MIDDLE &&
+            get_click_policy () != NAUTILUS_CLICK_POLICY_SINGLE &&
+            !button_event_modifies_selection (event))
+        {
+            gtk_tree_selection_unselect_all (selection);
+            gtk_tree_selection_select_path (selection, path);
+
+            activate_selected_items_alternate (view, NULL, TRUE);
+        }
     }
 
     gtk_tree_path_free (path);


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