[nautilus] Use a more GNOME 3 toolbar layout



commit 4583f7bc0c40f77871ca6346a81f4da355666405
Author: William Jon McCann <jmccann redhat com>
Date:   Sat May 26 09:40:14 2012 -0400

    Use a more GNOME 3 toolbar layout
    
    https://bugzilla.gnome.org/show_bug.cgi?id=676531

 src/Makefile.am             |    1 -
 src/nautilus-pathbar.c      |    5 ++-
 src/nautilus-toolbar-ui.xml |    7 ----
 src/nautilus-toolbar.c      |   83 ++++++++++++++++++++++++++++++++++---------
 src/nautilus-window-menus.c |    9 ++---
 src/nautilus-window.c       |   11 +++---
 src/nautilus.gresource.xml  |    1 -
 7 files changed, 79 insertions(+), 38 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 0f85ff2..664b7d2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -58,7 +58,6 @@ UI_FILES = \
 	nautilus-bookmarks-window.ui		\
 	nautilus-file-management-properties.ui	\
 	nautilus-icon-view-ui.xml		\
-	nautilus-toolbar-ui.xml			\
 	nautilus-directory-view-ui.xml		\
 	nautilus-desktop-icon-view-ui.xml	\
 	nautilus-list-view-ui.xml		\
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 3b0af23..a2dab9f 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -239,7 +239,7 @@ nautilus_path_bar_init (NautilusPathBar *path_bar)
 	gtk_widget_set_has_window (GTK_WIDGET (path_bar), FALSE);
         gtk_widget_set_redraw_on_allocate (GTK_WIDGET (path_bar), FALSE);
 
-        path_bar->priv->spacing = 3;
+        path_bar->priv->spacing = 0;
         path_bar->priv->up_slider_button = get_slider_button (path_bar, GTK_ARROW_LEFT);
         path_bar->priv->down_slider_button = get_slider_button (path_bar, GTK_ARROW_RIGHT);
 
@@ -279,6 +279,9 @@ nautilus_path_bar_init (NautilusPathBar *path_bar)
                           "trash_state_changed",
                           G_CALLBACK (trash_state_changed_cb),
                           path_bar);
+
+	gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (path_bar)),
+                                     GTK_STYLE_CLASS_LINKED);
 }
 
 static void
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index d770f44..fe9c360 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -29,6 +29,7 @@
 
 #include "nautilus-location-bar.h"
 #include "nautilus-pathbar.h"
+#include "nautilus-actions.h"
 #include "nautilus-window-private.h"
 
 #include <libnautilus-private/nautilus-global-preferences.h>
@@ -44,6 +45,8 @@ struct _NautilusToolbarPriv {
 	GtkWidget *location_bar;
 	GtkWidget *search_bar;
 
+	GtkToolItem *back_forward;
+
 	gboolean show_main_bar;
 	gboolean show_location_entry;
 	gboolean show_search_bar;
@@ -86,37 +89,69 @@ nautilus_toolbar_constructed (GObject *obj)
 {
 	NautilusToolbar *self = NAUTILUS_TOOLBAR (obj);
 	GtkToolItem *item;
-	GtkWidget *hbox, *toolbar, *search;
+	GtkWidget *hbox, *toolbar;
 	GtkStyleContext *context;
+	GtkWidget *tool_button, *box;
+	GtkToolItem *back_forward;
+	GtkToolItem *search;
+	GtkActionGroup *action_group;
+	GtkAction *action;
 
 	G_OBJECT_CLASS (nautilus_toolbar_parent_class)->constructed (obj);
 
 	gtk_style_context_set_junction_sides (gtk_widget_get_style_context (GTK_WIDGET (self)),
 					      GTK_JUNCTION_BOTTOM);
 
-	/* add the UI */
-	self->priv->ui_manager = gtk_ui_manager_new ();
-	gtk_ui_manager_add_ui_from_resource (self->priv->ui_manager, "/org/gnome/nautilus/nautilus-toolbar-ui.xml", NULL);
-	gtk_ui_manager_insert_action_group (self->priv->ui_manager, self->priv->action_group, 0);
-
-	toolbar = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar");
+	toolbar = gtk_toolbar_new ();
 	self->priv->toolbar = toolbar;
-	gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR);
-
-	context = gtk_widget_get_style_context (toolbar);
-	gtk_style_context_add_class (context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
-
-	search = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar/Search");
-	gtk_style_context_add_class (gtk_widget_get_style_context (search), GTK_STYLE_CLASS_RAISED);
-	gtk_widget_set_name (search, "nautilus-search-button");
 
 	gtk_box_pack_start (GTK_BOX (self), self->priv->toolbar, TRUE, TRUE, 0);
 	gtk_widget_show_all (self->priv->toolbar);
 
+	context = gtk_widget_get_style_context (toolbar);
+	/* Set the MENUBAR style class so it's possible to drag the app
+	 * using the toolbar. */
+	gtk_style_context_add_class (context, GTK_STYLE_CLASS_MENUBAR);
+
+	/* Back and Forward */
+	back_forward = gtk_tool_item_new ();
+	box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+	action_group = self->priv->action_group;
+
+	/* Back */
+	tool_button = gtk_button_new ();
+	gtk_button_set_image (GTK_BUTTON (tool_button), gtk_image_new ());
+	action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_BACK);
+	gtk_activatable_set_related_action (GTK_ACTIVATABLE (tool_button),
+					    action);
+	gtk_button_set_label (GTK_BUTTON (tool_button), NULL);
+	gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (tool_button));
+
+	/* Forward */
+	tool_button = gtk_button_new ();
+	gtk_button_set_image (GTK_BUTTON (tool_button), gtk_image_new ());
+	action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_FORWARD);
+	gtk_activatable_set_related_action (GTK_ACTIVATABLE (tool_button),
+					    action);
+	gtk_button_set_label (GTK_BUTTON (tool_button), NULL);
+	gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (tool_button));
+
+	gtk_style_context_add_class (gtk_widget_get_style_context (box),
+				     GTK_STYLE_CLASS_RAISED);
+	gtk_style_context_add_class (gtk_widget_get_style_context (box),
+				     GTK_STYLE_CLASS_LINKED);
+
+	gtk_container_add (GTK_CONTAINER (back_forward), box);
+	gtk_container_add (GTK_CONTAINER (self->priv->toolbar), GTK_WIDGET (back_forward));
+
+	gtk_widget_show_all (GTK_WIDGET (back_forward));
+	gtk_widget_set_margin_right (GTK_WIDGET (back_forward), 12);
+
+	/* regular path bar */
 	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
 	gtk_widget_show (hbox);
 
