[nautilus] Combine the search bar and query editor



commit 5521f24f74d18bad5cbec893f4cf42503fe8d02b
Author: William Jon McCann <jmccann redhat com>
Date:   Mon Jul 9 13:22:27 2012 -0400

    Combine the search bar and query editor
    
    Save vertical space by integrating the search bar
    with the query editor. This makes it less visually
    disruptive when a search becomes active.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679900

 src/Makefile.am                    |    2 -
 src/nautilus-query-editor.c        |  417 ++++++++++--------------------------
 src/nautilus-query-editor.h        |    9 +-
 src/nautilus-search-bar.c          |  228 --------------------
 src/nautilus-search-bar.h          |   65 ------
 src/nautilus-toolbar.c             |   40 ----
 src/nautilus-toolbar.h             |    3 -
 src/nautilus-window-manage-views.c |    3 -
 src/nautilus-window-menus.c        |    1 -
 src/nautilus-window-slot.c         |  207 ++++++++++++------
 src/nautilus-window-slot.h         |    3 +-
 src/nautilus-window.c              |  139 ++-----------
 src/nautilus-window.h              |    2 +-
 13 files changed, 274 insertions(+), 845 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 664b7d2..7226dff 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -142,8 +142,6 @@ nautilus_SOURCES = \
 	nautilus-properties-window.h		\
 	nautilus-query-editor.c			\
 	nautilus-query-editor.h			\
-	nautilus-search-bar.c			\
-	nautilus-search-bar.h			\
 	nautilus-self-check-functions.c 	\
 	nautilus-self-check-functions.h 	\
 	nautilus-toolbar.c			\
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 243586f..0fb4bd9 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -23,7 +23,7 @@
 
 #include <config.h>
 #include "nautilus-query-editor.h"
-#include "nautilus-window-slot.h"
+#include "nautilus-file-utilities.h"
 
 #include <string.h>
 #include <glib/gi18n.h>
@@ -34,7 +34,6 @@
 #include <gtk/gtk.h>
 
 typedef enum {
-	NAUTILUS_QUERY_EDITOR_ROW_LOCATION,
 	NAUTILUS_QUERY_EDITOR_ROW_TYPE,
 	
 	NAUTILUS_QUERY_EDITOR_ROW_LAST
@@ -67,14 +66,14 @@ struct NautilusQueryEditorDetails {
 	gboolean change_frozen;
 	guint typing_timeout_id;
 	gboolean is_visible;
-	GtkWidget *invisible_vbox;
-	GtkWidget *visible_vbox;
+	GtkWidget *vbox;
+
+	GtkWidget *search_current_button;
+	GtkWidget *search_all_button;
+	char *current_uri;
 
 	GList *rows;
 	char *last_set_query_text;
-	
-	NautilusSearchBar *bar;
-	NautilusWindowSlot *slot;
 };
 
 enum {
@@ -93,12 +92,6 @@ static void nautilus_query_editor_changed (NautilusQueryEditor *editor);
 static NautilusQueryEditorRow * nautilus_query_editor_add_row (NautilusQueryEditor *editor,
 							       NautilusQueryEditorRowType type);
 
-static GtkWidget *location_row_create_widgets  (NautilusQueryEditorRow *row);
-static void       location_row_add_to_query    (NautilusQueryEditorRow *row,
-					        NautilusQuery          *query);
-static void       location_row_free_data       (NautilusQueryEditorRow *row);
-static void       location_add_rows_from_query (NautilusQueryEditor    *editor,
-					        NautilusQuery          *query);
 static GtkWidget *type_row_create_widgets      (NautilusQueryEditorRow *row);
 static void       type_row_add_to_query        (NautilusQueryEditorRow *row,
 					        NautilusQuery          *query);
@@ -109,12 +102,6 @@ static void       type_add_rows_from_query     (NautilusQueryEditor    *editor,
 
 
 static NautilusQueryEditorRowOps row_type[] = {
-	{ N_("Location"),
-	  location_row_create_widgets,
-	  location_row_add_to_query,
-	  location_row_free_data,
-	  location_add_rows_from_query
-	},
 	{ N_("File Type"),
 	  type_row_create_widgets,
 	  type_row_add_to_query,
@@ -132,26 +119,11 @@ nautilus_query_editor_dispose (GObject *object)
 
 	editor = NAUTILUS_QUERY_EDITOR (object);
 
-	if (editor->details->typing_timeout_id) {
+	if (editor->details->typing_timeout_id > 0) {
 		g_source_remove (editor->details->typing_timeout_id);
 		editor->details->typing_timeout_id = 0;
 	}
 
-	if (editor->details->bar != NULL) {
-		g_signal_handlers_disconnect_by_func (editor->details->entry,
-						      entry_activate_cb,
-						      editor);
-		g_signal_handlers_disconnect_by_func (editor->details->entry,
-						      entry_changed_cb,
-						      editor);
-		
-		nautilus_search_bar_return_entry (editor->details->bar);
-
-		g_object_remove_weak_pointer (G_OBJECT (editor->details->bar),
-					      (gpointer *) &editor->details->bar);
-		editor->details->bar = NULL;
-	}
-
 	G_OBJECT_CLASS (nautilus_query_editor_parent_class)->dispose (object);
 }
 
@@ -213,10 +185,19 @@ nautilus_query_editor_class_init (NautilusQueryEditorClass *class)
 	g_type_class_add_private (class, sizeof (NautilusQueryEditorDetails));
 }
 
+GFile *
+nautilus_query_editor_get_location (NautilusQueryEditor *editor)
+{
+	GFile *file = NULL;
+	if (editor->details->current_uri != NULL)
+		file = g_file_new_for_uri (editor->details->current_uri);
+	return file;
+}
+
 static void
 entry_activate_cb (GtkWidget *entry, NautilusQueryEditor *editor)
 {
-	if (editor->details->typing_timeout_id) {
+	if (editor->details->typing_timeout_id > 0) {
 		g_source_remove (editor->details->typing_timeout_id);
 		editor->details->typing_timeout_id = 0;
 	}
@@ -230,11 +211,10 @@ typing_timeout_cb (gpointer user_data)
 	NautilusQueryEditor *editor;
 
 	editor = NAUTILUS_QUERY_EDITOR (user_data);
+	editor->details->typing_timeout_id = 0;
 
 	nautilus_query_editor_changed (editor);
 
-	editor->details->typing_timeout_id = 0;
-
 	return FALSE;
 }
 
@@ -247,7 +227,7 @@ entry_changed_cb (GtkWidget *entry, NautilusQueryEditor *editor)
 		return;
 	}
 
-	if (editor->details->typing_timeout_id) {
+	if (editor->details->typing_timeout_id > 0) {
 		g_source_remove (editor->details->typing_timeout_id);
 	}
 
@@ -257,88 +237,6 @@ entry_changed_cb (GtkWidget *entry, NautilusQueryEditor *editor)
 			       editor);
 }
 
-static void
-edit_clicked (GtkButton *button, NautilusQueryEditor *editor)
-{
-	nautilus_query_editor_set_visible (editor, TRUE);
-	nautilus_query_editor_grab_focus (editor);
-}
-
-/* Location */
-
-static GtkWidget *
-location_row_create_widgets (NautilusQueryEditorRow *row)
-{
-	GtkWidget *chooser;
-
-	chooser = gtk_file_chooser_button_new (_("Select folder to search in"),
-					       GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
-	gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), TRUE);
-	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser),
-					     g_get_home_dir ());
-	gtk_widget_show (chooser);
-
-	g_signal_connect_swapped (chooser, "current-folder-changed",
-				  G_CALLBACK (nautilus_query_editor_changed),
-				  row->editor);
-		
-	gtk_box_pack_start (GTK_BOX (row->hbox), chooser, FALSE, FALSE, 0);
-	
-	return chooser;
-}
-
-static void
-location_row_add_to_query (NautilusQueryEditorRow *row,
-			   NautilusQuery          *query)
-{
-	char *folder, *uri;
-	
-	folder = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (row->type_widget));
-	if (folder == NULL) {
-		/* I don't know why, but i got NULL here on initial search in browser mode
-		   even with the location set to the homedir in create_widgets... */
-		folder = g_strdup (g_get_home_dir ());
-	}
-	
-	uri = g_filename_to_uri (folder, NULL, NULL);
-	g_free (folder);
-		
-	nautilus_query_set_location (query, uri);
-	g_free (uri);
-}
-
-static void
-location_row_free_data (NautilusQueryEditorRow *row)
-{
-}
-
-static void
-location_add_rows_from_query (NautilusQueryEditor    *editor,
-			      NautilusQuery          *query)
-{
-	NautilusQueryEditorRow *row;
-	char *uri, *folder;
-	
-	uri = nautilus_query_get_location (query);
-
-	if (uri == NULL) {
-		return;
-	}
-	folder = g_filename_from_uri (uri, NULL, NULL);
-	g_free (uri);
-	if (folder == NULL) {
-		return;
-	}
-	
-	row = nautilus_query_editor_add_row (editor,
-					     NAUTILUS_QUERY_EDITOR_ROW_LOCATION);
-	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (row->type_widget),
-					     folder);
-	
-	g_free (folder);
-}
-
-
 /* Type */
 
 static gboolean
