Commit 82f8c136 authored by Cosimo Cecchi's avatar Cosimo Cecchi Committed by Bastien Nocera
Browse files

wacom: use a GResource for GtkBuilder UI definition and icons

https://bugzilla.gnome.org/show_bug.cgi?id=691132
parent f7ae09c5
......@@ -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
......@@ -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)
......
......@@ -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 {
......
......@@ -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);
......
......@@ -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 */
......
<?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>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment