[baobab/wip/vala] Use GResource



commit d83aa54dacdd247179eb882c460a4a70bd040480
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sat Feb 11 09:44:40 2012 +0100

    Use GResource

 configure.ac                               |    4 ++++
 data/Makefile.am                           |    7 -------
 src/Makefile.am                            |   17 +++++++++++++++--
 src/baobab-application.vala                |    2 +-
 {data => src}/baobab-main-window.ui        |    0
 {data => src}/baobab-menu.ui               |    0
 {data => src}/baobab-preferences-dialog.ui |    0
 src/baobab-window.vala                     |    2 +-
 src/baobab.gresource.xml                   |    8 ++++++++
 9 files changed, 29 insertions(+), 11 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8241399..a3345ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,6 +37,10 @@ AC_CACHE_SAVE
 
 GLIB_GSETTINGS
 
+# Resources
+GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
+AC_SUBST(GLIB_COMPILE_RESOURCES)
+
 GNOME_DOC_INIT
 
 PKG_CHECK_MODULES(gtk, gtk+-3.0 >= 3.3.6)
diff --git a/data/Makefile.am b/data/Makefile.am
index 0e4c1d1..6144343 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,9 +1,3 @@
-uidir = $(datadir)/baobab
-ui_DATA = \
-	baobab-main-window.ui \
-	baobab-menu.ui \
-	baobab-preferences-dialog.ui
-
 baobabappdir	   = $(datadir)/applications
 baobabapp_in_files = baobab.desktop.in
 baobabapp_DATA     = $(baobabapp_in_files:.desktop.in=.desktop)
@@ -24,7 +18,6 @@ gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml)
 man_MANS = baobab.1
 
 EXTRA_DIST = 				\
-	$(ui_DATA)			\
 	baobab.desktop.in.in		\
 	$(gsettingsschema_in_files)	\
 	$(man_MANS)
diff --git a/src/Makefile.am b/src/Makefile.am
index 9daab6a..c477700 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,6 +13,8 @@ INCLUDES = \
 
 bin_PROGRAMS = baobab
 
+BUILT_SOURCES = baobab_resources.c
+
 baobab_VALAFLAGS = --pkg gtk+-3.0
 baobab_SOURCES = \
 	fixes.vapi			\
@@ -28,7 +30,11 @@ baobab_SOURCES = \
 	baobab-application.vala		\
 	baobab-window.vala		\
 	baobab-connect-server.vala	\
-	main.vala
+	main.vala			\
+	$(BUILT_SOURCES)
+
+baobab_resources.c: baobab.gresource.xml baobab-main-window.ui baobab-preferences-dialog.ui
+	$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source baobab.gresource.xml
 
 AM_CFLAGS = \
 	$(gtk_CFLAGS)			\
@@ -51,6 +57,13 @@ MAINTAINERCLEANFILES = \
 	baobab-cellrenderers.c		\
 	baobab-window.c			\
 	baobab_vala.stamp		\
-	main.c
+	main.c				\
+	$(BUILT_SOURCES)
+
+EXTRA_DIST = \
+	baobab.gresource.xml \
+	baobab-main-window.ui \
+	baobab-preferences-dialog.ui \
+	baobab-menu.ui
 
 -include $(top_srcdir)/git.mk
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index 81cb47e..3d1451f 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -58,7 +58,7 @@ namespace Baobab {
 			var gtk_settings = Gtk.Settings.get_default ();
 			var builder = new Gtk.Builder ();
 			try {
-				builder.add_from_file (Config.PKGDATADIR + "/baobab-menu.ui");
+				builder.add_from_resource ("/org/gnome/baobab/ui/baobab-menu.ui");
 			} catch (Error e) {
 				error ("loading menu builder file: %s", e.message);
 			}
diff --git a/data/baobab-main-window.ui b/src/baobab-main-window.ui
similarity index 100%
rename from data/baobab-main-window.ui
rename to src/baobab-main-window.ui
diff --git a/data/baobab-menu.ui b/src/baobab-menu.ui
similarity index 100%
rename from data/baobab-menu.ui
rename to src/baobab-menu.ui
diff --git a/data/baobab-preferences-dialog.ui b/src/baobab-preferences-dialog.ui
similarity index 100%
rename from data/baobab-preferences-dialog.ui
rename to src/baobab-preferences-dialog.ui
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index cee8a66..411c65b 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -74,7 +74,7 @@ namespace Baobab {
 			// Build ourselves.
 			var builder = new Gtk.Builder ();
 			try {
-				builder.add_from_file (Config.PKGDATADIR + "/baobab-main-window.ui");
+				builder.add_from_resource ("/org/gnome/baobab/ui/baobab-main-window.ui");
 			} catch (Error e) {
 				error ("loading main builder file: %s", e.message);
 			}
diff --git a/src/baobab.gresource.xml b/src/baobab.gresource.xml
new file mode 100644
index 0000000..38573cf
--- /dev/null
+++ b/src/baobab.gresource.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/baobab/ui">
+    <file preprocess="xml-stripblanks">baobab-main-window.ui</file>
+    <file preprocess="xml-stripblanks">baobab-preferences-dialog.ui</file>
+    <file preprocess="xml-stripblanks">baobab-menu.ui</file>
+  </gresource>
+</gresources>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]