mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
sysprof: wire up window menu
This commit is contained in:
35
src/sysprof/gtk/menus.ui
Normal file
35
src/sysprof/gtk/menus.ui
Normal file
@ -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>
|
||||||
@ -31,6 +31,7 @@ struct _SysprofWindow
|
|||||||
{
|
{
|
||||||
GtkApplicationWindow parent_instance;
|
GtkApplicationWindow parent_instance;
|
||||||
SysprofNotebook *notebook;
|
SysprofNotebook *notebook;
|
||||||
|
GtkMenuButton *menu_button;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (SysprofWindow, sysprof_window, GTK_TYPE_APPLICATION_WINDOW)
|
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);
|
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
|
static void
|
||||||
sysprof_window_finalize (GObject *object)
|
sysprof_window_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
@ -116,10 +130,12 @@ sysprof_window_class_init (SysprofWindowClass *klass)
|
|||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->constructed = sysprof_window_constructed;
|
||||||
object_class->finalize = sysprof_window_finalize;
|
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_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_PROFILER_MENU_BUTTON);
|
||||||
g_type_ensure (SYSPROF_TYPE_NOTEBOOK);
|
g_type_ensure (SYSPROF_TYPE_NOTEBOOK);
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
<gresource prefix="/org/gnome/sysprof">
|
<gresource prefix="/org/gnome/sysprof">
|
||||||
<!-- Automatic GTK resources -->
|
<!-- Automatic GTK resources -->
|
||||||
<file>gtk/help-overlay.ui</file>
|
<file>gtk/help-overlay.ui</file>
|
||||||
|
<file>gtk/menus.ui</file>
|
||||||
|
|
||||||
<!-- Theme overrides -->
|
<!-- Theme overrides -->
|
||||||
<file compressed="true">theme/shared.css</file>
|
<file compressed="true">theme/shared.css</file>
|
||||||
|
|||||||
@ -10,6 +10,20 @@
|
|||||||
<property name="show-close-button">true</property>
|
<property name="show-close-button">true</property>
|
||||||
<property name="visible">true</property>
|
<property name="visible">true</property>
|
||||||
<property name="title" translatable="yes">Sysprof</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">
|
<child type="title">
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
|
|||||||
Reference in New Issue
Block a user