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

mouse: use a GResource for GtkBuilder UI definition and icons

https://bugzilla.gnome.org/show_bug.cgi?id=691132
parent 3b98a73b
......@@ -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
......@@ -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);
......
......@@ -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;
......
<?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>
#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);
......
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