[sysprof] sysprof: wire up window menu
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] sysprof: wire up window menu
- Date: Wed, 29 May 2019 22:31:01 +0000 (UTC)
commit 8e63320a1c347ade814e27a256176538cde3aadd
Author: Christian Hergert <chergert redhat com>
Date: Thu May 16 12:06:37 2019 -0700
sysprof: wire up window menu
src/sysprof/gtk/menus.ui | 35 +++++++++++++++++++++++++++++++++++
src/sysprof/sysprof-window.c | 18 +++++++++++++++++-
src/sysprof/sysprof.gresource.xml | 1 +
src/sysprof/ui/sysprof-window.ui | 14 ++++++++++++++
4 files changed, 67 insertions(+), 1 deletion(-)
---
diff --git a/src/sysprof/gtk/menus.ui b/src/sysprof/gtk/menus.ui
new file mode 100644
index 0000000..30b2e5b
--- /dev/null
+++ b/src/sysprof/gtk/menus.ui
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <menu id="win-menu">
+ <section id="win-menu-new">
+ <item>
+ <attribute name="label" translatable="yes">New Tab</attribute>
+ <attribute name="action">win.new-tab</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">New Window</attribute>
+ <attribute name="action">app.new-window</attribute>
+ </item>
+ </section>
+ <section id="win-menu-open">
+ <item>
+ <attribute name="label" translatable="yes">Open Captureā¦</attribute>
+ <attribute name="action">app.open-capture</attribute>
+ </item>
+ </section>
+ <section id="win-menu-misc">
+ <item>
+ <attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
+ <attribute name="action">app.show-help-overlay</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Help</attribute>
+ <attribute name="action">app.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Quit</attribute>
+ <attribute name="action">app.quit</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/src/sysprof/sysprof-window.c b/src/sysprof/sysprof-window.c
index d47eff9..7885434 100644
--- a/src/sysprof/sysprof-window.c
+++ b/src/sysprof/sysprof-window.c
@@ -31,6 +31,7 @@ struct _SysprofWindow
{
GtkApplicationWindow parent_instance;
SysprofNotebook *notebook;
+ GtkMenuButton *menu_button;
};
G_DEFINE_TYPE (SysprofWindow, sysprof_window, GTK_TYPE_APPLICATION_WINDOW)
@@ -104,6 +105,19 @@ close_tab_cb (GSimpleAction *action,
sysprof_notebook_close_current (self->notebook);
}
+static void
+sysprof_window_constructed (GObject *object)
+{
+ SysprofWindow *self = (SysprofWindow *)object;
+ GApplication *app = g_application_get_default ();
+ GMenu *menu;
+
+ G_OBJECT_CLASS (sysprof_window_parent_class)->constructed (object);
+
+ menu = gtk_application_get_menu_by_id (GTK_APPLICATION (app), "win-menu");
+ gtk_menu_button_set_menu_model (self->menu_button, G_MENU_MODEL (menu));
+}
+
static void
sysprof_window_finalize (GObject *object)
{
@@ -116,10 +130,12 @@ sysprof_window_class_init (SysprofWindowClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ object_class->constructed = sysprof_window_constructed;
object_class->finalize = sysprof_window_finalize;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-window.ui");
- gtk_widget_class_bind_template_child (widget_class, SysprofWindow , notebook);
+ gtk_widget_class_bind_template_child (widget_class, SysprofWindow, menu_button);
+ gtk_widget_class_bind_template_child (widget_class, SysprofWindow, notebook);
g_type_ensure (SYSPROF_TYPE_PROFILER_MENU_BUTTON);
g_type_ensure (SYSPROF_TYPE_NOTEBOOK);
diff --git a/src/sysprof/sysprof.gresource.xml b/src/sysprof/sysprof.gresource.xml
index 331f4d5..cdab05c 100644
--- a/src/sysprof/sysprof.gresource.xml
+++ b/src/sysprof/sysprof.gresource.xml
@@ -3,6 +3,7 @@
<gresource prefix="/org/gnome/sysprof">
<!-- Automatic GTK resources -->
<file>gtk/help-overlay.ui</file>
+ <file>gtk/menus.ui</file>
<!-- Theme overrides -->
<file compressed="true">theme/shared.css</file>
diff --git a/src/sysprof/ui/sysprof-window.ui b/src/sysprof/ui/sysprof-window.ui
index a5e85db..109f877 100644
--- a/src/sysprof/ui/sysprof-window.ui
+++ b/src/sysprof/ui/sysprof-window.ui
@@ -10,6 +10,20 @@
<property name="show-close-button">true</property>
<property name="visible">true</property>
<property name="title" translatable="yes">Sysprof</property>
+ <child>
+ <object class="GtkMenuButton" id="menu_button">
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">open-menu-symbolic</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
<child type="title">
<object class="GtkBox">
<property name="orientation">vertical</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]