@@ -847,7 +745,7 @@ remove_row_cb (GtkButton *clicked_button, NautilusQueryEditorRow *row)
 	NautilusQueryEditor *editor;
 
 	editor = row->editor;
-	gtk_container_remove (GTK_CONTAINER (editor->details->visible_vbox),
+	gtk_container_remove (GTK_CONTAINER (editor->details->vbox),
 			      row->hbox);
 	
 	editor->details->rows = g_list_remove (editor->details->rows, row);
@@ -905,7 +803,7 @@ nautilus_query_editor_add_row (NautilusQueryEditor *editor,
 	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
 	row->hbox = hbox;
 	gtk_widget_show (hbox);
-	gtk_box_pack_start (GTK_BOX (editor->details->visible_vbox), hbox, FALSE, FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (editor->details->vbox), hbox, FALSE, FALSE, 0);
 
 	combo = gtk_combo_box_text_new ();
 	row->combo = combo;
@@ -925,8 +823,8 @@ nautilus_query_editor_add_row (NautilusQueryEditor *editor,
 	create_type_widgets (row);
 	
 	button = gtk_button_new ();
-	image = gtk_image_new_from_stock (GTK_STOCK_REMOVE,
-					  GTK_ICON_SIZE_SMALL_TOOLBAR);
+	image = gtk_image_new_from_icon_name ("list-remove-symbolic",
+					      GTK_ICON_SIZE_SMALL_TOOLBAR);
 	gtk_container_add (GTK_CONTAINER (button), image);
 	gtk_widget_show (image);
 	gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
@@ -943,12 +841,6 @@ nautilus_query_editor_add_row (NautilusQueryEditor *editor,
 }
 
 static void
-go_search_cb (GtkButton *clicked_button, NautilusQueryEditor *editor)
-{
-	nautilus_query_editor_changed_force (editor, TRUE);
-}
-
-static void
 add_new_row_cb (GtkButton *clicked_button, NautilusQueryEditor *editor)
 {
 	nautilus_query_editor_add_row (editor, get_next_free_type (editor));
@@ -958,57 +850,41 @@ add_new_row_cb (GtkButton *clicked_button, NautilusQueryEditor *editor)
 static void
 nautilus_query_editor_init (NautilusQueryEditor *editor)
 {
-	GtkWidget *hbox, *label, *button;
-	char *label_markup;
-
 	editor->details = G_TYPE_INSTANCE_GET_PRIVATE (editor, NAUTILUS_TYPE_QUERY_EDITOR,
 						       NautilusQueryEditorDetails);
-	editor->details->is_visible = TRUE;
+	editor->details->is_visible = FALSE;
 
 	gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (editor)),
-				     GTK_STYLE_CLASS_QUESTION);
+				     GTK_STYLE_CLASS_TOOLBAR);
+	gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (editor)),
+				     GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
+
 	gtk_orientable_set_orientation (GTK_ORIENTABLE (editor), GTK_ORIENTATION_VERTICAL);
 
-	editor->details->invisible_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
-	gtk_container_set_border_width (GTK_CONTAINER (editor->details->invisible_vbox), 6);
-	gtk_box_pack_start (GTK_BOX (editor), editor->details->invisible_vbox,
-			    FALSE, FALSE, 0);
-	editor->details->visible_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
-	gtk_container_set_border_width (GTK_CONTAINER (editor->details->visible_vbox), 6);
-	gtk_box_pack_start (GTK_BOX (editor), editor->details->visible_vbox,
+	editor->details->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+	gtk_widget_set_no_show_all (editor->details->vbox, TRUE);
+	gtk_container_set_border_width (GTK_CONTAINER (editor->details->vbox), 6);
+	gtk_box_pack_start (GTK_BOX (editor), editor->details->vbox,
 			    FALSE, FALSE, 0);
-	/* Only show visible vbox */
-	gtk_widget_show (editor->details->visible_vbox);
-
-	/* Create invisible part: */
-	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-	gtk_box_pack_start (GTK_BOX (editor->details->invisible_vbox),
-			    hbox, FALSE, FALSE, 0);
-	gtk_widget_show (hbox);
-	
-	label = gtk_label_new ("");
-	label_markup = g_strconcat ("<b>", _("Search Folder"), "</b>", NULL);
-	gtk_label_set_markup (GTK_LABEL (label), label_markup);
-	g_free (label_markup);
-
-	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-	gtk_widget_show (label);
-	
-	button = gtk_button_new_with_label (_("Edit"));
-	gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
-	gtk_widget_show (button);
-
-	g_signal_connect (button, "clicked",
-			  G_CALLBACK (edit_clicked), editor);
-
-	gtk_widget_set_tooltip_text (button,
-				     _("Edit the saved search"));
 }
 
 void
 nautilus_query_editor_set_default_query (NautilusQueryEditor *editor)
 {
-	nautilus_query_editor_add_row (editor, NAUTILUS_QUERY_EDITOR_ROW_LOCATION);
+	nautilus_query_editor_changed (editor);
+}
+
+static void
+on_all_button_toggled (GtkToggleButton     *button,
+		       NautilusQueryEditor *editor)
+{
+	nautilus_query_editor_changed (editor);
+}
+
+static void
+on_current_button_toggled (GtkToggleButton     *button,
+			   NautilusQueryEditor *editor)
+{
 	nautilus_query_editor_changed (editor);
 }
 
@@ -1018,8 +894,8 @@ finish_first_line (NautilusQueryEditor *editor, GtkWidget *hbox, gboolean use_go
 	GtkWidget *button, *image;
 
 	button = gtk_button_new ();
-	image = gtk_image_new_from_stock (GTK_STOCK_ADD,
-					  GTK_ICON_SIZE_SMALL_TOOLBAR);
+	image = gtk_image_new_from_icon_name ("list-add-symbolic",
+					      GTK_ICON_SIZE_SMALL_TOOLBAR);
 	gtk_container_add (GTK_CONTAINER (button), image);
 	gtk_widget_show (image);
 	gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
@@ -1033,43 +909,32 @@ finish_first_line (NautilusQueryEditor *editor, GtkWidget *hbox, gboolean use_go
 	gtk_widget_set_tooltip_text (button,
 				     _("Add a new criterion to this search"));
 
-	if (use_go) {
-		button = gtk_button_new_with_label (_("Go"));
-	} else {
-		button = gtk_button_new_with_label (_("Reload"));
-	}
-	gtk_widget_show (button);
-
-	gtk_widget_set_tooltip_text (button,
-				     _("Perform or update the search"));
-		
-	g_signal_connect (button, "clicked",
-			  G_CALLBACK (go_search_cb), editor);
-		
-	gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+	editor->details->search_current_button = gtk_radio_button_new_with_label (NULL, _("Current"));
+	gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (editor->details->search_current_button), FALSE);
+	gtk_widget_show (editor->details->search_current_button);
+	editor->details->search_all_button = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (editor->details->search_current_button),
+											  _("All Files"));
+	gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (editor->details->search_all_button), FALSE);
+	gtk_widget_show (editor->details->search_all_button);
+	g_signal_connect (editor->details->search_all_button, "toggled",
+			  G_CALLBACK (on_all_button_toggled), editor);
+	g_signal_connect (editor->details->search_current_button, "toggled",
+			  G_CALLBACK (on_current_button_toggled), editor);
+	gtk_box_pack_start (GTK_BOX (hbox), editor->details->search_current_button, FALSE, FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (hbox), editor->details->search_all_button, FALSE, FALSE, 0);
 }
 
 static void
