[nautilus/wip/neilh/toolbar-reorg: 15/16] view: allow view to have more control over the toolbar menu



commit d71963c04d684aaaea9a21e4ea3a32c71fd03400
Author: Neil Herald <neil herald gmail com>
Date:   Sun Jun 19 17:35:49 2016 +0100

    view: allow view to have more control over the toolbar menu
    
    Currently we have this menu structure:
    
    ------------------------------
    1. New Folder/New Tab/Bookmark
    ------------------------------
    2. Zoom controls
    ------------------------------
    3. Undo/Redo
    ------------------------------
    4. Sort options
    ------------------------------
    5. Other view related controls
    ------------------------------
    
    The view creates 2-5, contained in a single GtkWidget - which is then
    passed to the toolbar via the enclosing window slot. The problem is that
    3 shouldn't be created or managed by the view as the controls in that
    section of the menu are not related to the view. We'd like to move this
    responsibility back to the toolbar, but that would mean the view must
    pass multiple menu sections back to the toolbar (as 3 is in the middle
    of the other view controls).
    
    This change allows the view to pass multiple sections back to the
    toolbar, using the new NautilusToolbarMenuSections structure. The files
    view now passes 2 as a separate section to 3-5 (3 will be moved out of
    the view in a future commit).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764632

 src/Makefile.am                                |    2 +
 src/nautilus-files-view.c                      |   37 +++++++--------
 src/nautilus-places-view.c                     |   14 ++----
 src/nautilus-toolbar-menu-sections.c           |   31 +++++++++++++
 src/nautilus-toolbar-menu-sections.h           |   35 ++++++++++++++
 src/nautilus-toolbar.c                         |   53 +++++++++++++--------
 src/nautilus-view.c                            |   29 ++++--------
 src/nautilus-view.h                            |   58 ++++++++++++-----------
 src/nautilus-window-slot.c                     |   25 +++++-----
 src/nautilus-window-slot.h                     |    3 +-
 src/resources/ui/nautilus-toolbar-menu.ui      |   11 ++++-
 src/resources/ui/nautilus-toolbar-view-menu.ui |    8 +++-
 12 files changed, 193 insertions(+), 113 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 4dc71ca..867e3c3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -223,6 +223,8 @@ nautilus_no_main_sources = \
        nautilus-special-location-bar.h         \
        nautilus-toolbar.c                      \
        nautilus-toolbar.h                      \
+       nautilus-toolbar-menu-sections.c        \
+       nautilus-toolbar-menu-sections.h        \
        nautilus-trash-bar.c                    \
        nautilus-trash-bar.h                    \
        nautilus-view.c                         \
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index b5e03d3..c34bd94 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -146,7 +146,6 @@ enum {
         PROP_WINDOW_SLOT = 1,
         PROP_SUPPORTS_ZOOMING,
         PROP_ICON,
-        PROP_VIEW_WIDGET,
         PROP_IS_SEARCH,
         PROP_IS_LOADING,
         PROP_LOCATION,
@@ -260,8 +259,8 @@ struct NautilusFilesViewDetails
         guint floating_bar_loading_timeout_id;
         GtkWidget *floating_bar;
 
-        /* View menu */
-        GtkWidget *view_menu_widget;
+        /* Toolbar menu */
+        NautilusToolbarMenuSections *toolbar_menu_sections;
         GtkWidget *sort_menu;
         GtkWidget *sort_trash_time;
         GtkWidget *visible_columns;
@@ -634,20 +633,21 @@ nautilus_files_view_get_icon (NautilusView *view)
 }
 
 /**
- * nautilus_files_view_get_view_widget:
+ * nautilus_files_view_get_toolbar_menu_sections:
  * @view: a #NautilusFilesView
  *
- * 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
+ * Retrieves the menu sections that should be added to the toolbar menu when
+ * this view is active
  *
- * Returns: (transfer none): a #GtkWidget for the view menu
+ * Returns: (transfer none): a #NautilusToolbarMenuSections with the details of
+ * which menu sections should be added to the menu
  */
