diff options
author | Sachin Daluja <30343-sachindaluja@users.noreply.gitlab.gnome.org> | 2020-05-24 13:29:49 -0400 |
---|---|---|
committer | António Fernandes <antoniojpfernandes@gmail.com> | 2020-07-12 16:27:10 +0000 |
commit | 9c08b6d2cf9ebe863d242446ab4e2fefc6620587 (patch) | |
tree | 92dbc29aec0c0cf2ceed6b4704ad636ff8873d09 /src | |
parent | 5561219e34d0925ea752ffd87c13cd95258e3172 (diff) | |
download | nautilus-9c08b6d2cf9ebe863d242446ab4e2fefc6620587.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-window-slot.c | 28 | ||||
-rw-r--r-- | src/nautilus-window-slot.h | 11 | ||||
-rw-r--r-- | 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 342ff35e2..2747b1754 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -178,20 +178,21 @@ static GMenuModel *real_get_templates_menu (NautilusWindowSlot *self); static void nautilus_window_slot_setup_extra_location_widgets (NautilusWindowSlot *self); 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; @@ -203,14 +204,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; @@ -233,11 +236,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 42bf092ff..bdb9dccfa 100644 --- a/src/nautilus-window-slot.h +++ b/src/nautilus-window-slot.h @@ -43,7 +43,8 @@ typedef struct gint view_before_search; GList *back_list; GList *forward_list; -} RestoreTabData; + NautilusBookmark *current_location_bookmark; +} NautilusNavigationState; struct _NautilusWindowSlotClass { GtkBoxClass parent_class; @@ -123,14 +124,14 @@ 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); NautilusQueryEditor *nautilus_window_slot_get_query_editor (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); diff --git a/src/nautilus-window.c b/src/nautilus-window.c index c7f076fee..ee5b16051 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -1216,7 +1216,7 @@ action_restore_tab (GSimpleAction *action, NautilusWindowOpenFlags flags; g_autoptr (GFile) location = NULL; NautilusWindowSlot *slot; - RestoreTabData *data; + NautilusNavigationState *data; if (g_queue_get_length (window->tab_data_queue) == 0) { @@ -1232,9 +1232,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 guint @@ -1435,7 +1435,7 @@ nautilus_window_slot_close (NautilusWindow *window, NautilusWindowSlot *slot) { NautilusWindowSlot *next_slot; - RestoreTabData *data; + NautilusNavigationState *data; DEBUG ("Requesting to remove slot %p from window %p", slot, window); if (window == NULL) @@ -1449,7 +1449,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 (window->tab_data_queue, data); @@ -2364,7 +2364,7 @@ nautilus_window_finalize (GObject *object) G_CALLBACK (nautilus_window_on_undo_changed), window); - g_queue_free_full (window->tab_data_queue, free_restore_tab_data); + g_queue_free_full (window->tab_data_queue, free_navigation_state); g_object_unref (window->pad_controller); |