[eog-plugins] postasa: Embed UI data files using GResource



commit 0ba3420843810b189c75219311c996f7a73bcdb5
Author: Felix Riemann <friemann gnome org>
Date:   Fri Dec 28 17:05:55 2012 +0100

    postasa: Embed UI data files using GResource

 plugins/postasa/Makefile.am                      |   21 ++++++++++++++-------
 plugins/postasa/eog-postasa-plugin.c             |   11 +++++++----
 plugins/postasa/eog-postasa-plugin.gresource.xml |    7 +++++++
 3 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/plugins/postasa/Makefile.am b/plugins/postasa/Makefile.am
index 96335fe..bf4b720 100644
--- a/plugins/postasa/Makefile.am
+++ b/plugins/postasa/Makefile.am
@@ -13,7 +13,11 @@ INCLUDES = \
 
 plugin_LTLIBRARIES = libpostasa.la
 
+BUILT_SOURCES = \
+	eog-postasa-plugin-resources.c
+
 libpostasa_la_SOURCES = \
+	${BUILT_SOURCES}				\
 	eog-postasa-plugin.h				\
 	eog-postasa-plugin.c
 
@@ -24,22 +28,25 @@ libpostasa_la_LDFLAGS = \
 libpostasa_la_LIBADD = $(EOG_LIBS)			\
 	$(POSTASA_LIBS)
 
+eog-postasa-plugin-resources.c: eog-postasa-plugin.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/eog-postasa-plugin.gresource.xml)
+	$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --internal --target=$@ --sourcedir=$(srcdir) --generate-source $(srcdir)/eog-postasa-plugin.gresource.xml
+
+UI_FILES = postasa-config.xml postasa-uploads.xml
 
 # Plugin Info
 
 plugin_in_files = postasa.plugin.desktop.in
 
-UI_FILES = postasa-config.xml postasa-uploads.xml
-ui_DATA = $(UI_FILES)
-uidir = $(EOG_PLUGINS_DATA_DIR)/postasa
-
 %.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(AM_V_GEN)$(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
 
 plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
 
-EXTRA_DIST = $(plugin_in_files) $(UI_FILES)
+EXTRA_DIST = \
+	$(plugin_in_files)	\
+	$(UI_FILES)		\
+	eog-postasa-plugin.gresource.xml
 
-CLEANFILES = $(plugin_DATA)
-DISTCLEANFILES = $(plugin_DATA)
+CLEANFILES = $(plugin_DATA) $(BUILT_SOURCES)
+DISTCLEANFILES = $(plugin_DATA) $(BUILT_SOURCES)
 
 -include $(top_srcdir)/git.mk
diff --git a/plugins/postasa/eog-postasa-plugin.c b/plugins/postasa/eog-postasa-plugin.c
index e2d8de6..e378bfa 100644
--- a/plugins/postasa/eog-postasa-plugin.c
+++ b/plugins/postasa/eog-postasa-plugin.c
@@ -38,8 +38,9 @@
 
 #include <gdata/gdata.h>
 
-#define GTKBUILDER_CONFIG_FILE EOG_POSTASA_DATA_DIR"/postasa-config.xml"
-#define GTKBUILDER_UPLOAD_FILE EOG_POSTASA_DATA_DIR"/postasa-uploads.xml"
+#define EOG_POSTASA_RESOURCE_PREFIX "/org/gnome/eog/plugins/postasa"
+#define GTKBUILDER_CONFIG_FILE EOG_POSTASA_RESOURCE_PREFIX"/postasa-config.xml"
+#define GTKBUILDER_UPLOAD_FILE EOG_POSTASA_RESOURCE_PREFIX"/postasa-uploads.xml"
 
 enum {
 	PROP_O,
@@ -197,7 +198,8 @@ uploads_get_dialog (EogPostasaPlugin *plugin)
 	if (plugin->priv->uploads_window == NULL) {
 		builder = gtk_builder_new ();
 		gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
-		gtk_builder_add_from_file (builder, GTKBUILDER_UPLOAD_FILE, &error);
+		gtk_builder_add_from_resource (builder, GTKBUILDER_UPLOAD_FILE,
+		                               &error);
 		if (error != NULL) {
 			g_warning ("Couldn't load Postasa uploads UI file:%d:%s", error->code, error->message);
 			g_error_free (error);
@@ -748,7 +750,8 @@ login_get_dialog (EogPostasaPlugin *plugin)
 	if (plugin->priv->login_dialog == NULL) {
 		builder = gtk_builder_new ();
 		gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
-		gtk_builder_add_from_file (builder, GTKBUILDER_CONFIG_FILE, &error);
+		gtk_builder_add_from_resource (builder, GTKBUILDER_CONFIG_FILE,
+		                               &error);
 		if (error != NULL) {
 			g_warning ("Couldn't load Postasa configuration UI file:%d:%s", error->code, error->message);
 			g_error_free (error);
diff --git a/plugins/postasa/eog-postasa-plugin.gresource.xml b/plugins/postasa/eog-postasa-plugin.gresource.xml
new file mode 100644
index 0000000..50442fc
--- /dev/null
+++ b/plugins/postasa/eog-postasa-plugin.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/eog/plugins/postasa">
+    <file compressed="true" preprocess="xml-stripblanks">postasa-config.xml</file>
+    <file compressed="true" preprocess="xml-stripblanks">postasa-uploads.xml</file>
+  </gresource>
+</gresources>



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