[nautilus] Fix focus handling



commit c78da8903804267ef7399d92753c5f5b2e811585
Author: Holger Berndt <hb gnome org>
Date:   Thu Mar 11 19:25:07 2010 +0100

    Fix focus handling
    
    Move the focus to a new window's first slot. The extra
    pane doesn't get focus initially, which fixes
    bug 612203.
    
    To make this work for all views, the focus_grab interface
    function was implemented for the directory view class.

 src/file-manager/fm-directory-view.c |   13 +++++++++++++
 src/nautilus-window-pane.c           |   18 +++++++++---------
 src/nautilus-window-pane.h           |    2 ++
 src/nautilus-window.c                |    2 +-
 4 files changed, 25 insertions(+), 10 deletions(-)
---
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index a9829d3..0997a15 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -1773,6 +1773,17 @@ slot_inactive (NautilusWindowSlot *slot,
 	remove_update_menus_timeout_callback (view);
 }
 
+static void
+fm_directory_view_grab_focus (NautilusView *view)
+{
+	/* focus the child of the scrolled window if it exists */
+	GtkWidget *child;
+	child = gtk_bin_get_child (GTK_BIN (view));
+	if (child) {
+		gtk_widget_grab_focus (GTK_WIDGET (child));
+	}
+}
+
 static GtkWidget *
 fm_directory_view_get_widget (NautilusView *view)
 {
@@ -1860,6 +1871,8 @@ fm_directory_view_set_selection_locations (NautilusView *nautilus_view,
 void
 fm_directory_view_init_view_iface (NautilusViewIface *iface)
 {
+	iface->grab_focus = fm_directory_view_grab_focus;
+
 	iface->get_widget = fm_directory_view_get_widget;
   	iface->load_location = fm_directory_view_load_location;
 	iface->stop_loading = fm_directory_view_stop_loading;
diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c
index cd3aa49..acb8657 100644
--- a/src/nautilus-window-pane.c
+++ b/src/nautilus-window-pane.c
@@ -185,19 +185,19 @@ nautilus_window_pane_sync_search_widgets (NautilusWindowPane *pane)
 }
 
 void
-nautilus_window_pane_switch_to (NautilusWindowPane *pane)
+nautilus_window_pane_grab_focus (NautilusWindowPane *pane)
 {
-	if (NAUTILUS_IS_WINDOW_PANE (pane)) {
-		GList *children;
-
-		children = gtk_container_get_children (GTK_CONTAINER (pane->active_slot->content_view));
-		if (children) {
-			gtk_widget_grab_focus (GTK_WIDGET (children->data));		
-			g_list_free (children);
-		}
+	if (NAUTILUS_IS_WINDOW_PANE (pane) && pane->active_slot) {
+		nautilus_view_grab_focus (pane->active_slot->content_view);
 	}	
 }
 
+void
+nautilus_window_pane_switch_to (NautilusWindowPane *pane)
+{
+	nautilus_window_pane_grab_focus (pane);
+}
+
 static void
 nautilus_window_pane_init (NautilusWindowPane *pane)
 {
diff --git a/src/nautilus-window-pane.h b/src/nautilus-window-pane.h
index 7a6a172..68c5d6c 100644
--- a/src/nautilus-window-pane.h
+++ b/src/nautilus-window-pane.h
@@ -89,5 +89,7 @@ void nautilus_window_pane_slot_close (NautilusWindowPane *pane, NautilusWindowSl
 
 NautilusWindowSlot* nautilus_window_pane_get_slot_for_content_box (NautilusWindowPane *pane, GtkWidget *content_box);
 void nautilus_window_pane_switch_to (NautilusWindowPane *pane);
+void nautilus_window_pane_grab_focus (NautilusWindowPane *pane);
+
 
 #endif /* NAUTILUS_WINDOW_PANE_H */
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 716561a..df54f48 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -707,7 +707,7 @@ nautilus_window_view_visible (NautilusWindow *window,
 		}
 	}
 
-	nautilus_view_grab_focus (window->details->active_pane->active_slot->content_view);
+	nautilus_window_pane_grab_focus (window->details->active_pane);
 
 	/* All slots and panes visible, show window */
 	nautilus_window_show_window (window);



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