[gnome-games] gnotravex: Support the latest GTK app menu changes
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] gnotravex: Support the latest GTK app menu changes
- Date: Sun, 5 Feb 2012 05:57:43 +0000 (UTC)
commit f12d11a988e699ffa8c9befc4d8c4c25bafbb850
Author: Jeremy Bicha <jbicha ubuntu com>
Date: Thu Feb 2 22:31:21 2012 -0500
gnotravex: Support the latest GTK app menu changes
The app menu API changed again (requires GTK 3.3.11)
https://bugzilla.gnome.org/show_bug.cgi?id=669289
configure.ac | 11 +++-
gnotravex/data/Makefile.am | 4 +
gnotravex/data/gnotravex.ui | 99 +++++++++++++++++++++++++++++++++
gnotravex/src/Makefile.am | 5 +-
gnotravex/src/config.vapi | 1 +
gnotravex/src/gnotravex.gresource.xml | 6 ++
gnotravex/src/gnotravex.vala | 42 +-------------
po/POTFILES.in | 1 +
8 files changed, 126 insertions(+), 43 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4077eba..fd160f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,6 +114,7 @@ need_opengl=no
need_glx=no
need_python=no
need_clutter=no
+need_gmenu=no
for game in $gamelist; do
case $game in
@@ -144,6 +145,10 @@ for game in $gamelist; do
quadrapassel|lightsoff|swell-foop|gnibbles) need_clutter=yes ;;
*) ;;
esac
+ case $game in
+ gnotravex) need_gmenu=yes ;;
+ *) ;;
+ esac
done
# Set a conditional for each game to build
@@ -243,12 +248,16 @@ AM_CONDITIONAL([PLATFORM_WIN32],[test "$platform_win32" = "yes"])
PYGOBJECT_REQUIRED=2.28.3
-GTK_REQUIRED=2.91.7
+GTK_REQUIRED=3.0.0
RSVG_REQUIRED=2.32.0
LIBCANBERRA_GTK_REQUIRED=0.26
GIO_REQUIRED=2.25.7
GSTREAMER_REQUIRED=0.10.11
+if test "$need_gmenu" = "yes"; then
+ GTK_REQUIRED=3.3.11
+fi
+
# Check for common modules
PKG_CHECK_MODULES([GMODULE],[gmodule-2.0])
diff --git a/gnotravex/data/Makefile.am b/gnotravex/data/Makefile.am
index d585e28..123770b 100644
--- a/gnotravex/data/Makefile.am
+++ b/gnotravex/data/Makefile.am
@@ -1,5 +1,8 @@
SUBDIRS = icons
+uidir = $(datadir)/gnotravex
+ui_DATA = gnotravex.ui
+
desktop_in_files = gnotravex.desktop.in.in
desktopdir = $(datadir)/applications
desktop_DATA = $(desktop_in_files:.desktop.in.in=.desktop)
@@ -13,6 +16,7 @@ gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
man_MANS = gnotravex.6
EXTRA_DIST = \
+ $(ui_DATA) \
$(gsettings_in_file) \
$(man_MANS)
diff --git a/gnotravex/data/gnotravex.ui b/gnotravex/data/gnotravex.ui
new file mode 100644
index 0000000..0503b56
--- /dev/null
+++ b/gnotravex/data/gnotravex.ui
@@ -0,0 +1,99 @@
+<interface>
+ <menu id="gnotravex-menu">
+ <section>
+ <item>
+ <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">_Pause</attribute>
+ <attribute name="action">app.pause</attribute>
+ <attribute name="accel">p</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Solve</attribute>
+ <attribute name="action">app.solve</attribute>
+ </item>
+ <submenu>
+ <attribute name="label" translatable="yes">_Move</attribute>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Up</attribute>
+ <attribute name="action">app.move-up</attribute>
+ <attribute name="accel"><Primary>Up</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Left</attribute>
+ <attribute name="action">app.move-left</attribute>
+ <attribute name="accel"><Primary>Left</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Right</attribute>
+ <attribute name="action">app.move-right</attribute>
+ <attribute name="accel"><Primary>Right</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Down</attribute>
+ <attribute name="action">app.move-down</attribute>
+ <attribute name="accel"><Primary>Down</attribute>
+ </item>
+ </section>
+ </submenu>
+ <item>
+ <attribute name="label" translatable="yes">_Scores</attribute>
+ <attribute name="action">app.scores</attribute>
+ </item>
+ </section>
+ <section>
+ <submenu>
+ <attribute name="label" translatable="yes">_Size</attribute>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_2x2</attribute>
+ <attribute name="action">app.size</attribute>
+ <attribute name="target">2</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_3x3</attribute>
+ <attribute name="action">app.size</attribute>
+ <attribute name="target">3</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_4x4</attribute>
+ <attribute name="action">app.size</attribute>
+ <attribute name="target">4</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_5x5</attribute>
+ <attribute name="action">app.size</attribute>
+ <attribute name="target">5</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_6x6</attribute>
+ <attribute name="action">app.size</attribute>
+ <attribute name="target">6</attribute>
+ </item>
+ </section>
+ </submenu>
+ </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>
+ </section>
+ <section>
+ <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/gnotravex/src/Makefile.am b/gnotravex/src/Makefile.am
index 88150b5..5424628 100644
--- a/gnotravex/src/Makefile.am
+++ b/gnotravex/src/Makefile.am
@@ -17,9 +17,10 @@ gnotravex_CFLAGS = \
-I$(top_srcdir)/libgames-support \
-DVERSION=\"$(VERSION)\" \
-DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
+ -DDATA_DIRECTORY=\"$(datadir)/gnotravex\" \
-DLOCALEDIR=\"$(datadir)/locale\" \
- $(GTK_CFLAGS) \
- $(AM_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(AM_CFLAGS) \
-Wno-unused
gnotravex_LDADD = \
diff --git a/gnotravex/src/config.vapi b/gnotravex/src/config.vapi
index 2e68d61..4b8963c 100644
--- a/gnotravex/src/config.vapi
+++ b/gnotravex/src/config.vapi
@@ -1,3 +1,4 @@
public const string VERSION;
public const string GETTEXT_PACKAGE;
public const string LOCALEDIR;
+public const string DATA_DIRECTORY;
diff --git a/gnotravex/src/gnotravex.gresource.xml b/gnotravex/src/gnotravex.gresource.xml
new file mode 100644
index 0000000..97d0778
--- /dev/null
+++ b/gnotravex/src/gnotravex.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/gnotravex">
+ <file>gnotravex-menu.ui</file>
+ </gresource>
+</gresources>
diff --git a/gnotravex/src/gnotravex.vala b/gnotravex/src/gnotravex.vala
index 20e2780..c235419 100644
--- a/gnotravex/src/gnotravex.vala
+++ b/gnotravex/src/gnotravex.vala
@@ -42,8 +42,8 @@ public class Gnotravex : Gtk.Application
try
{
var builder = new Gtk.Builder ();
- builder.add_from_string (menu_description, -1);
- set_app_menu ((GLib.MenuModel) builder.get_object ("app-menu"));
+ builder.add_from_file (Path.build_filename (DATA_DIRECTORY, "gnotravex.ui"));
+ set_app_menu ((MenuModel)builder.get_object ("gnotravex-menu"));
}
catch (Error e)
{
@@ -290,44 +290,6 @@ public class Gnotravex : Gtk.Application
{ "about", about_cb }
};
- private const string menu_description =
- "<interface>" +
- "<menu id='app-menu'>" +
- "<section>" +
- "<item label='_New Game' action='app.new-game' accel='<Primary>n'/>" +
- "<item label='_Pause' action='app.pause' accel='p'/>" +
- "<item label='_Solve' action='app.solve'/>" +
- "<submenu label='_Move'>" +
- "<section>" +
- "<item label='_Up' action='app.move-up' accel='<Primary>Up'/>" +
- "<item label='_Left' action='app.move-left' accel='<Primary>Left'/>" +
- "<item label='_Right' action='app.move-right' accel='<Primary>Right'/>" +
- "<item label='_Down' action='app.move-down' accel='<Primary>Down'/>" +
- "</section>" +
- "</submenu>" +
- "<item label='_Scores' action='app.scores'/>" +
- "</section>" +
- "<section>" +
- "<submenu label='_Size'>" +
- "<section>" +
- "<item label='_2Ã2' action='app.size' target='2'/>" +
- "<item label='_3Ã3' action='app.size' target='3'/>" +
- "<item label='_4Ã4' action='app.size' target='4'/>" +
- "<item label='_5Ã5' action='app.size' target='5'/>" +
- "<item label='_6Ã6' action='app.size' target='6'/>" +
- "</section>" +
- "</submenu>" +
- "</section>" +
- "<section>" +
- "<item label='_Help' action='app.help'/>" +
- "<item label='_About' action='app.about'/>" +
- "</section>" +
- "<section>" +
- "<item label='_Quit' action='app.quit'/>" +
- "</section>" +
- "</menu>" +
- "</interface>";
-
public static int main (string[] args)
{
Intl.setlocale (LocaleCategory.ALL, "");
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 67326ca..cb981cc 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -75,6 +75,7 @@ gnomine/data/org.gnome.gnomine.gschema.xml.in
gnomine/src/gnomine.vala
gnomine/src/minefield.vala
gnomine/src/minefield-view.vala
+[type: gettext/glade]gnotravex/data/gnotravex.ui
gnotravex/data/gnotravex.desktop.in.in
gnotravex/data/org.gnome.gnotravex.gschema.xml.in
gnotravex/src/gnotravex.vala
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]