[nautilus] Don't focus the search entry when we're activating a pane with search



commit 8f3e5b8d65d5c67ce6b762c8c33efc42ee13f6c3
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Dec 17 12:46:51 2009 +0100

    Don't focus the search entry when we're activating a pane with search
    
    This is not the right behaviour, and additionally it caused problems
    to do this from the focus in signal handler for the icon view, since
    the recursion of the focus changes caused HAS_FOCUS state to be mixed up.

 src/nautilus-navigation-window-menus.c |    6 ++++++
 src/nautilus-navigation-window.c       |   10 +++++++++-
 2 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index 2926fdd..1b083db 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -905,6 +905,12 @@ action_show_hide_search_callback (GtkAction *action,
 {
 	NautilusNavigationWindow *window;
 
+	/* This is used when toggling the action for updating the UI
+	   state only, not actually activating the action */
+	if (g_object_get_data (G_OBJECT (action), "blocked") != NULL) {
+		return;
+	}
+
 	window = NAUTILUS_NAVIGATION_WINDOW (user_data);
 
 	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index cf25fdb..d197f5b 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -823,14 +823,22 @@ nautilus_navigation_window_hide_search (NautilusNavigationWindow *window)
 	}
 }
 
+/* This updates the UI state of the search button, but does not
+   in itself trigger a search action */
 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");
+	action = gtk_action_group_get_action (window->details->navigation_action_group,
+					      "Search");
+
+	/* Block callback so we don't activate the action and thus focus the
+	   search entry */
+	g_object_set_data (G_OBJECT (action), "blocked", GINT_TO_POINTER (1));
 	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), state);
+	g_object_set_data (G_OBJECT (action), "blocked", NULL);
 }
 
 static void



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