[gnome-builder] workbench-header: add "primary" section for top-left



commit 51fae9c967f569e7caca328f1c1cd97b1080a074
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jul 10 01:50:27 2017 -0700

    workbench-header: add "primary" section for top-left
    
    We want a primary section that allows us to tweak how the
    buttons are placed next to each other. I can't think of a better
    name so this is what we got...

 libide/workbench/ide-workbench-header-bar.c  |   50 ++++++++++++++++++++++++++
 libide/workbench/ide-workbench-header-bar.h  |    2 +
 libide/workbench/ide-workbench-header-bar.ui |   13 +++++--
 libide/workbench/ide-workbench.ui            |   25 +++++--------
 4 files changed, 71 insertions(+), 19 deletions(-)
---
diff --git a/libide/workbench/ide-workbench-header-bar.c b/libide/workbench/ide-workbench-header-bar.c
index 896456b..414dcf4 100644
--- a/libide/workbench/ide-workbench-header-bar.c
+++ b/libide/workbench/ide-workbench-header-bar.c
@@ -20,6 +20,8 @@
 
 #include <dazzle.h>
 
+#include "ide-macros.h"
+
 #include "application/ide-application.h"
 #include "search/ide-search-entry.h"
 #include "util/ide-gtk.h"
@@ -34,6 +36,7 @@ typedef struct
   DzlPriorityBox  *left_box;
   IdeOmniBar      *omni_bar;
   IdeSearchEntry  *search_entry;
+  GtkBox          *primary;
 } IdeWorkbenchHeaderBarPrivate;
 
 static void buildable_iface_init (GtkBuildableIface *iface);
@@ -57,6 +60,7 @@ ide_workbench_header_bar_class_init (IdeWorkbenchHeaderBarClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, left_box);
   gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, menu_button);
   gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, omni_bar);
+  gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, primary);
   gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, right_box);
   gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, search_entry);
 
@@ -107,6 +111,28 @@ ide_workbench_header_bar_insert_left (IdeWorkbenchHeaderBar *self,
                                      NULL);
 }
 
