[gnome-control-center] mouse: 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] mouse: use a GResource for GtkBuilder UI definition and icons
- Date: Mon, 7 Jan 2013 10:05:19 +0000 (UTC)
commit db5aba75a181acafbe86118b6aa0085defa0a7f4
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Fri Jan 4 15:23:01 2013 +0100
mouse: use a GResource for GtkBuilder UI definition and icons
https://bugzilla.gnome.org/show_bug.cgi?id=691132
panels/mouse/Makefile.am | 25 ++++++++++++++-----------
panels/mouse/cc-mouse-panel.c | 15 +++++++++------
panels/mouse/gnome-mouse-test.c | 8 ++++----
panels/mouse/mouse.gresource.xml | 9 +++++++++
panels/mouse/test-gnome-mouse-test.c | 4 +++-
5 files changed, 39 insertions(+), 22 deletions(-)
---
diff --git a/panels/mouse/Makefile.am b/panels/mouse/Makefile.am
index 851a89e..20a26eb 100644
--- a/panels/mouse/Makefile.am
+++ b/panels/mouse/Makefile.am
@@ -5,13 +5,16 @@ INCLUDES = \
$(PANEL_CFLAGS) \
$(MOUSE_PANEL_CFLAGS) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
- -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
- -DGNOMECC_UI_DIR="\"$(uidir)\"" \
$(NULL)
noinst_LTLIBRARIES = libmouse-properties.la
+BUILT_SOURCES = \
+ cc-mouse-resources.c \
+ cc-mouse-resources.h
+
libmouse_properties_la_SOURCES = \
+ $(BUILT_SOURCES) \
cc-mouse-panel.c \
cc-mouse-panel.h \
gnome-mouse-properties.c \
@@ -23,7 +26,8 @@ libmouse_properties_la_SOURCES = \
libmouse_properties_la_LIBADD = $(PANEL_LIBS) $(MOUSE_PANEL_LIBS)
-test_gnome_mouse_test_SOURCES = \
+test_gnome_mouse_test_SOURCES = \
+ $(BUILT_SOURCES) \
gnome-mouse-test.c \
gnome-mouse-test.h \
test-gnome-mouse-test.c
@@ -33,14 +37,13 @@ noinst_PROGRAMS = test-gnome-mouse-test
test_gnome_mouse_test_CPPFLAGS = $(INCLUDES)
test_gnome_mouse_test_LDADD = $(PANEL_LIBS) $(MOUSE_PANEL_LIBS)
- INTLTOOL_DESKTOP_RULE@
+resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/mouse.gresource.xml)
+cc-mouse-resources.c: mouse.gresource.xml $(resource_files)
+ $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_mouse $<
+cc-mouse-resources.h: mouse.gresource.xml $(resource_files)
+ $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_mouse $<
-uidir = $(pkgdatadir)/ui
-ui_DATA = \
- gnome-mouse-properties.ui \
- gnome-mouse-test.ui \
- scroll-test-gegl.svg \
- scroll-test.svg
+ INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications
Desktop_in_files = gnome-mouse-panel.desktop.in
@@ -53,6 +56,6 @@ update-from-gsd:
git commit -m "mouse: Update from gnome-settings-daemon" $(INPUTFILES)
CLEANFILES = $(Desktop_in_files) $(desktop_DATA)
-EXTRA_DIST = $(ui_DATA)
+EXTRA_DIST = $(resource_files) mouse.gresource.xml
-include $(top_srcdir)/git.mk
diff --git a/panels/mouse/cc-mouse-panel.c b/panels/mouse/cc-mouse-panel.c
index 5d8465e..a3aabd9 100644
--- a/panels/mouse/cc-mouse-panel.c
+++ b/panels/mouse/cc-mouse-panel.c
@@ -23,6 +23,8 @@
*/
#include "cc-mouse-panel.h"
+#include "cc-mouse-resources.h"
+
#include "gnome-mouse-properties.h"
#include "gnome-mouse-test.h"
#include <gtk/gtk.h>
@@ -140,21 +142,22 @@ cc_mouse_panel_init (CcMousePanel *self)
GError *error = NULL;
priv = self->priv = MOUSE_PANEL_PRIVATE (self);
+ g_resources_register (cc_mouse_get_resource ());
priv->builder = gtk_builder_new ();
- gtk_builder_add_from_file (priv->builder,
- GNOMECC_UI_DIR "/gnome-mouse-properties.ui",
- &error);
+ gtk_builder_add_from_resource (priv->builder,
+ "/org/gnome/control-center/mouse/gnome-mouse-properties.ui",
+ &error);
if (error != NULL)
{
g_warning ("Error loading UI file: %s", error->message);
return;
}
- gtk_builder_add_from_file (priv->builder,
- GNOMECC_UI_DIR "/gnome-mouse-test.ui",
- &error);
+ gtk_builder_add_from_resource (priv->builder,
+ "/org/gnome/control-center/mouse/gnome-mouse-test.ui",
+ &error);
if (error != NULL)
{
g_warning ("Error loading UI file: %s", error->message);
diff --git a/panels/mouse/gnome-mouse-test.c b/panels/mouse/gnome-mouse-test.c
index 2919e68..c5f4d65 100644
--- a/panels/mouse/gnome-mouse-test.c
+++ b/panels/mouse/gnome-mouse-test.c
@@ -169,7 +169,7 @@ static void
setup_scroll_image (GtkWidget *widget)
{
static struct test_data_t data;
- char *filename;
+ const char *resource;
if (scroll_image_timeout_id != 0) {
g_source_remove (scroll_image_timeout_id);
@@ -177,10 +177,10 @@ setup_scroll_image (GtkWidget *widget)
}
if (double_click_state == DOUBLE_CLICK_TEST_GEGL)
- filename = GNOMECC_UI_DIR "/scroll-test-gegl.svg";
+ resource = "/org/gnome/control-center/mouse/scroll-test-gegl.svg";
else
- filename = GNOMECC_UI_DIR "/scroll-test.svg";
- gtk_image_set_from_file (GTK_IMAGE (widget), filename);
+ resource = "/org/gnome/control-center/mouse/scroll-test.svg";
+ gtk_image_set_from_resource (GTK_IMAGE (widget), resource);
if (double_click_state != DOUBLE_CLICK_TEST_GEGL)
return;
diff --git a/panels/mouse/mouse.gresource.xml b/panels/mouse/mouse.gresource.xml
new file mode 100644
index 0000000..2b3e6f7
--- /dev/null
+++ b/panels/mouse/mouse.gresource.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/control-center/mouse">
+ <file preprocess="xml-stripblanks">gnome-mouse-properties.ui</file>
+ <file preprocess="xml-stripblanks">gnome-mouse-test.ui</file>
+ <file>scroll-test.svg</file>
+ <file>scroll-test-gegl.svg</file>
+ </gresource>
+</gresources>
diff --git a/panels/mouse/test-gnome-mouse-test.c b/panels/mouse/test-gnome-mouse-test.c
index 096faca..da1bade 100644
--- a/panels/mouse/test-gnome-mouse-test.c
+++ b/panels/mouse/test-gnome-mouse-test.c
@@ -1,6 +1,7 @@
#include <config.h>
#include <gtk/gtk.h>
+#include "cc-mouse-resources.h"
#include "gnome-mouse-test.h"
static gboolean
@@ -22,10 +23,11 @@ int main (int argc, char **argv)
GError *error = NULL;
gtk_init (&argc, &argv);
+ g_resources_register (cc_mouse_get_resource ());
builder = gtk_builder_new ();
- gtk_builder_add_from_file (builder, "gnome-mouse-test.ui", &error);
+ gtk_builder_add_from_resource (builder, "/org/gnome/control-center/mouse/gnome-mouse-test.ui", &error);
if (error != NULL)
{
g_warning ("Error loading UI file: %s", error->message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]