=== modified file 'src/nautilus-navigation-window-menus.c'
--- src/nautilus-navigation-window-menus.c	2009-08-07 20:53:31 +0000
+++ src/nautilus-navigation-window-menus.c	2009-09-21 19:15:53 +0000
@@ -716,14 +716,47 @@
 }			   
 
 static void
-action_search_callback (GtkAction *action,
-			gpointer user_data)
+action_show_hide_search_callback (GtkAction *action,
+			          gpointer user_data)
 {
 	NautilusNavigationWindow *window;
 
 	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
 
-	nautilus_navigation_window_show_search (window);
+	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+		nautilus_navigation_window_show_search (window);
+	} else {
+		NautilusWindowSlot *slot;
+		GFile *location = NULL;
+		
+		slot = NAUTILUS_WINDOW (window)->details->active_slot;
+				
+		// Use the location bar as the return location
+		if (slot->query_editor == NULL){
+			location = g_file_dup (nautilus_window_slot_get_location (slot));
+		// Use the search location as the return location
+		} else {
+			NautilusQuery *query;		
+			char *uri;
+			
+			query = nautilus_query_editor_get_query (slot->query_editor);
+			uri = nautilus_query_get_location (query);
+			if (uri != NULL) {
+				location = g_file_new_for_uri (uri);
+				g_free (uri);
+			}
+		}
+		
+		// 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 (NAUTILUS_WINDOW (window), location);
+		g_object_unref (location);
+		
+		nautilus_navigation_window_hide_search (window);
+	}
 }
 
 static void
@@ -794,9 +827,6 @@
   /* name, stock id, label */  { "Edit Bookmarks", NULL, N_("_Edit Bookmarks..."),
                                  "<control>b", N_("Display a window that allows editing the bookmarks in this menu"),
                                  G_CALLBACK (action_edit_bookmarks_callback) },
-  /* name, stock id, label */  { "Search", "gtk-find", N_("_Search for Files..."),
-                                 "<control>F", N_("Locate documents and folders on this computer by name or content"),
-                                 G_CALLBACK (action_search_callback) },
 
 	{ "TabsPrevious", NULL, N_("_Previous Tab"), "<control>Page_Up",
 	  N_("Activate previous tab"),
@@ -833,7 +863,12 @@
   /* label, accelerator */   N_("St_atusbar"), NULL,
   /* tooltip */              N_("Change the visibility of this window's statusbar"),
                              G_CALLBACK (action_show_hide_statusbar_callback),
-  /* is_active */            TRUE }, 
+  /* is_active */            TRUE },
+  /* name, stock id */     { "Search", "gtk-find",
+  /* label, accelerator */   N_("_Search for Files..."), "<control>F", 
+  /* tooltip */              N_("Search documents and folders by name"),
+                             G_CALLBACK (action_show_hide_search_callback),
+  /* is_active */            FALSE }, 
 };
 
 void 

=== modified file 'src/nautilus-navigation-window.c'
--- src/nautilus-navigation-window.c	2009-08-07 20:53:31 +0000
+++ src/nautilus-navigation-window.c	2009-09-03 21:16:01 +0000
@@ -352,7 +352,7 @@
 	GtkWidget *view_as_menu_vbox;
 	GtkToolItem *item;
 	GtkWidget *hbox;
-
+	
 	window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, NAUTILUS_TYPE_NAVIGATION_WINDOW, NautilusNavigationWindowDetails);
 
 	window->details->content_paned = nautilus_horizontal_splitter_new ();
@@ -424,11 +424,16 @@
 	gtk_toolbar_insert (GTK_TOOLBAR (location_bar),
 			    item, -1);
 
+	window->navigation_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);   
+	gtk_size_group_set_ignore_hidden (window->navigation_group, FALSE);
+
 	window->details->location_button = location_button_create (window);
+	gtk_size_group_add_widget (window->navigation_group, window->details->location_button);
 	gtk_box_pack_start (GTK_BOX (hbox), window->details->location_button, FALSE, FALSE, 0);
 	gtk_widget_show (window->details->location_button);
 
 	window->path_bar = g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL);
+	gtk_size_group_add_widget (window->navigation_group, window->path_bar);
  	gtk_widget_show (window->path_bar);
 	
 	g_signal_connect_object (window->path_bar, "path_clicked",
@@ -441,6 +446,7 @@
 			    TRUE, TRUE, 0);
 
 	window->navigation_bar = nautilus_location_bar_new (window);
+	gtk_size_group_add_widget (window->navigation_group, window->navigation_bar);	
 	g_signal_connect_object (window->navigation_bar, "location_changed",
 				 G_CALLBACK (navigation_bar_location_changed_callback), window, 0);
 	g_signal_connect_object (window->navigation_bar, "cancel",
@@ -451,6 +457,7 @@
 			    TRUE, TRUE, 0);
 
 	window->search_bar = nautilus_search_bar_new ();
