diff options
-rw-r--r-- | src/nautilus-files-view.c | 4 | ||||
-rw-r--r-- | src/nautilus-places-view.c | 2 | ||||
-rw-r--r-- | src/nautilus-toolbar.c | 58 | ||||
-rw-r--r-- | src/nautilus-view.c | 3 | ||||
-rw-r--r-- | src/nautilus-view.h | 4 | ||||
-rw-r--r-- | src/resources/ui/nautilus-toolbar-view-menu.ui | 477 | ||||
-rw-r--r-- | src/resources/ui/nautilus-toolbar.ui | 19 |
7 files changed, 295 insertions, 272 deletions
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c index 9a0018396..74f08f3e9 100644 --- a/src/nautilus-files-view.c +++ b/src/nautilus-files-view.c @@ -637,8 +637,8 @@ nautilus_files_view_get_icon (NautilusView *view) * nautilus_files_view_get_view_widget: * @view: a #NautilusFilesView * - * Retrieves the view menu, as a #GtkWidget. If it's %NULL, - * the button renders insensitive. + * Retrieves the menu section, as a #GtkWidget that should be added to the toolbar + * menu for this view. If it's %NULL, no widget is added for this view * * Returns: (transfer none): a #GtkWidget for the view menu */ diff --git a/src/nautilus-places-view.c b/src/nautilus-places-view.c index f6214f880..ed46f2059 100644 --- a/src/nautilus-places-view.c +++ b/src/nautilus-places-view.c @@ -283,7 +283,7 @@ nautilus_places_view_set_search_query (NautilusView *view, static GtkWidget* nautilus_places_view_get_view_widget (NautilusView *view) { - /* By returning NULL, the view menu button turns insensitive */ + /* By returning NULL, no section will be added to the toolbar menu when this view is active */ return NULL; } diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c index f64f84f1f..63aa3ff8b 100644 --- a/src/nautilus-toolbar.c +++ b/src/nautilus-toolbar.c @@ -66,6 +66,7 @@ struct _NautilusToolbarPrivate { GtkWidget *operations_button; GtkWidget *view_button; + GtkWidget *view_menu_slot_section; GtkWidget *view_toggle_button; GtkWidget *view_toggle_icon; @@ -889,6 +890,7 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass) gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, operations_container); gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, operations_revealer); gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, view_button); + gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, view_menu_slot_section); gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, view_toggle_button); gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, view_toggle_icon); gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, path_bar_container); @@ -953,29 +955,39 @@ nautilus_toolbar_view_toggle_icon_transform_to (GBinding *binding, return TRUE; } -static gboolean -nautilus_toolbar_view_widget_transform_to (GBinding *binding, - const GValue *from_value, - GValue *to_value, - gpointer user_data) +static void +on_slot_view_widget_changed (NautilusToolbar *toolbar, + GParamSpec *param, + NautilusWindowSlot *slot) { - NautilusToolbar *toolbar; GtkWidget *view_widget; + GList *children; + GList *child; - toolbar = NAUTILUS_TOOLBAR (user_data); - view_widget = g_value_get_object (from_value); + children = gtk_container_get_children (GTK_CONTAINER (toolbar->priv->view_menu_slot_section)); + for (child = children; child != NULL; child = g_list_next (child)) { + gtk_container_remove (GTK_CONTAINER (toolbar->priv->view_menu_slot_section), + GTK_WIDGET (child->data)); + } + g_list_free (children); - gtk_menu_button_set_popover (GTK_MENU_BUTTON (toolbar->priv->view_button), NULL); + view_widget = nautilus_window_slot_get_view_widget (slot); + gtk_widget_set_sensitive (toolbar->priv->view_button, view_widget != NULL); + if (view_widget == NULL) + return; - g_value_set_object (to_value, view_widget); + gtk_box_pack_start (GTK_BOX (toolbar->priv->view_menu_slot_section), view_widget, FALSE, FALSE, 0); +} - /* Make the sensitivity change after the popover has been set, so that the sensitivity - * propagates to the popover. Otherwise the popover will remain greyed out after - * switching to a previous tab - */ - gtk_widget_set_sensitive (toolbar->priv->view_button, view_widget != NULL); +static void +disconnect_view_widget_change_handler (NautilusToolbar *toolbar) +{ + if (toolbar->priv->active_slot == NULL) + return; - return TRUE; + g_signal_handlers_disconnect_by_func (toolbar->priv->active_slot, + G_CALLBACK (on_slot_view_widget_changed), + toolbar); } void @@ -988,6 +1000,7 @@ nautilus_toolbar_set_active_slot (NautilusToolbar *toolbar, g_clear_pointer (&toolbar->priv->view_widget_binding, g_binding_unbind); if (toolbar->priv->active_slot != slot) { + disconnect_view_widget_change_handler (toolbar); toolbar->priv->active_slot = slot; if (slot) { @@ -999,16 +1012,11 @@ nautilus_toolbar_set_active_slot (NautilusToolbar *toolbar, NULL, toolbar, NULL); - toolbar->priv->view_widget_binding = - g_object_bind_property_full (slot, "view-widget", - toolbar->priv->view_button, "popover", - G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE, - (GBindingTransformFunc) nautilus_toolbar_view_widget_transform_to, - NULL, - toolbar, - NULL); - } + on_slot_view_widget_changed (toolbar, NULL, slot); + g_signal_connect_swapped (slot, "notify::view-widget", + G_CALLBACK (on_slot_view_widget_changed), toolbar); + } } } diff --git a/src/nautilus-view.c b/src/nautilus-view.c index 17916025f..79b9dc4fd 100644 --- a/src/nautilus-view.c +++ b/src/nautilus-view.c @@ -118,7 +118,8 @@ nautilus_view_get_icon (NautilusView *view) * nautilus_view_get_view_widget: * @view: a #NautilusView * - * Retrieves the view menu widget from @view. + * Retrieves the toolbar menu section (widget) from @view, that should be shown + * in the menu when this view is active * * Returns: (transfer none): the widget displayed under view menu. */ diff --git a/src/nautilus-view.h b/src/nautilus-view.h index 2bc9a13f9..4d3f12f73 100644 --- a/src/nautilus-view.h +++ b/src/nautilus-view.h @@ -39,8 +39,8 @@ struct _NautilusViewInterface GIcon* (*get_icon) (NautilusView *view); /* - * The widget that is displayed under the view menu. When set to NULL, the - * button gets insensitive. + * The toolbar menu section (widget), that should be shown in the menu + * when this view is active */ GtkWidget* (*get_view_widget) (NautilusView *view); diff --git a/src/resources/ui/nautilus-toolbar-view-menu.ui b/src/resources/ui/nautilus-toolbar-view-menu.ui index 8c66c9a89..f5cba450a 100644 --- a/src/resources/ui/nautilus-toolbar-view-menu.ui +++ b/src/resources/ui/nautilus-toolbar-view-menu.ui @@ -1,171 +1,197 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <object class ="GtkPopoverMenu" id="view_menu_widget"> + <object class="GtkBox" id="view_menu_widget"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="width_request">160</property> <child> - <object class="GtkBox"> + <object class="GtkBox" id="new_buttons_box"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="border_width">9</property> - <property name="orientation">vertical</property> - <property name="width_request">160</property> + <property name="orientation">horizontal</property> + <property name="homogeneous">True</property> + <property name="margin-bottom">9</property> + <style> + <class name="linked"/> + </style> <child> - <object class="GtkBox" id="new_buttons_box"> + <object class="GtkButton" id="new-folder"> <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="homogeneous">True</property> - <property name="margin-bottom">9</property> - <style> - <class name="linked"/> - </style> + <property name="action_name">view.new-folder</property> <child> - <object class="GtkButton" id="new-folder"> + <object class="GtkImage"> <property name="visible">True</property> - <property name="action_name">view.new-folder</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="icon-name">folder-new-symbolic</property> - <property name="icon-size">1</property> - </object> - </child> - <child internal-child="accessible"> - <object class="AtkObject"> - <property name="accessible-name" translatable="yes">New Folder</property> - </object> - </child> + <property name="icon-name">folder-new-symbolic</property> + <property name="icon-size">1</property> + </object> + </child> + <child internal-child="accessible"> + <object class="AtkObject"> + <property name="accessible-name" translatable="yes">New Folder</property> </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="bookmark-this-location"> + <property name="visible">True</property> + <property name="action_name">win.bookmark-current-location</property> <child> - <object class="GtkButton" id="bookmark-this-location"> + <object class="GtkImage"> <property name="visible">True</property> - <property name="action_name">win.bookmark-current-location</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="icon-name">bookmark-new-symbolic</property> - <property name="icon-size">1</property> - </object> - </child> - <child internal-child="accessible"> - <object class="AtkObject"> - <property name="accessible-name" translatable="yes">Bookmark this Location</property> - </object> - </child> + <property name="icon-name">bookmark-new-symbolic</property> + <property name="icon-size">1</property> + </object> + </child> + <child internal-child="accessible"> + <object class="AtkObject"> + <property name="accessible-name" translatable="yes">Bookmark this Location</property> </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="new-tab"> + <property name="visible">True</property> + <property name="action-name">win.new-tab</property> <child> - <object class="GtkButton" id="new-tab"> + <object class="GtkImage"> <property name="visible">True</property> - <property name="action-name">win.new-tab</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="icon-name">tab-new-symbolic</property> - <property name="icon-size">1</property> - </object> - </child> - <child internal-child="accessible"> - <object class="AtkObject"> - <property name="accessible-name" translatable="yes">New Tab</property> - </object> - </child> + <property name="icon-name">tab-new-symbolic</property> + <property name="icon-size">1</property> + </object> + </child> + <child internal-child="accessible"> + <object class="AtkObject"> + <property name="accessible-name" translatable="yes">New Tab</property> </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> </child> </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> </child> + </object> + </child> + <child> + <object class="GtkBox" id="zoom_controls_box"> + <property name="visible">True</property> + <property name="orientation">horizontal</property> + <property name="homogeneous">True</property> + <style> + <class name="linked"/> + </style> <child> - <object class="GtkBox" id="zoom_controls_box"> + <object class="GtkButton" id="zoom-out"> <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="homogeneous">True</property> - <style> - <class name="linked"/> - </style> + <property name="action-name">view.zoom-out</property> <child> - <object class="GtkButton" id="zoom-out"> + <object class="GtkImage"> <property name="visible">True</property> - <property name="action-name">view.zoom-out</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="icon-name">zoom-out-symbolic</property> - <property name="icon-size">1</property> - </object> - </child> - <child internal-child="accessible"> - <object class="AtkObject"> - <property name="accessible-name" translatable="yes">Zoom Out</property> - </object> - </child> + <property name="icon-name">zoom-out-symbolic</property> + <property name="icon-size">1</property> + </object> + </child> + <child internal-child="accessible"> + <object class="AtkObject"> + <property name="accessible-name" translatable="yes">Zoom Out</property> </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="zoom-default"> + <property name="visible">True</property> + <property name="action_name">view.zoom-standard</property> <child> - <object class="GtkButton" id="zoom-default"> + <object class="GtkLabel" id="zoom_level_label"> <property name="visible">True</property> - <property name="action_name">view.zoom-standard</property> - <child> - <object class="GtkLabel" id="zoom_level_label"> - <property name="visible">True</property> - <property name="width-chars">5</property> - </object> - </child> - <child internal-child="accessible"> - <object class="AtkObject"> - <property name="accessible-name" translatable="yes">Reset Zoom</property> - </object> - </child> + <property name="width-chars">5</property> + </object> + </child> + <child internal-child="accessible"> + <object class="AtkObject"> + <property name="accessible-name" translatable="yes">Reset Zoom</property> </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="zoom-in"> + <property name="visible">True</property> + <property name="action_name">view.zoom-in</property> <child> - <object class="GtkButton" id="zoom-in"> + <object class="GtkImage"> <property name="visible">True</property> - <property name="action_name">view.zoom-in</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="icon-name">zoom-in-symbolic</property> - <property name="icon-size">1</property> - </object> - </child> - <child internal-child="accessible"> - <object class="AtkObject"> - <property name="accessible-name" translatable="yes">Zoom In</property> - </object> - </child> + <property name="icon-name">zoom-in-symbolic</property> + <property name="icon-size">1</property> + </object> + </child> + <child internal-child="accessible"> + <object class="AtkObject"> + <property name="accessible-name" translatable="yes">Zoom In</property> </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> </child> </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> </child> + </object> + </child> + <child> + <object class="GtkSeparator"> + <property name="visible">True</property> + <property name="orientation">horizontal</property> + <property name="margin-top">6</property> + <property name="margin-bottom">6</property> + </object> + </child> + <child> + <object class="GtkModelButton" id="undo"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="text" translatable="yes">_Undo</property> + <property name="action-name">win.undo</property> + </object> + </child> + <child> + <object class="GtkModelButton" id="redo"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="text" translatable="yes">_Redo</property> + <property name="action-name">win.redo</property> + </object> + </child> + <child> + <object class="GtkBox" id="sort_menu"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> <child> <object class="GtkSeparator"> <property name="visible">True</property> @@ -175,151 +201,120 @@ </object> </child> <child> - <object class="GtkModelButton" id="undo"> + <object class="GtkLabel"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="text" translatable="yes">_Undo</property> - <property name="action-name">win.undo</property> + <property name="sensitive">False</property> + <property name="label" translatable="yes">Sort</property> + <property name="xalign">0</property> + <style> + <class name="nautilus-menu-sort-heading" /> + </style> </object> </child> <child> - <object class="GtkModelButton" id="redo"> + <object class="GtkModelButton" id="sort_name"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="text" translatable="yes">_Redo</property> - <property name="action-name">win.redo</property> + <property name="text" translatable="yes" context="Sort Criterion" comments="This is used to sort by name in the toolbar view menu">_A-Z</property> + <property name="action-name">view.sort</property> + <property name="action-target">'name'</property> </object> </child> <child> - <object class="GtkBox" id="sort_menu"> + <object class="GtkModelButton" id="sort_name_desc"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="orientation">vertical</property> - <child> - <object class="GtkSeparator"> - <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="margin-top">6</property> - <property name="margin-bottom">6</property> - </object> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="label" translatable="yes">Sort</property> - <property name="xalign">0</property> - <style> - <class name="nautilus-menu-sort-heading" /> - </style> - </object> - </child> - <child> - <object class="GtkModelButton" id="sort_name"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="text" translatable="yes" context="Sort Criterion" comments="This is used to sort by name in the toolbar view menu">_A-Z</property> - <property name="action-name">view.sort</property> - <property name="action-target">'name'</property> - </object> - </child> - <child> - <object class="GtkModelButton" id="sort_name_desc"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="text" translatable="yes" context="Sort Criterion" comments="This is used to sort by name, in descending order in the toolbar view menu">_Z-A</property> - <property name="action-name">view.sort</property> - <property name="action-target">'name-desc'</property> - </object> - </child> - <child> - <object class="GtkModelButton" id="sort_modification_date_desc"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="text" translatable="yes">Last _Modified</property> - <property name="action-name">view.sort</property> - <property name="action-target">'modification-date-desc'</property> - </object> - </child> - <child> - <object class="GtkModelButton" id="sort_modification_date"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="text" translatable="yes">_First Modified</property> - <property name="action-name">view.sort</property> - <property name="action-target">'modification-date'</property> - </object> - </child> - <child> - <object class="GtkModelButton" id="sort_size"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="text" translatable="yes">_Size</property> - <property name="action-name">view.sort</property> - <property name="action-target">'size'</property> - </object> - </child> - <child> - <object class="GtkModelButton" id="sort_type"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="text" translatable="yes">_Type</property> - <property name="action-name">view.sort</property> - <property name="action-target">'type'</property> - </object> - </child> - <child> - <object class="GtkModelButton" id="sort_trash_time"> - <property name="visible">False</property> - <property name="can_focus">True</property> - <property name="text" translatable="yes">Last _Trashed</property> - <property name="action-name">view.sort</property> - <property name="action-target">'trash-time'</property> - </object> - </child> + <property name="can_focus">True</property> + <property name="text" translatable="yes" context="Sort Criterion" comments="This is used to sort by name, in descending order in the toolbar view menu">_Z-A</property> + <property name="action-name">view.sort</property> + <property name="action-target">'name-desc'</property> </object> </child> <child> - <object class="GtkSeparator"> + <object class="GtkModelButton" id="sort_modification_date_desc"> <property name="visible">True</property> - <property name="orientation">horizontal</property> - <property name="margin-top">6</property> - <property name="margin-bottom">6</property> + <property name="can_focus">True</property> + <property name="text" translatable="yes">Last _Modified</property> + <property name="action-name">view.sort</property> + <property name="action-target">'modification-date-desc'</property> </object> </child> <child> - <object class="GtkModelButton" id="visible_columns"> - <property name="visible">False</property> + <object class="GtkModelButton" id="sort_modification_date"> + <property name="visible">True</property> <property name="can_focus">True</property> - <property name="text" translatable="yes">_Visible Columns…</property> - <property name="action-name">view.visible-columns</property> + <property name="text" translatable="yes">_First Modified</property> + <property name="action-name">view.sort</property> + <property name="action-target">'modification-date'</property> </object> </child> <child> - <object class="GtkModelButton" id="show_hidden_files"> + <object class="GtkModelButton" id="sort_size"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="text" translatable="yes">Show _Hidden Files</property> - <property name="action-name">view.show-hidden-files</property> + <property name="text" translatable="yes">_Size</property> + <property name="action-name">view.sort</property> + <property name="action-target">'size'</property> </object> </child> <child> - <object class="GtkModelButton" id="reload"> + <object class="GtkModelButton" id="sort_type"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="text" translatable="yes">R_eload</property> - <property name="action-name">win.reload</property> + <property name="text" translatable="yes">_Type</property> + <property name="action-name">view.sort</property> + <property name="action-target">'type'</property> </object> </child> <child> - <object class="GtkModelButton" id="stop"> + <object class="GtkModelButton" id="sort_trash_time"> <property name="visible">False</property> <property name="can_focus">True</property> - <property name="text" translatable="yes">St_op</property> - <property name="action-name">win.stop</property> + <property name="text" translatable="yes">Last _Trashed</property> + <property name="action-name">view.sort</property> + <property name="action-target">'trash-time'</property> </object> </child> </object> </child> + <child> + <object class="GtkSeparator"> + <property name="visible">True</property> + <property name="orientation">horizontal</property> + <property name="margin-top">6</property> + <property name="margin-bottom">6</property> + </object> + </child> + <child> + <object class="GtkModelButton" id="visible_columns"> + <property name="visible">False</property> + <property name="can_focus">True</property> + <property name="text" translatable="yes">_Visible Columns…</property> + <property name="action-name">view.visible-columns</property> + </object> + </child> + <child> + <object class="GtkModelButton" id="show_hidden_files"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="text" translatable="yes">Show _Hidden Files</property> + <property name="action-name">view.show-hidden-files</property> + </object> + </child> + <child> + <object class="GtkModelButton" id="reload"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="text" translatable="yes">R_eload</property> + <property name="action-name">win.reload</property> + </object> + </child> + <child> + <object class="GtkModelButton" id="stop"> + <property name="visible">False</property> + <property name="can_focus">True</property> + <property name="text" translatable="yes">St_op</property> + <property name="action-name">win.stop</property> + </object> + </child> </object> </interface> diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui index 3c3b1d553..21a751c3b 100644 --- a/src/resources/ui/nautilus-toolbar.ui +++ b/src/resources/ui/nautilus-toolbar.ui @@ -76,6 +76,7 @@ <property name="visible">True</property> <property name="sensitive">True</property> <property name="action_name">win.view-menu</property> + <property name="popover">view_menu_popover</property> <style> <class name="image-button"/> </style> @@ -201,4 +202,22 @@ </object> </child> </object> + <object class="GtkPopoverMenu" id="view_menu_popover"> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="border_width">9</property> + <property name="orientation">vertical</property> + <property name="width_request">160</property> + <child> + <object class="GtkBox" id="view_menu_slot_section"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + </object> + </child> + </object> + </child> + </object> </interface> |