Blame SOURCES/window-slot-Rename-RestoreTabData-to-NautilusNavigat.patch

ada084
From 148559bc6809aac40be4aff64b7d3a4e5ac3c59a Mon Sep 17 00:00:00 2001
ada084
From: Sachin Daluja <30343-sachindaluja@users.noreply.gitlab.gnome.org>
ada084
Date: Sun, 24 May 2020 13:29:49 -0400
ada084
Subject: [PATCH] window-slot: Rename RestoreTabData to NautilusNavigationState
ada084
ada084
This struct is going to be used to also restore navigation state when
ada084
replacing the active window slot in order to handle other-locations://
ada084
ada084
Also enhance it to also save and restore the current location bookmark.
ada084
---
ada084
 src/nautilus-window-slot.c | 28 ++++++++++++++++------------
ada084
 src/nautilus-window-slot.h | 11 ++++++-----
ada084
 src/nautilus-window.c      | 12 ++++++------
ada084
 3 files changed, 28 insertions(+), 23 deletions(-)
ada084
ada084
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
ada084
index bf040bff2..e688f0716 100644
ada084
--- a/src/nautilus-window-slot.c
ada084
+++ b/src/nautilus-window-slot.c
ada084
@@ -156,20 +156,21 @@ static void trash_state_changed_cb (NautilusTrashMonitor *monitor,
ada084
                                     gpointer              user_data);
ada084
 
ada084
 void
ada084
-free_restore_tab_data (gpointer data)
ada084
+free_navigation_state (gpointer data)
ada084
 {
ada084
-    RestoreTabData *tab_data = data;
ada084
+    NautilusNavigationState *navigation_state = data;
ada084
 
ada084
-    g_list_free_full (tab_data->back_list, g_object_unref);
ada084
-    g_list_free_full (tab_data->forward_list, g_object_unref);
ada084
-    nautilus_file_unref (tab_data->file);
ada084
+    g_list_free_full (navigation_state->back_list, g_object_unref);
ada084
+    g_list_free_full (navigation_state->forward_list, g_object_unref);
ada084
+    nautilus_file_unref (navigation_state->file);
ada084
+    g_clear_object (&navigation_state->current_location_bookmark);
ada084
 
ada084
-    g_free (tab_data);
ada084
+    g_free (navigation_state);
ada084
 }
ada084
 
ada084
 void
ada084
-nautilus_window_slot_restore_from_data (NautilusWindowSlot *self,
ada084
-                                        RestoreTabData     *data)
ada084
+nautilus_window_slot_restore_navigation_state (NautilusWindowSlot      *self,
ada084
+                                               NautilusNavigationState *data)
ada084
 {
ada084
     NautilusWindowSlotPrivate *priv;
ada084
 
ada084
@@ -181,14 +182,16 @@ nautilus_window_slot_restore_from_data (NautilusWindowSlot *self,
ada084
 
ada084
     priv->view_mode_before_search = data->view_before_search;
ada084
 
ada084
+    g_set_object (&priv->current_location_bookmark, data->current_location_bookmark);
ada084
+
ada084
     priv->location_change_type = NAUTILUS_LOCATION_CHANGE_RELOAD;
ada084
 }
ada084
 
ada084
-RestoreTabData *
ada084
-nautilus_window_slot_get_restore_tab_data (NautilusWindowSlot *self)
ada084
+NautilusNavigationState *
ada084
+nautilus_window_slot_get_navigation_state (NautilusWindowSlot *self)
ada084
 {
ada084
     NautilusWindowSlotPrivate *priv;
ada084
-    RestoreTabData *data;
ada084
+    NautilusNavigationState *data;
ada084
     GList *back_list;
ada084
     GList *forward_list;
ada084
 
ada084
@@ -211,11 +214,12 @@ nautilus_window_slot_get_restore_tab_data (NautilusWindowSlot *self)
ada084
      * the view mode before search and a reference to the file.
ada084
      * A GFile isn't enough, as the NautilusFile also keeps a
ada084
      * reference to the search directory */
ada084
-    data = g_new0 (RestoreTabData, 1);
ada084
+    data = g_new0 (NautilusNavigationState, 1);
ada084
     data->back_list = back_list;
ada084
     data->forward_list = forward_list;
ada084
     data->file = nautilus_file_get (priv->location);
ada084
     data->view_before_search = priv->view_mode_before_search;
ada084
+    g_set_object (&data->current_location_bookmark, priv->current_location_bookmark);
ada084
 
ada084
     return data;
ada084
 }
ada084
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
ada084
index bda1a920f..2edc96786 100644
ada084
--- a/src/nautilus-window-slot.h
ada084
+++ b/src/nautilus-window-slot.h
ada084
@@ -48,7 +48,8 @@ typedef struct
ada084
     gint view_before_search;
ada084
     GList *back_list;
ada084
     GList *forward_list;
ada084
-} RestoreTabData;
ada084
+    NautilusBookmark *current_location_bookmark;
ada084
+} NautilusNavigationState;
ada084
 
