[nautilus/wip/antoniof/make-window-slot-final: 10/16] window-slot: Stop using flags parameter for history navigation




commit d537c7a8761613b82465c955462c08a857bcf100
Author: Ernestas Kulik <ernestask gnome org>
Date:   Wed Jun 20 16:59:35 2018 +0300

    window-slot: Stop using flags parameter for history navigation
    
    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 89ebac72f..42de3efc5 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -169,7 +169,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 b579ca116..060893eab 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 f7de99348..f9887d5ee 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -222,7 +222,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);
 }
@@ -270,7 +270,7 @@ action_up (GSimpleAction *action,
         {
             nautilus_window_open_location_full (NAUTILUS_WINDOW (user_data),
                                                 parent,
-                                                nautilus_event_get_window_open_flags (),
+                                                0,
                                                 NULL, NULL);
         }
 
@@ -283,8 +283,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
@@ -292,8 +291,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
@@ -2692,11 +2690,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);
     }
 }
 
@@ -2880,30 +2878,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 ac8833a20..27dd89f9d 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -79,13 +79,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);


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