[tali] Use GResource for loading the app-menu.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tali] Use GResource for loading the app-menu.
- Date: Sun, 22 Feb 2015 20:03:12 +0000 (UTC)
commit b7b4ab3fdc3a5ae577c10b12ec5eef3f68871843
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sun Feb 22 20:52:11 2015 +0100
Use GResource for loading the app-menu.
configure.ac | 6 ++++++
data/Makefile.am | 3 +++
data/tali-menus.ui | 36 ++++++++++++++++++++++++++++++++++++
po/POTFILES.in | 3 ++-
src/Makefile.am | 12 +++++++++++-
src/gyahtzee.c | 18 +-----------------
src/tali.gresource.xml | 10 ++++++++++
7 files changed, 69 insertions(+), 19 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4797b77..6fd4ef6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,12 @@ PKG_CHECK_MODULES(TALI, [
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 4045c8d..81a6799 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,5 +1,8 @@
SUBDIRS = icons
+dist_noinst_DATA = \
+ tali-menus.ui
+
pixmapdir = $(datadir)/tali
pixmap_DATA = \
gnome-dice-1.svg \
diff --git a/data/tali-menus.ui b/data/tali-menus.ui
new file mode 100644
index 0000000..2eb1e7c
--- /dev/null
+++ b/data/tali-menus.ui
@@ -0,0 +1,36 @@
+<?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">_New Game</attribute>
+ <attribute name="action">app.new-game</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">app.preferences</attribute>
+ </item>
+ <item>
+ <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="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"><Primary>q</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6766762..e8fc7e7 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,9 +1,10 @@
# List of source files containing translatable strings.
# Please keep this file in alphabetical order.
[encoding: UTF-8]
+data/tali.appdata.xml.in
data/tali.desktop.in
+[type: gettext/glade]data/tali-menus.ui
data/org.gnome.tali.gschema.xml
-data/tali.appdata.xml.in
src/clist.c
src/games-scores-dialog.c
src/gyahtzee.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 6e47027..8563031 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,7 +17,13 @@ tali_SOURCES = \
games-scores-dialog.c \
games-scores-dialog.h \
games-scores-backend.c \
- games-scores-backend.h
+ games-scores-backend.h \
+ $(BUILT_SOURCES)
+
+BUILT_SOURCES = tali-resources.c
+
+tali-resources.c: $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies tali.gresource.xml)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source
tali.gresource.xml
tali_CPPFLAGS = \
-I$(top_srcdir) \
@@ -32,4 +38,8 @@ tali_CFLAGS = \
tali_LDADD = \
$(TALI_LIBS)
+MAINTAINERCLEANFILES = tali-resources.c
+
+EXTRA_DIST = tali.gresource.xml
+
-include $(top_srcdir)/git.mk
diff --git a/src/gyahtzee.c b/src/gyahtzee.c
index 0296635..76621f2 100644
--- a/src/gyahtzee.c
+++ b/src/gyahtzee.c
@@ -724,7 +724,6 @@ GyahtzeeCreateMainWindow (GApplication *app, gpointer user_data)
GtkWidget *tmp;
GtkWidget *dicebox;
GtkWidget *undo_button;
- GMenu *app_menu, *section;
int i, j;
window = gtk_application_window_new (application);
@@ -740,26 +739,11 @@ GyahtzeeCreateMainWindow (GApplication *app, gpointer user_data)
g_action_map_add_action_entries (G_ACTION_MAP (application), app_entries, G_N_ELEMENTS (app_entries),
application);
gtk_application_add_accelerator (application, "<Primary>z", "app.undo", NULL);
- gtk_application_add_accelerator (application, "<Primary>q", "app.quit", NULL);
gtk_application_add_accelerator (application, "<Primary>r", "app.roll", NULL);
- gtk_application_add_accelerator (application, "F1", "app.help", NULL);
-
- /*---- Menus ----*/
- app_menu = g_menu_new ();
- section = g_menu_new ();
- g_menu_append_section (app_menu, NULL, G_MENU_MODEL (section));
- g_menu_append (section, _("_New Game"), "app.new-game");
- g_menu_append (section, _("_Preferences"), "app.preferences");
- g_menu_append (section, _("_Scores"), "app.scores");
- section = g_menu_new ();
- g_menu_append_section (app_menu, NULL, G_MENU_MODEL (section));
- g_menu_append (section, _("_Help"), "app.help");
- g_menu_append (section, _("_About"), "app.about");
- g_menu_append (section, _("_Quit"), "app.quit");
+
scores_action = g_action_map_lookup_action (G_ACTION_MAP (application), "scores");
undo_action = g_action_map_lookup_action (G_ACTION_MAP (application), "undo");
update_undo_sensitivity ();
- gtk_application_set_app_menu (GTK_APPLICATION (application), G_MENU_MODEL (app_menu));
/*--- Headerbar ---*/
hbar = gtk_header_bar_new ();
diff --git a/src/tali.gresource.xml b/src/tali.gresource.xml
new file mode 100644
index 0000000..74f94a2
--- /dev/null
+++ b/src/tali.gresource.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <!-- <gresource prefix="/org/gnome/tali/ui">
+ <file preprocess="xml-stripblanks" alias="tali.ui">../data/tali.ui</file>
+ <file alias="tali.css">../data/tali.css</file>
+ </gresource> -->
+ <gresource prefix="/org/gnome/tali/gtk">
+ <file preprocess="xml-stripblanks" alias="menus.ui">../data/tali-menus.ui</file>
+ </gresource>
+</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]