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



commit 0653773ed8a63d5269b9b7f82681bce1b36704f9
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Jan 4 15:42:39 2013 +0100

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

 panels/online-accounts/Makefile.am                 |   19 +++++++++++++------
 panels/online-accounts/cc-online-accounts-panel.c  |    7 ++++---
 .../online-accounts/online-accounts.gresource.xml  |    6 ++++++
 3 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/panels/online-accounts/Makefile.am b/panels/online-accounts/Makefile.am
index fdbbb25..4ad9eb9 100644
--- a/panels/online-accounts/Makefile.am
+++ b/panels/online-accounts/Makefile.am
@@ -4,15 +4,18 @@ SUBDIRS = icons
 
 INCLUDES = 						\
 	$(PANEL_CFLAGS)					\
-	$(ONLINE_ACCOUNTS_PANEL_CFLAGS)				\
-	-DGNOMECC_UI_DIR="\"$(uidir)\""			\
+	$(ONLINE_ACCOUNTS_PANEL_CFLAGS)			\
 	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
-	-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""		\
 	$(NULL)
 
 noinst_LTLIBRARIES = libonline-accounts.la
 
+BUILT_SOURCES =				\
+	cc-online-accounts-resources.c	\
+	cc-online-accounts-resources.h
+
 libonline_accounts_la_SOURCES =		\
+	$(BUILT_SOURCES)		\
 	cc-online-accounts-add-account-dialog.c	\
 	cc-online-accounts-add-account-dialog.h	\
 	cc-online-accounts-model.c	\
@@ -23,8 +26,11 @@ libonline_accounts_la_SOURCES =		\
 libonline_accounts_la_LIBADD = $(PANEL_LIBS) $(ONLINE_ACCOUNTS_PANEL_LIBS)
 libonline_accounts_la_LDFLAGS = $(PANEL_LDFLAGS)
 
-uidir = $(pkgdatadir)/ui
-dist_ui_DATA = online-accounts.ui
+resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/online-accounts.gresource.xml)
+cc-online-accounts-resources.c: online-accounts.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_online_accounts $<
+cc-online-accounts-resources.h: online-accounts.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_online_accounts $<
 
 @INTLTOOL_DESKTOP_RULE@
 
@@ -32,6 +38,7 @@ desktopdir = $(datadir)/applications
 desktop_in_files = gnome-online-accounts-panel.desktop.in
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 
-CLEANFILES = $(desktop_in_files) $(desktop_DATA)
+CLEANFILES = $(desktop_in_files) $(desktop_DATA) $(BUILT_SOURCES)
+EXTRA_DIST = $(resource_files) online-accounts.gresource.xml
 
 -include $(top_srcdir)/git.mk
diff --git a/panels/online-accounts/cc-online-accounts-panel.c b/panels/online-accounts/cc-online-accounts-panel.c
index 9f6ad1e..5b0028d 100644
--- a/panels/online-accounts/cc-online-accounts-panel.c
+++ b/panels/online-accounts/cc-online-accounts-panel.c
@@ -143,13 +143,14 @@ cc_goa_panel_init (CcGoaPanel *panel)
   GtkTreeIter iter;
   GNetworkMonitor *monitor;
 
+  g_resources_register (cc_online_accounts_get_resource ());
   monitor = g_network_monitor_get_default();
 
   panel->builder = gtk_builder_new ();
   error = NULL;
-  if (gtk_builder_add_from_file (panel->builder,
-                                 GNOMECC_UI_DIR "/online-accounts.ui",
-                                 &error) == 0)
+  if (gtk_builder_add_from_resource (panel->builder,
+                                     "/org/gnome/control-center/online-accounts/online-accounts.ui",
+                                     &error) == 0)
     {
       goa_warning ("Error loading UI file: %s (%s, %d)",
                    error->message, g_quark_to_string (error->domain), error->code);
diff --git a/panels/online-accounts/online-accounts.gresource.xml b/panels/online-accounts/online-accounts.gresource.xml
new file mode 100644
index 0000000..b428394
--- /dev/null
+++ b/panels/online-accounts/online-accounts.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/control-center/online-accounts">
+    <file preprocess="xml-stripblanks">online-accounts.ui</file>
+  </gresource>
+</gresources>



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