-	/* regular path bar */
 	self->priv->path_bar = g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL);
 	gtk_box_pack_start (GTK_BOX (hbox), self->priv->path_bar, TRUE, TRUE, 0);
 
@@ -127,9 +162,23 @@ nautilus_toolbar_constructed (GObject *obj)
 	item = gtk_tool_item_new ();
 	gtk_tool_item_set_expand (item, TRUE);
 	gtk_container_add (GTK_CONTAINER (item), hbox);
-	gtk_toolbar_insert (GTK_TOOLBAR (self->priv->toolbar), item, 0);
+	gtk_container_add (GTK_CONTAINER (self->priv->toolbar), GTK_WIDGET (item));
 	gtk_widget_show (GTK_WIDGET (item));
 
+	/* search */
+	search = gtk_tool_item_new ();
+	tool_button = gtk_button_new ();
+	gtk_button_set_image (GTK_BUTTON (tool_button), gtk_image_new ());
+	action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_SEARCH);
+	gtk_activatable_set_related_action (GTK_ACTIVATABLE (tool_button),
+					    action);
+	gtk_button_set_label (GTK_BUTTON (tool_button), NULL);
+	gtk_widget_set_name (tool_button, "nautilus-search-button");
+	gtk_container_add (GTK_CONTAINER (search), GTK_WIDGET (tool_button));
+	gtk_container_add (GTK_CONTAINER (self->priv->toolbar), GTK_WIDGET (search));
+	gtk_widget_show_all (GTK_WIDGET (search));
+	gtk_widget_set_margin_left (GTK_WIDGET (search), 12);
+
 	/* search bar */
 	self->priv->search_bar = nautilus_search_bar_new ();
 	gtk_box_pack_start (GTK_BOX (self), self->priv->search_bar, TRUE, TRUE, 0);
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 6d8b7cc..47583cc 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -653,10 +653,10 @@ static const GtkActionEntry main_entries[] = {
   /* name, stock id, label */  { NAUTILUS_ACTION_CLOSE_ALL_WINDOWS, NULL, N_("Close _All Windows"),
                                  "<control>Q", N_("Close all Navigation windows"),
                                  G_CALLBACK (action_close_all_windows_callback) },
-  /* name, stock id, label */  { NAUTILUS_ACTION_BACK, GTK_STOCK_GO_BACK, N_("_Back"),
+  /* name, stock id, label */  { NAUTILUS_ACTION_BACK, "go-previous-symbolic", N_("_Back"),
 				 "<alt>Left", N_("Go to the previous visited location"),
 				 G_CALLBACK (action_back_callback) },
-  /* name, stock id, label */  { NAUTILUS_ACTION_FORWARD, GTK_STOCK_GO_FORWARD, N_("_Forward"),
+  /* name, stock id, label */  { NAUTILUS_ACTION_FORWARD, "go-next-symbolic", N_("_Forward"),
 				 "<alt>Right", N_("Go to the next visited location"),
 				 G_CALLBACK (action_forward_callback) },
   /* name, stock id, label */  { "Go to Location", NULL, N_("_Location..."),
@@ -726,7 +726,7 @@ nautilus_window_create_toolbar_action_group (NautilusWindow *window)
 	action = g_object_new (NAUTILUS_TYPE_NAVIGATION_ACTION,
 			       "name", NAUTILUS_ACTION_BACK,
 			       "label", _("_Back"),
-			       "stock_id", GTK_STOCK_GO_BACK,
+			       "icon-name", "go-previous-symbolic",
 			       "tooltip", _("Go to the previous visited location"),
 			       "arrow-tooltip", _("Back history"),
 			       "window", window,
@@ -742,7 +742,7 @@ nautilus_window_create_toolbar_action_group (NautilusWindow *window)
 	action = g_object_new (NAUTILUS_TYPE_NAVIGATION_ACTION,
 			       "name", NAUTILUS_ACTION_FORWARD,
 			       "label", _("_Forward"),
-			       "stock_id", GTK_STOCK_GO_FORWARD,
+			       "icon-name", "go-next-symbolic",
 			       "tooltip", _("Go to the next visited location"),
 			       "arrow-tooltip", _("Forward history"),
 			       "window", window,
@@ -762,7 +762,6 @@ nautilus_window_create_toolbar_action_group (NautilusWindow *window)
 					NULL));
 	gtk_action_group_add_action (action_group, action);
 	gtk_action_set_icon_name (GTK_ACTION (action), "edit-find-symbolic");
-	gtk_action_set_is_important (GTK_ACTION (action), TRUE);
 
 	g_object_unref (action);
 
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 0dd8e0b..b711e69 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1142,10 +1142,6 @@ create_toolbar (NautilusWindow *window)
 	nautilus_navigation_state_set_master (window->details->nav_state, window->details->toolbar_action_group );
 
 	toolbar = nautilus_toolbar_new (action_group);
-	gtk_box_pack_start (GTK_BOX (window->details->main_view),
-			    toolbar,
-			    FALSE, FALSE, 0);
-	gtk_widget_show (toolbar);
 
 	g_object_bind_property (window, "disable-chrome",
 				toolbar, "visible",
@@ -1176,7 +1172,6 @@ create_toolbar (NautilusWindow *window)
 
 	/* connect to the search bar signals */
 	search_bar = nautilus_toolbar_get_search_bar (NAUTILUS_TOOLBAR (toolbar));
-	gtk_size_group_add_widget (header_size_group, search_bar);
 
 	g_signal_connect_object (search_bar, "activate",
 				 G_CALLBACK (search_bar_activate_callback), window, 0);
@@ -1253,6 +1248,11 @@ nautilus_window_constructed (GObject *self)
 	/* Register to menu provider extension signal managing menu updates */
 	g_signal_connect_object (nautilus_signaller_get_current (), "popup_menu_changed",
 			 G_CALLBACK (nautilus_window_load_extension_menus), window, G_CONNECT_SWAPPED);
+	window->details->toolbar = create_toolbar (window);
+	gtk_container_add (GTK_CONTAINER (grid), window->details->toolbar);
+	gtk_widget_set_hexpand (window->details->toolbar, TRUE);
+	gtk_widget_set_vexpand (window->details->toolbar, FALSE);
+	gtk_widget_show (window->details->toolbar);
 
 	window->details->content_paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
 	gtk_widget_set_hexpand (window->details->content_paned, TRUE);
@@ -1266,7 +1266,6 @@ nautilus_window_constructed (GObject *self)
 			 TRUE, FALSE);
 	gtk_widget_show (window->details->main_view);
 
-	window->details->toolbar = create_toolbar (window);
 	window->details->notebook = create_notebook (window);
 
 	nautilus_window_initialize_bookmarks_menu (window);
diff --git a/src/nautilus.gresource.xml b/src/nautilus.gresource.xml
index 8e405a0..79ed90b 100644
--- a/src/nautilus.gresource.xml
+++ b/src/nautilus.gresource.xml
@@ -4,7 +4,6 @@
     <file compressed="true">nautilus-bookmarks-window.ui</file>
     <file compressed="true">nautilus-file-management-properties.ui</file>
     <file>nautilus-icon-view-ui.xml</file>
-    <file>nautilus-toolbar-ui.xml</file>
     <file>nautilus-directory-view-ui.xml</file>
     <file>nautilus-desktop-icon-view-ui.xml</file>
     <file>nautilus-list-view-ui.xml</file>



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