+	gtk_size_group_add_widget (window->navigation_group, window->search_bar);
 	g_signal_connect_object (window->search_bar, "activate",
 				 G_CALLBACK (search_bar_activate_callback), window, 0);
 	g_signal_connect_object (window->search_bar, "cancel",
@@ -753,6 +760,7 @@
 		} else {
 			nautilus_navigation_window_set_bar_mode (window, NAUTILUS_BAR_NAVIGATION);
 		}
+		nautilus_navigation_window_set_search_button (window, FALSE);
 		window->details->temporary_search_bar = FALSE;
 		success = TRUE;
 	}
@@ -1505,7 +1513,7 @@
 static void
 search_bar_cancel_callback (GtkWidget *widget,
 			    NautilusNavigationWindow *window)
-{
+{		
 	if (hide_temporary_bars (window)) {
 		restore_focus_widget (window);
 	}
@@ -1521,9 +1529,28 @@
 		nautilus_navigation_window_set_bar_mode (window, NAUTILUS_BAR_SEARCH);
 		window->details->temporary_search_bar = TRUE;
 		nautilus_search_bar_clear (NAUTILUS_SEARCH_BAR (window->search_bar));
-	}
-	
-	nautilus_search_bar_grab_focus (NAUTILUS_SEARCH_BAR (window->search_bar));
+		nautilus_search_bar_grab_focus (NAUTILUS_SEARCH_BAR (window->search_bar));	
+	}
+}
+
+void
+nautilus_navigation_window_hide_search (NautilusNavigationWindow *window)
+{
+	if (nautilus_navigation_window_search_bar_showing (window)) {
+		if (hide_temporary_bars (window)) {
+                	restore_focus_widget (window);
+        	}
+	}
+}
+
+void
+nautilus_navigation_window_set_search_button (NautilusNavigationWindow *window,
+					      gboolean state)
+{
+	GtkAction *action;	
+
+	action = gtk_action_group_get_action (window->details->navigation_action_group, "Search");
+       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), state);
 }
 
 /* either called due to slot change, or due to location change in the current slot. */
@@ -1717,12 +1744,14 @@
 
 	case NAUTILUS_BAR_PATH:
 		gtk_widget_show (window->path_bar);
+		gtk_widget_show (window->details->location_button);
 		gtk_widget_hide (window->navigation_bar);
 		gtk_widget_hide (window->search_bar);
 		break;
 
 	case NAUTILUS_BAR_NAVIGATION:
 		gtk_widget_show (window->navigation_bar);
+		gtk_widget_show (window->details->location_button);
 		gtk_widget_hide (window->path_bar);
 		gtk_widget_hide (window->search_bar);
 		break;
@@ -1731,6 +1760,7 @@
 		gtk_widget_show (window->search_bar);
 		gtk_widget_hide (window->path_bar);
 		gtk_widget_hide (window->navigation_bar);
+		gtk_widget_hide (window->details->location_button);
 		break;
 	}
 
@@ -1745,6 +1775,9 @@
 		g_signal_handlers_unblock_by_func (window->details->location_button,
 						   G_CALLBACK (location_button_toggled_cb),
 						   window);
+		nautilus_navigation_window_set_search_button (window, FALSE);
+	} else {
+		nautilus_navigation_window_set_search_button (window, TRUE);
 	}
 }
 

=== modified file 'src/nautilus-navigation-window.h'
--- src/nautilus-navigation-window.h	2009-08-07 20:53:31 +0000
+++ src/nautilus-navigation-window.h	2009-09-03 21:16:09 +0000
@@ -64,9 +64,12 @@
         /** UI stuff **/
         NautilusSidePane *sidebar;
         GtkWidget *view_as_combo_box;
+
+        GtkSizeGroup *navigation_group;
         GtkWidget *navigation_bar;
 	GtkWidget *path_bar;
         GtkWidget *search_bar;
+
 	GtkWidget *notebook;
 
         /* Current views stuff */
@@ -120,5 +123,8 @@
                                                           guint                     distance,
 							  gboolean                  new_tab);
 void     nautilus_navigation_window_show_search          (NautilusNavigationWindow *window);
+void     nautilus_navigation_window_hide_search          (NautilusNavigationWindow *window);
+void     nautilus_navigation_window_set_search_button	  (NautilusNavigationWindow *window,
+							   gboolean		    state);
 
 #endif

=== modified file 'src/nautilus-query-editor.c'
--- src/nautilus-query-editor.c	2009-08-07 20:53:31 +0000
+++ src/nautilus-query-editor.c	2009-09-03 21:16:23 +0000
@@ -1157,6 +1157,10 @@
 	GList *l;
 	NautilusQueryEditorRow *row;
 
+	if ( editor == NULL || editor->details == NULL || editor->details->entry == NULL){
+		return NULL;
+	}
+
 	query_text = gtk_entry_get_text (GTK_ENTRY (editor->details->entry));
 
 	/* Empty string is a NULL query */

