Blob Blame History Raw
From 148559bc6809aac40be4aff64b7d3a4e5ac3c59a Mon Sep 17 00:00:00 2001
From: Sachin Daluja <30343-sachindaluja@users.noreply.gitlab.gnome.org>
Date: Sun, 24 May 2020 13:29:49 -0400
Subject: [PATCH] window-slot: Rename RestoreTabData to NautilusNavigationState

This struct is going to be used to also restore navigation state when
replacing the active window slot in order to handle other-locations://

Also enhance it to also save and restore the current location bookmark.
---
 src/nautilus-window-slot.c | 28 ++++++++++++++++------------
 src/nautilus-window-slot.h | 11 ++++++-----
 src/nautilus-window.c      | 12 ++++++------
 3 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index bf040bff2..e688f0716 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -156,20 +156,21 @@ static void trash_state_changed_cb (NautilusTrashMonitor *monitor,
                                     gpointer              user_data);
 
 void
-free_restore_tab_data (gpointer data)
+free_navigation_state (gpointer data)
 {
-    RestoreTabData *tab_data = data;
+    NautilusNavigationState *navigation_state = data;
 
-    g_list_free_full (tab_data->back_list, g_object_unref);
-    g_list_free_full (tab_data->forward_list, g_object_unref);
-    nautilus_file_unref (tab_data->file);
+    g_list_free_full (navigation_state->back_list, g_object_unref);
+    g_list_free_full (navigation_state->forward_list, g_object_unref);
+    nautilus_file_unref (navigation_state->file);
+    g_clear_object (&navigation_state->current_location_bookmark);
 
-    g_free (tab_data);
+    g_free (navigation_state);
 }
 
 void
-nautilus_window_slot_restore_from_data (NautilusWindowSlot *self,
-                                        RestoreTabData     *data)
+nautilus_window_slot_restore_navigation_state (NautilusWindowSlot      *self,
+                                               NautilusNavigationState *data)
 {
     NautilusWindowSlotPrivate *priv;
 
@@ -181,14 +182,16 @@ nautilus_window_slot_restore_from_data (NautilusWindowSlot *self,
 
     priv->view_mode_before_search = data->view_before_search;
 
+    g_set_object (&priv->current_location_bookmark, data->current_location_bookmark);
+
     priv->location_change_type = NAUTILUS_LOCATION_CHANGE_RELOAD;
 }
 
-RestoreTabData *
-nautilus_window_slot_get_restore_tab_data (NautilusWindowSlot *self)
+NautilusNavigationState *
+nautilus_window_slot_get_navigation_state (NautilusWindowSlot *self)
 {
     NautilusWindowSlotPrivate *priv;
-    RestoreTabData *data;
+    NautilusNavigationState *data;
     GList *back_list;
     GList *forward_list;
 
@@ -211,11 +214,12 @@ nautilus_window_slot_get_restore_tab_data (NautilusWindowSlot *self)
      * the view mode before search and a reference to the file.
      * A GFile isn't enough, as the NautilusFile also keeps a
      * reference to the search directory */
-    data = g_new0 (RestoreTabData, 1);
+    data = g_new0 (NautilusNavigationState, 1);
     data->back_list = back_list;
     data->forward_list = forward_list;
     data->file = nautilus_file_get (priv->location);
     data->view_before_search = priv->view_mode_before_search;
+    g_set_object (&data->current_location_bookmark, priv->current_location_bookmark);
 
     return data;
 }
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index bda1a920f..2edc96786 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -48,7 +48,8 @@ typedef struct
     gint view_before_search;
     GList *back_list;
     GList *forward_list;
-} RestoreTabData;
+    NautilusBookmark *current_location_bookmark;
+} NautilusNavigationState;
 
 struct _NautilusWindowSlotClass {
 	GtkBoxClass parent_class;
@@ -117,13 +118,13 @@ void     nautilus_window_slot_search                       (NautilusWindowSlot *
 gboolean nautilus_window_slot_handles_location (NautilusWindowSlot *self,
                                                 GFile              *location);
 
-void nautilus_window_slot_restore_from_data (NautilusWindowSlot *self,
-                                             RestoreTabData     *data);
+void nautilus_window_slot_restore_navigation_state (NautilusWindowSlot      *self,
+                                                    NautilusNavigationState *data);
 
-RestoreTabData* nautilus_window_slot_get_restore_tab_data (NautilusWindowSlot *self);
+NautilusNavigationState* nautilus_window_slot_get_navigation_state (NautilusWindowSlot *self);
 
 /* Only used by slot-dnd */
 NautilusView*  nautilus_window_slot_get_current_view       (NautilusWindowSlot *slot);
 
-void free_restore_tab_data                                 (gpointer data);
+void free_navigation_state                                 (gpointer data);
 #endif /* NAUTILUS_WINDOW_SLOT_H */
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 175da6fce..900239cb8 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1349,7 +1349,7 @@ action_restore_tab (GSimpleAction *action,
     NautilusWindowOpenFlags flags;
     g_autoptr (GFile) location = NULL;
     NautilusWindowSlot *slot;
-    RestoreTabData *data;
+    NautilusNavigationState *data;
 
     priv = nautilus_window_get_instance_private (window);
 
@@ -1370,9 +1370,9 @@ action_restore_tab (GSimpleAction *action,
     slot = nautilus_window_create_and_init_slot (window, location, flags);
 
     nautilus_window_slot_open_location_full (slot, location, flags, NULL);
-    nautilus_window_slot_restore_from_data (slot, data);
+    nautilus_window_slot_restore_navigation_state (slot, data);
 
-    free_restore_tab_data (data);
+    free_navigation_state (data);
 }
 
 static void
@@ -1579,7 +1579,7 @@ nautilus_window_slot_close (NautilusWindow     *window,
 {
     NautilusWindowPrivate *priv;
     NautilusWindowSlot *next_slot;
-    RestoreTabData *data;
+    NautilusNavigationState *data;
 
     DEBUG ("Requesting to remove slot %p from window %p", slot, window);
     if (window == NULL)
@@ -1595,7 +1595,7 @@ nautilus_window_slot_close (NautilusWindow     *window,
         nautilus_window_set_active_slot (window, next_slot);
     }
 
-    data = nautilus_window_slot_get_restore_tab_data (slot);
+    data = nautilus_window_slot_get_navigation_state (slot);
     if (data != NULL)
     {
         g_queue_push_head (priv->tab_data_queue, data);
@@ -2533,7 +2533,7 @@ nautilus_window_finalize (GObject *object)
                                           G_CALLBACK (nautilus_window_on_undo_changed),
                                           window);
 
-    g_queue_free_full (priv->tab_data_queue, free_restore_tab_data);
+    g_queue_free_full (priv->tab_data_queue, free_navigation_state);
 
     g_object_unref (priv->pad_controller);
 
-- 
2.35.1