[sysprof/wip/chergert/sysprof-3] libsysprof-ui: menuing work and use libdazzle



commit 7b30b111a6534b307fc77e0e0d7d1c0141a75344
Author: Christian Hergert <chergert redhat com>
Date:   Sat May 18 15:57:09 2019 -0700

    libsysprof-ui: menuing work and use libdazzle

 src/sysprof/gtk/menus.ui          |  6 ++++++
 src/sysprof/sysprof-application.c |  7 +++++--
 src/sysprof/sysprof-application.h |  9 +++------
 src/sysprof/sysprof-window.c      | 22 ----------------------
 src/sysprof/sysprof.gresource.xml |  6 +++---
 src/sysprof/ui/sysprof-window.ui  | 14 +++++++-------
 6 files changed, 24 insertions(+), 40 deletions(-)
---
diff --git a/src/sysprof/gtk/menus.ui b/src/sysprof/gtk/menus.ui
index fdd805a..3f9aa3d 100644
--- a/src/sysprof/gtk/menus.ui
+++ b/src/sysprof/gtk/menus.ui
@@ -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>
diff --git a/src/sysprof/sysprof-application.c b/src/sysprof/sysprof-application.c
index 9480b09..7e9b757 100644
--- a/src/sysprof/sysprof-application.c
+++ b/src/sysprof/sysprof-application.c
@@ -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 } },
diff --git a/src/sysprof/sysprof-application.h b/src/sysprof/sysprof-application.h
index a3c2f51..d41c132 100644
--- a/src/sysprof/sysprof-application.h
+++ b/src/sysprof/sysprof-application.h
@@ -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 */
diff --git a/src/sysprof/sysprof-window.c b/src/sysprof/sysprof-window.c
index 7885434..98e4f24 100644
--- a/src/sysprof/sysprof-window.c
+++ b/src/sysprof/sysprof-window.c
@@ -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);
diff --git a/src/sysprof/sysprof.gresource.xml b/src/sysprof/sysprof.gresource.xml
index cdab05c..1190ae3 100644
--- a/src/sysprof/sysprof.gresource.xml
+++ b/src/sysprof/sysprof.gresource.xml
@@ -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>
diff --git a/src/sysprof/ui/sysprof-window.ui b/src/sysprof/ui/sysprof-window.ui
index 88b6b76..0467721 100644
--- a/src/sysprof/ui/sysprof-window.ui
+++ b/src/sysprof/ui/sysprof-window.ui
@@ -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>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]