[nautilus] window: don't remember focus widget when switching search visible



commit 6f64f5e23a1ba9e35c10f2da7fba6d80c76e2e97
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Oct 29 18:28:05 2012 -0400

    window: don't remember focus widget when switching search visible
    
    The workaround we need to make to focus the entry on-the-fly and
    synchronizing the visible state with the toolbar button badly clash with
    the focus widget state saving mechanism we have in place.
    We end up calling remember_focus_widget() on the newly-focused
    search entry in certain circumstances, so we end up restoring the focus
    on the (then hidden) search entry, which will then eat key events while
    invisible.
    
    Sidestep the issue entirely by just focusing back the view when closing
    the query editor.

 src/nautilus-window-menus.c   |    4 +++-
 src/nautilus-window-private.h |    3 ---
 src/nautilus-window-slot.c    |    4 ++++
 src/nautilus-window.c         |   24 +++++-------------------
 4 files changed, 12 insertions(+), 23 deletions(-)
---
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index c3a1a90..53ec012 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -416,9 +416,11 @@ action_show_hide_search_callback (GtkAction *action,
 				  NautilusWindow *window)
 {
 	gboolean active;
+	NautilusWindowSlot *slot;
 
 	active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
-	nautilus_window_set_search_visible (window, active);
+	slot = nautilus_window_get_active_slot (window);
+	nautilus_window_slot_set_search_visible (slot, active);
 }
 
 static void
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index d49a507..0dd01d4 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -107,9 +107,6 @@ void nautilus_window_sync_title            (NautilusWindow *window,
 void nautilus_window_sync_zoom_widgets     (NautilusWindow *window);
 void nautilus_window_sync_up_button        (NautilusWindow *window);
 
-void nautilus_window_set_search_visible   (NautilusWindow *window,
-                                           gboolean        visible);
-
 /* window menus */
 void               nautilus_window_initialize_actions                    (NautilusWindow    *window);
 void               nautilus_window_initialize_menus                      (NautilusWindow    *window);
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index e86187c..5b3254b 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -400,6 +400,10 @@ nautilus_window_slot_set_search_visible (NautilusWindowSlot *slot,
 			}
 		}
 
+		if (active_slot) {
+			nautilus_window_grab_focus (slot->details->window);
+		}
+
 		/* Now hide the editor and clear its state */
 		hide_query_editor (slot);
 	}
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 8cb978e..8a2b1c6 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -205,10 +205,13 @@ void
 nautilus_window_grab_focus (NautilusWindow *window)
 {
 	NautilusWindowSlot *slot;
+	NautilusView *view;
 
 	slot = nautilus_window_get_active_slot (window);
-	if (slot) {
-		nautilus_view_grab_focus (nautilus_window_slot_get_view (slot));
+	view = nautilus_window_slot_get_view (slot);
+
+	if (view) {
+		nautilus_view_grab_focus (view);
 	}
 }
 
@@ -269,23 +272,6 @@ notebook_switch_page_cb (GtkNotebook    *notebook,
 	return FALSE;
 }
 
-void
-nautilus_window_set_search_visible (NautilusWindow *window,
-				    gboolean visible)
-{
-	NautilusWindowSlot *slot;
-
-	slot = window->details->active_slot;
-
-	if (visible) {
-		remember_focus_widget (window);
-		nautilus_window_slot_set_search_visible (slot, TRUE);
-	} else {
-		restore_focus_widget (window);
-		nautilus_window_slot_set_search_visible (slot, FALSE);
-	}
-}
-
 static void
 close_slot (NautilusWindow     *window,
 	    NautilusWindowSlot *slot,



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