-static GtkWidget*
-nautilus_files_view_get_view_widget (NautilusView *view)
+static NautilusToolbarMenuSections *
+nautilus_files_view_get_toolbar_menu_sections (NautilusView *view)
 {
         g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), NULL);
 
-        return NAUTILUS_FILES_VIEW (view)->details->view_menu_widget;
+        return NAUTILUS_FILES_VIEW (view)->details->toolbar_menu_sections;
 }
 
 static gboolean
@@ -2944,7 +2944,9 @@ nautilus_files_view_finalize (GObject *object)
         g_clear_object (&view->details->view_action_group);
         g_clear_object (&view->details->background_menu);
         g_clear_object (&view->details->selection_menu);
-        g_clear_object (&view->details->view_menu_widget);
+        g_clear_object (&view->details->toolbar_menu_sections->zoom_section);
+        g_clear_object (&view->details->toolbar_menu_sections->extended_section);
+        g_free (view->details->toolbar_menu_sections);
 
         if (view->details->rename_file_popover != NULL) {
                 gtk_popover_set_relative_to (GTK_POPOVER (view->details->rename_file_popover),
@@ -7653,10 +7655,6 @@ nautilus_files_view_get_property (GObject    *object,
                 g_value_set_object (value, nautilus_view_get_icon (NAUTILUS_VIEW (view)));
                 break;
 
-        case PROP_VIEW_WIDGET:
-                g_value_set_object (value, nautilus_view_get_view_widget (NAUTILUS_VIEW (view)));
-                break;
-
         case PROP_IS_LOADING:
                 g_value_set_boolean (value, nautilus_view_is_loading (NAUTILUS_VIEW (view)));
                 break;
@@ -8096,7 +8094,7 @@ nautilus_files_view_iface_init (NautilusViewInterface *iface)
         iface->set_selection = nautilus_files_view_set_selection;
         iface->get_search_query = nautilus_files_view_get_search_query;
         iface->set_search_query = nautilus_files_view_set_search_query;
-        iface->get_view_widget = nautilus_files_view_get_view_widget;
+        iface->get_toolbar_menu_sections = nautilus_files_view_get_toolbar_menu_sections;
         iface->is_searching = nautilus_files_view_is_searching;
         iface->is_loading = nautilus_files_view_is_loading;
 }
@@ -8225,7 +8223,6 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
                                       G_PARAM_STATIC_STRINGS));
 
         g_object_class_override_property (oclass, PROP_ICON, "icon");
-        g_object_class_override_property (oclass, PROP_VIEW_WIDGET, "view-widget");
         g_object_class_override_property (oclass, PROP_IS_LOADING, "is-loading");
         g_object_class_override_property (oclass, PROP_IS_SEARCH, "is-searching");
         g_object_class_override_property (oclass, PROP_LOCATION, "location");
@@ -8257,9 +8254,11 @@ nautilus_files_view_init (NautilusFilesView *view)
         view->details = G_TYPE_INSTANCE_GET_PRIVATE (view, NAUTILUS_TYPE_FILES_VIEW,
                                                      NautilusFilesViewDetails);
 
-        /* View menu */
+        /* Toolbar menu */
         builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-toolbar-view-menu.ui");
-        view->details->view_menu_widget =  g_object_ref_sink (gtk_builder_get_object (builder, 
"view_menu_widget"));
+        view->details->toolbar_menu_sections = nautilus_toolbar_menu_sections_new ();
+        view->details->toolbar_menu_sections->zoom_section = g_object_ref_sink (gtk_builder_get_object 
(builder, "zoom_section"));
+        view->details->toolbar_menu_sections->extended_section = g_object_ref_sink (gtk_builder_get_object 
(builder, "extended_section"));
         view->details->zoom_controls_box = GTK_WIDGET (gtk_builder_get_object (builder, 
"zoom_controls_box"));
         view->details->zoom_level_label = GTK_WIDGET (gtk_builder_get_object (builder, "zoom_level_label"));
 