-setup_internal_entry (NautilusQueryEditor *editor)
+setup_widgets (NautilusQueryEditor *editor)
 {
-	GtkWidget *hbox, *label;
-	char *label_markup;
-	
+	GtkWidget *hbox;
+
 	/* Create visible part: */
 	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
 	gtk_widget_show (hbox);
-	gtk_box_pack_start (GTK_BOX (editor->details->visible_vbox), hbox, FALSE, FALSE, 0);
-
-	label = gtk_label_new ("");
-	label_markup = g_strconcat ("<b>", _("_Search for:"), "</b>", NULL);
-	gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), label_markup);
-	g_free (label_markup);
-	gtk_widget_show (label);
-
-	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (editor->details->vbox), hbox, FALSE, FALSE, 0);
 
-	editor->details->entry = gtk_entry_new ();
-	gtk_label_set_mnemonic_widget (GTK_LABEL (label), editor->details->entry);
+	editor->details->entry = gtk_search_entry_new ();
 	gtk_box_pack_start (GTK_BOX (hbox), editor->details->entry, TRUE, TRUE, 0);
 
 	g_signal_connect (editor->details->entry, "activate",
@@ -1081,46 +946,15 @@ setup_internal_entry (NautilusQueryEditor *editor)
 	finish_first_line (editor, hbox, TRUE);
 }
 
-static void
-setup_external_entry (NautilusQueryEditor *editor, GtkWidget *entry)
-{
-	GtkWidget *hbox, *label;
-	gchar *label_markup;
-	
-	/* Create visible part: */
-	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-	gtk_widget_show (hbox);
-	gtk_box_pack_start (GTK_BOX (editor->details->visible_vbox), hbox, FALSE, FALSE, 0);
-
-	label_markup = g_strconcat ("<b>", _("Search results"), "</b>", NULL);
-	label = gtk_label_new (NULL);
-	gtk_label_set_markup (GTK_LABEL (label), label_markup);
-	gtk_widget_show (label);
-
-	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
-	
-	editor->details->entry = entry;
-	g_signal_connect (editor->details->entry, "activate",
-			  G_CALLBACK (entry_activate_cb), editor);
-	g_signal_connect (editor->details->entry, "changed",
-			  G_CALLBACK (entry_changed_cb), editor);
-
-	finish_first_line (editor, hbox, FALSE);
-
-	g_free (label_markup);
-}
-
 void
 nautilus_query_editor_set_visible (NautilusQueryEditor *editor,
 				   gboolean visible)
 {
 	editor->details->is_visible = visible;
 	if (visible) {
-		gtk_widget_show (editor->details->visible_vbox);
-		gtk_widget_hide (editor->details->invisible_vbox);
+		gtk_widget_show (editor->details->vbox);
 	} else {
-		gtk_widget_hide (editor->details->visible_vbox);
-		gtk_widget_show (editor->details->invisible_vbox);
+		gtk_widget_hide (editor->details->vbox);
 	}
 }
 
@@ -1154,7 +988,7 @@ nautilus_query_editor_changed_force (NautilusQueryEditor *editor, gboolean force
 static void
 nautilus_query_editor_changed (NautilusQueryEditor *editor)
 {
-	nautilus_query_editor_changed_force (editor, FALSE);
+	nautilus_query_editor_changed_force (editor, TRUE);
 }
 
 void
@@ -1165,6 +999,22 @@ nautilus_query_editor_grab_focus (NautilusQueryEditor *editor)
 	}
 }
 
