[hitori] Gtk+ >= 3.15, GResource for loading the app-menu.
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hitori] Gtk+ >= 3.15, GResource for loading the app-menu.
- Date: Thu, 5 Mar 2015 10:30:52 +0000 (UTC)
commit 72315c89f5ab9108836639531c2229905e943add
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Feb 25 03:01:40 2015 +0100
Gtk+ >= 3.15, GResource for loading the app-menu.
https://bugzilla.gnome.org/show_bug.cgi?id=744981
Makefile.am | 16 ++++++++++-
configure.ac | 5 +++-
data/hitori-menus.ui | 66 ++++++++++++++++++++++++++++++++++++++++++++++
data/hitori.ui | 63 -------------------------------------------
po/POTFILES.in | 1 +
src/hitori.gresource.xml | 6 ++++
src/interface.c | 6 ----
7 files changed, 91 insertions(+), 72 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index ba7d45d..aff8d10 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,6 +13,9 @@ src_hitori_SOURCES = \
src/rules.c \
src/rules.h \
$(NULL)
+nodist_src_hitori_SOURCES = \
+ src/hitori-resources.c \
+ $(NULL)
src_hitori_CPPFLAGS = \
-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
@@ -70,11 +73,20 @@ EXTRA_DIST = \
$(NULL)
# CSS
-
cssdir = $(datadir)/hitori
css_DATA = data/hitori.css
+# GResources
+src/hitori-resources.c: $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir=$(top_srcdir)
$(top_srcdir)/src/hitori.gresource.xml)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(top_srcdir) --generate-source
$(top_srcdir)/src/hitori.gresource.xml
+
+CLEANFILES = src/hitori-resources.c
+EXTRA_DIST += src/hitori.gresource.xml
+
# UI file
+dist_noinst_DATA = \
+ data/hitori-menus.ui
+
uidir = $(datadir)/hitori
ui_DATA = data/hitori.ui
@@ -97,7 +109,7 @@ EXTRA_DIST += \
$(ui_DATA) \
$(desktop_in_files) \
$(NULL)
-CLEANFILES = $(desktop_DATA)
+CLEANFILES += $(desktop_DATA)
# AppData
@APPSTREAM_XML_RULES@
diff --git a/configure.ac b/configure.ac
index 852ce1c..483061a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,6 +19,9 @@ GNOME_MAINTAINER_MODE_DEFINES
AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[Enable debugging]),[debug=$enableval],[debug=no])
AM_CONDITIONAL([DEBUG],[test "$debug" = "yes"])
+# GResources
+AC_PATH_PROG([GLIB_COMPILE_RESOURCES],[glib-compile-resources])
+
# Internationalisation
GETTEXT_PACKAGE=hitori
AC_SUBST([GETTEXT_PACKAGE])
@@ -35,7 +38,7 @@ YELP_HELP_INIT
APPSTREAM_XML
# Dependencies
-PKG_CHECK_MODULES([GENERAL],[glib-2.0 gio-2.0 >= 2.32 gtk+-3.0 >= 3.13.2 gmodule-2.0 cairo >= 1.4])
+PKG_CHECK_MODULES([GENERAL],[glib-2.0 gio-2.0 >= 2.32 gtk+-3.0 >= 3.15.0 gmodule-2.0 cairo >= 1.4])
# Output!
AC_CONFIG_FILES([
diff --git a/data/hitori-menus.ui b/data/hitori-menus.ui
new file mode 100644
index 0000000..ec2c664
--- /dev/null
+++ b/data/hitori-menus.ui
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.12 -->
+ <menu id="app-menu">
+ <section>
+ <item>
+ <attribute name="action">app.new-game</attribute>
+ <attribute name="label" translatable="yes">_New Game</attribute>
+ <attribute name="accel"><Primary>n</attribute>
+ </item>
+ </section>
+ <section>
+ <submenu id="board_size_menu">
+ <attribute name="label" translatable="yes">Board _Size</attribute>
+ <section>
+ <item>
+ <attribute name="action">app.board-size</attribute>
+ <attribute name="label" translatable="yes">5×5</attribute>
+ <attribute name="target">5</attribute>
+ </item>
+ <item>
+ <attribute name="action">app.board-size</attribute>
+ <attribute name="label" translatable="yes">6×6</attribute>
+ <attribute name="target">6</attribute>
+ </item>
+ <item>
+ <attribute name="action">app.board-size</attribute>
+ <attribute name="label" translatable="yes">7×7</attribute>
+ <attribute name="target">7</attribute>
+ </item>
+ <item>
+ <attribute name="action">app.board-size</attribute>
+ <attribute name="label" translatable="yes">8×8</attribute>
+ <attribute name="target">8</attribute>
+ </item>
+ <item>
+ <attribute name="action">app.board-size</attribute>
+ <attribute name="label" translatable="yes">9×9</attribute>
+ <attribute name="target">9</attribute>
+ </item>
+ <item>
+ <attribute name="action">app.board-size</attribute>
+ <attribute name="label" translatable="yes">10×10</attribute>
+ <attribute name="target">10</attribute>
+ </item>
+ </section>
+ </submenu>
+ </section>
+ <section>
+ <item>
+ <attribute name="action">app.help</attribute>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="accel">F1</attribute>
+ </item>
+ <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"><Primary>q</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/data/hitori.ui b/data/hitori.ui
index 80991f8..c2d1594 100644
--- a/data/hitori.ui
+++ b/data/hitori.ui
@@ -2,69 +2,6 @@
<!--*- mode: xml -*-->
<interface>
<!-- interface-requires gtk+ 3.12 -->
- <menu id="app_menu">
- <section>
- <item>
- <attribute name="action">app.new-game</attribute>
- <attribute name="label" translatable="yes">_New Game</attribute>
- <attribute name="accel"><Primary>n</attribute>
- </item>
- </section>
- <section>
- <submenu id="board_size_menu">
- <attribute name="label" translatable="yes">Board _Size</attribute>
- <section>
- <item>
- <attribute name="action">app.board-size</attribute>
- <attribute name="label" translatable="yes">5×5</attribute>
- <attribute name="target">5</attribute>
- </item>
- <item>
- <attribute name="action">app.board-size</attribute>
- <attribute name="label" translatable="yes">6×6</attribute>
- <attribute name="target">6</attribute>
- </item>
- <item>
- <attribute name="action">app.board-size</attribute>
- <attribute name="label" translatable="yes">7×7</attribute>
- <attribute name="target">7</attribute>
- </item>
- <item>
- <attribute name="action">app.board-size</attribute>
- <attribute name="label" translatable="yes">8×8</attribute>
- <attribute name="target">8</attribute>
- </item>
- <item>
- <attribute name="action">app.board-size</attribute>
- <attribute name="label" translatable="yes">9×9</attribute>
- <attribute name="target">9</attribute>
- </item>
- <item>
- <attribute name="action">app.board-size</attribute>
- <attribute name="label" translatable="yes">10×10</attribute>
- <attribute name="target">10</attribute>
- </item>
- </section>
- </submenu>
- </section>
- <section>
- <item>
- <attribute name="action">app.help</attribute>
- <attribute name="label" translatable="yes">_Help</attribute>
- <attribute name="accel">F1</attribute>
- </item>
- <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"><Primary>q</attribute>
- </item>
- </section>
- </menu>
-
<object class="GtkApplicationWindow" id="hitori_main_window">
<property name="resizable">False</property>
<signal name="destroy" handler="hitori_destroy_cb"/>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 274bc5c..cf7353c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,6 +2,7 @@
[encoding: UTF-8]
data/hitori.desktop.in
data/hitori.appdata.xml.in
+[type: gettext/glade]data/hitori-menus.ui
[type: gettext/glade]data/hitori.ui
data/org.gnome.hitori.gschema.xml
src/interface.c
diff --git a/src/hitori.gresource.xml b/src/hitori.gresource.xml
new file mode 100644
index 0000000..c22aacd
--- /dev/null
+++ b/src/hitori.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/Hitori/gtk">
+ <file preprocess="xml-stripblanks" alias="menus.ui">./data/hitori-menus.ui</file>
+ </gresource>
+</gresources>
diff --git a/src/interface.c b/src/interface.c
index b61b245..582176b 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -72,7 +72,6 @@ hitori_create_interface (Hitori *hitori)
GtkStyleContext *style_context;
GtkCssProvider *css_provider;
const PangoFontDescription *font;
- GMenuModel *app_menu; /* owned */
GAction *action;
builder = gtk_builder_new ();
@@ -104,11 +103,6 @@ hitori_create_interface (Hitori *hitori)
hitori->drawing_area = GTK_WIDGET (gtk_builder_get_object (builder, "hitori_drawing_area"));
hitori->timer_label = GTK_LABEL (gtk_builder_get_object (builder, "hitori_timer"));
- /* Set up the app menu */
- app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "app_menu"));
- gtk_application_set_app_menu (GTK_APPLICATION (hitori), app_menu);
- g_object_unref (app_menu);
-
g_object_unref (builder);
/* Set up actions */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]