diff --git a/src/nautilus-places-view.c b/src/nautilus-places-view.c
index ed46f20..dfe5a7f 100644
--- a/src/nautilus-places-view.c
+++ b/src/nautilus-places-view.c
@@ -47,7 +47,6 @@ enum {
         PROP_ICON,
         PROP_LOCATION,
         PROP_SEARCH_QUERY,
-        PROP_VIEW_WIDGET,
         PROP_IS_LOADING,
         PROP_IS_SEARCHING,
         LAST_PROP
@@ -160,10 +159,6 @@ nautilus_places_view_get_property (GObject    *object,
                 g_value_set_object (value, nautilus_view_get_search_query (view));
                 break;
 
-        case PROP_VIEW_WIDGET:
-                g_value_set_object (value, nautilus_view_get_view_widget (view));
-                break;
-
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
         }
@@ -280,10 +275,10 @@ nautilus_places_view_set_search_query (NautilusView  *view,
         g_free (text);
 }
 
-static GtkWidget*
-nautilus_places_view_get_view_widget (NautilusView *view)
+static NautilusToolbarMenuSections *
+nautilus_places_view_get_toolbar_menu_sections (NautilusView *view)
 {
-        /* By returning NULL, no section will be added to the toolbar menu when this view is active */
+        /* By returning NULL, no sections will be added to the toolbar menu when this view is active */
         return NULL;
 }
 
@@ -317,7 +312,7 @@ nautilus_places_view_iface_init (NautilusViewInterface *iface)
         iface->set_selection = nautilus_places_view_set_selection;
         iface->get_search_query = nautilus_places_view_get_search_query;
         iface->set_search_query = nautilus_places_view_set_search_query;
-        iface->get_view_widget = nautilus_places_view_get_view_widget;
+        iface->get_toolbar_menu_sections = nautilus_places_view_get_toolbar_menu_sections;
         iface->is_loading = nautilus_places_view_is_loading;
         iface->is_searching = nautilus_places_view_is_searching;
 }
@@ -336,7 +331,6 @@ nautilus_places_view_class_init (NautilusPlacesViewClass *klass)
         g_object_class_override_property (object_class, PROP_IS_SEARCHING, "is-searching");
         g_object_class_override_property (object_class, PROP_LOCATION, "location");
         g_object_class_override_property (object_class, PROP_SEARCH_QUERY, "search-query");
-        g_object_class_override_property (object_class, PROP_VIEW_WIDGET, "view-widget");
 }
 
 static void
diff --git a/src/nautilus-toolbar-menu-sections.c b/src/nautilus-toolbar-menu-sections.c
new file mode 100644
index 0000000..04360dc
--- /dev/null
+++ b/src/nautilus-toolbar-menu-sections.c
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2016 Neil Herald <neil herald gmail com>
+ *
+ * Nautilus is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Nautilus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
+
+#include "nautilus-toolbar-menu-sections.h"
+
+
+NautilusToolbarMenuSections *
+nautilus_toolbar_menu_sections_new (void)
+{
+        NautilusToolbarMenuSections *sections;
+
+        sections = g_new0 (NautilusToolbarMenuSections, 1);
+
+        return sections;
+}
diff --git a/src/nautilus-toolbar-menu-sections.h b/src/nautilus-toolbar-menu-sections.h
new file mode 100644
index 0000000..296b21f
--- /dev/null
+++ b/src/nautilus-toolbar-menu-sections.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 Neil Herald <neil herald gmail com>
+ *
+ * Nautilus is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Nautilus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef NAUTILUS_TOOLBAR_MENU_SECTIONS_H
+#define NAUTILUS_TOOLBAR_MENU_SECTIONS_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct _NautilusToolbarMenuSections NautilusToolbarMenuSections;
+
+struct _NautilusToolbarMenuSections {
+        GtkWidget *zoom_section;
+        GtkWidget *extended_section;
+};
+
+NautilusToolbarMenuSections *nautilus_toolbar_menu_sections_new (void);
+
+G_END_DECLS
+
+#endif /* NAUTILUS_TOOLBAR_MENU_SECTIONS_H */
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 7a642ec..0a09dd9 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -35,6 +35,7 @@
 #include "nautilus-ui-utilities.h"
 #include "nautilus-progress-info-manager.h"
 #include "nautilus-file-operations.h"