+static void
+add_location_to_query (NautilusQueryEditor *editor,
+		       NautilusQuery       *query)
+{
+	char *uri;
+
+	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->details->search_all_button))) {
+		uri = nautilus_get_home_directory_uri ();
+	} else {
+		uri = g_strdup (editor->details->current_uri);
+	}
+
+	nautilus_query_set_location (query, uri);
+	g_free (uri);
+}
+
 NautilusQuery *
 nautilus_query_editor_get_query (NautilusQueryEditor *editor)
 {
@@ -1187,6 +1037,8 @@ nautilus_query_editor_get_query (NautilusQueryEditor *editor)
 	query = nautilus_query_new ();
 	nautilus_query_set_text (query, query_text);
 
+	add_location_to_query (editor, query);
+
 	for (l = editor->details->rows; l != NULL; l = l->next) {
 		row = l->data;
 		
@@ -1209,84 +1061,47 @@ nautilus_query_editor_clear_query (NautilusQueryEditor *editor)
 }
 
 GtkWidget *
-nautilus_query_editor_new (gboolean start_hidden)
+nautilus_query_editor_new (void)
 {
 	GtkWidget *editor;
 
 	editor = g_object_new (NAUTILUS_TYPE_QUERY_EDITOR, NULL);
-	nautilus_query_editor_set_visible (NAUTILUS_QUERY_EDITOR (editor),
-					   !start_hidden);
-	
-	setup_internal_entry (NAUTILUS_QUERY_EDITOR (editor));
-		
+	setup_widgets (NAUTILUS_QUERY_EDITOR (editor));
+
 	return editor;
 }
 
 static void
-detach_from_external_entry (NautilusQueryEditor *editor)
+update_location (NautilusQueryEditor *editor,
+		 NautilusQuery       *query)
 {
-	if (editor->details->bar != NULL) {
-		nautilus_search_bar_return_entry (editor->details->bar);
-		g_signal_handlers_block_by_func (editor->details->entry,
-						 entry_activate_cb,
-						 editor);
-		g_signal_handlers_block_by_func (editor->details->entry,
-						 entry_changed_cb,
-						 editor);
-	}
-}
+	char *uri;
+	NautilusFile *file;
 
-static void
-attach_to_external_entry (NautilusQueryEditor *editor)
-{
-	if (editor->details->bar != NULL) {
-		nautilus_search_bar_borrow_entry (editor->details->bar);
-		g_signal_handlers_unblock_by_func (editor->details->entry,
-						   entry_activate_cb,
-						   editor);
-		g_signal_handlers_unblock_by_func (editor->details->entry,
-						   entry_changed_cb,
-						   editor);
-
-		editor->details->change_frozen = TRUE;
-		gtk_entry_set_text (GTK_ENTRY (editor->details->entry),
-				    editor->details->last_set_query_text);
-		editor->details->change_frozen = FALSE;
+	uri = nautilus_query_get_location (query);
+	if (uri == NULL) {
+		return;
 	}
-}
-
-GtkWidget*
-nautilus_query_editor_new_with_bar (gboolean start_hidden,
-				    gboolean start_attached,
-				    NautilusSearchBar *bar,
-				    NautilusWindowSlot *slot)
-{
-	GtkWidget *entry;
-	NautilusQueryEditor *editor;
-
-	editor = NAUTILUS_QUERY_EDITOR (g_object_new (NAUTILUS_TYPE_QUERY_EDITOR, NULL));
-	nautilus_query_editor_set_visible (editor, !start_hidden);
-
-	editor->details->bar = bar;
-	g_object_add_weak_pointer (G_OBJECT (editor->details->bar),
-				   (gpointer *) &editor->details->bar);
-
-	editor->details->slot = slot;
+	g_free (editor->details->current_uri);
+	editor->details->current_uri = uri;
+	file = nautilus_file_get_by_uri (uri);
+
+	if (file != NULL) {
+		char *name;
+		if (nautilus_file_is_home (file)) {
+			name = g_strdup (_("Home"));
+		} else {
+			char *filename;
+			filename = nautilus_file_get_display_name (file);
+			name = g_strdup_printf ("\342\200\234%s\342\200\235", filename);
+			g_free (filename);
+		}
+		gtk_button_set_label (GTK_BUTTON (editor->details->search_current_button),
+				      name);
+		g_free (name);
 
-	entry = nautilus_search_bar_borrow_entry (bar);
-	setup_external_entry (editor, entry);
-	if (!start_attached) {
-		detach_from_external_entry (editor);
+		nautilus_file_unref (file);
 	}
-
-	g_signal_connect_object (slot, "active",
-				 G_CALLBACK (attach_to_external_entry),
-				 editor, G_CONNECT_SWAPPED);
-	g_signal_connect_object (slot, "inactive",
-				 G_CALLBACK (detach_from_external_entry),
-				 editor, G_CONNECT_SWAPPED);
-	
-	return GTK_WIDGET (editor);
 }
 
 void
@@ -1309,6 +1124,8 @@ nautilus_query_editor_set_query (NautilusQueryEditor *editor, NautilusQuery *que
 	editor->details->change_frozen = TRUE;
 	gtk_entry_set_text (GTK_ENTRY (editor->details->entry), text);
 
+	update_location (editor, query);
+
 	for (type = 0; type < NAUTILUS_QUERY_EDITOR_ROW_LAST; type++) {
 		row_type[type].add_rows_from_query (editor, query);
 	}
diff --git a/src/nautilus-query-editor.h b/src/nautilus-query-editor.h
index dc56278..7cdbaa6 100644
--- a/src/nautilus-query-editor.h
+++ b/src/nautilus-query-editor.h
@@ -28,8 +28,6 @@
 
 #include <libnautilus-private/nautilus-query.h>
 
-#include "nautilus-search-bar.h"
-
 #define NAUTILUS_TYPE_QUERY_EDITOR nautilus_query_editor_get_type()
 #define NAUTILUS_QUERY_EDITOR(obj) \
   (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_QUERY_EDITOR, NautilusQueryEditor))
@@ -61,11 +59,7 @@ typedef struct {
 #include "nautilus-window-slot.h"
 
 GType      nautilus_query_editor_get_type     	   (void);
-GtkWidget* nautilus_query_editor_new          	   (gboolean start_hidden);
-GtkWidget* nautilus_query_editor_new_with_bar      (gboolean start_hidden,
-						    gboolean start_attached,
-						    NautilusSearchBar *bar,
-						    NautilusWindowSlot *slot);
+GtkWidget* nautilus_query_editor_new          	   (void);
 void       nautilus_query_editor_set_default_query (NautilusQueryEditor *editor);
 
 void	   nautilus_query_editor_grab_focus (NautilusQueryEditor *editor);
@@ -74,6 +68,7 @@ void       nautilus_query_editor_clear_query (NautilusQueryEditor *editor);
 NautilusQuery *nautilus_query_editor_get_query   (NautilusQueryEditor *editor);
 void           nautilus_query_editor_set_query   (NautilusQueryEditor *editor,
 						  NautilusQuery       *query);
+GFile *        nautilus_query_editor_get_location (NautilusQueryEditor *editor);
 void           nautilus_query_editor_set_visible (NautilusQueryEditor *editor,
 						  gboolean             visible);
 
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index f174888..db04293 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -45,20 +45,17 @@ struct _NautilusToolbarPriv {
 
 	GtkWidget *path_bar;
 	GtkWidget *location_bar;
-	GtkWidget *search_bar;
 
 	GtkToolItem *back_forward;
 
 	gboolean show_main_bar;
 	gboolean show_location_entry;
-	gboolean show_search_bar;
 };
 
 enum {
 	PROP_ACTION_GROUP = 1,
 	PROP_UI_MANAGER,
 	PROP_SHOW_LOCATION_ENTRY,
-	PROP_SHOW_SEARCH_BAR,
 	PROP_SHOW_MAIN_BAR,
 	NUM_PROPERTIES
 };
@@ -82,9 +79,6 @@ toolbar_update_appearance (NautilusToolbar *self)
 				show_location_entry);
 	gtk_widget_set_visible (self->priv->path_bar,
 				!show_location_entry);
-
-	gtk_widget_set_visible (self->priv->search_bar,
-				self->priv->show_search_bar);
 }
 
 static gint
@@ -221,10 +215,6 @@ nautilus_toolbar_constructed (GObject *obj)
 	gtk_widget_show_all (GTK_WIDGET (tool_item));
 	gtk_widget_set_margin_left (GTK_WIDGET (tool_item), 6);
 
-	/* search bar */
-	self->priv->search_bar = nautilus_search_bar_new ();
-	gtk_box_pack_start (GTK_BOX (self), self->priv->search_bar, TRUE, TRUE, 0);
-
 	g_signal_connect_swapped (nautilus_preferences,
 				  "changed::" NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY,
 				  G_CALLBACK (toolbar_update_appearance), self);
@@ -252,9 +242,6 @@ nautilus_toolbar_get_property (GObject *object,
 	case PROP_SHOW_LOCATION_ENTRY:
 		g_value_set_boolean (value, self->priv->show_location_entry);
 		break;
-	case PROP_SHOW_SEARCH_BAR:
-		g_value_set_boolean (value, self->priv->show_search_bar);
-		break;
 	case PROP_SHOW_MAIN_BAR:
 		g_value_set_boolean (value, self->priv->show_main_bar);
 		break;
@@ -282,9 +269,6 @@ nautilus_toolbar_set_property (GObject *object,
 	case PROP_SHOW_LOCATION_ENTRY:
 		nautilus_toolbar_set_show_location_entry (self, g_value_get_boolean (value));
 		break;
-	case PROP_SHOW_SEARCH_BAR:
-		nautilus_toolbar_set_show_search_bar (self, g_value_get_boolean (value));
-		break;
 	case PROP_SHOW_MAIN_BAR:
 		nautilus_toolbar_set_show_main_bar (self, g_value_get_boolean (value));
 		break;
@@ -337,12 +321,6 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
 				      "Whether to show the location entry instead of the pathbar",
 				      FALSE,
 				      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-	properties[PROP_SHOW_SEARCH_BAR] =
-		g_param_spec_boolean ("show-search-bar",
-				      "Whether to show the search bar",
-				      "Whether to show the search bar beside the toolbar",
-				      FALSE,
-				      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 	properties[PROP_SHOW_MAIN_BAR] =
 		g_param_spec_boolean ("show-main-bar",
 				      "Whether to show the main bar",
@@ -377,12 +355,6 @@ nautilus_toolbar_get_location_bar (NautilusToolbar *self)
 	return self->priv->location_bar;
 }
 
-GtkWidget *
-nautilus_toolbar_get_search_bar (NautilusToolbar *self)
-{
-	return self->priv->search_bar;
-}
-
 void
 nautilus_toolbar_set_show_main_bar (NautilusToolbar *self,
 				    gboolean show_main_bar)
@@ -406,15 +378,3 @@ nautilus_toolbar_set_show_location_entry (NautilusToolbar *self,
 		g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_LOCATION_ENTRY]);
 	}
 }
-
-void
-nautilus_toolbar_set_show_search_bar (NautilusToolbar *self,
-				      gboolean show_search_bar)
-{
-	if (show_search_bar != self->priv->show_search_bar) {
-		self->priv->show_search_bar = show_search_bar;
-		toolbar_update_appearance (self);
-
-		g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_SEARCH_BAR]);
-	}
-}
diff --git a/src/nautilus-toolbar.h b/src/nautilus-toolbar.h
index 742f05b..344760a 100644
--- a/src/nautilus-toolbar.h
+++ b/src/nautilus-toolbar.h
@@ -67,13 +67,10 @@ GtkWidget *nautilus_toolbar_new (GtkUIManager *ui_manager,
 
 GtkWidget *nautilus_toolbar_get_path_bar (NautilusToolbar *self);
 GtkWidget *nautilus_toolbar_get_location_bar (NautilusToolbar *self);
-GtkWidget *nautilus_toolbar_get_search_bar (NautilusToolbar *self);
 
 void nautilus_toolbar_set_show_main_bar (NautilusToolbar *self,
 					 gboolean show_main_bar);
 void nautilus_toolbar_set_show_location_entry (NautilusToolbar *self,
 					       gboolean show_location_entry);
-void nautilus_toolbar_set_show_search_bar (NautilusToolbar *self,
-					   gboolean show_search_bar);
 
 #endif /* __NAUTILUS_TOOLBAR_H__ */
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index c41a205..f8fa114 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -32,7 +32,6 @@
 #include "nautilus-application.h"
 #include "nautilus-floating-bar.h"
 #include "nautilus-location-bar.h"
-#include "nautilus-search-bar.h"
 #include "nautilus-pathbar.h"
 #include "nautilus-window-private.h"
 #include "nautilus-window-slot.h"
@@ -1398,8 +1397,6 @@ update_for_new_location (NautilusWindowSlot *slot)
 		
 		directory = nautilus_directory_get (slot->location);
 
-		nautilus_window_slot_update_query_editor (slot);
-
 		if (nautilus_directory_is_in_trash (directory)) {
 			nautilus_window_slot_show_trash_bar (slot);
 		}
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 9a263b9..b178ebf 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -39,7 +39,6 @@
 #include "nautilus-window-bookmarks.h"
 #include "nautilus-window-private.h"
 #include "nautilus-desktop-window.h"
-#include "nautilus-search-bar.h"
 #include <gtk/gtk.h>
 #include <gio/gio.h>
 #include <glib/gi18n.h>
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 011318d..407c49b 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -26,6 +26,7 @@
 
 #include "nautilus-window-slot.h"
 
+#include "nautilus-actions.h"
 #include "nautilus-desktop-window.h"
 #include "nautilus-toolbar.h"
 #include "nautilus-floating-bar.h"
@@ -52,83 +53,162 @@ enum {
 static guint signals[LAST_SIGNAL] = { 0 };
 
 static void
-query_editor_changed_callback (NautilusSearchBar *bar,
-			       NautilusQuery *query,
-			       gboolean reload,
-			       NautilusWindowSlot *slot)
+sync_search_directory (NautilusWindowSlot *slot)
 {
 	NautilusDirectory *directory;
+	NautilusQuery *query;
 
 	g_assert (NAUTILUS_IS_FILE (slot->viewed_file));
 
 	directory = nautilus_directory_get_for_file (slot->viewed_file);
 	g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory));
 
+	query = nautilus_query_editor_get_query (slot->query_editor);
 	nautilus_search_directory_set_query (NAUTILUS_SEARCH_DIRECTORY (directory),
 					     query);
-	if (reload) {
-		nautilus_window_slot_reload (slot);
+	g_object_unref (query);
+	nautilus_window_slot_reload (slot);
+
+	nautilus_directory_unref (directory);
+}
+
+static void
+sync_search_location_cb (NautilusWindow *window,
+			 GError *error,
+			 gpointer user_data)
+{
+	NautilusWindowSlot *slot = user_data;
+
+	sync_search_directory (slot);
+}
+
+static void
+create_new_search (NautilusWindowSlot *slot)
+{
+	char *uri;
+	NautilusDirectory *directory;
+	GFile *location;
+
+	uri = nautilus_search_directory_generate_new_uri ();
+	location = g_file_new_for_uri (uri);
+
+	directory = nautilus_directory_get (location);
+	g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory));
+
+	nautilus_window_slot_open_location_full (slot, location, 0, NULL, sync_search_location_cb, slot);
+
+	nautilus_directory_unref (directory);
+	g_object_unref (location);
+	g_free (uri);
+}
+
+static void
+query_editor_cancel_callback (NautilusQueryEditor *editor,
+			      NautilusWindowSlot *slot)
+{
+	GtkAction *search;
+
+	search = gtk_action_group_get_action (slot->window->details->toolbar_action_group,
+					      NAUTILUS_ACTION_SEARCH);
+
+	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (search), FALSE);
+}
+
+static void
+query_editor_changed_callback (NautilusQueryEditor *editor,
+			       NautilusQuery *query,
+			       gboolean reload,
+			       NautilusWindowSlot *slot)
+{
+	NautilusDirectory *directory;
+
+	g_assert (NAUTILUS_IS_FILE (slot->viewed_file));
+
+	directory = nautilus_directory_get_for_file (slot->viewed_file);
+	if (!NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
+		/* this is the first change from the query editor. we
+		   ask for a location change to the search directory,
+		   indicate the directory needs to be sync'd with the
+		   current query. */
+		create_new_search (slot);
+	} else {
+		sync_search_directory (slot);
 	}
 
 	nautilus_directory_unref (directory);
 }
 
 static void
