[nautilus/wip/ernestask/gtk4-continued: 47/164] window-slot: Stop using flags parameter for history navigation



commit bc46b67800b25908b6404184dd168091856478eb
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 | 42 ++++++++++++++----------------------------
 src/nautilus-window.c      | 38 ++++++--------------------------------
 src/nautilus-window.h      |  4 +---
 4 files changed, 22 insertions(+), 64 deletions(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index fb0d2d4c0..9f24795ea 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -165,7 +165,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 b3a7bc211..de9e88d38 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -2236,25 +2236,24 @@ nautilus_window_slot_set_content_view (NautilusWindowSlot *self,
 void
 nautilus_window_back_or_forward (NautilusWindow          *window,
                                  gboolean                 back,
-                                 guint                    distance,
-                                 NautilusWindowOpenFlags  flags)
+                                 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;
     }
@@ -2268,28 +2267,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 0d1234f15..5001029db 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -213,7 +213,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);
 }
@@ -261,7 +261,7 @@ action_up (GSimpleAction *action,
         {
             nautilus_window_open_location_full (NAUTILUS_WINDOW (user_data),
                                                 parent,
-                                                nautilus_event_get_window_open_flags (),
+                                                0,
                                                 NULL, NULL);
         }
 
@@ -274,8 +274,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
@@ -283,8 +282,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
@@ -2589,11 +2587,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);
     }
 }
 
@@ -2770,30 +2768,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 d5a5ecd91..6721c5175 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -74,13 +74,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]