[nautilus] slot: save return location before clearing query editor state



commit 0b33b33deadce9980727bc3a4d82efbdd8596601
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Oct 29 16:02:23 2012 -0400

    slot: save return location before clearing query editor state
    
    Or we'll always return to $HOME.

 src/nautilus-window-slot.c |   36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)
---
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 22adf21..e86187c 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -374,19 +374,37 @@ nautilus_window_slot_set_search_visible (NautilusWindowSlot *slot,
 	GtkActionGroup *action_group;
 	GtkAction *action;
 	gboolean old_visible;
-	GFile *location;
+	GFile *return_location;
+	gboolean active_slot;
 
 	/* set search active state for the slot */
 	old_visible = slot->details->search_visible;
 	slot->details->search_visible = visible;
 
+	return_location = NULL;
+	active_slot = (slot == nautilus_window_get_active_slot (slot->details->window));
+
 	if (visible) {
 		show_query_editor (slot);
 	} else {
+		/* If search was active on this slot and became inactive, change
+		 * the slot location to the real directory.
+		 */
+		if (old_visible && active_slot) {
+			/* Use the query editor search root if possible */
+			return_location = nautilus_window_slot_get_query_editor_location (slot);
+
+			/* Use the home directory as a fallback */
+			if (return_location == NULL) {
+				return_location = g_file_new_for_path (g_get_home_dir ());
+			}
+		}
+
+		/* Now hide the editor and clear its state */
 		hide_query_editor (slot);
 	}
 
-	if (slot != nautilus_window_get_active_slot (slot->details->window)) {
+	if (!active_slot) {
 		return;
 	}
 
@@ -398,17 +416,9 @@ nautilus_window_slot_set_search_visible (NautilusWindowSlot *slot,
 	/* If search was active on this slot and became inactive, change
 	 * the slot location to the real directory.
 	 */
-	if (!visible && old_visible) {
-		/* 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);
+	if (return_location != NULL) {
+		nautilus_window_slot_open_location (slot, return_location, 0);
+		g_object_unref (return_location);
 	}
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]