-real_update_query_editor (NautilusWindowSlot *slot)
+update_query_editor (NautilusWindowSlot *slot)
 {
 	NautilusDirectory *directory;
 	NautilusSearchDirectory *search_directory;
 	NautilusQuery *query;
-	GtkWidget *query_editor;
-	gboolean slot_is_active;
-	NautilusWindow *window;
-
-	window = slot->window;
-	query_editor = NULL;
-	slot_is_active = (slot == nautilus_window_get_active_slot (window));
 
 	directory = nautilus_directory_get (slot->location);
+
+	query = NULL;
+
 	if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
 		search_directory = NAUTILUS_SEARCH_DIRECTORY (directory);
+		query = nautilus_search_directory_get_query (search_directory);
+	}
 
-		if (nautilus_search_directory_is_saved_search (search_directory)) {
-			query_editor = nautilus_query_editor_new (TRUE);
-			nautilus_window_sync_search_widgets (window);
-		} else {
-			GtkWidget *search_bar;
+	if (query == NULL) {
+		char *uri;
+		uri = g_file_get_uri (slot->location);
+		query = nautilus_query_new ();
+		nautilus_query_set_location (query, uri);
+		g_free (uri);
+	}
+	nautilus_query_editor_set_query (slot->query_editor,
+					 query);
+	g_object_unref (query);
 
-			search_bar = nautilus_toolbar_get_search_bar (NAUTILUS_TOOLBAR (window->details->toolbar));
-			query_editor = nautilus_query_editor_new_with_bar (FALSE,
-									   slot_is_active,
-									   NAUTILUS_SEARCH_BAR (search_bar),
-									   slot);
-		}
+	nautilus_directory_unref (directory);
+}
+
+static void
+ensure_query_editor (NautilusWindowSlot *slot)
+{
+	GtkWidget *query_editor;
+
+	if (slot->query_editor != NULL) {
+		return;
 	}
 
+	query_editor = nautilus_query_editor_new ();
 	slot->query_editor = NAUTILUS_QUERY_EDITOR (query_editor);
 
-	if (query_editor != NULL) {
-		g_signal_connect_object (query_editor, "changed",
-					 G_CALLBACK (query_editor_changed_callback), slot, 0);
-		
-		query = nautilus_search_directory_get_query (search_directory);
-		if (query != NULL) {
-			nautilus_query_editor_set_query (NAUTILUS_QUERY_EDITOR (query_editor),
-							 query);
-			g_object_unref (query);
-		} else {
-			nautilus_query_editor_set_default_query (NAUTILUS_QUERY_EDITOR (query_editor));
-		}
+	nautilus_window_slot_add_extra_location_widget (slot, query_editor);
+	gtk_widget_show (query_editor);
+	nautilus_query_editor_grab_focus (slot->query_editor);
 
-		nautilus_window_slot_add_extra_location_widget (slot, query_editor);
-		gtk_widget_show (query_editor);
-		nautilus_query_editor_grab_focus (NAUTILUS_QUERY_EDITOR (query_editor));
+	update_query_editor (slot);
 
-		g_object_add_weak_pointer (G_OBJECT (slot->query_editor),
-					   (gpointer *) &slot->query_editor);
-	}
+	g_signal_connect_object (slot->query_editor, "changed",
+				 G_CALLBACK (query_editor_changed_callback), slot, 0);
+	g_signal_connect_object (slot->query_editor, "cancel",
+				 G_CALLBACK (query_editor_cancel_callback), slot, 0);
 
-	nautilus_directory_unref (directory);
+	g_object_add_weak_pointer (G_OBJECT (slot->query_editor),
+				   (gpointer *) &slot->query_editor);
+}
+
+void
+nautilus_window_slot_set_query_editor_visible (NautilusWindowSlot *slot,
+					       gboolean            visible)
+{
+	if (visible) {
+		ensure_query_editor (slot);
+		nautilus_query_editor_set_visible (slot->query_editor, TRUE);
+		nautilus_query_editor_grab_focus (slot->query_editor);
+	} else {
+		if (slot->query_editor != NULL) {
+			gtk_widget_destroy (GTK_WIDGET (slot->query_editor));
+			g_assert (slot->query_editor == NULL);
+		}
+	}
 }
 
 static void
