From b8ab8514c33f6e01465d37ebde4097461fc42d4d Mon Sep 17 00:00:00 2001 From: Ernestas Kulik Date: Wed, 20 Jun 2018 16:59:35 +0300 Subject: window-slot: Stop using flags parameter for history navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The feature that allows opening a new window from the history popup menu by middle-clicking hasn’t been working for three years, since the flags parameter in nautilus_window_back_or_forward() is not honored. In some places it’s used inappropriately, so it’s better to just drop the code and rethink the approach if such a feature is desirable. --- src/nautilus-toolbar.c | 2 +- src/nautilus-window-slot.c | 46 ++++++++++++++++------------------------------ src/nautilus-window.c | 38 ++++++-------------------------------- src/nautilus-window.h | 4 +--- 4 files changed, 24 insertions(+), 66 deletions(-) diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c index 7b1fa07f2..acc1ea485 100644 --- a/src/nautilus-toolbar.c +++ b/src/nautilus-toolbar.c @@ -171,7 +171,7 @@ activate_back_or_forward_menu_item (GtkMenuItem *menu_item, index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "user_data")); - nautilus_window_back_or_forward (window, back, index, nautilus_event_get_window_open_flags ()); + nautilus_window_back_or_forward (window, back, index); } static void diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index 505d1782f..17ed6e164 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -2283,27 +2283,26 @@ nautilus_window_slot_set_content_view (NautilusWindowSlot *self, } void -nautilus_window_back_or_forward (NautilusWindow *window, - gboolean back, - guint distance, - NautilusWindowOpenFlags flags) +nautilus_window_back_or_forward (NautilusWindow *window, + gboolean back, + guint distance) { NautilusWindowSlot *self; + NautilusWindowSlotPrivate *priv; GList *list; - GFile *location; guint len; NautilusBookmark *bookmark; + g_autoptr (GFile) location = NULL; GFile *old_location; - NautilusWindowSlotPrivate *priv; + g_autofree char *scroll_pos = NULL; self = nautilus_window_get_active_slot (window); priv = nautilus_window_slot_get_instance_private (self); list = back ? priv->back_list : priv->forward_list; - - len = (guint) g_list_length (list); + len = g_list_length (list); /* If we can't move in the direction at all, just return. */ - if (len == 0) + if (list == NULL) { return; } @@ -2317,28 +2316,15 @@ nautilus_window_back_or_forward (NautilusWindow *window, bookmark = g_list_nth_data (list, distance); location = nautilus_bookmark_get_location (bookmark); + old_location = nautilus_window_slot_get_location (self); + scroll_pos = nautilus_bookmark_get_scroll_pos (bookmark); - if (flags != 0) - { - nautilus_window_slot_open_location_full (self, location, flags, NULL); - } - else - { - char *scroll_pos; - - old_location = nautilus_window_slot_get_location (self); - scroll_pos = nautilus_bookmark_get_scroll_pos (bookmark); - begin_location_change - (self, - location, old_location, NULL, - back ? NAUTILUS_LOCATION_CHANGE_BACK : NAUTILUS_LOCATION_CHANGE_FORWARD, - distance, - scroll_pos); - - g_free (scroll_pos); - } - - g_object_unref (location); + begin_location_change (self, + location, old_location, + NULL, + back ? NAUTILUS_LOCATION_CHANGE_BACK : NAUTILUS_LOCATION_CHANGE_FORWARD, + distance, + scroll_pos); } /* reload the contents of the window */ diff --git a/src/nautilus-window.c b/src/nautilus-window.c index f004d629e..9b6df9767 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -221,7 +221,7 @@ action_go_home (GSimpleAction *action, window = NAUTILUS_WINDOW (user_data); home = g_file_new_for_path (g_get_home_dir ()); - nautilus_window_open_location_full (window, home, nautilus_event_get_window_open_flags (), NULL, NULL); + nautilus_window_open_location_full (window, home, 0, NULL, NULL); g_object_unref (home); } @@ -269,7 +269,7 @@ action_up (GSimpleAction *action, { nautilus_window_open_location_full (NAUTILUS_WINDOW (user_data), parent, - nautilus_event_get_window_open_flags (), + 0, NULL, NULL); } @@ -282,8 +282,7 @@ action_back (GSimpleAction *action, GVariant *state, gpointer user_data) { - nautilus_window_back_or_forward (NAUTILUS_WINDOW (user_data), - TRUE, 0, nautilus_event_get_window_open_flags ()); + nautilus_window_back_or_forward (NAUTILUS_WINDOW (user_data), TRUE, 0); } static void @@ -291,8 +290,7 @@ action_forward (GSimpleAction *action, GVariant *state, gpointer user_data) { - nautilus_window_back_or_forward (NAUTILUS_WINDOW (user_data), - FALSE, 0, nautilus_event_get_window_open_flags ()); + nautilus_window_back_or_forward (NAUTILUS_WINDOW (user_data), FALSE, 0); } static void @@ -2683,11 +2681,11 @@ on_multi_press_gesture_pressed (GtkGestureMultiPress *gesture, if (mouse_extra_buttons && (button == mouse_back_button)) { - nautilus_window_back_or_forward (window, TRUE, 0, 0); + nautilus_window_back_or_forward (window, TRUE, 0); } else if (mouse_extra_buttons && (button == mouse_forward_button)) { - nautilus_window_back_or_forward (window, FALSE, 0, 0); + nautilus_window_back_or_forward (window, FALSE, 0); } } @@ -2863,30 +2861,6 @@ nautilus_window_new (GdkScreen *screen) NULL); } -NautilusWindowOpenFlags -nautilus_event_get_window_open_flags (void) -{ - NautilusWindowOpenFlags flags = 0; - GdkEvent *event; - - event = gtk_get_current_event (); - - if (event == NULL) - { - return flags; - } - - if ((event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) && - (event->button.button == GDK_BUTTON_MIDDLE)) - { - flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB; - } - - gdk_event_free (event); - - return flags; -} - void nautilus_window_show_about_dialog (NautilusWindow *window) { diff --git a/src/nautilus-window.h b/src/nautilus-window.h index 27ebbb247..6f95fef64 100644 --- a/src/nautilus-window.h +++ b/src/nautilus-window.h @@ -80,13 +80,11 @@ void nautilus_window_hide_sidebar (NautilusWindow *window); void nautilus_window_show_sidebar (NautilusWindow *window); void nautilus_window_back_or_forward (NautilusWindow *window, gboolean back, - guint distance, - NautilusWindowOpenFlags flags); + guint distance); void nautilus_window_reset_menus (NautilusWindow *window); GtkWidget * nautilus_window_get_notebook (NautilusWindow *window); -NautilusWindowOpenFlags nautilus_event_get_window_open_flags (void); void nautilus_window_show_about_dialog (NautilusWindow *window); GtkWidget *nautilus_window_get_toolbar (NautilusWindow *window); -- cgit v1.2.1