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



commit 30644257115832cc2c305786b239581d49c9aeb8
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Jan 4 15:54:43 2013 +0100

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

 panels/printers/Makefile.am               |   24 +++++++++++++-----------
 panels/printers/cc-printers-panel.c       |    8 +++++---
 panels/printers/pp-jobs-dialog.c          |    6 +++---
 panels/printers/pp-new-printer-dialog.c   |    6 +++---
 panels/printers/pp-options-dialog.c       |    6 +++---
 panels/printers/pp-ppd-selection-dialog.c |    6 +++---
 panels/printers/printers.gresource.xml    |   10 ++++++++++
 7 files changed, 40 insertions(+), 26 deletions(-)
---
diff --git a/panels/printers/Makefile.am b/panels/printers/Makefile.am
index 1083139..d38405a 100644
--- a/panels/printers/Makefile.am
+++ b/panels/printers/Makefile.am
@@ -1,25 +1,20 @@
 cappletname = printers
 
-uidir = $(pkgdatadir)/ui/printers
-dist_ui_DATA = \
-	new-printer-dialog.ui	\
-	ppd-selection-dialog.ui	\
-	options-dialog.ui	\
-	jobs-dialog.ui		\
-	printers.ui
-
 INCLUDES = 						\
 	$(PANEL_CFLAGS)					\
 	$(PRINTERS_PANEL_CFLAGS)			\
 	-I$(top_srcdir)/shell/				\
 	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
-	-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""		\
-	-DDATADIR="\"$(uidir)\""			\
 	$(NULL)
 
 noinst_LTLIBRARIES = libprinters.la
 
+BUILT_SOURCES =			\
+	cc-printers-resources.c	\
+	cc-printers-resources.h
+
 libprinters_la_SOURCES =		\
+	$(BUILT_SOURCES)		\
 	pp-new-printer.c		\
 	pp-new-printer.h		\
 	pp-maintenance-command.c	\
@@ -47,12 +42,19 @@ libprinters_la_SOURCES =		\
 
 libprinters_la_LIBADD = $(PRINTERS_PANEL_LIBS) $(PANEL_LIBS) $(CUPS_LIBS)
 
+resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/printers.gresource.xml)
+cc-printers-resources.c: printers.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_printers $<
+cc-printers-resources.h: printers.gresource.xml $(resource_files)
+	$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_printers $<
+
 @INTLTOOL_DESKTOP_RULE@
 
 desktopdir = $(datadir)/applications
 desktop_in_files = gnome-printers-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) printers.gresource.xml
 
 -include $(top_srcdir)/git.mk
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index f4b12ec..1167b49 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -20,6 +20,7 @@
 #include <config.h>
 
 #include "cc-printers-panel.h"
+#include "cc-printers-resources.h"
 
 #include <string.h>
 #include <glib/gi18n-lib.h>
@@ -2833,6 +2834,7 @@ cc_printers_panel_init (CcPrintersPanel *self)
   guint                   builder_result;
 
   priv = self->priv = PRINTERS_PANEL_PRIVATE (self);
+  g_resources_register (cc_printers_get_resource ());
 
   /* initialize main data structure */
   priv->builder = gtk_builder_new ();
@@ -2870,9 +2872,9 @@ cc_printers_panel_init (CcPrintersPanel *self)
 
   priv->preferred_drivers = NULL;
 
-  builder_result = gtk_builder_add_objects_from_file (priv->builder,
-                                                      DATADIR"/printers.ui",
-                                                      objects, &error);
+  builder_result = gtk_builder_add_objects_from_resource (priv->builder,
+                                                          "/org/gnome/control-center/printers/printers.ui",
+                                                          objects, &error);
 
   if (builder_result == 0)
     {
diff --git a/panels/printers/pp-jobs-dialog.c b/panels/printers/pp-jobs-dialog.c
index 7e0ef9f..c7aad5d 100644
--- a/panels/printers/pp-jobs-dialog.c
+++ b/panels/printers/pp-jobs-dialog.c
@@ -441,9 +441,9 @@ pp_jobs_dialog_new (GtkWindow            *parent,
   dialog->builder = gtk_builder_new ();
   dialog->parent = GTK_WIDGET (parent);
 
-  builder_result = gtk_builder_add_objects_from_file (dialog->builder,
-                                                      DATADIR"/jobs-dialog.ui",
-                                                      objects, &error);
+  builder_result = gtk_builder_add_objects_from_resource (dialog->builder,
+                                                          "/org/gnome/control-center/printers/jobs-dialog.ui",
+                                                          objects, &error);
 
   if (builder_result == 0)
     {
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index 90c57c1..413bd55 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -267,9 +267,9 @@ pp_new_printer_dialog_init (PpNewPrinterDialog *dialog)
 
   priv->builder = gtk_builder_new ();
 
-  builder_result = gtk_builder_add_objects_from_file (priv->builder,
-                                                      DATADIR"/new-printer-dialog.ui",
-                                                      objects, &error);
+  builder_result = gtk_builder_add_objects_from_resource (priv->builder,
+                                                          "/org/gnome/control-center/printers/new-printer-dialog.ui",
+                                                          objects, &error);
 
   if (builder_result == 0)
     {
diff --git a/panels/printers/pp-options-dialog.c b/panels/printers/pp-options-dialog.c
index f967693..d6e23dd 100644
--- a/panels/printers/pp-options-dialog.c
+++ b/panels/printers/pp-options-dialog.c
@@ -894,9 +894,9 @@ pp_options_dialog_new (GtkWindow            *parent,
   dialog->builder = gtk_builder_new ();
   dialog->parent = GTK_WIDGET (parent);
 
-  builder_result = gtk_builder_add_objects_from_file (dialog->builder,
-                                                      DATADIR"/options-dialog.ui",
-                                                      objects, &error);
+  builder_result = gtk_builder_add_objects_from_resource (dialog->builder,
+                                                          "/org/gnome/control-center/printers/options-dialog.ui",
+                                                          objects, &error);
 
   if (builder_result == 0)
     {
diff --git a/panels/printers/pp-ppd-selection-dialog.c b/panels/printers/pp-ppd-selection-dialog.c
index 0798df8..950f5d1 100644
--- a/panels/printers/pp-ppd-selection-dialog.c
+++ b/panels/printers/pp-ppd-selection-dialog.c
@@ -368,9 +368,9 @@ pp_ppd_selection_dialog_new (GtkWindow            *parent,
   dialog->builder = gtk_builder_new ();
   dialog->parent = GTK_WIDGET (parent);
 
-  builder_result = gtk_builder_add_objects_from_file (dialog->builder,
-                                                      DATADIR"/ppd-selection-dialog.ui",
-                                                      objects, &error);
+  builder_result = gtk_builder_add_objects_from_resource (dialog->builder,
+                                                          "/org/gnome/control-center/printers/ppd-selection-dialog.ui",
+                                                          objects, &error);
 
   if (builder_result == 0)
     {
diff --git a/panels/printers/printers.gresource.xml b/panels/printers/printers.gresource.xml
new file mode 100644
index 0000000..291c65a
--- /dev/null
+++ b/panels/printers/printers.gresource.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/control-center/printers">
+    <file preprocess="xml-stripblanks">jobs-dialog.ui</file>
+    <file preprocess="xml-stripblanks">new-printer-dialog.ui</file>
+    <file preprocess="xml-stripblanks">options-dialog.ui</file>
+    <file preprocess="xml-stripblanks">ppd-selection-dialog.ui</file>
+    <file preprocess="xml-stripblanks">printers.ui</file>
+  </gresource>
+</gresources>



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