@@ -578,41 +658,28 @@ nautilus_window_slot_set_status (NautilusWindowSlot *slot,
 	}
 }
 
-/* nautilus_window_slot_update_query_editor:
- * 
- * Update the query editor.
- * Called when the location has changed.
- *
- * @slot: The NautilusWindowSlot in question.
- */
-void
-nautilus_window_slot_update_query_editor (NautilusWindowSlot *slot)
-{
-	if (slot->query_editor != NULL) {
-		gtk_widget_destroy (GTK_WIDGET (slot->query_editor));
-		g_assert (slot->query_editor == NULL);
-	}
-
-	real_update_query_editor (slot);
-}
-
 static void
-remove_all (GtkWidget *widget,
-	    gpointer data)
+remove_all_extra_location_widgets (GtkWidget *widget,
+				   gpointer data)
 {
-	GtkContainer *container;
-	container = GTK_CONTAINER (data);
+	NautilusWindowSlot *slot = data;
+	NautilusDirectory *directory;
 
-	gtk_container_remove (container, widget);
+	directory = nautilus_directory_get (slot->location);
+	if (!NAUTILUS_IS_SEARCH_DIRECTORY (directory)
+	    || (widget != GTK_WIDGET (slot->query_editor))) {
+		gtk_container_remove (GTK_CONTAINER (slot->extra_location_widgets), widget);
+	}
+
+	nautilus_directory_unref (directory);
 }
 
 void
 nautilus_window_slot_remove_extra_location_widgets (NautilusWindowSlot *slot)
 {
 	gtk_container_foreach (GTK_CONTAINER (slot->extra_location_widgets),
-			       remove_all,
-			       slot->extra_location_widgets);
-	gtk_widget_hide (slot->extra_location_widgets);
+			       remove_all_extra_location_widgets,
+			       slot);
 }
 
 void
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index a1ef1c8..42586f1 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -120,7 +120,8 @@ NautilusWindowSlot * nautilus_window_slot_new (NautilusWindow *window);
 
 void    nautilus_window_slot_update_title		   (NautilusWindowSlot *slot);
 void    nautilus_window_slot_update_icon		   (NautilusWindowSlot *slot);
