Commit faf64653 authored by William Jon McCann's avatar William Jon McCann

Migrate menu bar to a view menu button

https://bugzilla.gnome.org/show_bug.cgi?id=676531
parent 2c3191c5
<?xml version="1.0" encoding="utf-8"?>
<ui>
<accelerator action="OpenAccel"/>
<accelerator action="OpenCloseParent"/>
<accelerator action="PropertiesAccel"/>
<accelerator action="RenameSelectAll"/>
<menubar name="MenuBar">
<menu action="File">
<popup name="ViewMenu">
<placeholder name="New Items Placeholder">
<menuitem name="New Folder" action="New Folder"/>
<menuitem name="New Folder with Selection" action="New Folder with Selection"/>
......@@ -49,7 +49,6 @@
<menuitem name="Save Search" action="Save Search"/>
<menuitem name="Save Search As" action="Save Search As"/>
</placeholder>
</menu>
<menu action="Edit">
<placeholder name="Clipboard Actions">
<menuitem name="Cut" action="Cut"/>
......@@ -83,7 +82,7 @@
<menuitem name="Show Hidden Files" action="Show Hidden Files"/>
</placeholder>
</menu>
</menubar>
</popup>
<popup name="background">
<placeholder name="Before Zoom Items">
<placeholder name="New Object Items">
......
<ui>
<menubar name="MenuBar">
<popup name="ViewMenu">
<menu action="Edit">
<placeholder name="Edit Items Placeholder">
<menuitem name="Stretch" action="Stretch"/>
......@@ -23,10 +23,9 @@
<menuitem name="Clean Up" action="Clean Up"/>
<menuitem name="Keep Aligned" action="Keep Aligned"/>
</placeholder>
</menu>
</menubar>
<popup name="background">
</popup>
<popup name="background">
<placeholder name="Before Zoom Items">
<placeholder name="View Items">
<menu action="Arrange Items">
......@@ -45,8 +44,8 @@
<menuitem name="Keep Aligned" action="Keep Aligned"/>
</placeholder>
</placeholder>
</popup>
<popup name="selection">
</popup>
<popup name="selection">
<placeholder name="Icon Appearance Items"/>
</popup>
</popup>
</ui>
<ui>
<menubar name="MenuBar">
<popup name="ViewMenu">
<menu action="View">
<placeholder name="View Items Placeholder">
<menuitem name="Visible Columns" action="Visible Columns"/>
</placeholder>
</menu>
</menubar>
</popup>
</ui>
......@@ -7,8 +7,7 @@
<accelerator action="ZoomInAccel"/>
<accelerator action="ZoomInAccel2"/>
<accelerator action="ZoomOutAccel"/>
<menubar name="MenuBar">
<menu action="File">
<popup name="ViewMenu">
<placeholder name="New Items Placeholder">
<menuitem name="New Tab" action="New Tab"/>
<menuitem name="New Window" action="New Window"/>
......@@ -23,13 +22,6 @@
<separator/>
<placeholder name="Global File Items Placeholder"/>
<separator/>
<placeholder name="Extension Actions"/>
<separator/>
<placeholder name="Close Items Placeholder">
<menuitem name="Close All Windows" action="Close All Windows"/>
</placeholder>
<menuitem name="Close" action="Close"/>
</menu>
<menu action="Edit">
<placeholder name="Undostack Actions"/>
<separator/>
......@@ -69,7 +61,6 @@
<placeholder name="Short List"/>
</placeholder>
</menu>
<placeholder name="Other Menus">
<menu action="Bookmarks">
<menuitem name="Add Bookmark" action="Add Bookmark"/>
<menuitem name="Edit Bookmark" action="Edit Bookmarks"/>
......@@ -77,18 +68,13 @@
<separator/>
<placeholder name="Bookmarks Placeholder"/>
</menu>
<placeholder name="Extension Actions"/>
<separator/>
<placeholder name="Close Items Placeholder">
<menuitem name="Close All Windows" action="Close All Windows"/>
</placeholder>
<menu action="Help">
<menuitem action="NautilusHelp"/>
<menuitem action="NautilusHelpSearch"/>
<menuitem action="NautilusHelpSort"/>
<menuitem action="NautilusHelpLost"/>
<menuitem action="NautilusHelpShare"/>
<separator/>
<menuitem name="About Nautilus" action="About Nautilus"/>
</menu>
</menubar>
<menuitem name="Close" action="Close"/>
</popup>
<popup name="background">
<placeholder name="Before Zoom Items">
<placeholder name="New Window Items"/>
......
......@@ -54,6 +54,7 @@ struct _NautilusToolbarPriv {
enum {
PROP_ACTION_GROUP = 1,
PROP_UI_MANAGER,
PROP_SHOW_LOCATION_ENTRY,
PROP_SHOW_SEARCH_BAR,
PROP_SHOW_MAIN_BAR,
......@@ -88,12 +89,14 @@ static void
nautilus_toolbar_constructed (GObject *obj)
{
NautilusToolbar *self = NAUTILUS_TOOLBAR (obj);
GtkToolItem *item;
GtkWidget *hbox, *toolbar;
GtkStyleContext *context;
GtkWidget *tool_button, *box;
GtkWidget *tool_button;
GtkWidget *menu;
GtkWidget *image;
GtkWidget *box;
GtkToolItem *back_forward;
GtkToolItem *search;
GtkToolItem *tool_item;
GtkActionGroup *action_group;
GtkAction *action;
......@@ -159,14 +162,14 @@ nautilus_toolbar_constructed (GObject *obj)
self->priv->location_bar = nautilus_location_bar_new ();
gtk_box_pack_start (GTK_BOX (hbox), self->priv->location_bar, TRUE, TRUE, 0);
item = gtk_tool_item_new ();
gtk_tool_item_set_expand (item, TRUE);
gtk_container_add (GTK_CONTAINER (item), hbox);
gtk_container_add (GTK_CONTAINER (self->priv->toolbar), GTK_WIDGET (item));
gtk_widget_show (GTK_WIDGET (item));
tool_item = gtk_tool_item_new ();
gtk_tool_item_set_expand (tool_item, TRUE);
gtk_container_add (GTK_CONTAINER (tool_item), hbox);
gtk_container_add (GTK_CONTAINER (self->priv->toolbar), GTK_WIDGET (tool_item));
gtk_widget_show (GTK_WIDGET (tool_item));
/* search */
search = gtk_tool_item_new ();
tool_item = 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);
......@@ -174,10 +177,23 @@ nautilus_toolbar_constructed (GObject *obj)
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);
gtk_container_add (GTK_CONTAINER (tool_item), GTK_WIDGET (tool_button));
gtk_container_add (GTK_CONTAINER (self->priv->toolbar), GTK_WIDGET (tool_item));
gtk_widget_show_all (GTK_WIDGET (tool_item));
gtk_widget_set_margin_left (GTK_WIDGET (tool_item), 12);
/* Page Menu */
tool_item = gtk_tool_item_new ();
tool_button = gtk_menu_button_new ();
menu = gtk_ui_manager_get_widget (self->priv->ui_manager, "/ViewMenu");
gtk_menu_button_set_menu (GTK_MENU_BUTTON (tool_button), menu);
image = gtk_image_new ();
gtk_image_set_from_icon_name (GTK_IMAGE (image), "emblem-system-symbolic", GTK_ICON_SIZE_MENU);
gtk_button_set_image (GTK_BUTTON (tool_button), image);
gtk_container_add (GTK_CONTAINER (tool_item), tool_button);
gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (tool_item));
gtk_widget_show_all (GTK_WIDGET (tool_item));
gtk_widget_set_margin_left (GTK_WIDGET (tool_item), 6);
/* search bar */
self->priv->search_bar = nautilus_search_bar_new ();
......@@ -231,6 +247,9 @@ nautilus_toolbar_set_property (GObject *object,
NautilusToolbar *self = NAUTILUS_TOOLBAR (object);
switch (property_id) {
case PROP_UI_MANAGER:
self->priv->ui_manager = g_value_get_object (value);
break;
case PROP_ACTION_GROUP:
self->priv->action_group = g_value_dup_object (value);
break;
......@@ -281,6 +300,13 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
GTK_TYPE_ACTION_GROUP,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
properties[PROP_UI_MANAGER] =
g_param_spec_object ("ui-manager",
"The UI manager",
"The UI manager",
GTK_TYPE_UI_MANAGER,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
properties[PROP_SHOW_LOCATION_ENTRY] =
g_param_spec_boolean ("show-location-entry",
"Whether to show the location entry",
......@@ -305,10 +331,12 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
}
GtkWidget *
nautilus_toolbar_new (GtkActionGroup *action_group)
nautilus_toolbar_new (GtkUIManager *ui_manager,
GtkActionGroup *action_group)
{
return g_object_new (NAUTILUS_TYPE_TOOLBAR,
"action-group", action_group,
"ui-manager", ui_manager,
"orientation", GTK_ORIENTATION_VERTICAL,
NULL);
}
......
......@@ -62,7 +62,8 @@ struct _NautilusToolbarClass {
GType nautilus_toolbar_get_type (void);
GtkWidget *nautilus_toolbar_new (GtkActionGroup *action_group);
GtkWidget *nautilus_toolbar_new (GtkUIManager *ui_manager,
GtkActionGroup *action_group);
GtkWidget *nautilus_toolbar_get_path_bar (NautilusToolbar *self);
GtkWidget *nautilus_toolbar_get_location_bar (NautilusToolbar *self);
......
......@@ -104,12 +104,12 @@
#define MAX_QUEUED_UPDATES 500
#define NAUTILUS_VIEW_MENU_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER "/MenuBar/File/Open Placeholder/Open With/Applications Placeholder"
#define NAUTILUS_VIEW_MENU_PATH_APPLICATIONS_PLACEHOLDER "/MenuBar/File/Open Placeholder/Applications Placeholder"
#define NAUTILUS_VIEW_MENU_PATH_SCRIPTS_PLACEHOLDER "/MenuBar/File/Open Placeholder/Scripts/Scripts Placeholder"
#define NAUTILUS_VIEW_MENU_PATH_EXTENSION_ACTIONS_PLACEHOLDER "/MenuBar/Edit/Extension Actions"
#define NAUTILUS_VIEW_MENU_PATH_NEW_DOCUMENTS_PLACEHOLDER "/MenuBar/File/New Items Placeholder/New Documents/New Documents Placeholder"
#define NAUTILUS_VIEW_MENU_PATH_OPEN "/MenuBar/File/Open Placeholder/Open"
#define NAUTILUS_VIEW_MENU_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER "/ViewMenu/Open Placeholder/Open With/Applications Placeholder"
#define NAUTILUS_VIEW_MENU_PATH_APPLICATIONS_PLACEHOLDER "/ViewMenu/Open Placeholder/Applications Placeholder"
#define NAUTILUS_VIEW_MENU_PATH_SCRIPTS_PLACEHOLDER "/ViewMenu/Open Placeholder/Scripts/Scripts Placeholder"
#define NAUTILUS_VIEW_MENU_PATH_EXTENSION_ACTIONS_PLACEHOLDER "/ViewMenu/Edit/Extension Actions"
#define NAUTILUS_VIEW_MENU_PATH_NEW_DOCUMENTS_PLACEHOLDER "/ViewMenu/New Items Placeholder/New Documents/New Documents Placeholder"
#define NAUTILUS_VIEW_MENU_PATH_OPEN "/ViewMenu/Open Placeholder/Open"
#define NAUTILUS_VIEW_POPUP_PATH_SELECTION "/selection"
#define NAUTILUS_VIEW_POPUP_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER "/selection/Open Placeholder/Open With/Applications Placeholder"
......
......@@ -41,7 +41,7 @@
#include <glib/gi18n.h>
#define MENU_ITEM_MAX_WIDTH_CHARS 32
#define MENU_PATH_BOOKMARKS_PLACEHOLDER "/MenuBar/Other Menus/Bookmarks/Bookmarks Placeholder"
#define MENU_PATH_BOOKMARKS_PLACEHOLDER "/ViewMenu/Bookmarks/Bookmarks Placeholder"
static GtkWindow *bookmarks_window = NULL;
......
......@@ -60,7 +60,7 @@
#include <libnautilus-private/nautilus-trash-monitor.h>
#include <string.h>
#define MENU_PATH_EXTENSION_ACTIONS "/MenuBar/File/Extension Actions"
#define MENU_PATH_EXTENSION_ACTIONS "/ViewMenu/Extension Actions"
#define POPUP_PATH_EXTENSION_ACTIONS "/background/Before Zoom Items/Extension Actions"
#define NETWORK_URI "network:"
......@@ -729,7 +729,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");
g_object_unref (action);
navigation_state = nautilus_window_get_navigation_state (window);
......
......@@ -71,7 +71,7 @@
#include <sys/time.h>
/* dock items */
#define NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER "/MenuBar/View/View Choices/Short List"
#define NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER "/ViewMenu/View/View Choices/Short List"
#define MAX_TITLE_LENGTH 180
......@@ -1141,7 +1141,7 @@ create_toolbar (NautilusWindow *window)
G_CALLBACK (action_show_hide_search_callback), window);
nautilus_navigation_state_set_master (window->details->nav_state, window->details->toolbar_action_group );
toolbar = nautilus_toolbar_new (action_group);
toolbar = nautilus_toolbar_new (nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window)), action_group);
g_object_bind_property (window, "disable-chrome",
toolbar, "visible",
......@@ -1219,7 +1219,6 @@ nautilus_window_constructed (GObject *self)
{
NautilusWindow *window;
GtkWidget *grid;
GtkWidget *menu;
NautilusWindowSlot *slot;
window = NAUTILUS_WINDOW (self);
......@@ -1239,12 +1238,6 @@ nautilus_window_constructed (GObject *self)
nautilus_window_initialize_menus (window);
nautilus_window_initialize_actions (window);
menu = gtk_ui_manager_get_widget (window->details->ui_manager, "/MenuBar");
window->details->menubar = menu;
gtk_widget_set_hexpand (menu, TRUE);
gtk_widget_show (menu);
gtk_container_add (GTK_CONTAINER (grid), menu);
/* 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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment