nautilus r14293 - in branches/multiview: . src



Author: cneumair
Date: Sat Jun 28 18:27:43 2008
New Revision: 14293
URL: http://svn.gnome.org/viewvc/nautilus?rev=14293&view=rev

Log:
2008-06-28  Christian Neumair  <cneumair gnome org>

	* src/nautilus-query-editor.c (nautilus_query_editor_clear_query),
	(nautilus_query_editor_new), (detach_from_external_entry),
	(attach_to_external_entry), (nautilus_query_editor_new_with_bar),
	(nautilus_query_editor_set_query):
	* src/nautilus-query-editor.h:
	Attach to and detach from search bar entry as slot becomes active/
	inactive, restore search entry text on activation.


Modified:
   branches/multiview/ChangeLog
   branches/multiview/src/nautilus-query-editor.c
   branches/multiview/src/nautilus-query-editor.h

Modified: branches/multiview/src/nautilus-query-editor.c
==============================================================================
--- branches/multiview/src/nautilus-query-editor.c	(original)
+++ branches/multiview/src/nautilus-query-editor.c	Sat Jun 28 18:27:43 2008
@@ -23,6 +23,7 @@
 
 #include <config.h>
 #include "nautilus-query-editor.h"
+#include "nautilus-window-slot.h"
 
 #include <string.h>
 #include <libnautilus-private/nautilus-marshal.h>
@@ -86,8 +87,10 @@
 	GtkWidget *visible_vbox;
 
 	GList *rows;
+	char *last_set_query_text;
 	
 	NautilusSearchBar *bar;
+	NautilusWindowSlot *slot;
 };
 
 enum {
@@ -1188,11 +1191,16 @@
 {
 	editor->details->change_frozen = TRUE;
 	gtk_entry_set_text (GTK_ENTRY (editor->details->entry), "");
+
+	g_free (editor->details->last_set_query_text);
+	editor->details->last_set_query_text = g_strdup ("");
+
 	editor->details->change_frozen = FALSE;
 }
 
 GtkWidget *
-nautilus_query_editor_new (gboolean start_hidden, gboolean is_indexed)
+nautilus_query_editor_new (gboolean start_hidden,
+			   gboolean is_indexed)
 {
 	GtkWidget *editor;
 
@@ -1208,10 +1216,45 @@
 	return editor;
 }
 
+static void
+detach_from_external_entry (NautilusQueryEditor *editor)
+{
+	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);
+	}
+}
+
+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;
+	}
+}
+
 GtkWidget*
 nautilus_query_editor_new_with_bar (gboolean start_hidden,
 				    gboolean is_indexed,
-				    NautilusSearchBar *bar)
+				    gboolean start_attached,
+				    NautilusSearchBar *bar,
+				    NautilusWindowSlot *slot)
 {
 	GtkWidget *entry;
 	NautilusQueryEditor *editor;
@@ -1223,9 +1266,21 @@
 
 	editor->details->bar = bar;
 	eel_add_weak_pointer (&editor->details->bar);
-	
+
+	editor->details->slot = slot;
+
 	entry = nautilus_search_bar_borrow_entry (bar);
 	setup_external_entry (editor, entry);
+	if (!start_attached) {
+		detach_from_external_entry (editor);
+	}
+
+	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);
 }
@@ -1234,7 +1289,7 @@
 nautilus_query_editor_set_query (NautilusQueryEditor *editor, NautilusQuery *query)
 {
 	NautilusQueryEditorRowType type;
-	const char *text;
+	char *text;
 
 	if (!query) {
 		nautilus_query_editor_clear_query (editor);
@@ -1242,8 +1297,9 @@
 	}
 
 	text = nautilus_query_get_text (query);
+
 	if (!text) {
-		text = "";
+		text = g_strdup ("");
 	}
 
 	editor->details->change_frozen = TRUE;
@@ -1254,4 +1310,7 @@
 	}
 	
 	editor->details->change_frozen = FALSE;
+
+	g_free (editor->details->last_set_query_text);
+	editor->details->last_set_query_text = text;
 }

Modified: branches/multiview/src/nautilus-query-editor.h
==============================================================================
--- branches/multiview/src/nautilus-query-editor.h	(original)
+++ branches/multiview/src/nautilus-query-editor.h	Sat Jun 28 18:27:43 2008
@@ -28,6 +28,7 @@
 #include <gtk/gtkentry.h>
 #include <libnautilus-private/nautilus-query.h>
 #include <nautilus-search-bar.h>
+#include "nautilus-window-info.h"
 
 #define NAUTILUS_TYPE_QUERY_EDITOR (nautilus_query_editor_get_type ())
 #define NAUTILUS_QUERY_EDITOR(obj) GTK_CHECK_CAST (obj, NAUTILUS_TYPE_QUERY_EDITOR, NautilusQueryEditor)
@@ -55,7 +56,9 @@
 						    gboolean is_indexed);
 GtkWidget* nautilus_query_editor_new_with_bar      (gboolean start_hidden,
 						    gboolean is_indexed,
-						    NautilusSearchBar *bar);
+						    gboolean start_attached,
+						    NautilusSearchBar *bar,
+						    NautilusWindowSlot *slot);
 void       nautilus_query_editor_set_default_query (NautilusQueryEditor *editor);
 
 void	   nautilus_query_editor_grab_focus (NautilusQueryEditor *editor);



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