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



commit b7571896aad55b9824081151d18e554c0566bfbe
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Jan 4 14:52:41 2013 +0100

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

 panels/display/Makefile.am           |   22 ++++++++++++++--------
 panels/display/cc-display-panel.c    |    4 +++-
 panels/display/display.gresource.xml |    6 ++++++
 3 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/panels/display/Makefile.am b/panels/display/Makefile.am
index 0294634..2110136 100644
--- a/panels/display/Makefile.am
+++ b/panels/display/Makefile.am
@@ -1,12 +1,14 @@
 # This is used in PANEL_CFLAGS
 cappletname = display
 
-uidir = $(pkgdatadir)/ui
-dist_ui_DATA = display-capplet.ui
-
 noinst_LTLIBRARIES = libdisplay.la
 
+BUILT_SOURCES =			\
+	cc-display-resources.c	\
+	cc-display-resources.h
+
 libdisplay_la_SOURCES =		\
+	$(BUILT_SOURCES)	\
 	cc-display-panel.c	\
 	cc-display-panel.h	\
 	cc-rr-labeler.c		\
@@ -16,6 +18,12 @@ libdisplay_la_SOURCES =		\
 
 libdisplay_la_LIBADD = $(PANEL_LIBS) $(DISPLAY_PANEL_LIBS)
 
+resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/display.gresource.xml)
+cc-display-resources.c: display.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_display $<
+cc-display-resources.h: display.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_display $<
+
 # You will need a recent intltool or the patch from this bug
 # http://bugzilla.gnome.org/show_bug.cgi?id=462312
 @INTLTOOL_POLICY_RULE@
@@ -39,12 +47,10 @@ desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
 
 INCLUDES   = $(PANEL_CFLAGS) \
 	     $(DISPLAY_PANEL_CFLAGS) \
-	     -DSBINDIR="\"$(sbindir)\"" \
-	     -DUIDIR="\"$(uidir)\"" \
-	     -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-	     -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""
+	     -DGNOMELOCALEDIR="\"$(datadir)/locale\""
 
-CLEANFILES = $(Desktop_in_files) $(desktop_DATA)
+CLEANFILES = $(Desktop_in_files) $(desktop_DATA) $(BUILT_SOURCES)
+EXTRA_DIST = $(resource_files) display.gresource.xml
 
 if MAINTAINER_MODE
 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index 90acd34..e4f2433 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -25,6 +25,7 @@
 #include <sys/wait.h>
 
 #include "cc-display-panel.h"
+#include "cc-display-resources.h"
 
 #include <gtk/gtk.h>
 #include "scrollarea.h"
@@ -2571,6 +2572,7 @@ dialog_map_event_cb (GtkWidget *widget, GdkEventAny *event, gpointer data)
 static void
 cc_display_panel_init (CcDisplayPanel *self)
 {
+  g_resources_register (cc_display_get_resource ());
 }
 
 static GObject *
@@ -2594,7 +2596,7 @@ cc_display_panel_constructor (GType                  gtype,
   error = NULL;
   self->priv->builder = builder = gtk_builder_new ();
 
-  if (!gtk_builder_add_objects_from_file (builder, UIDIR "/display-capplet.ui", objects, &error))
+  if (!gtk_builder_add_objects_from_resource (builder, "/org/gnome/control-center/display/display-capplet.ui", objects, &error))
     {
       g_warning ("Could not parse UI definition: %s", error->message);
       g_error_free (error);
diff --git a/panels/display/display.gresource.xml b/panels/display/display.gresource.xml
new file mode 100644
index 0000000..05bad6e
--- /dev/null
+++ b/panels/display/display.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/control-center/display">
+    <file preprocess="xml-stripblanks">display-capplet.ui</file>
+  </gresource>
+</gresources>



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