[gnome-robots] Use GResource for loading the app-menu.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-robots] Use GResource for loading the app-menu.
- Date: Sun, 22 Feb 2015 21:16:14 +0000 (UTC)
commit 8bcbd50ae1d7e79905d2705c6066a0982c265c7a
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sun Feb 22 21:59:06 2015 +0100
Use GResource for loading the app-menu.
configure.ac | 6 ++++++
data/Makefile.am | 10 +++++-----
data/app-menu.ui | 18 +++++++++---------
src/Makefile.am | 12 +++++++++++-
src/gnome-robots.c | 7 -------
src/robots.gresource.xml | 10 ++++++++++
6 files changed, 41 insertions(+), 22 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 63e597a..84569bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,12 @@ PKG_CHECK_MODULES(ROBOTS, [
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 f56ce52..33f3502 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,5 +1,8 @@
SUBDIRS = icons
+dist_noinst_DATA = \
+ app-menu.ui
+
gsettings_SCHEMAS = org.gnome.robots.gschema.xml
@GSETTINGS_RULES@
@@ -59,18 +62,15 @@ appstream_XML = $(appstream_in_files:.xml.in=.xml)
@APPSTREAM_XML_RULES@
@INTLTOOL_XML_RULE@
-pkgdata_DATA = app-menu.ui
-
EXTRA_DIST = $(cursor_files) \
- $(appstream_in_files) \
+ $(appstream_in_files) \
$(pixmap_DATA) \
$(sounds_DATA) \
$(theme_DATA) \
$(desktop_in_files) \
$(config_DATA) \
$(gsettings_SCHEMAS) \
- $(man_MANS) \
- $(pkgdata_DATA)
+ $(man_MANS)
CLEANFILES = \
$(appstream_XML) \
diff --git a/data/app-menu.ui b/data/app-menu.ui
index 24180ce..e94f4bd 100644
--- a/data/app-menu.ui
+++ b/data/app-menu.ui
@@ -1,34 +1,34 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <!-- interface-requires gtk+ 3.4 -->
- <menu id="appmenu">
+ <requires lib="gtk+" version="3.12"/>
+ <menu id="app-menu">
<section>
<item>
- <attribute name="label" translatable="yes">New Game</attribute>
+ <attribute name="label" translatable="yes">_New Game</attribute>
<attribute name="action">app.new-game</attribute>
<attribute name="accel"><Primary>n</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">Preferences</attribute>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">Scores</attribute>
+ <attribute name="label" translatable="yes">_Scores</attribute>
<attribute name="action">app.scores</attribute>
</item>
</section>
<section>
<item>
- <attribute name="label" translatable="yes">Help</attribute>
+ <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="label" translatable="yes">_About</attribute>
<attribute name="action">app.about</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">Quit</attribute>
+ <attribute name="label" translatable="yes">_Quit</attribute>
<attribute name="action">app.quit</attribute>
<attribute name="accel"><Primary>q</attribute>
</item>
diff --git a/src/Makefile.am b/src/Makefile.am
index c02dca3..16754ed 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -44,7 +44,13 @@ gnome_robots_SOURCES = \
cursor-right.h \
cursor-up.h \
cursor-up-left.h \
- cursor-up-right.h
+ cursor-up-right.h \
+ $(BUILT_SOURCES)
+
+BUILT_SOURCES = robots-resources.c
+
+robots-resources.c: $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies robots.gresource.xml)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source
robots.gresource.xml
gnome_robots_CPPFLAGS = \
-I$(top_srcdir) \
@@ -61,4 +67,8 @@ gnome_robots_LDADD = \
$(ROBOTS_LIBS) \
-lm
+MAINTAINERCLEANFILES = robots-resources.c
+
+EXTRA_DIST = robots.gresource.xml
+
-include $(top_srcdir)/git.mk
diff --git a/src/gnome-robots.c b/src/gnome-robots.c
index 8f555d4..6b5d55c 100644
--- a/src/gnome-robots.c
+++ b/src/gnome-robots.c
@@ -324,8 +324,6 @@ activate (GtkApplication *app, gpointer user_data)
GtkWidget *errordialog, *vbox, *hbox, *label, *button, *gridframe;
GtkSizeGroup *size_group;
GtkStyleContext *style_context;
- GtkBuilder *builder;
- GMenuModel *appmenu;
headerbar = gtk_header_bar_new ();
gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), _("Robots"));
@@ -342,11 +340,6 @@ activate (GtkApplication *app, gpointer user_data)
g_action_map_add_action_entries (G_ACTION_MAP (app), app_entries, G_N_ELEMENTS (app_entries), app);
g_action_map_add_action_entries (G_ACTION_MAP (window), win_entries, G_N_ELEMENTS (win_entries), app);
- builder = gtk_builder_new_from_file (g_build_filename (DATA_DIRECTORY, "app-menu.ui", NULL));
- appmenu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
- gtk_application_set_app_menu (app, appmenu);
- g_object_unref (builder);
-
make_cursors ();
game_area = gtk_drawing_area_new ();
diff --git a/src/robots.gresource.xml b/src/robots.gresource.xml
new file mode 100644
index 0000000..5bad0f5
--- /dev/null
+++ b/src/robots.gresource.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <!-- <gresource prefix="/org/gnome/robots/ui">
+ <file preprocess="xml-stripblanks" alias="robots.ui">../data/robots.ui</file>
+ <file alias="robots.css">../data/robots.css</file>
+ </gresource> -->
+ <gresource prefix="/org/gnome/robots/gtk">
+ <file preprocess="xml-stripblanks" alias="menus.ui">../data/app-menu.ui</file>
+ </gresource>
+</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]