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



commit b6b77de98251bb9b36d7c4ecfdf90d51404126cf
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Jan 4 16:07:25 2013 +0100

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

 panels/screen/Makefile.am          |   17 ++++++++++++-----
 panels/screen/cc-screen-panel.c    |    9 ++++++---
 panels/screen/screen.gresource.xml |    6 ++++++
 3 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/panels/screen/Makefile.am b/panels/screen/Makefile.am
index 668439e..26bad74 100644
--- a/panels/screen/Makefile.am
+++ b/panels/screen/Makefile.am
@@ -3,21 +3,27 @@ cappletname = screen
 INCLUDES = 						\
 	$(PANEL_CFLAGS)					\
 	$(SCREEN_PANEL_CFLAGS)			\
-	-DGNOMECC_UI_DIR="\"$(uidir)\""			\
 	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
-	-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""		\
 	$(NULL)
 
 noinst_LTLIBRARIES = libscreen.la
 
+BUILT_SOURCES =			\
+	cc-screen-resources.c	\
+	cc-screen-resources.h
+
 libscreen_la_SOURCES =		\
+	$(BUILT_SOURCES)	\
 	cc-screen-panel.c	\
 	cc-screen-panel.h
 
 libscreen_la_LIBADD = $(PANEL_LIBS) $(SCREEN_PANEL_LIBS)
 
-uidir = $(pkgdatadir)/ui
-dist_ui_DATA = screen.ui
+resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/screen.gresource.xml)
+cc-screen-resources.c: screen.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_screen $<
+cc-screen-resources.h: screen.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_screen $<
 
 @INTLTOOL_DESKTOP_RULE@
 
@@ -25,6 +31,7 @@ desktopdir = $(datadir)/applications
 desktop_in_files = gnome-screen-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) screen.gresource.xml
 
 -include $(top_srcdir)/git.mk
diff --git a/panels/screen/cc-screen-panel.c b/panels/screen/cc-screen-panel.c
index 2a9e108..2358a93 100644
--- a/panels/screen/cc-screen-panel.c
+++ b/panels/screen/cc-screen-panel.c
@@ -20,6 +20,8 @@
  */
 
 #include "cc-screen-panel.h"
+#include "cc-screen-resources.h"
+
 #include <string.h>
 
 CC_PANEL_REGISTER (CcScreenPanel, cc_screen_panel)
@@ -435,13 +437,14 @@ cc_screen_panel_init (CcScreenPanel *self)
   GtkWidget  *widget;
 
   self->priv = SCREEN_PANEL_PRIVATE (self);
+  g_resources_register (cc_screen_get_resource ());
 
   self->priv->builder = gtk_builder_new ();
 
   error = NULL;
-  gtk_builder_add_from_file (self->priv->builder,
-                             GNOMECC_UI_DIR "/screen.ui",
-                             &error);
+  gtk_builder_add_from_resource (self->priv->builder,
+                                 "/org/gnome/control-center/screen/screen.ui",
+                                 &error);
 
   if (error != NULL)
     {
diff --git a/panels/screen/screen.gresource.xml b/panels/screen/screen.gresource.xml
new file mode 100644
index 0000000..e46325f
--- /dev/null
+++ b/panels/screen/screen.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/control-center/screen">
+    <file preprocess="xml-stripblanks">screen.ui</file>
+  </gresource>
+</gresources>



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