Commit f24fd693 authored by Carlos Soriano Sánchez's avatar Carlos Soriano Sánchez
Browse files

window-slot: sync search visibility when using history

We can return to an old location which happens to be a search
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.
parent 95cadccf
......@@ -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 */
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;
......@@ -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),
/* 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);
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)
/* 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");
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment