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



commit 28b6974b8303a7a40096c61c48b15b2ab7b90c18
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Jan 4 16:12:55 2013 +0100

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

 panels/search/Makefile.am                  |   19 ++++++++++++-------
 panels/search/cc-search-locations-dialog.c |    6 +++---
 panels/search/cc-search-panel.c            |    8 +++++---
 panels/search/search.gresource.xml         |    7 +++++++
 4 files changed, 27 insertions(+), 13 deletions(-)
---
diff --git a/panels/search/Makefile.am b/panels/search/Makefile.am
index c209d24..fd23321 100644
--- a/panels/search/Makefile.am
+++ b/panels/search/Makefile.am
@@ -3,16 +3,19 @@ cappletname = search
 INCLUDES = 						\
 	$(PANEL_CFLAGS)					\
 	$(SEARCH_PANEL_CFLAGS)				\
-	-DGNOMECC_UI_DIR="\"$(uidir)\""			\
 	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
-	-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""		\
 	-DDATADIR="\"$(datadir)\""			\
 	-I$(top_srcdir)/panels/common/			\
 	$(NULL)
 
 noinst_LTLIBRARIES = libsearch.la
 
+BUILT_SOURCES =			\
+	cc-search-resources.c	\
+	cc-search-resources.h
+
 libsearch_la_SOURCES =		\
+	$(BUILT_SOURCES)	\
 	cc-search-locations-dialog.c \
 	cc-search-locations-dialog.h \
 	cc-search-panel.c	\
@@ -20,10 +23,11 @@ libsearch_la_SOURCES =		\
 
 libsearch_la_LIBADD = $(PANEL_LIBS) $(SEARCH_PANEL_LIBS)
 
-uidir = $(pkgdatadir)/ui
-dist_ui_DATA = 		\
-	search.ui 	\
-	search-locations-dialog.ui
+resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/search.gresource.xml)
+cc-search-resources.c: search.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_search $<
+cc-search-resources.h: search.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_search $<
 
 @INTLTOOL_DESKTOP_RULE@
 
@@ -31,6 +35,7 @@ desktopdir = $(datadir)/applications
 desktop_in_files = gnome-search-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) search.gresource.xml
 
 -include $(top_srcdir)/git.mk
diff --git a/panels/search/cc-search-locations-dialog.c b/panels/search/cc-search-locations-dialog.c
index b857a0a..e9ea62c 100644
--- a/panels/search/cc-search-locations-dialog.c
+++ b/panels/search/cc-search-locations-dialog.c
@@ -705,9 +705,9 @@ cc_search_locations_dialog_new (CcSearchPanel *self)
   GError *error = NULL;
 
   dialog_builder = gtk_builder_new ();
-  gtk_builder_add_from_file (dialog_builder,
-                             GNOMECC_UI_DIR "/search-locations-dialog.ui",
-                             &error);
+  gtk_builder_add_from_resource (dialog_builder,
+                                 "/org/gnome/control-center/search/search-locations-dialog.ui",
+                                 &error);
 
   if (error != NULL)
     {
diff --git a/panels/search/cc-search-panel.c b/panels/search/cc-search-panel.c
index 94e15ab..84c5d3e 100644
--- a/panels/search/cc-search-panel.c
+++ b/panels/search/cc-search-panel.c
@@ -21,6 +21,7 @@
 
 #include "cc-search-panel.h"
 #include "cc-search-locations-dialog.h"
+#include "cc-search-resources.h"
 
 #include <egg-list-box/egg-list-box.h>
 #include <gio/gdesktopappinfo.h>
@@ -576,13 +577,14 @@ cc_search_panel_init (CcSearchPanel *self)
   guint res;
 
   self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, CC_TYPE_SEARCH_PANEL, CcSearchPanelPrivate);
+  g_resources_register (cc_search_get_resource ());
 
   self->priv->builder = gtk_builder_new ();
 
   error = NULL;
-  res = gtk_builder_add_from_file (self->priv->builder,
-                                   GNOMECC_UI_DIR "/search.ui",
-                                   &error);
+  res = gtk_builder_add_from_resource (self->priv->builder,
+                                       "/org/gnome/control-center/search/search.ui",
+                                       &error);
 
   if (res == 0)
     {
diff --git a/panels/search/search.gresource.xml b/panels/search/search.gresource.xml
new file mode 100644
index 0000000..50388ff
--- /dev/null
+++ b/panels/search/search.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/control-center/search">
+    <file preprocess="xml-stripblanks">search.ui</file>
+    <file preprocess="xml-stripblanks">search-locations-dialog.ui</file>
+  </gresource>
+</gresources>



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