[nautilus/wip/csoriano/next-18: 3/13] window-slot: sync search visibility when using history
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/csoriano/next-18: 3/13] window-slot: sync search visibility when using history
- Date: Mon, 18 Jan 2016 10:02:50 +0000 (UTC)
commit e3fbc0a189b58734f9d6f454f9c9b37d0dad4147
Author: Carlos Soriano <csoriano gnome org>
Date: Thu Dec 17 10:32:07 2015 +0100
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
src/nautilus-files-view.c | 17 ++++++++++++++++-
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 457e72e..32a56fd 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -3103,6 +3103,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);
}
@@ -7703,7 +7711,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;
NautilusFile *file;
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 0a7437a..0c07df2 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");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]