ada084
 struct _NautilusWindowSlotClass {
ada084
 	GtkBoxClass parent_class;
ada084
@@ -117,13 +118,13 @@ void     nautilus_window_slot_search                       (NautilusWindowSlot *
ada084
 gboolean nautilus_window_slot_handles_location (NautilusWindowSlot *self,
ada084
                                                 GFile              *location);
ada084
 
ada084
-void nautilus_window_slot_restore_from_data (NautilusWindowSlot *self,
ada084
-                                             RestoreTabData     *data);
ada084
+void nautilus_window_slot_restore_navigation_state (NautilusWindowSlot      *self,
ada084
+                                                    NautilusNavigationState *data);
ada084
 
ada084
-RestoreTabData* nautilus_window_slot_get_restore_tab_data (NautilusWindowSlot *self);
ada084
+NautilusNavigationState* nautilus_window_slot_get_navigation_state (NautilusWindowSlot *self);
ada084
 
ada084
 /* Only used by slot-dnd */
ada084
 NautilusView*  nautilus_window_slot_get_current_view       (NautilusWindowSlot *slot);
ada084
 
ada084
-void free_restore_tab_data                                 (gpointer data);
ada084
+void free_navigation_state                                 (gpointer data);
ada084
 #endif /* NAUTILUS_WINDOW_SLOT_H */
ada084
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
ada084
index 175da6fce..900239cb8 100644
ada084
--- a/src/nautilus-window.c
ada084
+++ b/src/nautilus-window.c
ada084
@@ -1349,7 +1349,7 @@ action_restore_tab (GSimpleAction *action,
ada084
     NautilusWindowOpenFlags flags;
ada084
     g_autoptr (GFile) location = NULL;
ada084
     NautilusWindowSlot *slot;
ada084
-    RestoreTabData *data;
ada084
+    NautilusNavigationState *data;
ada084
 
ada084
     priv = nautilus_window_get_instance_private (window);
ada084
 
ada084
@@ -1370,9 +1370,9 @@ action_restore_tab (GSimpleAction *action,
ada084
     slot = nautilus_window_create_and_init_slot (window, location, flags);
ada084
 
ada084
     nautilus_window_slot_open_location_full (slot, location, flags, NULL);
ada084
-    nautilus_window_slot_restore_from_data (slot, data);
ada084
+    nautilus_window_slot_restore_navigation_state (slot, data);
ada084
 
ada084
-    free_restore_tab_data (data);
ada084
+    free_navigation_state (data);
ada084
 }
ada084
 
ada084
 static void
ada084
@@ -1579,7 +1579,7 @@ nautilus_window_slot_close (NautilusWindow     *window,
ada084
 {
ada084
     NautilusWindowPrivate *priv;
ada084
     NautilusWindowSlot *next_slot;
ada084
-    RestoreTabData *data;
ada084
+    NautilusNavigationState *data;
ada084
 
ada084
     DEBUG ("Requesting to remove slot %p from window %p", slot, window);
ada084
     if (window == NULL)
ada084
@@ -1595,7 +1595,7 @@ nautilus_window_slot_close (NautilusWindow     *window,
ada084
         nautilus_window_set_active_slot (window, next_slot);
ada084
     }
ada084
 
ada084
-    data = nautilus_window_slot_get_restore_tab_data (slot);
ada084
+    data = nautilus_window_slot_get_navigation_state (slot);
ada084
     if (data != NULL)
ada084
     {
ada084
         g_queue_push_head (priv->tab_data_queue, data);
ada084
@@ -2533,7 +2533,7 @@ nautilus_window_finalize (GObject *object)
ada084
                                           G_CALLBACK (nautilus_window_on_undo_changed),
ada084
                                           window);
ada084
 
ada084
-    g_queue_free_full (priv->tab_data_queue, free_restore_tab_data);
ada084
+    g_queue_free_full (priv->tab_data_queue, free_navigation_state);
ada084
 
ada084
     g_object_unref (priv->pad_controller);
ada084
 
ada084
-- 
ada084
2.35.1
ada084