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



commit 645778eaee339e3b925158780b34772471999392
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Jan 4 15:54:33 2013 +0100

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

 panels/power/Makefile.am         |   17 ++++++++++++-----
 panels/power/cc-power-panel.c    |    8 +++++---
 panels/power/power.gresource.xml |    6 ++++++
 3 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/panels/power/Makefile.am b/panels/power/Makefile.am
index 0db4126..79d5988 100644
--- a/panels/power/Makefile.am
+++ b/panels/power/Makefile.am
@@ -5,15 +5,18 @@ SUBDIRS = icons
 INCLUDES = 						\
 	$(PANEL_CFLAGS)					\
 	$(POWER_PANEL_CFLAGS)				\
-	-DGNOMECC_UI_DIR="\"$(uidir)\""			\
 	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
-	-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""		\
 	-I$(srcdir)/../../shell/			\
 	$(NULL)
 
 noinst_LTLIBRARIES = libpower.la
 
+BUILT_SOURCES =			\
+	cc-power-resources.c	\
+	cc-power-resources.h
+
 libpower_la_SOURCES =		\
+	$(BUILT_SOURCES)	\
 	cc-power-panel.c	\
 	cc-power-panel.h
 
@@ -29,8 +32,11 @@ INCLUDES += $(NETWORK_MANAGER_CFLAGS)
 libpower_la_LIBADD += $(NETWORK_MANAGER_LIBS)
 endif
 
-uidir = $(pkgdatadir)/ui
-dist_ui_DATA = power.ui
+resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/power.gresource.xml)
+cc-power-resources.c: power.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_power $<
+cc-power-resources.h: power.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_power $<
 
 @INTLTOOL_DESKTOP_RULE@
 
@@ -38,6 +44,7 @@ desktopdir = $(datadir)/applications
 desktop_in_files = gnome-power-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) power.gresource.xml
 
 -include $(top_srcdir)/git.mk
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 0b7849d..b8d4c26 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -36,6 +36,7 @@
 #endif
 
 #include "cc-power-panel.h"
+#include "cc-power-resources.h"
 
 /* Uncomment this to test the behaviour of the panel in
  * battery-less situations:
@@ -1895,13 +1896,14 @@ cc_power_panel_init (CcPowerPanel *self)
   GtkWidget  *box;
 
   priv = self->priv = POWER_PANEL_PRIVATE (self);
+  g_resources_register (cc_power_get_resource ());
 
   priv->builder = gtk_builder_new ();
 
   error = NULL;
-  gtk_builder_add_from_file (priv->builder,
-                             GNOMECC_UI_DIR "/power.ui",
-                             &error);
+  gtk_builder_add_from_resource (self->priv->builder,
+                                 "/org/gnome/control-center/power/power.ui",
+                                 &error);
 
   if (error != NULL)
     {
diff --git a/panels/power/power.gresource.xml b/panels/power/power.gresource.xml
new file mode 100644
index 0000000..1654e97
--- /dev/null
+++ b/panels/power/power.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/control-center/power">
+    <file preprocess="xml-stripblanks">power.ui</file>
+  </gresource>
+</gresources>



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