+#include "nautilus-toolbar-menu-sections.h"
 
 #include <glib/gi18n.h>
 #include <math.h>
@@ -66,7 +67,8 @@ struct _NautilusToolbarPrivate {
 
        GtkWidget *operations_button;
         GtkWidget *view_button;
-        GtkWidget *view_menu_slot_section;
+        GtkWidget *view_menu_zoom_section;
+        GtkWidget *view_menu_extended_section;
         GtkWidget *view_toggle_button;
         GtkWidget *view_toggle_icon;
 
@@ -763,7 +765,8 @@ nautilus_toolbar_init (NautilusToolbar *self)
 
         builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-toolbar-menu.ui");
         menu_popover = GTK_WIDGET (gtk_builder_get_object (builder, "menu_popover"));
-        self->priv->view_menu_slot_section = GTK_WIDGET (gtk_builder_get_object (builder, 
"view_menu_slot_section"));
+        self->priv->view_menu_zoom_section = GTK_WIDGET (gtk_builder_get_object (builder, 
"view_menu_zoom_section"));
+        self->priv->view_menu_extended_section = GTK_WIDGET (gtk_builder_get_object (builder, 
"view_menu_extended_section"));
         gtk_menu_button_set_popover (GTK_MENU_BUTTON (self->priv->view_button), menu_popover);
         g_object_unref (builder);
 
@@ -964,36 +967,46 @@ nautilus_toolbar_view_toggle_icon_transform_to (GBinding     *binding,
 }
 
 static void
-on_slot_view_widget_changed (NautilusToolbar    *toolbar,
-                             GParamSpec         *param,
-                             NautilusWindowSlot *slot)
+container_remove_all_children (GtkContainer *container)
 {
-        GtkWidget *view_widget;
         GList *children;
         GList *child;
 
-        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));
-        }
+        children = gtk_container_get_children (container);
+        for (child = children; child != NULL; child = g_list_next (child))
+                gtk_container_remove (container, GTK_WIDGET (child->data));
         g_list_free (children);
+}
 
-        view_widget = nautilus_window_slot_get_view_widget (slot);
-        if (view_widget == NULL)
+static void
+on_slot_toolbar_menu_sections_changed (NautilusToolbar    *toolbar,
+                                       GParamSpec         *param,
+                                       NautilusWindowSlot *slot)
+{
+        NautilusToolbarMenuSections *new_sections;
+
+        container_remove_all_children (GTK_CONTAINER (toolbar->priv->view_menu_zoom_section));
+        container_remove_all_children (GTK_CONTAINER (toolbar->priv->view_menu_extended_section));
+
+        new_sections = nautilus_window_slot_get_toolbar_menu_sections (slot);
+        if (new_sections == NULL)
                 return;
 
-        gtk_box_pack_start (GTK_BOX (toolbar->priv->view_menu_slot_section), view_widget, FALSE, FALSE, 0);
+        if (new_sections->zoom_section != NULL)
+                gtk_box_pack_start (GTK_BOX (toolbar->priv->view_menu_zoom_section), 
new_sections->zoom_section, FALSE, FALSE, 0);
+
+        if (new_sections->extended_section != NULL)
+                gtk_box_pack_start (GTK_BOX (toolbar->priv->view_menu_extended_section), 
new_sections->extended_section, FALSE, FALSE, 0);
 }
 
 static void
-disconnect_view_widget_change_handler (NautilusToolbar *toolbar)
+disconnect_toolbar_menu_sections_change_handler (NautilusToolbar *toolbar)
 {
         if (toolbar->priv->active_slot == NULL)
                 return;
 
         g_signal_handlers_disconnect_by_func (toolbar->priv->active_slot,
-                                              G_CALLBACK (on_slot_view_widget_changed),
+                                              G_CALLBACK (on_slot_toolbar_menu_sections_changed),
                                               toolbar);
 }
 
