summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2012-10-26 17:39:47 -0400
committerCosimo Cecchi <cosimoc@gnome.org>2012-10-26 17:45:35 -0400
commit0b59aa2e0477b8e7f044a33d3a7281d7c3b2770b (patch)
treef7b4c194ed9cbe4bc1c5acf86a1d25abe7c48172
parentf017a93b9ba3a465059ebca8eeb79138c983bd96 (diff)
downloadnautilus-0b59aa2e0477b8e7f044a33d3a7281d7c3b2770b.tar.gz
slot: ensure we're back from an active search when changing location
When search is turned off, we want to change the location of the slot to the search base folder. 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-slot.c21
-rw-r--r--src/nautilus-window.c14
2 files changed, 21 insertions, 14 deletions
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 0e6321e36..7b86e9f11 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -101,6 +101,7 @@ struct NautilusWindowSlotDetails {
gulong qe_changed_id;
gulong qe_cancel_id;
gulong qe_activated_id;
+ gboolean search_active;
/* Load state */
GCancellable *find_mount_cancellable;
@@ -142,11 +143,31 @@ toggle_toolbar_search_button (NautilusWindowSlot *slot,
{
GtkActionGroup *action_group;
GtkAction *action;
+ gboolean old_active;
+ GFile *location;
action_group = nautilus_window_get_main_action_group (slot->details->window);
action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_SEARCH);
+ old_active = slot->details->search_active;
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
+ slot->details->search_active = active;
+
+ /* If search was active on this slot and became inactive, change
+ * the slot location to the real directory.
+ */
+ if (!active && old_active) {
+ /* Use the query editor search root if possible */
+ location = nautilus_window_slot_get_query_editor_location (slot);
+
+ /* Use the home directory as a fallback */
+ if (location == NULL) {
+ location = g_file_new_for_path (g_get_home_dir ());
+ }
+
+ nautilus_window_slot_open_location (slot, location, 0);
+ g_object_unref (location);
+ }
}
static void
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index e94fbba74..bf10c9e36 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -282,21 +282,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 */
- location = nautilus_window_slot_get_query_editor_location (slot);
-
- /* 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);
}
}