[libdazzle] example: add gear menu
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] example: add gear menu
- Date: Sat, 8 Jul 2017 08:16:49 +0000 (UTC)
commit ea4fcdfdf2948dcc346b7ec877c059d692a16d1a
Author: Christian Hergert <chergert redhat com>
Date: Sat Jul 8 01:16:09 2017 -0700
example: add gear menu
With a fullscreen action that can be toggled.
examples/app/example-window.c | 8 ++++++++
examples/app/example-window.ui | 18 ++++++++++++++++++
examples/app/gtk/menus.ui | 8 ++++++++
3 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/examples/app/example-window.c b/examples/app/example-window.c
index 7c9a73e..aaec2e2 100644
--- a/examples/app/example-window.c
+++ b/examples/app/example-window.c
@@ -12,6 +12,7 @@ struct _ExampleWindow
GtkNotebook *notebook;
DzlEmptyState *empty_state;
GtkStack *stack;
+ GtkPopover *gear_popover;
};
G_DEFINE_TYPE (ExampleWindow, example_window, DZL_TYPE_APPLICATION_WINDOW)
@@ -152,6 +153,7 @@ example_window_class_init (ExampleWindowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/example/ui/example-window.ui");
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, dockbin);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, empty_state);
+ gtk_widget_class_bind_template_child (widget_class, ExampleWindow, gear_popover);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, header_bar);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, notebook);
gtk_widget_class_bind_template_child (widget_class, ExampleWindow, stack);
@@ -163,6 +165,8 @@ example_window_init (ExampleWindow *self)
DzlShortcutController *controller;
g_autoptr(GPropertyAction) left = NULL;
g_autoptr(GPropertyAction) right = NULL;
+ DzlApplication *app;
+ GMenu *menu;
gtk_widget_init_template (GTK_WIDGET (self));
@@ -191,6 +195,10 @@ example_window_init (ExampleWindow *self)
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (left));
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (right));
+
+ app = DZL_APPLICATION (g_application_get_default ());
+ menu = dzl_application_get_menu_by_id (app, "gear-menu");
+ gtk_popover_bind_model (self->gear_popover, G_MENU_MODEL (menu), NULL);
}
GtkWidget *
diff --git a/examples/app/example-window.ui b/examples/app/example-window.ui
index 92752a8..5e11289 100644
--- a/examples/app/example-window.ui
+++ b/examples/app/example-window.ui
@@ -55,6 +55,22 @@
<property name="pack-type">end</property>
</packing>
</child>
+ <child>
+ <object class="GtkMenuButton" id="gear_menu">
+ <property name="visible">true</property>
+ <property name="popover">gear_popover</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">open-menu-symbolic</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
</object>
</child>
<child>
@@ -115,4 +131,6 @@
</object>
</child>
</template>
+ <object class="GtkPopover" id="gear_popover">
+ </object>
</interface>
diff --git a/examples/app/gtk/menus.ui b/examples/app/gtk/menus.ui
index 765091b..009d9a7 100644
--- a/examples/app/gtk/menus.ui
+++ b/examples/app/gtk/menus.ui
@@ -17,4 +17,12 @@
</item>
</section>
</menu>
+ <menu id="gear-menu">
+ <section id="gear-menu-fullscreen">
+ <item>
+ <attribute name="label" translatable="yes">_Fullscreen</attribute>
+ <attribute name="action">win.fullscreen</attribute>
+ </item>
+ </section>
+ </menu>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]