@@ -1007,7 +1020,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);
+                disconnect_toolbar_menu_sections_change_handler (toolbar);
                 toolbar->priv->active_slot = slot;
 
                 if (slot) {
@@ -1020,9 +1033,9 @@ nautilus_toolbar_set_active_slot (NautilusToolbar    *toolbar,
                                                                      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);
+                        on_slot_toolbar_menu_sections_changed (toolbar, NULL, slot);
+                        g_signal_connect_swapped (slot, "notify::toolbar-menu-sections",
+                                                  G_CALLBACK (on_slot_toolbar_menu_sections_changed), 
toolbar);
                 }
         }
 }
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 79b9dc4..ac462b5 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -38,18 +38,6 @@ nautilus_view_default_init (NautilusViewInterface *iface)
                                                                   G_PARAM_READABLE));
 
         /**
-         * NautilusView::view-widget:
-         *
-         * %TRUE if the view is loading the location, %FALSE otherwise.
-         */
-        g_object_interface_install_property (iface,
-                                             g_param_spec_object ("view-widget",
-                                                                  "View widget for the menu",
-                                                                  "The view widget that appears under the 
view menu",
-                                                                  GTK_TYPE_WIDGET,
-                                                                  G_PARAM_READABLE));
-
-        /**
          * NautilusView::is-loading:
          *
          * %TRUE if the view is loading the location, %FALSE otherwise.
@@ -115,20 +103,21 @@ nautilus_view_get_icon (NautilusView *view)
 }
 
 /**
- * nautilus_view_get_view_widget:
+ * nautilus_view_get_toolbar_menu_sections:
  * @view: a #NautilusView
  *
- * Retrieves the toolbar menu section (widget) from @view, that should be shown
- * in the menu when this view is active
+ * Retrieves the menu sections to show in the main toolbar menu when this view
+ * is active
  *
- * Returns: (transfer none): the widget displayed under view menu.
+ * Returns: (transfer none): a #NautilusToolbarMenuSections with the sections to
+ * be displayed
  */
-GtkWidget*
-nautilus_view_get_view_widget (NautilusView *view)
+NautilusToolbarMenuSections *
+nautilus_view_get_toolbar_menu_sections (NautilusView *view)
 {
-        g_return_val_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->get_view_widget, NULL);
+        g_return_val_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->get_toolbar_menu_sections, NULL);
 
-        return NAUTILUS_VIEW_GET_IFACE (view)->get_view_widget (view);
+        return NAUTILUS_VIEW_GET_IFACE (view)->get_toolbar_menu_sections (view);
 }
 
 /**
diff --git a/src/nautilus-view.h b/src/nautilus-view.h
index 4d3f12f..ad019d6 100644
--- a/src/nautilus-view.h
+++ b/src/nautilus-view.h
@@ -24,6 +24,7 @@
 #include <gtk/gtk.h>
 
 #include "nautilus-query.h"
+#include "nautilus-toolbar-menu-sections.h"
 
 G_BEGIN_DECLS
 
@@ -36,58 +37,59 @@ struct _NautilusViewInterface
         GTypeInterface parent;
 
         /* The icon that represents the view */
-        GIcon*               (*get_icon)                   (NautilusView         *view);
+        GIcon*                          (*get_icon)                  (NautilusView         *view);
 
         /*
-         * The toolbar menu section (widget), that should be shown in the menu
-         * when this view is active
+         * Returns the menu sections that should be shown in the toolbar menu
+         * when this view is active. Implementations can return %NULL to
+         * indicate that no extra sections should be added to the menu
          */
-        GtkWidget*           (*get_view_widget)            (NautilusView         *view);
+        NautilusToolbarMenuSections *   (*get_toolbar_menu_sections) (NautilusView         *view);
 
         /* Current location of the view */
-        GFile*               (*get_location)               (NautilusView         *view);
-        void                 (*set_location)               (NautilusView         *view,
-                                                            GFile                *location);
+        GFile*                          (*get_location)              (NautilusView         *view);
+        void                            (*set_location)              (NautilusView         *view,
+                                                                      GFile                *location);
 
         /* Selection */
