[gnome-maps] Use GResource for the app menu



commit 8483ed9cd342af44d23b2892e31c8cbd56ba1fc9
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Mar 25 18:40:43 2013 -0400

    Use GResource for the app menu

 configure.ac                 |    3 +++
 src/Makefile.am              |   10 ++++++++++
 src/app-menu.ui              |   15 +++++++++++++++
 src/application.js           |   13 ++++++++-----
 src/gnome-maps.gresource.xml |    6 ++++++
 5 files changed, 42 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index cc4074e..d8cc06d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,6 +36,9 @@ GLIB_GSETTINGS
 GJS_CONSOLE=`$PKG_CONFIG --variable=gjs_console gjs-1.0`
 AC_SUBST(GJS_CONSOLE)
 
+GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
+AC_SUBST(GLIB_COMPILE_RESOURCES)
+
 LIBGD_INIT([
   header-bar
   tagged-entry
diff --git a/src/Makefile.am b/src/Makefile.am
index bc78136..50d9c61 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,6 +30,16 @@ do_subst = sed -e 's|@abs_top_srcdir[ ]|$(abs_top_srcdir)|g' \
 include $(INTROSPECTION_MAKEFILE)
 include Makefile-js.am
 
+resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies 
$(srcdir)/gnome-maps.gresource.xml)
+gnome-maps.gresource: gnome-maps.gresource.xml $(resource_files)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) $<
+EXTRA_DIST += gnome-maps.gresource.xml $(resource_files)
+
+resourcedir = $(pkgdatadir)
+resource_DATA = gnome-maps.gresource
+
+CLEANFILES += gnome-maps.gresource
+
 bin_SCRIPTS = gnome-maps
 
 gnome-maps: gnome-maps.in
diff --git a/src/app-menu.ui b/src/app-menu.ui
new file mode 100644
index 0000000..fa1e631
--- /dev/null
+++ b/src/app-menu.ui
@@ -0,0 +1,15 @@
+<interface>
+  <menu id="app-menu">
+    <section>
+      <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>
+    </section>
+  </menu>
+</interface>
diff --git a/src/application.js b/src/application.js
index 57598e9..3c5e99c 100644
--- a/src/application.js
+++ b/src/application.js
@@ -91,9 +91,10 @@ const Application = new Lang.Class({
     },
 
     _initAppMenu: function() {
-        let menu = new Gio.Menu ();
-        menu.append(_("About Maps"), "app.about");
-        menu.append(_("Quit"), "app.quit");
+        let builder = new Gtk.Builder();
+        builder.add_from_resource('/org/gnome/maps/app-menu.ui');
+
+        let menu = builder.get_object('app-menu');
         this.set_app_menu(menu);
     },
 
@@ -103,6 +104,9 @@ const Application = new Lang.Class({
 
         GtkClutter.init(null);
 
+        let resource = Gio.Resource.load(Path.RESOURCE_DIR + '/gnome-maps.gresource');
+        resource._register();
+
         application = this;
         settings = new Gio.Settings({ schema: 'org.gnome.maps' });
 
@@ -110,8 +114,7 @@ const Application = new Lang.Class({
             { name: 'about',
               callback: this._onActionAbout },
             { name: 'quit',
-              callback: this._onActionQuit,
-              accel: '<Primary>q' }
+              callback: this._onActionQuit }
         ];
 
         this._initActions();
diff --git a/src/gnome-maps.gresource.xml b/src/gnome-maps.gresource.xml
new file mode 100644
index 0000000..1d61020
--- /dev/null
+++ b/src/gnome-maps.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/maps">
+    <file preprocess="xml-stripblanks">app-menu.ui</file>
+  </gresource>
+</gresources>


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