[gnome-builder] stack-header: use DzlMenuButton
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] stack-header: use DzlMenuButton
- Date: Wed, 19 Jul 2017 11:15:42 +0000 (UTC)
commit abbf16f4be8bd478f1e1d675486a71b836e1d16c
Author: Christian Hergert <chergert redhat com>
Date: Mon Jul 10 17:34:06 2017 -0700
stack-header: use DzlMenuButton
Switch to using DzlMenuButton so we can unify more of our
menuing code.
We have a bunch of menus now, and they are all slightly
different. Some had to use widgets, others didn't. DzlMenuButton
has been made so that we can reduce those differences and use
common code (almost) everywhere.
The one thing DzlMenuButton doesn't yet support is subpages, so
the gear menu will have to continue being a GtkMenuButton for
now.
libide/layout/ide-layout-stack-header.c | 23 ++++++++++++++++-------
libide/layout/ide-layout-stack-header.ui | 18 +++---------------
2 files changed, 19 insertions(+), 22 deletions(-)
---
diff --git a/libide/layout/ide-layout-stack-header.c b/libide/layout/ide-layout-stack-header.c
index 4f4fd14..a1a34b0 100644
--- a/libide/layout/ide-layout-stack-header.c
+++ b/libide/layout/ide-layout-stack-header.c
@@ -55,8 +55,7 @@ struct _IdeLayoutStackHeader
guint foreground_rgba_set : 1;
GtkButton *close_button;
- GtkMenuButton *document_button;
- GtkPopover *document_popover;
+ DzlMenuButton *document_button;
GtkMenuButton *title_button;
GtkPopover *title_popover;
GtkListBox *title_list_box;
@@ -94,22 +93,32 @@ _ide_layout_stack_header_focus_list (IdeLayoutStackHeader *self)
void
_ide_layout_stack_header_hide (IdeLayoutStackHeader *self)
{
+ GtkPopover *popover;
+
g_return_if_fail (IDE_IS_LAYOUT_STACK_HEADER (self));
/* This is like _ide_layout_stack_header_popdown() but we hide the
* popovers immediately without performing the popdown animation.
*/
- gtk_widget_hide (GTK_WIDGET (self->document_popover));
+ popover = gtk_menu_button_get_popover (GTK_MENU_BUTTON (self->document_button));
+ if (popover != NULL)
+ gtk_widget_hide (GTK_WIDGET (popover));
+
gtk_widget_hide (GTK_WIDGET (self->title_popover));
}
void
_ide_layout_stack_header_popdown (IdeLayoutStackHeader *self)
{
+ GtkPopover *popover;
+
g_return_if_fail (IDE_IS_LAYOUT_STACK_HEADER (self));
- gtk_popover_popdown (self->document_popover);
+ popover = gtk_menu_button_get_popover (GTK_MENU_BUTTON (self->document_button));
+ if (popover != NULL)
+ gtk_popover_popdown (popover);
+
gtk_popover_popdown (self->title_popover);
}
@@ -611,7 +620,6 @@ ide_layout_stack_header_class_init (IdeLayoutStackHeaderClass *klass)
gtk_widget_class_set_css_name (widget_class, "idelayoutstackheader");
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/ui/ide-layout-stack-header.ui");
gtk_widget_class_bind_template_child (widget_class, IdeLayoutStackHeader, close_button);
- gtk_widget_class_bind_template_child (widget_class, IdeLayoutStackHeader, document_popover);
gtk_widget_class_bind_template_child (widget_class, IdeLayoutStackHeader, document_button);
gtk_widget_class_bind_template_child (widget_class, IdeLayoutStackHeader, title_box);
gtk_widget_class_bind_template_child (widget_class, IdeLayoutStackHeader, title_button);
@@ -652,8 +660,9 @@ ide_layout_stack_header_init (IdeLayoutStackHeader *self)
*/
self->menu = dzl_joined_menu_new ();
- gtk_popover_bind_model (self->document_popover, G_MENU_MODEL (self->menu), NULL);
- frame_section = dzl_application_get_menu_by_id (DZL_APPLICATION_DEFAULT, "ide-layout-stack-frame-menu");
+ dzl_menu_button_set_model (self->document_button, G_MENU_MODEL (self->menu));
+ frame_section = dzl_application_get_menu_by_id (DZL_APPLICATION_DEFAULT,
+ "ide-layout-stack-frame-menu");
dzl_joined_menu_append_menu (self->menu, G_MENU_MODEL (frame_section));
/*
diff --git a/libide/layout/ide-layout-stack-header.ui b/libide/layout/ide-layout-stack-header.ui
index 2e4192e..0ea9e37 100644
--- a/libide/layout/ide-layout-stack-header.ui
+++ b/libide/layout/ide-layout-stack-header.ui
@@ -1,12 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <object class="GtkPopover" id="document_popover">
- <property name="width-request">250</property>
- <property name="border-width">10</property>
- <style>
- <class name="document-popover"/>
- </style>
- </object>
<object class="GtkPopover" id="title_popover">
<property name="width-request">350</property>
<property name="border-width">18</property>
@@ -170,16 +163,11 @@
</packing>
</child>
<child>
- <object class="GtkMenuButton" id="document_button">
+ <object class="DzlMenuButton" id="document_button">
<property name="focus-on-click">false</property>
- <property name="popover">document_popover</property>
+ <property name="icon-name">pan-down-symbolic</property>
+ <property name="show-arrow">false</property>
<property name="visible">true</property>
- <child>
- <object class="GtkImage">
- <property name="icon-name">pan-down-symbolic</property>
- <property name="visible">true</property>
- </object>
- </child>
</object>
<packing>
<property name="pack-type">end</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]