[nautilus/wip/neilh/toolbar-reorg: 13/16] toolbar: move the toolbar menu ui definition into its own file



commit 2b7b890ad2d1ed5c977c65687fb98f67dca21c1f
Author: Neil Herald <neil herald gmail com>
Date:   Sun May 22 16:50:08 2016 +0100

    toolbar: move the toolbar menu ui definition into its own file
    
    The popover ui definition was in the toolbars definition file which was
    getting pretty big. Have moved the popover definition into its own file,
    to separate things out a bit.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764632

 src/nautilus-toolbar.c                    |   12 +++-
 src/resources/nautilus.gresource.xml      |    1 +
 src/resources/ui/nautilus-toolbar-menu.ui |  100 ++++++++++++++++++++++++++++
 src/resources/ui/nautilus-toolbar.ui      |  101 +----------------------------
 4 files changed, 114 insertions(+), 100 deletions(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 767254e..7a642ec 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -65,6 +65,7 @@ struct _NautilusToolbarPrivate {
         guint operations_button_attention_timeout_id;
 
        GtkWidget *operations_button;
+        GtkWidget *view_button;
         GtkWidget *view_menu_slot_section;
         GtkWidget *view_toggle_button;
         GtkWidget *view_toggle_icon;
@@ -754,9 +755,18 @@ on_progress_has_viewers_changed (NautilusProgressInfoManager *manager,
 static void
 nautilus_toolbar_init (NautilusToolbar *self)
 {
+        GtkBuilder *builder;
+        GtkWidget *menu_popover;
+
        self->priv = nautilus_toolbar_get_instance_private (self);
        gtk_widget_init_template (GTK_WIDGET (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"));
+        gtk_menu_button_set_popover (GTK_MENU_BUTTON (self->priv->view_button), menu_popover);
+        g_object_unref (builder);
+
        self->priv->path_bar = g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL);
        gtk_container_add (GTK_CONTAINER (self->priv->path_bar_container),
                                          self->priv->path_bar);
@@ -888,7 +898,7 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
        gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, operations_popover);
        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_menu_slot_section);
+        gtk_widget_class_bind_template_child_private (widget_class, NautilusToolbar, view_button);
         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);
diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml
index 30a0566..a5917fc 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -6,6 +6,7 @@
     <file>gtk/menus.ui</file>
     <file>ui/nautilus-pathbar-context-menu.ui</file>
     <file>ui/nautilus-toolbar.ui</file>
+    <file>ui/nautilus-toolbar-menu.ui</file>
     <file>ui/nautilus-toolbar-view-menu.ui</file>
     <file>ui/nautilus-create-folder-dialog.ui</file>
     <file>ui/nautilus-rename-file-popover.ui</file>
diff --git a/src/resources/ui/nautilus-toolbar-menu.ui b/src/resources/ui/nautilus-toolbar-menu.ui
new file mode 100644
index 0000000..48f27e1
--- /dev/null
+++ b/src/resources/ui/nautilus-toolbar-menu.ui
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <object class="GtkPopoverMenu" id="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">
+            <property name="visible">True</property>
+            <property name="orientation">horizontal</property>
+            <property name="homogeneous">True</property>
+            <style>
+              <class name="linked"/>
+            </style>
+            <child>
+              <object class="GtkButton" id="new-folder">
+                <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>
+              </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="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>
+              </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="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>
+              </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="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>
diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui
index c63fa8a..e19334b 100644
--- a/src/resources/ui/nautilus-toolbar.ui
+++ b/src/resources/ui/nautilus-toolbar.ui
@@ -72,11 +72,11 @@
       </packing>
     </child>
     <child>
-      <object class="GtkMenuButton" id="view-button">
+      <object class="GtkMenuButton" id="view_button">
         <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>
+        <!-- Popover defined in nautilus-toolbar-menu.ui -->
         <style>
           <class name="image-button"/>
         </style>
@@ -202,101 +202,4 @@
       </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">
-            <property name="visible">True</property>
-            <property name="orientation">horizontal</property>
-            <property name="homogeneous">True</property>
-            <style>
-              <class name="linked"/>
-            </style>
-            <child>
-              <object class="GtkButton" id="new-folder">
-                <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>
-              </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="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>
-              </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="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>
-              </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="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>


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