diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2012-10-26 18:02:57 -0400 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2012-10-26 18:02:57 -0400 |
commit | 569e11cbc6bd635effa487f7b07fee9f5ba9661b (patch) | |
tree | e6c62d7e38c2f543b65b0dfad7b52d73442b0dee | |
parent | 4ef1f9f77773623123855a12b898019748d45ffd (diff) | |
download | nautilus-569e11cbc6bd635effa487f7b07fee9f5ba9661b.tar.gz |
slot: ensure we're back from an active search when changing location
We used to keep track of the search active state using the state of the
search toggle button; unfortunately, the button is per-window,
so its active state will also be synchronized when switching tabs.
This will cause a non-search slot that becomes active following a tab
switch from a search slot to think its search just became inactive, and
will then change its location to the default ($HOME).
Fix the bug by keeping an additional state per-slot for whether there's
an active search.
https://bugzilla.gnome.org/show_bug.cgi?id=686893
-rw-r--r-- | src/nautilus-window-private.h | 2 | ||||
-rw-r--r-- | src/nautilus-window-slot.c | 10 | ||||
-rw-r--r-- | src/nautilus-window-slot.h | 1 | ||||
-rw-r--r-- | src/nautilus-window.c | 42 |
4 files changed, 31 insertions, 24 deletions
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h index e908a799b..94d622055 100644 --- a/src/nautilus-window-private.h +++ b/src/nautilus-window-private.h @@ -116,6 +116,8 @@ void nautilus_window_sync_zoom_widgets (NautilusWindow *window); void nautilus_window_sync_up_button (NautilusWindow *window); void nautilus_window_sync_view_as_menus (NautilusWindow *window); +void nautilus_window_set_search_action_active (NautilusWindow *window, + gboolean active); void nautilus_window_set_search_visible (NautilusWindow *window, gboolean visible); diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index 620ca7042..43215d22a 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -141,15 +141,7 @@ static void query_editor_cancel_callback (NautilusQueryEditor *editor, NautilusWindowSlot *slot) { - GtkAction *search; - NautilusWindow *window; - GtkActionGroup *action_group; - - window = slot->details->window; - action_group = nautilus_window_get_main_action_group (window); - search = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_SEARCH); - - gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (search), FALSE); + nautilus_window_set_search_action_active (slot->details->window, FALSE); } static void diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h index 2c91c70ed..e0f787247 100644 --- a/src/nautilus-window-slot.h +++ b/src/nautilus-window-slot.h @@ -91,6 +91,7 @@ struct NautilusWindowSlot { gulong qe_changed_id; gulong qe_cancel_id; gulong qe_activated_id; + gboolean search_active; /* New location. */ NautilusLocationChangeType location_change_type; diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 2f676b2f6..0adb78bab 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -280,22 +280,7 @@ nautilus_window_set_search_visible (NautilusWindow *window, remember_focus_widget (window); nautilus_window_slot_set_query_editor_visible (slot, TRUE); } else { - GFile *location = NULL; - restore_focus_widget (window); - - /* Use the location bar as the return location */ - if (slot->query_editor != NULL) { - location = nautilus_query_editor_get_location (slot->query_editor); - /* Last try: use the home directory as the return location */ - if (location == NULL) { - location = g_file_new_for_path (g_get_home_dir ()); - } - - nautilus_window_go_to (window, location); - g_object_unref (location); - } - nautilus_window_slot_set_query_editor_visible (slot, FALSE); } } @@ -676,11 +661,38 @@ toggle_toolbar_search_button (NautilusWindow *window, gboolean active) { GtkAction *action; + NautilusWindowSlot *slot; + gboolean old_active; + GFile *location; + slot = nautilus_window_get_active_slot (window); action = gtk_action_group_get_action (nautilus_window_get_main_action_group (window), NAUTILUS_ACTION_SEARCH); + old_active = slot->search_active; gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active); + slot->search_active = active; + + if (!active && old_active) { + /* Use the location bar as the return location */ + if (slot->query_editor != NULL) { + location = nautilus_query_editor_get_location (slot->query_editor); + /* Last try: use the home directory as the return location */ + if (location == NULL) { + location = g_file_new_for_path (g_get_home_dir ()); + } + + nautilus_window_go_to (window, location); + g_object_unref (location); + } + } +} + +void +nautilus_window_set_search_action_active (NautilusWindow *window, + gboolean active) +{ + toggle_toolbar_search_button (window, active); } void |