[gnome-builder] workbench: add sizing workarounds for centering omnibar
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] workbench: add sizing workarounds for centering omnibar
- Date: Tue, 28 Jun 2016 00:04:27 +0000 (UTC)
commit 82cbb209f111a6a884268aeadbdd8bb4ca64ad3f
Author: Christian Hergert <chergert redhat com>
Date: Wed Jun 22 13:41:26 2016 -0700
workbench: add sizing workarounds for centering omnibar
This is less than ideal, because it's the result of 2 bugs in gtk+ size
requests that we are working around.
The first, is the lack of hexpand support in left/right of the headerbar.
The second, is that the center widget + sizing of neighbors is not
respected when a GtkBox is packed as the custom title.
Where this will be apparent, is when the content is compressed and there
are uneven buttons on the left/right. You'll see spacing enforced for the
size group contained widgetry, which will be rather annoying im presume.
Either way, this works for now and allows us to move forward.
libide/workbench/ide-workbench-header-bar.c | 16 +++++++----
libide/workbench/ide-workbench-header-bar.ui | 36 ++++++++++++++++++++++---
2 files changed, 41 insertions(+), 11 deletions(-)
---
diff --git a/libide/workbench/ide-workbench-header-bar.c b/libide/workbench/ide-workbench-header-bar.c
index ca08781..92d2dc5 100644
--- a/libide/workbench/ide-workbench-header-bar.c
+++ b/libide/workbench/ide-workbench-header-bar.c
@@ -30,6 +30,8 @@ typedef struct
{
GtkMenuButton *menu_button;
EggPriorityBox *center_box;
+ EggPriorityBox *center_right_box;
+ EggPriorityBox *center_left_box;
EggPriorityBox *right_box;
EggPriorityBox *left_box;
} IdeWorkbenchHeaderBarPrivate;
@@ -53,6 +55,8 @@ ide_workbench_header_bar_class_init (IdeWorkbenchHeaderBarClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/ui/ide-workbench-header-bar.ui");
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, center_box);
+ gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, center_right_box);
+ gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, center_left_box);
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, menu_button);
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, left_box);
gtk_widget_class_bind_template_child_private (widget_class, IdeWorkbenchHeaderBar, right_box);
@@ -100,12 +104,12 @@ ide_workbench_header_bar_insert_left (IdeWorkbenchHeaderBar *self,
/*
* NOTE: Because GtkHeaderBar does not currently support hexpand, we
* need to check the pack_type requested and possibly insert it
- * into our custom center-child (with opposite pack_type).
+ * into our custom center-child.
*/
if (pack_type == GTK_PACK_END)
- gtk_container_add_with_properties (GTK_CONTAINER (priv->center_box), widget,
- "pack-type", GTK_PACK_START,
+ gtk_container_add_with_properties (GTK_CONTAINER (priv->center_left_box), widget,
+ "pack-type", pack_type,
"priority", priority,
NULL);
else
@@ -130,12 +134,12 @@ ide_workbench_header_bar_insert_right (IdeWorkbenchHeaderBar *self,
/*
* NOTE: Because GtkHeaderBar does not currently support hexpand, we
* need to check the pack_type requested and possibly insert it
- * into our custom center-child (with opposite pack_type).
+ * into our custom center-child.
*/
if (pack_type == GTK_PACK_START)
- gtk_container_add_with_properties (GTK_CONTAINER (priv->center_box), widget,
- "pack-type", GTK_PACK_END,
+ gtk_container_add_with_properties (GTK_CONTAINER (priv->center_right_box), widget,
+ "pack-type", pack_type,
"priority", priority,
NULL);
else
diff --git a/libide/workbench/ide-workbench-header-bar.ui b/libide/workbench/ide-workbench-header-bar.ui
index ee76c1a..f730d75 100644
--- a/libide/workbench/ide-workbench-header-bar.ui
+++ b/libide/workbench/ide-workbench-header-bar.ui
@@ -15,18 +15,36 @@
</packing>
</child>
<child type="title">
- <object class="EggPriorityBox" id="center_box">
+ <object class="GtkBox" id="center_box">
<property name="spacing">6</property>
<property name="visible">true</property>
- <!--
- We might need separate children for center-right and center-left
- -->
+ <child>
+ <object class="EggPriorityBox" id="center_left_box">
+ <property name="halign">end</property>
+ <property name="visible">true</property>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ <property name="fill">true</property>
+ <property name="expand">true</property>
+ </packing>
+ </child>
<child type="center">
<object class="IdeOmniBar" id="bar">
- <property name="valign">center</property>
<property name="visible">true</property>
</object>
</child>
+ <child>
+ <object class="EggPriorityBox" id="center_right_box">
+ <property name="halign">start</property>
+ <property name="visible">true</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ <property name="fill">true</property>
+ <property name="expand">true</property>
+ </packing>
+ </child>
</object>
</child>
<child>
@@ -72,4 +90,12 @@
</packing>
</child>
</template>
+ <object class="GtkSizeGroup">
+ <property name="mode">GTK_SIZE_GROUP_HORIZONTAL</property>
+ <widgets>
+ <!-- This is required due to bug https://bugzilla.gnome.org/show_bug.cgi?id=767932 -->
+ <widget name="center_right_box"/>
+ <widget name="center_left_box"/>
+ </widgets>
+ </object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]