-        GList*               (*get_selection)              (NautilusView         *view);
-        void                 (*set_selection)              (NautilusView         *view,
-                                                            GList                *selection);
+        GList*                          (*get_selection)             (NautilusView         *view);
+        void                            (*set_selection)             (NautilusView         *view,
+                                                                      GList                *selection);
 
         /* Search */
-        NautilusQuery*       (*get_search_query)           (NautilusView         *view);
-        void                 (*set_search_query)           (NautilusView         *view,
-                                                            NautilusQuery        *query);
+        NautilusQuery*                  (*get_search_query)          (NautilusView         *view);
+        void                            (*set_search_query)          (NautilusView         *view,
+                                                                      NautilusQuery        *query);
 
         /* Whether the current view is loading the location */
-        gboolean             (*is_loading)                 (NautilusView         *view);
+        gboolean                        (*is_loading)                (NautilusView         *view);
 
         /* Whether the current view is searching or not */
-        gboolean             (*is_searching)               (NautilusView         *view);
+        gboolean                        (*is_searching)              (NautilusView         *view);
 };
 
-GIcon*             nautilus_view_get_icon                  (NautilusView         *view);
+GIcon *                        nautilus_view_get_icon                  (NautilusView         *view);
 
-GtkWidget*         nautilus_view_get_view_widget           (NautilusView         *view);
+NautilusToolbarMenuSections *  nautilus_view_get_toolbar_menu_sections (NautilusView         *view);
 
-GFile*             nautilus_view_get_location              (NautilusView         *view);
+GFile *                        nautilus_view_get_location              (NautilusView         *view);
 
-void               nautilus_view_set_location              (NautilusView         *view,
-                                                            GFile                *location);
+void                           nautilus_view_set_location              (NautilusView         *view,
+                                                                        GFile                *location);
 
-GList*             nautilus_view_get_selection             (NautilusView         *view);
+GList *                        nautilus_view_get_selection             (NautilusView         *view);
 
-void               nautilus_view_set_selection             (NautilusView         *view,
-                                                            GList                *selection);
+void                           nautilus_view_set_selection             (NautilusView         *view,
+                                                                        GList                *selection);
 
-NautilusQuery*     nautilus_view_get_search_query          (NautilusView         *view);
+NautilusQuery *                nautilus_view_get_search_query          (NautilusView         *view);
 
-void               nautilus_view_set_search_query          (NautilusView         *view,
-                                                            NautilusQuery        *query);
+void                           nautilus_view_set_search_query          (NautilusView         *view,
+                                                                        NautilusQuery        *query);
 
-gboolean           nautilus_view_is_loading                (NautilusView         *view);
+gboolean                       nautilus_view_is_loading                (NautilusView         *view);
 
-gboolean           nautilus_view_is_searching              (NautilusView         *view);
+gboolean                       nautilus_view_is_searching              (NautilusView         *view);
 
 G_END_DECLS
 
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 3a0f643..a15b23f 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -54,7 +54,7 @@ enum {
         PROP_ACTIVE = 1,
        PROP_WINDOW,
         PROP_ICON,
-        PROP_VIEW_WIDGET,
+        PROP_TOOLBAR_MENU_SECTIONS,
        PROP_LOADING,
         PROP_LOCATION,
        NUM_PROPERTIES
@@ -648,8 +648,8 @@ nautilus_window_slot_get_property (GObject *object,
         case PROP_ICON:
                 g_value_set_object (value, nautilus_window_slot_get_icon (self));
                 break;
-        case PROP_VIEW_WIDGET:
-                g_value_set_object (value, nautilus_window_slot_get_view_widget (self));
+        case PROP_TOOLBAR_MENU_SECTIONS:
+                g_value_set_pointer (value, nautilus_window_slot_get_toolbar_menu_sections (self));
                 break;
         case PROP_LOADING:
                 g_value_set_boolean (value, nautilus_window_slot_get_loading (self));
@@ -2332,7 +2332,7 @@ nautilus_window_slot_switch_new_content_view (NautilusWindowSlot *self)
                gtk_widget_show (widget);
 
                 g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON]);
-                g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VIEW_WIDGET]);
+                g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TOOLBAR_MENU_SECTIONS]);
        }
 
 done:
