diff options
author | Corey Berla <corey@berla.me> | 2022-07-11 19:37:39 -0700 |
---|---|---|
committer | Corey Berla <corey@berla.me> | 2022-07-16 08:13:19 -0700 |
commit | aa1f6d50c4b620a92e6eb70dc446b451c9e3d80e (patch) | |
tree | 5ee6b898068142912ef57ed2946877711e3bc5a8 | |
parent | 802a33b3e7f5cffd267065add44325d92341b2c7 (diff) | |
download | nautilus-aa1f6d50c4b620a92e6eb70dc446b451c9e3d80e.tar.gz |
toolbar: Open new tab on back/forward middle click
Middle click should open a new tab. This is consistent with
the main view, sidebar, and pathbar. When opening the new tab
set the location preemptively to either one location forward or
back.
Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/1490
-rw-r--r-- | src/nautilus-toolbar.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c index 365cb4721..81af953eb 100644 --- a/src/nautilus-toolbar.c +++ b/src/nautilus-toolbar.c @@ -222,11 +222,31 @@ navigation_button_press_cb (GtkGestureClick *gesture, { NautilusToolbar *self; GtkWidget *widget; + guint button; self = NAUTILUS_TOOLBAR (user_data); + button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)); widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)); - show_menu (self, widget); + if (button == GDK_BUTTON_PRIMARY) + { + /* Don't do anything, primary click is handled through activate */ + gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED); + return; + } + else if (button == GDK_BUTTON_MIDDLE) + { + NautilusNavigationDirection direction; + + direction = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), + "nav-direction")); + + nautilus_window_back_or_forward_in_new_tab (self->window, direction); + } + else if (button == GDK_BUTTON_SECONDARY) + { + show_menu (self, widget); + } } static void @@ -837,13 +857,13 @@ nautilus_toolbar_constructed (GObject *object) controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ()); gtk_widget_add_controller (self->back_button, controller); - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), GDK_BUTTON_SECONDARY); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0); g_signal_connect (controller, "pressed", G_CALLBACK (navigation_button_press_cb), self); controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ()); gtk_widget_add_controller (self->forward_button, controller); - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), GDK_BUTTON_SECONDARY); + gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0); g_signal_connect (controller, "pressed", G_CALLBACK (navigation_button_press_cb), self); |