From ada0841d4f4a2362b92d668ada15f0f0366caea4 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: May 10 2022 04:10:50 +0000 Subject: import nautilus-3.28.1-16.el8 --- diff --git a/SOURCES/window-Streamline-RestoreTabData-memory-management.patch b/SOURCES/window-Streamline-RestoreTabData-memory-management.patch new file mode 100644 index 0000000..4223c38 --- /dev/null +++ b/SOURCES/window-Streamline-RestoreTabData-memory-management.patch @@ -0,0 +1,118 @@ +From 4bdd3fad8d51e50e3539c8e04bc91538467bd236 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ant=C3=B3nio=20Fernandes?= +Date: Wed, 8 Jul 2020 14:44:38 +0100 +Subject: [PATCH] window: Streamline RestoreTabData memory management + +When restoring the back and forward lists, we make a deep copy only to +free the data immediately afterwards. + +Instead of reallocating the lists unnecessarily, let's just steal them. + +Also, use g_queue_free_full() to make free_restore_tab_data() a proper +GDestroyNotify; also define it in window-slot.c, where it belongs. +--- + src/nautilus-window-slot.c | 16 ++++++++++++++-- + src/nautilus-window-slot.h | 1 + + src/nautilus-window.c | 20 ++------------------ + 3 files changed, 17 insertions(+), 20 deletions(-) + +diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c +index c3260aeb0..bf040bff2 100644 +--- a/src/nautilus-window-slot.c ++++ b/src/nautilus-window-slot.c +@@ -155,6 +155,18 @@ static void trash_state_changed_cb (NautilusTrashMonitor *monitor, + gboolean is_empty, + gpointer user_data); + ++void ++free_restore_tab_data (gpointer data) ++{ ++ RestoreTabData *tab_data = 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_free (tab_data); ++} ++ + void + nautilus_window_slot_restore_from_data (NautilusWindowSlot *self, + RestoreTabData *data) +@@ -163,9 +175,9 @@ nautilus_window_slot_restore_from_data (NautilusWindowSlot *self, + + priv = nautilus_window_slot_get_instance_private (self); + +- priv->back_list = g_list_copy_deep (data->back_list, (GCopyFunc) g_object_ref, NULL); ++ priv->back_list = g_steal_pointer (&data->back_list); + +- priv->forward_list = g_list_copy_deep (data->forward_list, (GCopyFunc) g_object_ref, NULL); ++ priv->forward_list = g_steal_pointer (&data->forward_list); + + priv->view_mode_before_search = data->view_before_search; + +diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h +index 573357d9b..bda1a920f 100644 +--- a/src/nautilus-window-slot.h ++++ b/src/nautilus-window-slot.h +@@ -125,4 +125,5 @@ RestoreTabData* nautilus_window_slot_get_restore_tab_data (NautilusWindowSlot *s + /* Only used by slot-dnd */ + NautilusView* nautilus_window_slot_get_current_view (NautilusWindowSlot *slot); + ++void free_restore_tab_data (gpointer data); + #endif /* NAUTILUS_WINDOW_SLOT_H */ +diff --git a/src/nautilus-window.c b/src/nautilus-window.c +index 1f8d5208e..175da6fce 100644 +--- a/src/nautilus-window.c ++++ b/src/nautilus-window.c +@@ -79,8 +79,6 @@ static GtkWidget *nautilus_window_ensure_location_entry (NautilusWindow *window) + static void close_slot (NautilusWindow *window, + NautilusWindowSlot *slot, + gboolean remove_from_notebook); +-static void free_restore_tab_data (gpointer data, +- gpointer user_data); + + /* Sanity check: highest mouse button value I could find was 14. 5 is our + * lower threshold (well-documented to be the one of the button events for the +@@ -1374,7 +1372,7 @@ action_restore_tab (GSimpleAction *action, + nautilus_window_slot_open_location_full (slot, location, flags, NULL); + nautilus_window_slot_restore_from_data (slot, data); + +- free_restore_tab_data (data, NULL); ++ free_restore_tab_data (data); + } + + static void +@@ -2501,19 +2499,6 @@ nautilus_window_destroy (GtkWidget *object) + GTK_WIDGET_CLASS (nautilus_window_parent_class)->destroy (object); + } + +-static void +-free_restore_tab_data (gpointer data, +- gpointer user_data) +-{ +- RestoreTabData *tab_data = 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_free (tab_data); +-} +- + static void + nautilus_window_finalize (GObject *object) + { +@@ -2548,8 +2533,7 @@ nautilus_window_finalize (GObject *object) + G_CALLBACK (nautilus_window_on_undo_changed), + window); + +- g_queue_foreach (priv->tab_data_queue, (GFunc) free_restore_tab_data, NULL); +- g_queue_free (priv->tab_data_queue); ++ g_queue_free_full (priv->tab_data_queue, free_restore_tab_data); + + g_object_unref (priv->pad_controller); + +-- +2.35.1 + diff --git a/SOURCES/window-slot-Rename-RestoreTabData-to-NautilusNavigat.patch b/SOURCES/window-slot-Rename-RestoreTabData-to-NautilusNavigat.patch new file mode 100644 index 0000000..5a18665 --- /dev/null +++ b/SOURCES/window-slot-Rename-RestoreTabData-to-NautilusNavigat.patch @@ -0,0 +1,170 @@ +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 + diff --git a/SOURCES/window-window-slot-Save-and-restore-navigation-histo.patch b/SOURCES/window-window-slot-Save-and-restore-navigation-histo.patch new file mode 100644 index 0000000..01c25ed --- /dev/null +++ b/SOURCES/window-window-slot-Save-and-restore-navigation-histo.patch @@ -0,0 +1,242 @@ +From fe7533b0b82e2ebc7767006ee9768572700a91df Mon Sep 17 00:00:00 2001 +From: Sachin Daluja <30343-sachindaluja@users.noreply.gitlab.gnome.org> +Date: Sun, 10 May 2020 22:30:03 -0400 +Subject: [PATCH] window, window-slot: Save and restore navigation history + +When a new window slot instance replaces the existing one to handle the new +location. + +This allows back and forward history lists to be preserved when the window +switches between instances of different window slot classes. + +Closes https://gitlab.gnome.org/GNOME/nautilus/-/issues/32 +--- + src/nautilus-window-slot.c | 48 +++++++++++++++++++--- + src/nautilus-window-slot.h | 13 ++++++ + src/nautilus-window.c | 84 +++++++++++++++++++++++++++++++++++++- + 3 files changed, 138 insertions(+), 7 deletions(-) + +diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c +index e688f0716..69040fc44 100644 +--- a/src/nautilus-window-slot.c ++++ b/src/nautilus-window-slot.c +@@ -176,6 +176,9 @@ nautilus_window_slot_restore_navigation_state (NautilusWindowSlot *self, + + priv = nautilus_window_slot_get_instance_private (self); + ++ /* We are restoring saved history to newly created slot with no history. */ ++ g_warn_if_fail (priv->back_list == NULL && priv->forward_list == NULL); ++ + priv->back_list = g_steal_pointer (&data->back_list); + + priv->forward_list = g_steal_pointer (&data->forward_list); +@@ -2003,12 +2006,11 @@ nautilus_window_slot_set_content_view (NautilusWindowSlot *self, + } + + void +-nautilus_window_back_or_forward (NautilusWindow *window, +- gboolean back, +- guint distance, +- NautilusWindowOpenFlags flags) ++nautilus_window_slot_back_or_forward (NautilusWindowSlot *self, ++ gboolean back, ++ guint distance, ++ NautilusWindowOpenFlags flags) + { +- NautilusWindowSlot *self; + GList *list; + GFile *location; + guint len; +@@ -2016,7 +2018,6 @@ nautilus_window_back_or_forward (NautilusWindow *window, + GFile *old_location; + NautilusWindowSlotPrivate *priv; + +- self = nautilus_window_get_active_slot (window); + priv = nautilus_window_slot_get_instance_private (self); + list = back ? priv->back_list : priv->forward_list; + +@@ -3308,3 +3309,38 @@ nautilus_window_slot_get_loading (NautilusWindowSlot *self) + + return priv->loading; + } ++ ++/* ++ * Open the specified location and set up the navigation history including the ++ * back and forward lists. This function is intended to be called when switching ++ * between NautilusWindowSlot and NautilusOtherLocationsWindowSlot. It allows ++ * the navigation history accumulated in the slot being replaced to be loaded ++ * into the replacing slot. ++ * ++ * The 'location' member variable is set to the new location before calling ++ * begin_location_change() to ensure that it matches the ++ * 'current_location_bookmark' member as expected by the location change ++ * pipeline. ++ */ ++void ++nautilus_window_slot_open_location_set_navigation_state (NautilusWindowSlot *self, ++ GFile *location, ++ NautilusWindowOpenFlags flags, ++ GList *new_selection, ++ NautilusLocationChangeType change_type, ++ NautilusNavigationState *navigation_state, ++ guint distance) ++{ ++ NautilusWindowSlotPrivate *priv; ++ ++ priv = nautilus_window_slot_get_instance_private (self); ++ ++ nautilus_window_slot_restore_navigation_state (self, navigation_state); ++ ++ g_clear_object (&priv->location); ++ ++ priv->location = nautilus_file_get_location (navigation_state->file); ++ ++ begin_location_change (self, location, NULL, new_selection, ++ change_type, distance, NULL); ++} +diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h +index 2edc96786..cbd3454ce 100644 +--- a/src/nautilus-window-slot.h ++++ b/src/nautilus-window-slot.h +@@ -82,6 +82,14 @@ void nautilus_window_slot_open_location_full (NautilusWindowSlot + NautilusWindowOpenFlags flags, + GList *new_selection); + ++void nautilus_window_slot_open_location_set_navigation_state (NautilusWindowSlot *slot, ++ GFile *location, ++ NautilusWindowOpenFlags flags, ++ GList *new_selection, ++ NautilusLocationChangeType change_type, ++ NautilusNavigationState *navigation_state, ++ guint distance); ++ + GFile * nautilus_window_slot_get_location (NautilusWindowSlot *slot); + + NautilusBookmark *nautilus_window_slot_get_bookmark (NautilusWindowSlot *slot); +@@ -126,5 +134,10 @@ NautilusNavigationState* nautilus_window_slot_get_navigation_state (NautilusWind + /* Only used by slot-dnd */ + NautilusView* nautilus_window_slot_get_current_view (NautilusWindowSlot *slot); + ++void nautilus_window_slot_back_or_forward (NautilusWindowSlot *slot, ++ gboolean back, ++ guint distance, ++ NautilusWindowOpenFlags flags); ++ + void free_navigation_state (gpointer data); + #endif /* NAUTILUS_WINDOW_SLOT_H */ +diff --git a/src/nautilus-window.c b/src/nautilus-window.c +index 900239cb8..af01b43e7 100644 +--- a/src/nautilus-window.c ++++ b/src/nautilus-window.c +@@ -613,6 +613,7 @@ nautilus_window_open_location_full (NautilusWindow *window, + { + NautilusWindowSlot *active_slot; + gboolean new_tab_at_end; ++ NautilusNavigationState *navigation_state = NULL; + + /* The location owner can be one of the slots requesting to handle an + * unhandled location. But this slot can be destroyed when switching to +@@ -644,6 +645,8 @@ nautilus_window_open_location_full (NautilusWindow *window, + } + else if (!nautilus_window_slot_handles_location (target_slot, location)) + { ++ navigation_state = nautilus_window_slot_get_navigation_state (active_slot); ++ + target_slot = replace_active_slot (window, location, flags); + } + +@@ -655,7 +658,19 @@ nautilus_window_open_location_full (NautilusWindow *window, + nautilus_window_set_active_slot (window, target_slot); + } + +- nautilus_window_slot_open_location_full (target_slot, location, flags, selection); ++ if (navigation_state != NULL) ++ { ++ nautilus_window_slot_open_location_set_navigation_state (target_slot, ++ location, flags, selection, ++ NAUTILUS_LOCATION_CHANGE_STANDARD, ++ navigation_state, 0); ++ ++ free_navigation_state (navigation_state); ++ } ++ else ++ { ++ nautilus_window_slot_open_location_full (target_slot, location, flags, selection); ++ } + + g_object_unref (location); + } +@@ -3099,3 +3114,70 @@ nautilus_window_search (NautilusWindow *window, + g_warning ("Trying search on a slot but no active slot present"); + } + } ++ ++/* Ideally, this method should be a simple wrapper for the slot method. However, ++ * going back or forward can result in a new slot (or another subclass), so we ++ * workaround that by duplicating part of nautilus_window_slot_back_or_forward() ++ */ ++void ++nautilus_window_back_or_forward (NautilusWindow *window, ++ gboolean back, ++ guint distance, ++ NautilusWindowOpenFlags flags) ++{ ++ NautilusWindowSlot *slot; ++ GList *next_location_list, *back_list, *forward_list; ++ GFile *next_location; ++ guint len; ++ NautilusBookmark *next_location_bookmark; ++ gboolean active_slot_handles_location; ++ ++ slot = nautilus_window_get_active_slot (window); ++ back_list = nautilus_window_slot_get_back_history (slot); ++ forward_list = nautilus_window_slot_get_forward_history (slot); ++ ++ next_location_list = back ? back_list : forward_list; ++ ++ len = (guint) g_list_length (next_location_list); ++ ++ /* If we can't move in the direction at all, just return. */ ++ if (len == 0) ++ { ++ return; ++ } ++ ++ /* If the distance to move is off the end of the list, go to the end ++ * of the list. */ ++ if (distance >= len) ++ { ++ distance = len - 1; ++ } ++ ++ next_location_bookmark = g_list_nth_data (next_location_list, distance); ++ next_location = nautilus_bookmark_get_location (next_location_bookmark); ++ ++ active_slot_handles_location = nautilus_window_slot_handles_location (slot, next_location); ++ ++ if (!active_slot_handles_location) ++ { ++ NautilusNavigationState *navigation_state; ++ NautilusLocationChangeType location_change_type; ++ ++ navigation_state = nautilus_window_slot_get_navigation_state (slot); ++ ++ location_change_type = back ? NAUTILUS_LOCATION_CHANGE_BACK : NAUTILUS_LOCATION_CHANGE_FORWARD; ++ ++ slot = replace_active_slot (window, next_location, flags); ++ ++ nautilus_window_slot_open_location_set_navigation_state (slot, ++ next_location, flags, NULL, ++ location_change_type, ++ navigation_state, distance); ++ ++ free_navigation_state (navigation_state); ++ } ++ else ++ { ++ nautilus_window_slot_back_or_forward (slot, back, distance, flags); ++ } ++} +-- +2.35.1 + diff --git a/SPECS/nautilus.spec b/SPECS/nautilus.spec index 1eece52..01b1c6a 100644 --- a/SPECS/nautilus.spec +++ b/SPECS/nautilus.spec @@ -8,7 +8,7 @@ Name: nautilus Version: 3.28.1 -Release: 15%{?dist} +Release: 16%{?dist} Summary: File manager for GNOME License: GPLv3+ @@ -69,6 +69,11 @@ Patch33: search-engine-tracker-Expand-macro-as-string.patch # https://bugzilla.redhat.com/show_bug.cgi?id=1906499 Patch34: nautilus-file.c-Fix-open-writable-file-in-recent-tab.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=2068092 +Patch35: window-Streamline-RestoreTabData-memory-management.patch +Patch36: window-slot-Rename-RestoreTabData-to-NautilusNavigat.patch +Patch37: window-window-slot-Save-and-restore-navigation-histo.patch + BuildRequires: gtk-doc BuildRequires: meson BuildRequires: gcc @@ -181,6 +186,9 @@ desktop-file-validate $RPM_BUILD_ROOT%{_datadir}/applications/*.desktop %{_datadir}/gir-1.0/*.gir %changelog +* Wed Apr 13 2022 Ondrej Holy - 3.28.1-16 +- Save and restore navigation history when changing window slot (#2068092) + * Wed Jan 6 2021 Ondrej Holy - 3.28.1-15 - Fix activation_uri handling to prevent invalid bookmarks (rhbz#1906499)