[gnome-builder] view-stack: use GtkPopover and GMenuModel for view stack menu
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] view-stack: use GtkPopover and GMenuModel for view stack menu
- Date: Wed, 2 Sep 2015 06:18:13 +0000 (UTC)
commit 7ac49c2e9842db333951b65fc83762f24f9a19a1
Author: Christian Hergert <christian hergert me>
Date: Tue Sep 1 23:17:28 2015 -0700
view-stack: use GtkPopover and GMenuModel for view stack menu
This is not an ideal thing, as I think our custom design before looked
better than what gets generated by gtk_popover_bind_model(). However, we
really need to move in this direction so that plugins can merge menu items
with the system.
I think this design is going to change in the near future, so probably an
okay change to get where we are going.
C'est la vie
data/gtk/menus.ui | 65 ++++++++++++++
data/ui/gb-view-stack.ui | 205 ---------------------------------------------
src/views/gb-view-stack.c | 8 ++
3 files changed, 73 insertions(+), 205 deletions(-)
---
diff --git a/data/gtk/menus.ui b/data/gtk/menus.ui
index e15c61a..99399f5 100644
--- a/data/gtk/menus.ui
+++ b/data/gtk/menus.ui
@@ -101,6 +101,71 @@
</section>
-->
</menu>
+ <menu id="gb-view-stack-menu">
+ <section id="gb-view-stack-splits">
+ <attribute name="id">splits-section</attribute>
+ <attribute name="display-hint">horizontal-buttons</attribute>
+ <attribute name="label" translatable="yes">Split</attribute>
+ <item>
+ <attribute name="label" translatable="yes">Split Left</attribute>
+ <attribute name="action">view-stack.split-left</attribute>
+ <attribute name="verb-icon">builder-split-tab-left-symbolic</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Split Right</attribute>
+ <attribute name="action">view-stack.split-right</attribute>
+ <attribute name="verb-icon">builder-split-tab-right-symbolic</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Split Down</attribute>
+ <attribute name="action">view-stack.split-down</attribute>
+ <attribute name="verb-icon">builder-split-tab-symbolic</attribute>
+ </item>
+ </section>
+ <section id="gb-view-stack-moves">
+ <attribute name="id">move-section</attribute>
+ <attribute name="display-hint">horizontal-buttons</attribute>
+ <attribute name="label" translatable="yes">Move</attribute>
+ <item>
+ <attribute name="label" translatable="yes">Move Left</attribute>
+ <attribute name="action">view-stack.move-left</attribute>
+ <attribute name="verb-icon">builder-move-left-symbolic</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Move Right</attribute>
+ <attribute name="action">view-stack.move-right</attribute>
+ <attribute name="verb-icon">builder-move-right-symbolic</attribute>
+ </item>
+ </section>
+ <section id="gb-view-stack-preview">
+ <item>
+ <attribute name="label" translatable="yes">Pre_view</attribute>
+ <attribute name="action">view.preview</attribute>
+ </item>
+ </section>
+ <section id="gb-view-stack-save">
+ <item>
+ <attribute name="label" translatable="yes">_Save</attribute>
+ <attribute name="action">view.save</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Save As</attribute>
+ <attribute name="action">view.save-as</attribute>
+ </item>
+ </section>
+ <section id="gb-view-stack-print">
+ <item>
+ <attribute name="label" translatable="yes">Print</attribute>
+ <attribute name="action">view.print</attribute>
+ </item>
+ </section>
+ <section id="gb-view-stack-close">
+ <item>
+ <attribute name="label" translatable="yes">_Close</attribute>
+ <attribute name="action">view-stack.close</attribute>
+ </item>
+ </section>
+ </menu>
<menu id="gb-project-tree-display-options">
<section id="gb-project-tree-display-options-section">
<submenu>
diff --git a/data/ui/gb-view-stack.ui b/data/ui/gb-view-stack.ui
index 1600dba..b5c12a2 100644
--- a/data/ui/gb-view-stack.ui
+++ b/data/ui/gb-view-stack.ui
@@ -167,204 +167,6 @@
</child>
</template>
<object class="GtkPopover" id="popover">
- <child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <property name="spacing">12</property>
- <property name="visible">true</property>
- <property name="margin-start">6</property>
- <property name="margin-end">6</property>
- <property name="margin-top">12</property>
- <property name="margin-bottom">12</property>
- <child>
- <object class="GtkBox">
- <property name="margin-end">12</property>
- <property name="margin-start">12</property>
- <property name="spacing">6</property>
- <property name="visible">true</property>
- <child>
- <object class="GtkLabel" id="split_label">
- <property name="label" translatable="yes">Split</property>
- <property name="visible">true</property>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">true</property>
- <property name="margin-start">6</property>
- <style>
- <class name="linked"/>
- </style>
- <child>
- <object class="GtkButton">
- <property name="visible">true</property>
- <property name="action-name">view-stack.split-left</property>
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage">
- <property name="visible">true</property>
- <property name="icon-name">builder-split-tab-left-symbolic</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkButton">
- <property name="visible">true</property>
- <property name="action-name">view-stack.split-right</property>
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage">
- <property name="visible">true</property>
- <property name="icon-name">builder-split-tab-right-symbolic</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkToggleButton">
- <property name="visible">true</property>
- <property name="action-name">view-stack.split-down</property>
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage">
- <property name="visible">true</property>
- <property name="icon-name">builder-split-tab-symbolic</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="margin-end">12</property>
- <property name="margin-start">12</property>
- <property name="spacing">6</property>
- <property name="visible">true</property>
- <child>
- <object class="GtkLabel" id="move_label">
- <property name="visible">true</property>
- <property name="label" translatable="yes">Move</property>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="hexpand">true</property>
- <property name="margin-start">6</property>
- <property name="visible">true</property>
- <style>
- <class name="linked"/>
- </style>
- <child>
- <object class="GtkButton">
- <property name="action-name">view-stack.move-left</property>
- <property name="hexpand">true</property>
- <property name="visible">true</property>
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage">
- <property name="visible">true</property>
- <property name="icon-name">builder-move-left-symbolic</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkButton">
- <property name="action-name">view-stack.move-right</property>
- <property name="hexpand">true</property>
- <property name="visible">true</property>
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage">
- <property name="visible">true</property>
- <property name="icon-name">builder-move-right-symbolic</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <property name="visible">true</property>
- <child>
- <object class="GtkModelButton">
- <property name="action-name">view.preview</property>
- <property name="halign">fill</property>
- <property name="hexpand">true</property>
- <property name="text" translatable="yes">Preview</property>
- <property name="visible">true</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <property name="visible">true</property>
- <child>
- <object class="GtkModelButton">
- <property name="action-name">view.save</property>
- <property name="halign">fill</property>
- <property name="hexpand">true</property>
- <property name="text" translatable="yes">Save</property>
- <property name="visible">true</property>
- </object>
- </child>
- <child>
- <object class="GtkModelButton">
- <property name="action-name">view.save-as</property>
- <property name="halign">fill</property>
- <property name="hexpand">true</property>
- <property name="text" translatable="yes">Save As</property>
- <property name="visible">true</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <property name="visible">true</property>
- <child>
- <object class="GtkModelButton">
- <property name="action-name">view.print</property>
- <property name="halign">fill</property>
- <property name="hexpand">true</property>
- <property name="text" translatable="yes">Print</property>
- <property name="visible">true</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkModelButton">
- <property name="halign">fill</property>
- <property name="hexpand">true</property>
- <property name="action-name">view-stack.close</property>
- <property name="text" translatable="yes">Close</property>
- <property name="visible">true</property>
- </object>
- </child>
- </object>
- </child>
</object>
<object class="GtkPopover" id="views_popover">
<child>
@@ -388,11 +190,4 @@
</object>
</child>
</object>
- <object class="GtkSizeGroup">
- <property name="mode">horizontal</property>
- <widgets>
- <widget name="split_label"/>
- <widget name="move_label"/>
- </widgets>
- </object>
</interface>
diff --git a/src/views/gb-view-stack.c b/src/views/gb-view-stack.c
index 8b46344..5926b1f 100644
--- a/src/views/gb-view-stack.c
+++ b/src/views/gb-view-stack.c
@@ -562,8 +562,16 @@ gb_view_stack_class_init (GbViewStackClass *klass)
static void
gb_view_stack_init (GbViewStack *self)
{
+ GtkApplication *app;
+ GMenu *menu;
+
gtk_widget_init_template (GTK_WIDGET (self));
+ app = GTK_APPLICATION (g_application_get_default ());
+ menu = gtk_application_get_menu_by_id (app, "gb-view-stack-menu");
+
+ gtk_popover_bind_model (self->popover, G_MENU_MODEL (menu), NULL);
+
g_signal_connect_object (self->stack,
"notify::visible-child",
G_CALLBACK (gb_view_stack__notify_visible_child),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]