mouse: use a GResource for GtkBuilder UI definition and icons
https://bugzilla.gnome.org/show_bug.cgi?id=691132
This commit is contained in:
parent
3b98a73b69
commit
db5aba75a1
5 changed files with 39 additions and 22 deletions
|
@ -5,13 +5,16 @@ INCLUDES = \
|
||||||
$(PANEL_CFLAGS) \
|
$(PANEL_CFLAGS) \
|
||||||
$(MOUSE_PANEL_CFLAGS) \
|
$(MOUSE_PANEL_CFLAGS) \
|
||||||
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
|
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
|
||||||
-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
|
|
||||||
-DGNOMECC_UI_DIR="\"$(uidir)\"" \
|
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
noinst_LTLIBRARIES = libmouse-properties.la
|
noinst_LTLIBRARIES = libmouse-properties.la
|
||||||
|
|
||||||
|
BUILT_SOURCES = \
|
||||||
|
cc-mouse-resources.c \
|
||||||
|
cc-mouse-resources.h
|
||||||
|
|
||||||
libmouse_properties_la_SOURCES = \
|
libmouse_properties_la_SOURCES = \
|
||||||
|
$(BUILT_SOURCES) \
|
||||||
cc-mouse-panel.c \
|
cc-mouse-panel.c \
|
||||||
cc-mouse-panel.h \
|
cc-mouse-panel.h \
|
||||||
gnome-mouse-properties.c \
|
gnome-mouse-properties.c \
|
||||||
|
@ -24,6 +27,7 @@ libmouse_properties_la_SOURCES = \
|
||||||
libmouse_properties_la_LIBADD = $(PANEL_LIBS) $(MOUSE_PANEL_LIBS)
|
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.c \
|
||||||
gnome-mouse-test.h \
|
gnome-mouse-test.h \
|
||||||
test-gnome-mouse-test.c
|
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_CPPFLAGS = $(INCLUDES)
|
||||||
test_gnome_mouse_test_LDADD = $(PANEL_LIBS) $(MOUSE_PANEL_LIBS)
|
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
|
@INTLTOOL_DESKTOP_RULE@
|
||||||
ui_DATA = \
|
|
||||||
gnome-mouse-properties.ui \
|
|
||||||
gnome-mouse-test.ui \
|
|
||||||
scroll-test-gegl.svg \
|
|
||||||
scroll-test.svg
|
|
||||||
|
|
||||||
desktopdir = $(datadir)/applications
|
desktopdir = $(datadir)/applications
|
||||||
Desktop_in_files = gnome-mouse-panel.desktop.in
|
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)
|
git commit -m "mouse: Update from gnome-settings-daemon" $(INPUTFILES)
|
||||||
|
|
||||||
CLEANFILES = $(Desktop_in_files) $(desktop_DATA)
|
CLEANFILES = $(Desktop_in_files) $(desktop_DATA)
|
||||||
EXTRA_DIST = $(ui_DATA)
|
EXTRA_DIST = $(resource_files) mouse.gresource.xml
|
||||||
|
|
||||||
-include $(top_srcdir)/git.mk
|
-include $(top_srcdir)/git.mk
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cc-mouse-panel.h"
|
#include "cc-mouse-panel.h"
|
||||||
|
#include "cc-mouse-resources.h"
|
||||||
|
|
||||||
#include "gnome-mouse-properties.h"
|
#include "gnome-mouse-properties.h"
|
||||||
#include "gnome-mouse-test.h"
|
#include "gnome-mouse-test.h"
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
@ -140,11 +142,12 @@ cc_mouse_panel_init (CcMousePanel *self)
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
priv = self->priv = MOUSE_PANEL_PRIVATE (self);
|
priv = self->priv = MOUSE_PANEL_PRIVATE (self);
|
||||||
|
g_resources_register (cc_mouse_get_resource ());
|
||||||
|
|
||||||
priv->builder = gtk_builder_new ();
|
priv->builder = gtk_builder_new ();
|
||||||
|
|
||||||
gtk_builder_add_from_file (priv->builder,
|
gtk_builder_add_from_resource (priv->builder,
|
||||||
GNOMECC_UI_DIR "/gnome-mouse-properties.ui",
|
"/org/gnome/control-center/mouse/gnome-mouse-properties.ui",
|
||||||
&error);
|
&error);
|
||||||
if (error != NULL)
|
if (error != NULL)
|
||||||
{
|
{
|
||||||
|
@ -152,8 +155,8 @@ cc_mouse_panel_init (CcMousePanel *self)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_builder_add_from_file (priv->builder,
|
gtk_builder_add_from_resource (priv->builder,
|
||||||
GNOMECC_UI_DIR "/gnome-mouse-test.ui",
|
"/org/gnome/control-center/mouse/gnome-mouse-test.ui",
|
||||||
&error);
|
&error);
|
||||||
if (error != NULL)
|
if (error != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -169,7 +169,7 @@ static void
|
||||||
setup_scroll_image (GtkWidget *widget)
|
setup_scroll_image (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
static struct test_data_t data;
|
static struct test_data_t data;
|
||||||
char *filename;
|
const char *resource;
|
||||||
|
|
||||||
if (scroll_image_timeout_id != 0) {
|
if (scroll_image_timeout_id != 0) {
|
||||||
g_source_remove (scroll_image_timeout_id);
|
g_source_remove (scroll_image_timeout_id);
|
||||||
|
@ -177,10 +177,10 @@ setup_scroll_image (GtkWidget *widget)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (double_click_state == DOUBLE_CLICK_TEST_GEGL)
|
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
|
else
|
||||||
filename = GNOMECC_UI_DIR "/scroll-test.svg";
|
resource = "/org/gnome/control-center/mouse/scroll-test.svg";
|
||||||
gtk_image_set_from_file (GTK_IMAGE (widget), filename);
|
gtk_image_set_from_resource (GTK_IMAGE (widget), resource);
|
||||||
|
|
||||||
if (double_click_state != DOUBLE_CLICK_TEST_GEGL)
|
if (double_click_state != DOUBLE_CLICK_TEST_GEGL)
|
||||||
return;
|
return;
|
||||||
|
|
9
panels/mouse/mouse.gresource.xml
Normal file
9
panels/mouse/mouse.gresource.xml
Normal file
|
@ -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>
|
|
@ -1,6 +1,7 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "cc-mouse-resources.h"
|
||||||
#include "gnome-mouse-test.h"
|
#include "gnome-mouse-test.h"
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -22,10 +23,11 @@ int main (int argc, char **argv)
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
gtk_init (&argc, &argv);
|
gtk_init (&argc, &argv);
|
||||||
|
g_resources_register (cc_mouse_get_resource ());
|
||||||
|
|
||||||
builder = gtk_builder_new ();
|
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)
|
if (error != NULL)
|
||||||
{
|
{
|
||||||
g_warning ("Error loading UI file: %s", error->message);
|
g_warning ("Error loading UI file: %s", error->message);
|
||||||
|
|
Loading…
Add table
Reference in a new issue