[gnome-control-center] common: use a GResource for GtkBuilder UI definition



commit ce1e2eddd86761ff40c2ac6b3719104605c1046d
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Jan 4 17:05:48 2013 +0100

    common: use a GResource for GtkBuilder UI definition
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691132

 panels/common/Makefile.am           |   22 +++++++++++++---------
 panels/common/cc-language-chooser.c |   11 ++++++-----
 panels/common/common.gresource.xml  |    6 ++++++
 3 files changed, 25 insertions(+), 14 deletions(-)
---
diff --git a/panels/common/Makefile.am b/panels/common/Makefile.am
index b854428..5ee6b6d 100644
--- a/panels/common/Makefile.am
+++ b/panels/common/Makefile.am
@@ -7,13 +7,15 @@ noinst_PROGRAMS = list-languages
 AM_CPPFLAGS =						\
 	$(PANEL_CFLAGS)					\
 	$(LIBLANGUAGE_CFLAGS)				\
-	-DDATADIR=\""$(datadir)"\"			\
-	-DUIDIR=\""$(pkgdatadir)/ui"\"			\
 	-DLIBLOCALEDIR=\""$(prefix)/lib/locale"\"       \
-	-DGNOMELOCALEDIR=\""$(datadir)/locale"\"        \
-	-DUM_PIXMAP_DIR=\""$(pkgdatadir)/pixmaps"\"
+	-DGNOMELOCALEDIR=\""$(datadir)/locale"\"
+
+BUILT_SOURCES =			\
+	cc-common-resources.c	\
+	cc-common-resources.h
 
 liblanguage_la_SOURCES =		\
+	$(BUILT_SOURCES)		\
 	gdm-languages.h 		\
 	gdm-languages.c 		\
 	locarchive.h			\
@@ -29,14 +31,16 @@ list_languages_SOURCES = list-languages.c
 list_languages_LDADD = liblanguage.la
 list_languages_CFLAGS = $(LIBLANGUAGE_CFLAGS)
 
-uidir = $(pkgdatadir)/ui
-
-dist_ui_DATA = \
-	language-chooser.ui
+resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/common.gresource.xml)
+cc-common-resources.c: common.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_common $<
+cc-common-resources.h: common.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_common $<
 
 rulesdir = $(datadir)/polkit-1/rules.d/
 rules_DATA = gnome-control-center.rules
 
-EXTRA_DIST = $(rules_DATA)
+EXTRA_DIST = $(rules_DATA) $(resource_files)
+CLEANFILES = $(BUILT_SOURCES)
 
 -include $(top_srcdir)/git.mk
diff --git a/panels/common/cc-language-chooser.c b/panels/common/cc-language-chooser.c
index 763c4cb..76adbe8 100644
--- a/panels/common/cc-language-chooser.c
+++ b/panels/common/cc-language-chooser.c
@@ -33,6 +33,7 @@
 
 #include "cc-language-chooser.h"
 #include "cc-common-language.h"
+#include "cc-common-resources.h"
 #include "gdm-languages.h"
 
 gchar *
@@ -263,7 +264,6 @@ GtkWidget *
 cc_language_chooser_new (GtkWidget *parent, gboolean regions)
 {
         GtkBuilder *builder;
-        const char *filename;
         GError *error = NULL;
         GtkWidget *chooser;
         GtkWidget *list;
@@ -275,11 +275,12 @@ cc_language_chooser_new (GtkWidget *parent, gboolean regions)
 	GtkTreeModel *model;
 	GtkTreeModel *filter_model;
 
+        g_resources_register (cc_common_get_resource ());
+
         builder = gtk_builder_new ();
-        filename = UIDIR "/language-chooser.ui";
-        if (!g_file_test (filename, G_FILE_TEST_EXISTS))
-                filename = "data/language-chooser.ui";
-        if (!gtk_builder_add_from_file (builder, filename, &error)) {
+        if (!gtk_builder_add_from_resource (builder,
+                                            "/org/gnome/control-center/common/language-chooser.ui",
+                                            &error)) {
                 g_warning ("failed to load language chooser: %s", error->message);
                 g_error_free (error);
                 return NULL;
diff --git a/panels/common/common.gresource.xml b/panels/common/common.gresource.xml
new file mode 100644
index 0000000..da6c818
--- /dev/null
+++ b/panels/common/common.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/control-center/common">
+    <file preprocess="xml-stripblanks">language-chooser.ui</file>
+  </gresource>
+</gresources>



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