[gnome-control-center] wacom: use a GResource for GtkBuilder UI definition and icons
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] wacom: use a GResource for GtkBuilder UI definition and icons
- Date: Mon, 7 Jan 2013 10:06:10 +0000 (UTC)
commit 82f8c136c0b36abccb41feb12e6c4042d031c9f9
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Fri Jan 4 16:36:56 2013 +0100
wacom: use a GResource for GtkBuilder UI definition and icons
https://bugzilla.gnome.org/show_bug.cgi?id=691132
panels/wacom/Makefile.am | 31 ++++++++++++++-----------------
panels/wacom/calibrator/Makefile.am | 3 ---
panels/wacom/cc-wacom-page.c | 25 +++++++++++--------------
panels/wacom/cc-wacom-panel.c | 10 ++++++----
panels/wacom/cc-wacom-stylus-page.c | 19 ++++++++-----------
panels/wacom/wacom.gresource.xml | 16 ++++++++++++++++
6 files changed, 55 insertions(+), 49 deletions(-)
---
diff --git a/panels/wacom/Makefile.am b/panels/wacom/Makefile.am
index 92fcf75..acb7eeb 100644
--- a/panels/wacom/Makefile.am
+++ b/panels/wacom/Makefile.am
@@ -8,13 +8,17 @@ INCLUDES = \
$(WACOM_PANEL_CFLAGS) \
-I$(srcdir)/calibrator \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
- -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
-DGNOMECC_UI_DIR="\"$(uidir)\"" \
$(NULL)
noinst_LTLIBRARIES = libwacom-properties.la
+BUILT_SOURCES = \
+ cc-wacom-resources.c \
+ cc-wacom-resources.h
+
libwacom_properties_la_SOURCES = \
+ $(BUILT_SOURCES) \
cc-wacom-panel.c \
cc-wacom-panel.h \
cc-wacom-page.c \
@@ -36,6 +40,7 @@ libwacom_properties_la_LIBADD = $(PANEL_LIBS) $(WACOM_PANEL_LIBS) $(builddir)/ca
noinst_PROGRAMS = test-wacom
test_wacom_SOURCES = \
+ $(BUILT_SOURCES) \
test-wacom.c \
cc-wacom-page.c \
cc-wacom-page.h \
@@ -54,21 +59,13 @@ test_wacom_SOURCES = \
test_wacom_CPPFLAGS = $(INCLUDES)
test_wacom_LDADD = $(PANEL_LIBS) $(WACOM_PANEL_LIBS) $(builddir)/calibrator/libwacom-calibrator.la
- INTLTOOL_DESKTOP_RULE@
-
-pixmapdir = $(pkgdatadir)/ui
-pixmap_DATA = \
- wacom-tablet.svg \
- wacom-stylus.svg \
- wacom-stylus-airbrush.svg \
- wacom-stylus-inking.svg \
- wacom-stylus-art-pen.svg \
- wacom-stylus-classic.svg \
- wacom-tablet-cintiq.svg \
- wacom-tablet-pc.svg
+resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/wacom.gresource.xml)
+cc-wacom-resources.c: wacom.gresource.xml $(resource_files)
+ $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_wacom $<
+cc-wacom-resources.h: wacom.gresource.xml $(resource_files)
+ $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_wacom $<
-uidir = $(pkgdatadir)/ui
-ui_DATA = gnome-wacom-properties.ui wacom-stylus-page.ui button-mapping.ui
+ INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications
desktop_in_files = gnome-wacom-panel.desktop.in
@@ -83,7 +80,7 @@ update-from-gsd:
FILES="$(COMMONFILES)" DIR="$(COMMONDIR)" $(top_srcdir)/update-from-gsd.sh && changed=true ; \
git commit -m "wacom: Update from gnome-settings-daemon" $(WACOMFILES) $(COMMONFILES)
-CLEANFILES = $(Desktop_in_files) $(desktop_DATA)
-EXTRA_DIST = $(ui_DATA) $(pixmap_DATA)
+CLEANFILES = $(Desktop_in_files) $(desktop_DATA) $(BUILT_SOURCES)
+EXTRA_DIST = $(resource_files) wacom.gresource.xml
-include $(top_srcdir)/git.mk
diff --git a/panels/wacom/calibrator/Makefile.am b/panels/wacom/calibrator/Makefile.am
index d800558..372084f 100644
--- a/panels/wacom/calibrator/Makefile.am
+++ b/panels/wacom/calibrator/Makefile.am
@@ -5,9 +5,6 @@ INCLUDES = \
$(PANEL_CFLAGS) \
$(WACOM_PANEL_CFLAGS) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
- -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
- -DGNOMECC_UI_DIR="\"$(uidir)\"" \
- -DPIXMAP_DIR=\""$(datadir)/gnome-control-center/pixmaps"\" \
$(NULL)
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index 862d74a..c4b037e 100644
--- a/panels/wacom/cc-wacom-page.c
+++ b/panels/wacom/cc-wacom-page.c
@@ -864,9 +864,9 @@ map_buttons_button_clicked_cb (GtkButton *button,
g_assert (priv->mapping_builder == NULL);
priv->mapping_builder = gtk_builder_new ();
- gtk_builder_add_from_file (priv->mapping_builder,
- GNOMECC_UI_DIR "/button-mapping.ui",
- &error);
+ gtk_builder_add_from_resource (priv->mapping_builder,
+ "/org/gnome/control-center/wacom/button-mapping.ui",
+ &error);
if (error != NULL) {
g_warning ("Error loading UI file: %s", error->message);
@@ -1124,10 +1124,10 @@ cc_wacom_page_init (CcWacomPage *self)
priv->builder = gtk_builder_new ();
- gtk_builder_add_objects_from_file (priv->builder,
- GNOMECC_UI_DIR "/gnome-wacom-properties.ui",
- objects,
- &error);
+ gtk_builder_add_objects_from_resource (priv->builder,
+ "/org/gnome/control-center/wacom/gnome-wacom-properties.ui",
+ objects,
+ &error);
if (error != NULL) {
g_warning ("Error loading UI file: %s", error->message);
g_object_unref (priv->builder);
@@ -1173,16 +1173,13 @@ set_icon_name (CcWacomPage *page,
const char *icon_name)
{
CcWacomPagePrivate *priv;
- char *filename, *path;
+ char *resource;
priv = page->priv;
- filename = g_strdup_printf ("%s.svg", icon_name);
- path = g_build_filename (GNOMECC_UI_DIR, filename, NULL);
- g_free (filename);
-
- gtk_image_set_from_file (GTK_IMAGE (WID (widget_name)), path);
- g_free (path);
+ resource = g_strdup_printf ("/org/gnome/control-center/wacom/%s.svg", icon_name);
+ gtk_image_set_from_resource (GTK_IMAGE (WID (widget_name)), resource);
+ g_free (resource);
}
typedef struct {
diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c
index 1cf6b4e..2bbbeac 100644
--- a/panels/wacom/cc-wacom-panel.c
+++ b/panels/wacom/cc-wacom-panel.c
@@ -27,6 +27,7 @@
#include "cc-wacom-panel.h"
#include "cc-wacom-page.h"
+#include "cc-wacom-resources.h"
#include "gsd-wacom-device.h"
#define WID(x) (GtkWidget *) gtk_builder_get_object (priv->builder, x)
@@ -334,13 +335,14 @@ cc_wacom_panel_init (CcWacomPanel *self)
};
priv = self->priv = WACOM_PANEL_PRIVATE (self);
+ g_resources_register (cc_wacom_get_resource ());
priv->builder = gtk_builder_new ();
- gtk_builder_add_objects_from_file (priv->builder,
- GNOMECC_UI_DIR "/gnome-wacom-properties.ui",
- objects,
- &error);
+ gtk_builder_add_objects_from_resource (priv->builder,
+ "/org/gnome/control-center/wacom/gnome-wacom-properties.ui",
+ objects,
+ &error);
if (error != NULL)
{
g_warning ("Error loading UI file: %s", error->message);
diff --git a/panels/wacom/cc-wacom-stylus-page.c b/panels/wacom/cc-wacom-stylus-page.c
index 9b88144..b063d52 100644
--- a/panels/wacom/cc-wacom-stylus-page.c
+++ b/panels/wacom/cc-wacom-stylus-page.c
@@ -297,10 +297,10 @@ cc_wacom_stylus_page_init (CcWacomStylusPage *self)
priv->builder = gtk_builder_new ();
- gtk_builder_add_objects_from_file (priv->builder,
- GNOMECC_UI_DIR "/wacom-stylus-page.ui",
- objects,
- &error);
+ gtk_builder_add_objects_from_resource (priv->builder,
+ "/org/gnome/control-center/wacom/wacom-stylus-page.ui",
+ objects,
+ &error);
if (error != NULL) {
g_warning ("Error loading UI file: %s", error->message);
g_object_unref (priv->builder);
@@ -339,16 +339,13 @@ set_icon_name (CcWacomStylusPage *page,
const char *icon_name)
{
CcWacomStylusPagePrivate *priv;
- char *filename, *path;
+ char *resource;
priv = page->priv;
- filename = g_strdup_printf ("%s.svg", icon_name);
- path = g_build_filename (GNOMECC_UI_DIR, filename, NULL);
- g_free (filename);
-
- gtk_image_set_from_file (GTK_IMAGE (WID (widget_name)), path);
- g_free (path);
+ resource = g_strdup_printf ("/org/gnome/control-center/wacom/%s.svg", icon_name);
+ gtk_image_set_from_resource (GTK_IMAGE (WID (widget_name)), resource);
+ g_free (resource);
}
/* Different types of layout for the stylus config */
diff --git a/panels/wacom/wacom.gresource.xml b/panels/wacom/wacom.gresource.xml
new file mode 100644
index 0000000..7d46190
--- /dev/null
+++ b/panels/wacom/wacom.gresource.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/control-center/wacom">
+ <file preprocess="xml-stripblanks">gnome-wacom-properties.ui</file>
+ <file preprocess="xml-stripblanks">wacom-stylus-page.ui</file>
+ <file preprocess="xml-stripblanks">button-mapping.ui</file>
+ <file>wacom-tablet.svg</file>
+ <file>wacom-stylus.svg</file>
+ <file>wacom-stylus-airbrush.svg</file>
+ <file>wacom-stylus-inking.svg</file>
+ <file>wacom-stylus-art-pen.svg</file>
+ <file>wacom-stylus-classic.svg</file>
+ <file>wacom-tablet-cintiq.svg</file>
+ <file>wacom-tablet-pc.svg</file>
+ </gresource>
+</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]