@@ -2505,12 +2505,11 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass)
                                     G_TYPE_ICON,
                                     G_PARAM_READABLE);
 
-        properties[PROP_VIEW_WIDGET] =
-               g_param_spec_object ("view-widget",
-                                    "Widget for the view menu",
-                                    "The widget for the view's menu",
-                                    GTK_TYPE_WIDGET,
-                                    G_PARAM_READABLE);
+        properties[PROP_TOOLBAR_MENU_SECTIONS] =
+                g_param_spec_pointer ("toolbar-menu-sections",
+                                      "Menu sections for the toolbar menu",
+                                      "The menu sections to add to the toolbar menu for this slot",
+                                      G_PARAM_READABLE);
 
         properties[PROP_LOCATION] =
                g_param_spec_object ("location",
@@ -2762,8 +2761,8 @@ nautilus_window_slot_get_icon (NautilusWindowSlot *self)
         return view ? nautilus_view_get_icon (view) : NULL;
 }
 
-GtkWidget*
-nautilus_window_slot_get_view_widget (NautilusWindowSlot *self)
+NautilusToolbarMenuSections *
+nautilus_window_slot_get_toolbar_menu_sections (NautilusWindowSlot *self)
 {
         NautilusView *view;
 
@@ -2771,7 +2770,7 @@ nautilus_window_slot_get_view_widget (NautilusWindowSlot *self)
 
         view = nautilus_window_slot_get_current_view (self);
 
-        return view ? nautilus_view_get_view_widget (view) : NULL;
+        return view ? nautilus_view_get_toolbar_menu_sections (view) : NULL;
 }
 
 gboolean
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index ed4c5eb..57b83fa 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -40,6 +40,7 @@ G_DECLARE_DERIVABLE_TYPE (NautilusWindowSlot, nautilus_window_slot, NAUTILUS, WI
 #include "nautilus-files-view.h"
 #include "nautilus-view.h"
 #include "nautilus-window.h"
+#include "nautilus-toolbar-menu-sections.h"
 
 
 struct _NautilusWindowSlotClass {
@@ -95,7 +96,7 @@ void    nautilus_window_slot_queue_reload                (NautilusWindowSlot *slot);
 
 GIcon*   nautilus_window_slot_get_icon                     (NautilusWindowSlot *slot);
 
-GtkWidget* nautilus_window_slot_get_view_widget            (NautilusWindowSlot *slot);
+NautilusToolbarMenuSections * nautilus_window_slot_get_toolbar_menu_sections (NautilusWindowSlot *slot);
 
 gboolean nautilus_window_slot_get_active                   (NautilusWindowSlot *slot);
 
diff --git a/src/resources/ui/nautilus-toolbar-menu.ui b/src/resources/ui/nautilus-toolbar-menu.ui
index 48f27e1..05ab33f 100644
--- a/src/resources/ui/nautilus-toolbar-menu.ui
+++ b/src/resources/ui/nautilus-toolbar-menu.ui
@@ -88,7 +88,16 @@
           </object>
         </child>
         <child>
-          <object class="GtkBox" id="view_menu_slot_section">
+          <!-- Zoom controls are added to this, if the view supports them -->
+          <object class="GtkBox" id="view_menu_zoom_section">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+          </object>
+        </child>
+        <child>
+          <!-- Other controls custom to the view are added to this -->
+          <object class="GtkBox" id="view_menu_extended_section">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="orientation">vertical</property>
diff --git a/src/resources/ui/nautilus-toolbar-view-menu.ui b/src/resources/ui/nautilus-toolbar-view-menu.ui
index 0d72075..38968db 100644
--- a/src/resources/ui/nautilus-toolbar-view-menu.ui
+++ b/src/resources/ui/nautilus-toolbar-view-menu.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <object class="GtkBox" id="view_menu_widget">
+  <object class="GtkBox" id="zoom_section">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="orientation">vertical</property>
@@ -84,6 +84,12 @@
         </child>
       </object>
     </child>
+  </object>
+  <object class="GtkBox" id="extended_section">
+    <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="GtkSeparator">
         <property name="visible">True</property>


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