diff options
author | Carlos Soriano <csoriano@gnome.org> | 2015-12-17 10:32:07 +0100 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2015-12-17 15:52:48 +0100 |
commit | f24fd6934d03361899e2626c6dbd8bc01eb252c7 (patch) | |
tree | 418e4bc4690c1d74c4675fcc0ff5d36458c5e2ed | |
parent | 95cadccf263bfd5b17d3d94a0469ebd6cdce889a (diff) | |
download | nautilus-f24fd6934d03361899e2626c6dbd8bc01eb252c7.tar.gz |
window-slot: sync search visibility when using history
We can return to an old location which happens to be a search
location.
The issue is, we were not updating all the associated properties
of the search when that happened so the window slot and the
files view was in a inconsistent state.
For that, we need the files view to also accept to change to search
locations, in which case it needs to set it's query appropiately
to the query the search location was using.
Thanks to Georges for the initial work on this.
https://bugzilla.gnome.org/show_bug.cgi?id=756183
-rw-r--r-- | src/nautilus-files-view.c | 17 | ||||
-rw-r--r-- | src/nautilus-window-slot.c | 16 |
2 files changed, 26 insertions, 7 deletions
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c index e4371fe9f..1a7842583 100644 --- a/src/nautilus-files-view.c +++ b/src/nautilus-files-view.c @@ -3092,6 +3092,14 @@ nautilus_files_view_set_location (NautilusView *view, nautilus_profile_start (NULL); directory = nautilus_directory_get (location); load_directory (NAUTILUS_FILES_VIEW (view), directory); + /* In case we want to load a previous search, sync the query */ + if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) { + NautilusQuery *previous_query; + + previous_query = nautilus_search_directory_get_query (NAUTILUS_SEARCH_DIRECTORY (directory)); + nautilus_view_set_search_query (view, previous_query); + g_object_unref (previous_query); + } nautilus_directory_unref (directory); nautilus_profile_end (NULL); } @@ -7754,7 +7762,14 @@ nautilus_files_view_set_search_query (NautilusView *view, * Reuse the search directory and reload it. */ nautilus_search_directory_set_query (NAUTILUS_SEARCH_DIRECTORY (files_view->details->model), query); - nautilus_view_set_location (view, location); + /* It's important to use load_directory instead of set_location, + * since the location is already correct, however we need + * to reload the directory with the new query set. But + * set_location has a check for wheter the location is a + * search directory, so setting the location to a search + * directory when is already serching will enter a loop. + */ + load_directory (files_view, nautilus_directory_ref (files_view->details->model)); } else { NautilusDirectory *directory; gchar *uri; diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index b10de0034..f775a14f3 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -249,14 +249,13 @@ nautilus_window_slot_content_view_matches (NautilusWindowSlot *slot, } static void -check_search_visible (NautilusWindowSlot *slot) +update_search_visible (NautilusWindowSlot *slot) { NautilusQuery *query; NautilusView *view; gchar *text; GAction *action; - query = nautilus_query_editor_get_query (slot->details->query_editor); action = g_action_map_lookup_action (G_ACTION_MAP (slot->details->slot_action_group), "search-visible"); /* Don't allow search on desktop */ @@ -265,10 +264,15 @@ check_search_visible (NautilusWindowSlot *slot) view = nautilus_window_slot_get_current_view (slot); /* If we changed location just to another search location, for example, - * when changing the query, just keep the search visible */ - if (nautilus_view_is_searching (view)) + * when changing the query, just keep the search visible. + * Make sure the search is visible though, since we could be returning + * from a previous search location when using the history */ + if (nautilus_view_is_searching (view)) { + nautilus_window_slot_set_search_visible (slot, TRUE); return; + } + query = nautilus_query_editor_get_query (slot->details->query_editor); if (query) { text = nautilus_query_get_text (query); /* If the view is not searching, but search is visible, and the @@ -295,10 +299,10 @@ nautilus_window_slot_sync_actions (NautilusWindowSlot *slot) return; } - /* Check if we need to close the search or not after changing the location. + /* Check if we need to close the search or show search after changing the location. * Needs to be done after the change has been done, if not, a loop happens, * because setting the search enabled or not actually opens a location */ - check_search_visible (slot); + update_search_visible (slot); /* Files view mode */ action = g_action_map_lookup_action (G_ACTION_MAP (slot->details->slot_action_group), "files-view-mode"); |