[gnome-boxes] app: Let GtkApplication load the appmenu



commit 3bf05816938ce9cc6e59737917e4bd75f9bf51c6
Author: Felipe Borges <felipeborges gnome org>
Date:   Wed Apr 26 17:24:37 2017 +0200

    app: Let GtkApplication load the appmenu
    
    When there's a resource_base_path set, GtkApplication can
    automatically find a gtk/menus.ui file and set it as an
    appmenu.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782789

 data/gnome-boxes.gresource.xml |    1 +
 data/ui/menus.ui               |   23 +++++++++++++++++++++++
 src/app.vala                   |    9 +--------
 3 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index d4c71bc..5708bc8 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -2,6 +2,7 @@
 <gresources>
   <gresource prefix="/org/gnome/Boxes">
     <file>gtk-style.css</file>
+    <file preprocess="xml-stripblanks" alias="gtk/menus.ui">ui/menus.ui</file>
     <file>icons/boxes-arrow.svg</file>
     <file>icons/boxes-create.png</file>
     <file>icons/empty-boxes.png</file>
diff --git a/data/ui/menus.ui b/data/ui/menus.ui
new file mode 100644
index 0000000..448a6d0
--- /dev/null
+++ b/data/ui/menus.ui
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<interface>
+  <menu id="app-menu">
+    <item>
+      <attribute name="action">win.kbd-shortcuts</attribute>
+      <attribute name="label" translatable="yes">Keyboard Shortcuts</attribute>
+    </item>
+    <item>
+      <attribute name="action">app.help</attribute>
+      <attribute name="label" translatable="yes">Help</attribute>
+    </item>
+    <item>
+      <attribute name="action">app.about</attribute>
+      <attribute name="label" translatable="yes">About</attribute>
+    </item>
+    <item>
+      <attribute name="action">app.quit</attribute>
+      <attribute name="label" translatable="yes">Quit</attribute>
+      <attribute name="accel">&lt;Primary&gt;q</attribute>
+    </item>
+  </menu>
+</interface>
diff --git a/src/app.vala b/src/app.vala
index eed58c8..66b5151 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -45,6 +45,7 @@ private class Boxes.App: Gtk.Application {
     public App () {
         application_id = "org.gnome.Boxes";
         flags |= ApplicationFlags.HANDLES_COMMAND_LINE;
+        resource_base_path = "/org/gnome/Boxes";
 
         app = this;
         async_launcher = AsyncLauncher.get_default ();
@@ -121,14 +122,6 @@ private class Boxes.App: Gtk.Application {
         unowned string [] args2 = args;
         Gtk.init (ref args2);
 
-        var menu = new GLib.Menu ();
-        menu.append (_("Keyboard Shortcuts"), "win.kbd-shortcuts");
-        menu.append (_("Help"), "app.help");
-        menu.append (_("About"), "app.about");
-        menu.append (_("Quit"), "app.quit");
-
-        set_app_menu (menu);
-
         collection = new Collection ();
 
         collection.item_added.connect ((item) => {


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