[nautilus/wip/gbsneto/search-popover: 2/8] window-slot: fix search state when going back/forward
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/gbsneto/search-popover: 2/8] window-slot: fix search state when going back/forward
- Date: Wed, 7 Oct 2015 12:26:32 +0000 (UTC)
commit 2b6fca9a63d11f66ff7dff73bb1e69b51c07896c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Oct 5 11:24:27 2015 -0300
window-slot: fix search state when going back/forward
When a search is performed, Nautilus adds it to the history
stack, and we can return to it through the back or forward
buttons.
While we can indeed go back to the search, the UI components
such as the search bar doesn't update accordingly, leaving us
with a search directory without a search bar.
Fix that by properly checking the search-visible action state.
src/nautilus-files-view.c | 15 +++++++++++++++
src/nautilus-window-slot.c | 23 +++++++++++++++++++++--
2 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index c8af384..0846913 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -3080,9 +3080,24 @@ nautilus_files_view_set_location (NautilusView *view,
GFile *location)
{
NautilusDirectory *directory;
+ NautilusFilesView *files_view;
nautilus_profile_start (NULL);
+ files_view = NAUTILUS_FILES_VIEW (view);
directory = nautilus_directory_get (location);
+
+ /* If we're entering a search directory, the search query
+ * must be updated to match the current search.
+ */
+ if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
+ NautilusQuery *query;
+
+ query = nautilus_search_directory_get_query (NAUTILUS_SEARCH_DIRECTORY (directory));
+
+ g_set_object (&files_view->details->search_query, query);
+ g_clear_object (&query);
+ }
+
load_directory (NAUTILUS_FILES_VIEW (view), directory);
nautilus_directory_unref (directory);
nautilus_profile_end (NULL);
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index c32bde2..093dcde 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -256,7 +256,6 @@ check_search_visible (NautilusWindowSlot *slot)
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 */
@@ -266,8 +265,28 @@ 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))
+ if (nautilus_view_is_searching (view)) {
+ GVariant *variant;
+ gboolean search_visible;
+
+ variant = g_action_get_state (action);
+ search_visible = g_variant_get_boolean (variant);
+
+ g_variant_unref (variant);
+
+ /* When we go back or forward to a search location, the search
+ * state must be restored.
+ */
+ if (!search_visible) {
+ nautilus_query_editor_set_query (slot->details->query_editor,
+ nautilus_view_get_search_query (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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]