-void    nautilus_window_slot_update_query_editor	   (NautilusWindowSlot *slot);
+void    nautilus_window_slot_set_query_editor_visible	   (NautilusWindowSlot *slot,
+							    gboolean            visible);
 
 GFile * nautilus_window_slot_get_location		   (NautilusWindowSlot *slot);
 char *  nautilus_window_slot_get_location_uri		   (NautilusWindowSlot *slot);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 7b6181d..7ee9a82 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -38,7 +38,6 @@
 #include "nautilus-notebook.h"
 #include "nautilus-places-sidebar.h"
 #include "nautilus-pathbar.h"
-#include "nautilus-search-bar.h"
 #include "nautilus-toolbar.h"
 #include "nautilus-view-factory.h"
 #include "nautilus-window-manage-views.h"
@@ -198,46 +197,6 @@ bookmark_list_get_uri_index (GList *list, GFile *location)
 }
 
 static void
-search_bar_activate_callback (NautilusSearchBar *bar,
-			      NautilusWindow    *window)
-{
-	char *uri, *current_uri;
-	NautilusDirectory *directory;
-	NautilusSearchDirectory *search_directory;
-	NautilusQuery *query;
-	GFile *location;
-	GtkWidget *search_bar;
-
-	uri = nautilus_search_directory_generate_new_uri ();
-	location = g_file_new_for_uri (uri);
-
-	directory = nautilus_directory_get (location);
-	g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory));
-
-	search_directory = NAUTILUS_SEARCH_DIRECTORY (directory);
-
-	search_bar = nautilus_toolbar_get_search_bar (NAUTILUS_TOOLBAR (window->details->toolbar));
-
-	query = nautilus_search_bar_get_query (NAUTILUS_SEARCH_BAR (search_bar));
-
-	if (query != NULL) {
-		current_uri = nautilus_window_slot_get_location_uri (window->details->active_slot);
-
-		nautilus_query_set_location (query, current_uri);
-		nautilus_search_directory_set_query (search_directory, query);
-
-		g_free (current_uri);
-		g_object_unref (query);
-	}
-
-	nautilus_window_slot_open_location (window->details->active_slot, location, 0);
-
-	nautilus_directory_unref (directory);
-	g_object_unref (location);
-	g_free (uri);
-}
-
-static void
 nautilus_window_hide_temporary_bars (NautilusWindow *window)
 {
 	NautilusWindowSlot *slot;
@@ -255,7 +214,6 @@ nautilus_window_hide_temporary_bars (NautilusWindow *window)
 		 */
 		if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
 			nautilus_toolbar_set_show_main_bar (NAUTILUS_TOOLBAR (window->details->toolbar), FALSE);
-			nautilus_toolbar_set_show_search_bar (NAUTILUS_TOOLBAR (window->details->toolbar), TRUE);
 		} else {
 			gtk_widget_hide (window->details->toolbar);
 		}
@@ -265,18 +223,6 @@ nautilus_window_hide_temporary_bars (NautilusWindow *window)
 }
 
 static void
