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



commit e30613e355582c17824c80515e1b8b6facbdd5d5
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Jan 4 13:17:31 2013 +0100

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

 panels/background/Makefile.am              |   20 +++++++++++---------
 panels/background/background.gresource.xml |    6 ++++++
 panels/background/cc-background-panel.c    |   13 +++++++------
 3 files changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/panels/background/Makefile.am b/panels/background/Makefile.am
index d32b75a..15d42f9 100644
--- a/panels/background/Makefile.am
+++ b/panels/background/Makefile.am
@@ -1,10 +1,6 @@
 # This is used in PANEL_CFLAGS
 cappletname = background
 
-uidir = $(pkgdatadir)/ui/background
-dist_ui_DATA = \
-	background.ui
-
 slideshowicondir = $(datadir)/icons/hicolor/scalable/categories/
 dist_slideshowicon_DATA = slideshow-symbolic.svg
 
@@ -15,17 +11,16 @@ INCLUDES =						\
 	$(PANEL_CFLAGS)					\
 	$(BACKGROUND_PANEL_CFLAGS)			\
 	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
-	-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""		\
-	-DUIDIR="\"$(uidir)\""				\
 	-DDATADIR="\"$(datadir)\""			\
 	-DGNOME_DESKTOP_USE_UNSTABLE_API		\
-	-DPIXMAP_DIR=\""$(datadir)/gnome-control-center/pixmaps"\"	\
 	$(NULL)
 
 noinst_LTLIBRARIES = libbackground.la
 
-BUILT_SOURCES =            \
-	gdesktop-enums-types.c \
+BUILT_SOURCES = 			\
+	cc-background-resources.c 	\
+	cc-background-resources.h 	\
+	gdesktop-enums-types.c		\
 	gdesktop-enums-types.h
 
 libbackground_la_SOURCES =		\
@@ -56,6 +51,12 @@ INCLUDES += $(SOCIALWEB_CFLAGS)
 libbackground_la_LIBADD += $(SOCIALWEB_LIBS)
 endif
 
+resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/background.gresource.xml)
+cc-background-resources.c: background.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_background $<
+cc-background-resources.h: background.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_background $<
+
 gdesktop-enums-types.h: stamp-gdesktop-enums-types.h
 	@true
 
@@ -91,5 +92,6 @@ desktop_in_files = gnome-background-panel.desktop.in
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 
 CLEANFILES = $(desktop_in_files) $(desktop_DATA) $(BUILT_SOURCES) stamp-gdesktop-enums-types.h
+EXTRA_DIST = $(resource_files) background.gresource.xml
 
 -include $(top_srcdir)/git.mk
diff --git a/panels/background/background.gresource.xml b/panels/background/background.gresource.xml
new file mode 100644
index 0000000..e8e4ff3
--- /dev/null
+++ b/panels/background/background.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/control-center/background">
+    <file preprocess="xml-stripblanks">background.ui</file>
+  </gresource>
+</gresources>
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index ebebaf2..178e34b 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -30,11 +30,11 @@
 
 #include "cc-background-panel.h"
 
+#include "cc-background-chooser-dialog.h"
 #include "cc-background-item.h"
+#include "cc-background-resources.h"
 #include "cc-background-xml.h"
 
-#include "cc-background-chooser-dialog.h"
-
 #include "bg-pictures-source.h"
 
 #define WP_PATH_ID "org.gnome.desktop.background"
@@ -733,12 +733,13 @@ cc_background_panel_init (CcBackgroundPanel *self)
 
   priv = self->priv = BACKGROUND_PANEL_PRIVATE (self);
 
-  priv->builder = gtk_builder_new ();
   priv->connection = g_application_get_dbus_connection (g_application_get_default ());
+  g_resources_register (cc_background_get_resource ());
 
-  gtk_builder_add_objects_from_file (priv->builder,
-                                     UIDIR"/background.ui",
-                                     objects, &err);
+  priv->builder = gtk_builder_new ();
+  gtk_builder_add_objects_from_resource (priv->builder,
+                                         "/org/gnome/control-center/background/background.ui",
+                                         objects, &err);
 
   if (err)
     {



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