libsysprof-ui: menuing work and use libdazzle

This commit is contained in:
Christian Hergert
2019-05-18 15:57:09 -07:00
parent 82a5c68476
commit b92ef7440f
6 changed files with 24 additions and 40 deletions

View File

@ -5,32 +5,38 @@
<item>
<attribute name="label" translatable="yes">New Tab</attribute>
<attribute name="action">win.new-tab</attribute>
<attribute name="accel">&lt;primary&gt;t</attribute>
</item>
<item>
<attribute name="label" translatable="yes">New Window</attribute>
<attribute name="action">app.new-window</attribute>
<attribute name="accel">&lt;primary&gt;n</attribute>
</item>
</section>
<section id="win-menu-open">
<item>
<attribute name="label" translatable="yes">Open Capture…</attribute>
<attribute name="action">app.open-capture</attribute>
<attribute name="accel">&lt;primary&gt;o</attribute>
</item>
</section>
<section id="win-menu-close">
<item>
<attribute name="label" translatable="yes">Close</attribute>
<attribute name="action">win.close-tab</attribute>
<attribute name="accel">&lt;primary&gt;w</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>
<attribute name="accel">&lt;primary&gt;question</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Help</attribute>
<attribute name="action">app.help</attribute>
<attribute name="accel">F1</attribute>
</item>
<item>
<attribute name="label" translatable="yes">About Sysprof</attribute>

View File

@ -27,15 +27,18 @@
struct _SysprofApplication
{
GtkApplication parent_instance;
DzlApplication parent_instance;
};
G_DEFINE_TYPE (SysprofApplication, sysprof_application, GTK_TYPE_APPLICATION)
G_DEFINE_TYPE (SysprofApplication, sysprof_application, DZL_TYPE_APPLICATION)
struct {
const gchar *action_name;
const gchar *accels[12];
} default_accels[] = {
{ "app.help", { "F1", NULL } },
{ "app.new-window", { "<Primary>n", NULL } },
{ "app.open-capture", { "<Primary>o", NULL } },
{ "zoom.zoom-in", { "<Primary>plus", "<Primary>KP_Add", "<Primary>equal", "ZoomIn", NULL } },
{ "zoom.zoom-out", { "<Primary>minus", "<Primary>KP_Subtract", "ZoomOut", NULL } },
{ "zoom.zoom-one", { "<Primary>0", "<Primary>KP_0", NULL } },

View File

@ -16,19 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SYSPROF_APPLICATION_H
#define SYSPROF_APPLICATION_H
#pragma once
#include <gtk/gtk.h>
#include <dazzle.h>
G_BEGIN_DECLS
#define SYSPROF_TYPE_APPLICATION (sysprof_application_get_type())
G_DECLARE_FINAL_TYPE (SysprofApplication, sysprof_application, SYSPROF, APPLICATION, GtkApplication)
G_DECLARE_FINAL_TYPE (SysprofApplication, sysprof_application, SYSPROF, APPLICATION, DzlApplication)
SysprofApplication *sysprof_application_new (void);
G_END_DECLS
#endif /* SYSPROF_APPLICATION_H */

View File

@ -105,34 +105,12 @@ 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)
{
G_OBJECT_CLASS (sysprof_window_parent_class)->finalize (object);
}
static void
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, menu_button);
gtk_widget_class_bind_template_child (widget_class, SysprofWindow, notebook);

View File

@ -2,14 +2,14 @@
<gresources>
<gresource prefix="/org/gnome/sysprof">
<!-- Automatic GTK resources -->
<file>gtk/help-overlay.ui</file>
<file>gtk/menus.ui</file>
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
<!-- Theme overrides -->
<file compressed="true">theme/shared.css</file>
<file compressed="true">theme/Adwaita-shared.css</file>
<!-- UI Files -->
<file compressed="true">ui/sysprof-window.ui</file>
<file preprocess="xml-stripblanks">ui/sysprof-window.ui</file>
</gresource>
</gresources>

View File

@ -11,14 +11,14 @@
<property name="visible">true</property>
<property name="title" translatable="yes">Sysprof</property>
<child>
<object class="GtkMenuButton" id="menu_button">
<object class="DzlMenuButton" id="menu_button">
<property name="icon-name">open-menu-symbolic</property>
<property name="show-accels">true</property>
<property name="menu-id">win-menu</property>
<property name="visible">true</property>
<child>
<object class="GtkImage">
<property name="icon-name">open-menu-symbolic</property>
<property name="visible">true</property>
</object>
</child>
<style>
<class name="image-button"/>
</style>
</object>
<packing>
<property name="pack-type">end</property>