[cheese] Move application menu into GtkBuilder resource



commit 24d86997c3500f50e0dee947983bb9e42e02573c
Author: David King <amigadave amigadave com>
Date:   Tue Nov 12 09:17:39 2013 +0000

    Move application menu into GtkBuilder resource

 Makefile.am                 |    1 +
 data/cheese-appmenu.ui      |   32 ++++++++++++++++++++++++++++++++
 data/cheese.gresource.xml   |   13 +++++++------
 po/POTFILES.in              |    1 +
 src/cheese-application.vala |   20 +++-----------------
 5 files changed, 44 insertions(+), 23 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index b0d5804..9611891 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -198,6 +198,7 @@ endif
 noinst_resource_files = \
        data/cheese.css \
        data/cheese-viewport.json \
+       data/cheese-appmenu.ui \
        data/cheese-main-window.ui \
        data/cheese-prefs.ui
 
diff --git a/data/cheese-appmenu.ui b/data/cheese-appmenu.ui
new file mode 100644
index 0000000..2948e1b
--- /dev/null
+++ b/data/cheese-appmenu.ui
@@ -0,0 +1,32 @@
+<interface domain="cheese">
+    <menu id="appmenu">
+        <section>
+            <item>
+                <attribute name="accel">F11</attribute>
+                <attribute name="label" translatable="yes">_Fullscreen</attribute>
+                <attribute name="action">app.fullscreen</attribute>
+            </item>
+            <item>
+                <attribute name="label" translatable="yes">P_references</attribute>
+                <attribute name="action">app.preferences</attribute>
+            </item>
+        </section>
+        <section>
+            <item>
+                <attribute name="accel">F1</attribute>
+                <attribute name="label" translatable="yes">_Help</attribute>
+                <attribute name="action">app.help</attribute>
+            </item>
+            <item>
+                <attribute name="label" translatable="yes">_About</attribute>
+                <attribute name="action">app.about</attribute>
+            </item>
+            <item>
+                <attribute name="accel">&lt;Primary&gt;q</attribute>
+                <attribute name="label" translatable="yes">_Quit</attribute>
+                <attribute name="action">app.quit</attribute>
+            </item>
+        </section>
+    </menu>
+</interface>
+
diff --git a/data/cheese.gresource.xml b/data/cheese.gresource.xml
index 306e856..514c212 100644
--- a/data/cheese.gresource.xml
+++ b/data/cheese.gresource.xml
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
-  <gresource prefix='/org/gnome/Cheese'>
-    <file>cheese.css</file>
-    <file>cheese-viewport.json</file>
-    <file preprocess="xml-stripblanks">cheese-main-window.ui</file>
-    <file preprocess="xml-stripblanks">cheese-prefs.ui</file>
-  </gresource>
+    <gresource prefix='/org/gnome/Cheese'>
+        <file>cheese.css</file>
+        <file>cheese-viewport.json</file>
+        <file preprocess="xml-stripblanks">cheese-appmenu.ui</file>
+        <file preprocess="xml-stripblanks">cheese-main-window.ui</file>
+        <file preprocess="xml-stripblanks">cheese-prefs.ui</file>
+    </gresource>
 </gresources>
 
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8675246..ef8d803 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,7 @@
 # List of source files containing translatable strings.
 # Please keep this file sorted alphabetically.
 [encoding: UTF-8]
+[type: gettext/glade]data/cheese-appmenu.ui
 [type: gettext/glade]data/cheese-main-window.ui
 [type: gettext/glade]data/cheese-prefs.ui
 data/cheese.desktop.in.in
diff --git a/src/cheese-application.vala b/src/cheese-application.vala
index 8cc46f1..aef5ad4 100644
--- a/src/cheese-application.vala
+++ b/src/cheese-application.vala
@@ -113,23 +113,9 @@ public class Cheese.Application : Gtk.Application
             Window.set_default_icon_name ("cheese");
 
             // Create the menus.
-            var menu = new GLib.Menu ();
-            var section = new GLib.Menu ();
-            menu.append_section (null, section);
-            var item = new GLib.MenuItem (_("_Fullscreen"), "app.fullscreen");
-            item.set_attribute ("accel", "s", "F11");
-            section.append_item (item);
-            section.append (_("P_references"), "app.preferences");
-            section = new GLib.Menu ();
-            menu.append_section (null, section);
-            item = new GLib.MenuItem (_("_Help"), "app.help");
-            item.set_attribute ("accel", "s", "F1");
-            section.append_item (item);
-            section.append (_("_About"), "app.about");
-            item = new GLib.MenuItem (_("_Quit"), "app.quit");
-            item.set_attribute ("accel", "s", "<Primary>q");
-            section.append_item (item);
-            set_app_menu (menu);
+            var builder = new Gtk.Builder.from_resource ("/org/gnome/Cheese/cheese-appmenu.ui");
+            var appmenu = builder.get_object ("appmenu") as GLib.MenuModel;
+            this.set_app_menu (appmenu);
 
             this.add_accelerator ("space", "app.shoot", null);
 


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