[lightsoff] Use GResource for loading the app-menu.



commit f3d6134b4180a7002ea8e8c0e5e6812a7e96630b
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed Mar 4 05:28:34 2015 +0100

    Use GResource for loading the app-menu.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745625

 configure.ac                |    6 ++++++
 data/Makefile.am            |    3 +++
 data/lightsoff-menus.ui     |   29 +++++++++++++++++++++++++++++
 po/POTFILES.in              |    1 +
 src/Makefile.am             |   10 +++++++++-
 src/lightsoff.gresource.xml |   11 +++++++++++
 src/lightsoff.vala          |   14 --------------
 7 files changed, 59 insertions(+), 15 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index cbf326e..463a9b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,6 +34,12 @@ AC_CHECK_LIB([m],[floor])
 AC_PATH_PROG([DESKTOP_FILE_VALIDATE], [desktop-file-validate], [/bin/true])
 
 dnl ###########################################################################
+dnl GResources
+dnl ###########################################################################
+
+AC_PATH_PROG([GLIB_COMPILE_RESOURCES],[glib-compile-resources])
+
+dnl ###########################################################################
 dnl Internationalization
 dnl ###########################################################################
 
diff --git a/data/Makefile.am b/data/Makefile.am
index 8fc4a80..53547fc 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,5 +1,8 @@
 SUBDIRS = icons
 
+dist_noinst_DATA = \
+       lightsoff-menus.ui
+
 lightsoffdir = $(datadir)/lightsoff
 lightsoff_DATA = \
        off.svg \
diff --git a/data/lightsoff-menus.ui b/data/lightsoff-menus.ui
new file mode 100644
index 0000000..502ad18
--- /dev/null
+++ b/data/lightsoff-menus.ui
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="3.12"/>
+  <menu id="app-menu">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Start Over</attribute>
+        <attribute name="action">win.new-game</attribute>
+        <attribute name="accel">&lt;Primary&gt;n</attribute>
+      </item>
+    </section>
+    <section>
+      <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</attribute>
+        <attribute name="action">app.about</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Quit</attribute>
+        <attribute name="action">app.quit</attribute>
+        <attribute name="accel">&lt;Primary&gt;q</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 37c6802..333d070 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@
 [encoding: UTF-8]
 data/lightsoff.appdata.xml.in
 data/lightsoff.desktop.in
+[type: gettext/glade]data/lightsoff-menus.ui
 data/org.gnome.lightsoff.gschema.xml
 src/board-view.vala
 src/game-view.vala
diff --git a/src/Makefile.am b/src/Makefile.am
index 284c7c2..da86918 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,11 +1,14 @@
 bin_PROGRAMS = lightsoff
 
+BUILT_SOURCES = lightsoff-resources.c
+
 lightsoff_SOURCES = \
        board-view.vala \
        config.vapi \
        lightsoff.vala \
        puzzle-generator.vala \
-       game-view.vala
+       game-view.vala \
+       $(BUILT_SOURCES)
 
 lightsoff_VALAFLAGS = \
        --pkg posix \
@@ -24,8 +27,13 @@ lightsoff_CFLAGS = \
 lightsoff_LDADD =      \
        $(LIGHTSOFF_LIBS)
 
+lightsoff-resources.c: $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies lightsoff.gresource.xml)
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source 
lightsoff.gresource.xml
+
 CLEANFILES = \
        $(patsubst %.vala,%.c,$(filter %.vala, $(SOURCES))) \
        *_vala.stamp
 
+EXTRA_DIST = lightsoff.gresource.xml
+
 -include $(top_srcdir)/git.mk
diff --git a/src/lightsoff.gresource.xml b/src/lightsoff.gresource.xml
new file mode 100644
index 0000000..312ca7d
--- /dev/null
+++ b/src/lightsoff.gresource.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <!-- <gresource prefix="/org/gnome/lightsoff/ui">
+    <file preprocess="xml-stripblanks" alias="lightsoff.ui">../data/lightsoff.ui</file>
+    <file alias="lightsoff.css">../data/lightsoff.css</file>
+  </gresource> -->
+  <gresource prefix="/org/gnome/lightsoff/gtk">
+    <file preprocess="xml-stripblanks" alias="menus.ui">../data/lightsoff-menus.ui</file>
+  </gresource>
+</gresources>
+
diff --git a/src/lightsoff.vala b/src/lightsoff.vala
index 627ed7f..9a58088 100644
--- a/src/lightsoff.vala
+++ b/src/lightsoff.vala
@@ -42,20 +42,6 @@ public class LightsOff : Gtk.Application
         Gtk.Settings.get_default ().set ("gtk-application-prefer-dark-theme", true);
 
         add_action_entries (action_entries, this);
-        add_accelerator ("<Primary>n", "win.new-game", null);
-        add_accelerator ("F1", "app.help", null);
-        add_accelerator ("<Primary>q", "app.quit", null);
-
-        var menu = new Menu ();
-        var section = new Menu ();
-        menu.append_section (null, section);
-        section.append (_("_Start Over"), "win.new-game");
-        section = new Menu ();
-        menu.append_section (null, section);
-        section.append (_("_Help"), "app.help");
-        section.append (_("_About"), "app.about");
-        section.append (_("_Quit"), "app.quit");
-        set_app_menu (menu);
 
         settings = new Settings ("org.gnome.lightsoff");
 


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