-search_bar_cancel_callback (GtkWidget      *widget,
-			    NautilusWindow *window)
-{
-	GtkAction *search;
-
-	search = gtk_action_group_get_action (window->details->toolbar_action_group,
-					      NAUTILUS_ACTION_SEARCH);
-
-	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (search), FALSE);
-}
-
-static void
 unset_focus_widget (NautilusWindow *window)
 {
 	if (window->details->last_focus_widget != NULL) {
@@ -293,9 +239,7 @@ widget_is_in_temporary_bars (GtkWidget      *widget,
 	gboolean res = FALSE;
 
 	if ((gtk_widget_get_ancestor (widget, NAUTILUS_TYPE_LOCATION_BAR) != NULL &&
-	     window->details->temporary_navigation_bar) ||
-	    (gtk_widget_get_ancestor (widget, NAUTILUS_TYPE_SEARCH_BAR) != NULL &&
-	     window->details->temporary_search_bar))
+	     window->details->temporary_navigation_bar))
 		res = TRUE;
 
 	return res;
@@ -350,36 +294,11 @@ navigation_bar_cancel_callback (GtkWidget      *widget,
 }
 
 static void
-nautilus_window_ensure_search_bar (NautilusWindow *window)
-{
-	GtkWidget *search_bar;
-
-	remember_focus_widget (window);
-	nautilus_toolbar_set_show_search_bar (NAUTILUS_TOOLBAR (window->details->toolbar), TRUE);
-	search_bar = nautilus_toolbar_get_search_bar (NAUTILUS_TOOLBAR (window->details->toolbar));
-	nautilus_search_bar_grab_focus (NAUTILUS_SEARCH_BAR (search_bar));
-}
-
-static void
-nautilus_window_hide_search_bar (NautilusWindow *window)
-{
-	nautilus_toolbar_set_show_search_bar (NAUTILUS_TOOLBAR (window->details->toolbar), FALSE);
-	restore_focus_widget (window);
-
-	if (window->details->temporary_search_bar) {
-		window->details->temporary_search_bar = FALSE;
-
-		gtk_widget_hide (window->details->toolbar);
-	}
-}
-
-static void
 navigation_bar_location_changed_callback (GtkWidget      *widget,
 					  GFile          *location,
 					  NautilusWindow *window)
 {
 	nautilus_toolbar_set_show_location_entry (NAUTILUS_TOOLBAR (window->details->toolbar), FALSE);
-	nautilus_window_hide_search_bar (window);
 	nautilus_window_hide_temporary_bars (window);
 
 	restore_focus_widget (window);
@@ -414,31 +333,21 @@ action_show_hide_search_callback (GtkAction *action,
 				  gpointer user_data)
 {
 	NautilusWindow *window = user_data;
+	NautilusWindowSlot *slot;
+
+	slot = window->details->active_slot;
 
 	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
-		nautilus_window_ensure_search_bar (window);
+		remember_focus_widget (window);
+		nautilus_window_slot_set_query_editor_visible (slot, TRUE);
 	} else {
-		NautilusWindowSlot *slot;
 		GFile *location = NULL;
 
-		slot = window->details->active_slot;
-		nautilus_window_hide_search_bar (window);
+		restore_focus_widget (window);
 
 		/* Use the location bar as the return location */
 		if (slot->query_editor != NULL) {
-			NautilusQuery *query;
-			char *uri;
-
-			query = nautilus_query_editor_get_query (slot->query_editor);
-			if (query != NULL) {
-				uri = nautilus_query_get_location (query);
-				if (uri != NULL) {
-					location = g_file_new_for_uri (uri);
-					g_free (uri);
-				}
-				g_object_unref (query);
-			}
-
+			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 ());
@@ -447,6 +356,8 @@ action_show_hide_search_callback (GtkAction *action,
 			nautilus_window_go_to (window, location);
 			g_object_unref (location);
 		}
+
+		nautilus_window_slot_set_query_editor_visible (slot, FALSE);
 	}
 }
 
@@ -829,17 +740,14 @@ nautilus_window_slot_close (NautilusWindow     *window,
 }
 
 static void
-toggle_toolbar_search_button (NautilusWindow *window)
+toggle_toolbar_search_button (NautilusWindow *window,
+			      gboolean        active)
 {
 	GtkAction *action;
 
 	action = gtk_action_group_get_action (window->details->toolbar_action_group, NAUTILUS_ACTION_SEARCH);
 
-	g_signal_handlers_block_by_func (action,
-					 action_show_hide_search_callback, window);
-	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
-	g_signal_handlers_unblock_by_func (action,
-					   action_show_hide_search_callback, window);
+	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
 }
 
 void
@@ -856,17 +764,9 @@ nautilus_window_sync_search_widgets (NautilusWindow *window)
 	}
 
 	if (search_directory != NULL) {
-		if (!nautilus_search_directory_is_saved_search (search_directory)) {
-			nautilus_toolbar_set_show_search_bar (NAUTILUS_TOOLBAR (window->details->toolbar), TRUE);
-			window->details->temporary_search_bar = FALSE;
-		} else {
-			toggle_toolbar_search_button (window);
-		}
+		toggle_toolbar_search_button (window, TRUE);
 	} else {
-		GtkWidget *search_bar;
-
-		search_bar = nautilus_toolbar_get_search_bar (NAUTILUS_TOOLBAR (window->details->toolbar));
-		search_bar_cancel_callback (search_bar, window);
+		toggle_toolbar_search_button (window, FALSE);
 	}
 
 	nautilus_directory_unref (directory);
@@ -1137,7 +1037,6 @@ create_toolbar (NautilusWindow *window)
 	GtkWidget *toolbar;
 	GtkWidget *path_bar;
 	GtkWidget *location_bar;
-	GtkWidget *search_bar;
 
 	header_size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
 	gtk_size_group_set_ignore_hidden (header_size_group, FALSE);
@@ -1179,14 +1078,6 @@ create_toolbar (NautilusWindow *window)
 	g_signal_connect_object (location_bar, "cancel",
 				 G_CALLBACK (navigation_bar_cancel_callback), window, 0);
 
-	/* connect to the search bar signals */
-	search_bar = nautilus_toolbar_get_search_bar (NAUTILUS_TOOLBAR (toolbar));
-
-	g_signal_connect_object (search_bar, "activate",
-				 G_CALLBACK (search_bar_activate_callback), window, 0);
-	g_signal_connect_object (search_bar, "cancel",
-				 G_CALLBACK (search_bar_cancel_callback), window, 0);
-
 	g_object_unref (header_size_group);
 
 	return toolbar;
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 2578cc8..50e9e6c 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -139,8 +139,8 @@ void                 nautilus_window_slot_close            (NautilusWindow *wind
 
 GtkWidget *          nautilus_window_ensure_location_bar   (NautilusWindow *window);
 void                 nautilus_window_sync_location_widgets (NautilusWindow *window);
-void                 nautilus_window_sync_search_widgets   (NautilusWindow *window);
 void                 nautilus_window_grab_focus            (NautilusWindow *window);
+void                 nautilus_window_sync_search_widgets   (NautilusWindow *window);
 
 void     nautilus_window_hide_sidebar         (NautilusWindow *window);
 void     nautilus_window_show_sidebar         (NautilusWindow *window);



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