+/**
+ * ide_workbench_header_bar_add_primary:
+ * @self: a #IdeWorkbenchHeaderBar
+ *
+ * This will add @widget to the special box at the top left of the window next
+ * to the perspective selector. This is a special location in that the spacing
+ * is treated differently than other locations on the header bar.
+ *
+ * Since: 3.26
+ */
+void
+ide_workbench_header_bar_add_primary (IdeWorkbenchHeaderBar *self,
+                                      GtkWidget             *widget)
+{
+  IdeWorkbenchHeaderBarPrivate *priv = ide_workbench_header_bar_get_instance_private (self);
+
+  g_return_if_fail (IDE_IS_WORKBENCH_HEADER_BAR (self));
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  gtk_container_add (GTK_CONTAINER (priv->primary), widget);
+}
+
 void
 ide_workbench_header_bar_insert_right (IdeWorkbenchHeaderBar *self,
                                        GtkWidget             *widget,
@@ -146,9 +172,33 @@ ide_workbench_header_bar_get_internal_child (GtkBuildable *buildable,
 }
 
 static void
+ide_workbench_header_bar_add_child (GtkBuildable *buildable,
+                                    GtkBuilder   *builder,
+                                    GObject      *object,
+                                    const gchar  *type)
+{
+  IdeWorkbenchHeaderBar *self = (IdeWorkbenchHeaderBar *)buildable;
+  GtkBuildableIface *parent;
+
+  g_return_if_fail (IDE_IS_WORKBENCH_HEADER_BAR (self));
+  g_return_if_fail (GTK_IS_BUILDER (builder));
+  g_return_if_fail (GTK_IS_WIDGET (object));
+
+  if (ide_str_equal0 (type, "primary"))
+    {
+      ide_workbench_header_bar_add_primary (self, GTK_WIDGET (object));
+      return;
+    }
+
+  parent = g_type_interface_peek_parent (GTK_BUILDABLE_GET_IFACE (self));
+  parent->add_child (buildable, builder, object, type);
+}
+
+static void
 buildable_iface_init (GtkBuildableIface *iface)
 {
   iface->get_internal_child = ide_workbench_header_bar_get_internal_child;
+  iface->add_child = ide_workbench_header_bar_add_child;
 }
 
 /**
diff --git a/libide/workbench/ide-workbench-header-bar.h b/libide/workbench/ide-workbench-header-bar.h
index 69d3a41..c4aeae4 100644
--- a/libide/workbench/ide-workbench-header-bar.h
+++ b/libide/workbench/ide-workbench-header-bar.h
@@ -46,6 +46,8 @@ struct _IdeWorkbenchHeaderBarClass
 GtkWidget  *ide_workbench_header_bar_new          (void);
 IdeOmniBar *ide_workbench_header_bar_get_omni_bar (IdeWorkbenchHeaderBar *self);
 void        ide_workbench_header_bar_focus_search (IdeWorkbenchHeaderBar *self);
+void        ide_workbench_header_bar_add_primary  (IdeWorkbenchHeaderBar *self,
+                                                   GtkWidget             *widget);
 void        ide_workbench_header_bar_insert_left  (IdeWorkbenchHeaderBar *self,
                                                    GtkWidget             *widget,
                                                    GtkPackType            pack_type,
diff --git a/libide/workbench/ide-workbench-header-bar.ui b/libide/workbench/ide-workbench-header-bar.ui
index 8705244..971f029 100644
--- a/libide/workbench/ide-workbench-header-bar.ui
+++ b/libide/workbench/ide-workbench-header-bar.ui
@@ -4,9 +4,16 @@
   <template class="IdeWorkbenchHeaderBar" parent="GtkHeaderBar">
     <property name="show-close-button">true</property>
     <child>
+      <object class="GtkBox" id="primary">
+        <property name="spacing">12</property>
+        <property name="visible">true</property>
+        <property name="margin-end">24</property>
+      </object>
+    </child>
+    <child>
       <object class="DzlPriorityBox" id="left_box">
         <property name="hexpand">true</property>
-        <property name="spacing">30</property>
+        <property name="spacing">24</property>
         <property name="visible">true</property>
       </object>
       <packing>
@@ -22,7 +29,7 @@
     <child>
       <object class="DzlPriorityBox" id="right_box">
         <property name="hexpand">true</property>
-        <property name="spacing">30</property>
+        <property name="spacing">24</property>
         <property name="visible">true</property>
         <child>
           <object class="IdeRunButton">
@@ -69,7 +76,7 @@
         </child>
         <child>
           <object class="IdeSearchEntry" id="search_entry">
-            <property name="max-width-chars">30</property>
+            <property name="max-width-chars">24</property>
             <property name="placeholder-text" translatable="yes">Press Ctrl+. to search</property>
             <property name="visible">true</property>
           </object>
diff --git a/libide/workbench/ide-workbench.ui b/libide/workbench/ide-workbench.ui
index c231441..0c95105 100644
--- a/libide/workbench/ide-workbench.ui
+++ b/libide/workbench/ide-workbench.ui
@@ -11,22 +11,15 @@
         <child>
           <object class="IdeWorkbenchHeaderBar" id="header_bar">
             <property name="visible">true</property>
-            <child internal-child="left">
-              <object class="DzlPriorityBox">
-                <child>
-                  <object class="DzlMenuButton" id="perspective_menu_button">
-                    <property name="icon-name"></property>
-                    <property name="menu-id">perspectives-menu</property>
-                    <property name="show-accels">true</property>
-                    <property name="show-arrow">true</property>
-                    <property name="show-icons">true</property>
-                    <property name="transitions-enabled">false</property>
-                    <property name="visible">false</property>
-                  </object>
-                  <packing>
-                    <property name="priority">-100000</property>
-                  </packing>
-                </child>
+            <child type="primary">
+              <object class="DzlMenuButton" id="perspective_menu_button">
+                <property name="focus-on-click">false</property>
+                <property name="menu-id">perspectives-menu</property>
+                <property name="show-accels">true</property>
+                <property name="show-arrow">true</property>
+                <property name="show-icons">true</property>
+                <property name="transitions-enabled">false</property>
+                <property name="visible">false</property>
               </object>
             </child>
           </object>


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