[nautilus] pane: don't make the toolbar for inactive pane insensitive



commit 01382c267728e2dd00cc8b48cd6024dbae183345
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Feb 13 21:11:16 2012 -0500

    pane: don't make the toolbar for inactive pane insensitive
    
    At the same time, we have to listen for events on the toolbar items to
    set the active pane.

 src/nautilus-search-bar.c   |    6 ++++++
 src/nautilus-search-bar.h   |    1 +
 src/nautilus-window-menus.c |    2 ++
 src/nautilus-window-pane.c  |   30 +++++++++++++++++++++++++++---
 4 files changed, 36 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-search-bar.c b/src/nautilus-search-bar.c
index a4072c8..a34027b 100644
--- a/src/nautilus-search-bar.c
+++ b/src/nautilus-search-bar.c
@@ -175,6 +175,12 @@ nautilus_search_bar_init (NautilusSearchBar *bar)
 }
 
 GtkWidget *
+nautilus_search_bar_get_entry (NautilusSearchBar *bar)
+{
+	return bar->details->entry;
+}
+
+GtkWidget *
 nautilus_search_bar_borrow_entry (NautilusSearchBar *bar)
 {
 	GtkBindingSet *binding_set;
diff --git a/src/nautilus-search-bar.h b/src/nautilus-search-bar.h
index bb8674f..c55e1b7 100644
--- a/src/nautilus-search-bar.h
+++ b/src/nautilus-search-bar.h
@@ -56,6 +56,7 @@ typedef struct {
 GType      nautilus_search_bar_get_type     	(void);
 GtkWidget* nautilus_search_bar_new          	(void);
 
+GtkWidget *    nautilus_search_bar_get_entry     (NautilusSearchBar *bar);
 GtkWidget *    nautilus_search_bar_borrow_entry  (NautilusSearchBar *bar);
 void           nautilus_search_bar_return_entry  (NautilusSearchBar *bar);
 void           nautilus_search_bar_grab_focus    (NautilusSearchBar *bar);
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index bd1d279..fdefb38 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -1119,6 +1119,7 @@ nautilus_window_create_toolbar_action_group (NautilusWindow *window)
 			       "arrow-tooltip", _("Back history"),
 			       "window", window,
 			       "direction", NAUTILUS_NAVIGATION_DIRECTION_BACK,
+			       "sensitive", FALSE,
 			       NULL);
 	g_signal_connect (action, "activate",
 			  G_CALLBACK (action_back_callback), window);
@@ -1134,6 +1135,7 @@ nautilus_window_create_toolbar_action_group (NautilusWindow *window)
 			       "arrow-tooltip", _("Forward history"),
 			       "window", window,
 			       "direction", NAUTILUS_NAVIGATION_DIRECTION_FORWARD,
+			       "sensitive", FALSE,
 			       NULL);
 	g_signal_connect (action, "activate",
 			  G_CALLBACK (action_forward_callback), window);
diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c
index 4ee2532..b5658eb 100644
--- a/src/nautilus-window-pane.c
+++ b/src/nautilus-window-pane.c
@@ -285,6 +285,17 @@ navigation_bar_location_changed_callback (GtkWidget *widget,
 	g_object_unref (location);
 }
 
+static gboolean
+toolbar_focus_in_callback (GtkWidget *widget,
+			   GdkEventFocus *event,
+			   gpointer user_data)
+{
+	NautilusWindowPane *pane = user_data;
+	nautilus_window_set_active_pane (pane->window, pane);
+
+	return FALSE;
+}
+
 static void
 path_bar_location_changed_callback (GtkWidget *widget,
 				    GFile *location,
@@ -294,6 +305,7 @@ path_bar_location_changed_callback (GtkWidget *widget,
 	int i;
 
 	slot = pane->active_slot;
+	nautilus_window_set_active_pane (pane->window, pane);
 
 	/* check whether we already visited the target location */
 	i = bookmark_list_get_uri_index (slot->back_list, location);
@@ -651,6 +663,15 @@ setup_search_action (NautilusWindowPane *pane)
 }
 
 static void
+toolbar_action_group_activated_callback (GtkActionGroup *action_group,
+					 GtkAction *action,
+					 gpointer user_data)
+{
+	NautilusWindowPane *pane = user_data;
+	nautilus_window_set_active_pane (pane->window, pane);
+}
+
+static void
 nautilus_window_pane_set_property (GObject *object,
 				   guint arg_id,
 				   const GValue *value,
@@ -722,6 +743,8 @@ nautilus_window_pane_constructed (GObject *obj)
 	pane->action_group = action_group;
 
 	setup_search_action (pane);
+	g_signal_connect (pane->action_group, "pre-activate",
+			  G_CALLBACK (toolbar_action_group_activated_callback), pane);
 
 	gtk_box_pack_start (GTK_BOX (pane),
 			    pane->tool_bar,
@@ -760,6 +783,8 @@ nautilus_window_pane_constructed (GObject *obj)
 				 G_CALLBACK (navigation_bar_location_changed_callback), pane, 0);
 	g_signal_connect_object (pane->location_bar, "cancel",
 				 G_CALLBACK (navigation_bar_cancel_callback), pane, 0);
+	g_signal_connect_object (nautilus_location_bar_get_entry (NAUTILUS_LOCATION_BAR (pane->location_bar)), "focus-in-event",
+				 G_CALLBACK (toolbar_focus_in_callback), pane, 0);
 
 	/* connect to the search bar signals */
 	pane->search_bar = nautilus_toolbar_get_search_bar (NAUTILUS_TOOLBAR (pane->tool_bar));
@@ -769,6 +794,8 @@ nautilus_window_pane_constructed (GObject *obj)
 				 G_CALLBACK (search_bar_activate_callback), pane, 0);
 	g_signal_connect_object (pane->search_bar, "cancel",
 				 G_CALLBACK (search_bar_cancel_callback), pane, 0);
+	g_signal_connect_object (nautilus_search_bar_get_entry (NAUTILUS_SEARCH_BAR (pane->search_bar)), "focus-in-event",
+				 G_CALLBACK (toolbar_focus_in_callback), pane, 0);
 
 	/* initialize the notebook */
 	pane->notebook = g_object_new (NAUTILUS_TYPE_NOTEBOOK, NULL);
@@ -878,9 +905,6 @@ nautilus_window_pane_set_active (NautilusWindowPane *pane,
 		nautilus_navigation_state_set_master (nav_state, pane->action_group);
 	}
 
-	/* toolbar */
-	gtk_widget_set_sensitive (pane->tool_bar, is_active);
-
 	/* pane inactive style */
 	nautilus_window_pane_set_active_style (pane, is_active);
 }



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