[gnome-contacts] Read app menu from resources
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Read app menu from resources
- Date: Tue, 24 Jan 2012 15:28:32 +0000 (UTC)
commit b95c9c928345fba18c1d25a2d576f0c3951a5bf2
Author: Alexander Larsson <alexl redhat com>
Date: Tue Jan 24 16:05:14 2012 +0100
Read app menu from resources
configure.ac | 9 ++++++++-
src/Makefile.am | 5 +++++
src/app-menu.ui | 11 +++++++++++
src/contacts-app.vala | 12 +-----------
src/contacts.gresource.xml | 6 ++++++
vapi/custom.vapi | 5 ++++-
6 files changed, 35 insertions(+), 13 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9ad86eb..315386b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,7 +32,7 @@ AC_SUBST(GETTEXT_PACKAGE)
pkg_modules="gtk+-3.0
- glib-2.0 >= 2.29.12
+ glib-2.0 >= 2.31.10
gnome-desktop-3.0
folks >= 0.6.1.1
folks-telepathy
@@ -48,4 +48,11 @@ PKG_CHECK_MODULES(CONTACTS, [$pkg_modules])
CONTACTS_PACKAGES="--pkg gtk+-3.0 --pkg gio-2.0 --pkg folks --pkg folks-telepathy --pkg folks-eds --pkg libnotify"
AC_SUBST(CONTACTS_PACKAGES)
+#############
+# Resources #
+#############
+
+GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
+AC_SUBST(GLIB_COMPILE_RESOURCES)
+
AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index 503a95a..18b1e9f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,7 +39,12 @@ vala_sources = \
main.vala \
$(NULL)
+contact-resources.c: contacts.gresource.xml app-menu.ui
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/contacts.gresource.xml \
+ --target=$@ --sourcedir=$(srcdir) --c-name contacts --generate-source
+
gnome_contacts_SOURCES = \
+ contact-resources.c \
gtk-notification.c \
contacts-esd-setup.c \
$(vala_sources) \
diff --git a/src/app-menu.ui b/src/app-menu.ui
new file mode 100644
index 0000000..a57674d
--- /dev/null
+++ b/src/app-menu.ui
@@ -0,0 +1,11 @@
+<interface>
+ <menu id='app-menu'>
+ <section>
+ <item label='_Change Address Book...' action='app.change_book'/>
+ </section>
+ <section>
+ <item label='_About Contacts' action='app.about'/>
+ <item label='_Quit' action='app.quit' accel='<Primary>q'/>
+ </section>
+ </menu>
+</interface>
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 1b3c058..1467902 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -233,17 +233,7 @@ public class Contacts.App : Gtk.Application {
var builder = new Builder ();
builder.set_translation_domain (Config.GETTEXT_PACKAGE);
try {
- builder.add_from_string ("<interface>" +
- " <menu id='app-menu'>" +
- " <section>" +
- " <item label='_Change Address Book...' action='app.change_book'/>" +
- " </section>" +
- " <section>" +
- " <item label='_About Contacts' action='app.about'/>" +
- " <item label='_Quit' action='app.quit' accel='<Primary>q'/>" +
- " </section>" +
- " </menu>" +
- "</interface>", -1);
+ Gtk.my_builder_add_from_resource (builder, "/org/gnome/contacts/app-menu.ui");
set_app_menu ((MenuModel)builder.get_object ("app-menu"));
} catch {
warning ("Failed to parsing ui file");
diff --git a/src/contacts.gresource.xml b/src/contacts.gresource.xml
new file mode 100644
index 0000000..8cebfc2
--- /dev/null
+++ b/src/contacts.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/contacts">
+ <file>app-menu.ui</file>
+ </gresource>
+</gresources>
diff --git a/vapi/custom.vapi b/vapi/custom.vapi
index b1f4c66..eace183 100644
--- a/vapi/custom.vapi
+++ b/vapi/custom.vapi
@@ -47,4 +47,7 @@ namespace Gtk {
public void set_timeout (uint timeout_msec);
public void dismiss ();
public virtual signal void dismissed ();
- }}
+ }
+ [CCode (cname = "gtk_builder_add_from_resource")]
+ public static unowned uint my_builder_add_from_resource (Gtk.Builder builder, string path) throws GLib.Error;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]