[nautilus] list-view: Fix middle-click behaviour



commit db8a8d6c1633b1589973b7e6b8ed892ca1ac1315
Author: George Mocanu <mocanu geo98 gmail com>
Date:   Sun Jun 3 16:31:12 2018 +0300

    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 163afb0a0..767f0b260 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -697,16 +697,9 @@ on_tree_view_multi_press_gesture_pressed (GtkGestureMultiPress *gesture,
                     nautilus_file_unref (file);
                 }
             }
-            else
+            else if ((button == GDK_BUTTON_PRIMARY || button == GDK_BUTTON_SECONDARY))
             {
-                if ((button == GDK_BUTTON_PRIMARY || button == GDK_BUTTON_SECONDARY))
-                {
-                    activate_selected_items (view);
-                }
-                else if (button == GDK_BUTTON_MIDDLE)
-                {
-                    activate_selected_items_alternate (view, NULL, TRUE);
-                }
+                activate_selected_items (view);
             }
         }
         else
@@ -864,6 +857,19 @@ on_tree_view_multi_press_gesture_pressed (GtkGestureMultiPress *gesture,
             nautilus_files_view_pop_up_selection_context_menu (NAUTILUS_FILES_VIEW (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 (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_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);


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