From 7f41f1e9cc0c93d404e82b694d07070b46650a1d Mon Sep 17 00:00:00 2001 From: rbuj Date: Mon, 27 Jan 2020 17:53:38 +0100 Subject: Use gresources for UI files --- .travis.yml | 2 + configure.ac | 21 +++ libmatekbd/Makefile.am | 159 ++++++++++++--------- libmatekbd/matekbd-keyboard-drawing.c | 8 +- .../org.mate.peripherals.keyboard.gresource.xml | 22 +++ 5 files changed, 140 insertions(+), 72 deletions(-) create mode 100644 libmatekbd/org.mate.peripherals.keyboard.gresource.xml diff --git a/.travis.yml b/.travis.yml index 0d3db6b..d7f3a41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -87,6 +87,7 @@ requires: - libglib2.0-dev - libgtk-3-dev - libxklavier-dev + - libxml2-utils - make - mate-common @@ -118,6 +119,7 @@ requires: - libglib2.0-dev - libgtk-3-dev - libxklavier-dev + - libxml2-utils - make - mate-common diff --git a/configure.ac b/configure.ac index 9d88e77..33ef625 100644 --- a/configure.ac +++ b/configure.ac @@ -44,6 +44,27 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext package]) AM_GNU_GETTEXT_VERSION([0.19.8]) AM_GNU_GETTEXT([external]) + +# ********************** +# GLIB_COMPILE_RESOURCES +# ********************** + +AC_ARG_VAR([GLIB_COMPILE_RESOURCES],[glib-compile-resources bin]) +AC_PATH_PROG([GLIB_COMPILE_RESOURCES],[glib-compile-resources],[]) +if test -z "$GLIB_COMPILE_RESOURCES"; then + AC_MSG_ERROR([glib-compile-resources not found]) +fi + +# ******* +# XMLLINT +# ******* + +AC_ARG_VAR([XMLLINT],[xmllint bin]) +AC_PATH_PROG([XMLLINT],[xmllint],[]) +if test -z "$XMLLINT"; then + AC_MSG_ERROR([xmllint not found]) +fi + # ***************************************************************************** AC_CHECK_FUNCS(setlocale) diff --git a/libmatekbd/Makefile.am b/libmatekbd/Makefile.am index 97f0bab..77d8a5f 100644 --- a/libmatekbd/Makefile.am +++ b/libmatekbd/Makefile.am @@ -1,85 +1,105 @@ +NULL = lib_LTLIBRARIES = libmatekbd.la libmatekbdui.la -uidir = $(pkgdatadir)/ui -ui_DATA = show-layout.ui - -common_CFLAGS = \ - -I$(top_srcdir) \ - $(GDK_CFLAGS) \ - $(GIO_CFLAGS) \ - $(LIBXKLAVIER_CFLAGS) \ - $(XLIB_CFLAGS) \ - -I$(top_srcdir)/intl \ - -DG_LOG_DOMAIN=\"MateKbdIndicator\" \ - -DDATADIR=\"$(datadir)\" \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DLIBDIR=\"$(libdir)\" - -libmatekbd_la_CFLAGS = $(common_CFLAGS) - -libmatekbdui_la_CFLAGS = $(common_CFLAGS) \ - -DUIDIR=\"$(uidir)\" \ - $(GTK_CFLAGS) +common_CFLAGS = \ + -I$(top_srcdir) \ + $(GDK_CFLAGS) \ + $(GIO_CFLAGS) \ + $(LIBXKLAVIER_CFLAGS) \ + $(XLIB_CFLAGS) \ + -I$(top_srcdir)/intl \ + -DG_LOG_DOMAIN=\"MateKbdIndicator\" \ + -DDATADIR=\"$(datadir)\" \ + -DSYSCONFDIR=\"$(sysconfdir)\" \ + -DLIBDIR=\"$(libdir)\" \ + $(NULL) common_LDFLAGS = -version-info @VERSION_INFO@ -no-undefined -common_LIBADD = \ - $(GDK_LIBS) \ - $(GIO_LIBS) \ - $(LIBXKLAVIER_LIBS) \ - $(XLIB_LIBS) - -libmatekbd_la_LDFLAGS = $(common_LDFLAGS) -libmatekbd_la_LIBADD = $(common_LIBADD) - -libmatekbdui_la_LDFLAGS = $(common_LDFLAGS) -libmatekbdui_la_LIBADD = libmatekbd.la \ - $(common_LIBADD) \ - $(GLIB_LIBS) \ - $(GMODULE_LIBS) \ - $(GTK_LIBS) - -libmatekbd_la_SOURCES = \ - matekbd-desktop-config.c \ - matekbd-keyboard-config.c \ - matekbd-util.c - -libmatekbdui_la_SOURCES = \ - matekbd-indicator-config.c \ - matekbd-indicator.c \ - matekbd-status.c \ - matekbd-indicator-marshal.c \ - matekbd-keyboard-drawing-marshal.c \ - matekbd-keyboard-drawing.c - -BUILT_SOURCES = matekbd-indicator-marshal.c \ - matekbd-indicator-marshal.h \ - matekbd-keyboard-drawing-marshal.c \ - matekbd-keyboard-drawing-marshal.h +common_LIBADD = \ + $(GDK_LIBS) \ + $(GIO_LIBS) \ + $(LIBXKLAVIER_LIBS) \ + $(XLIB_LIBS) \ + $(NULL) + +libmatekbd_la_SOURCES = \ + matekbd-desktop-config.c \ + matekbd-keyboard-config.c \ + matekbd-util.c \ + $(NULL) +libmatekbd_la_CFLAGS = \ + $(common_CFLAGS) \ + $(NULL) +libmatekbd_la_LDFLAGS = \ + $(common_LDFLAGS) \ + $(NULL) +libmatekbd_la_LIBADD = \ + $(common_LIBADD) \ + $(NULL) + +libmatekbdui_la_SOURCES = \ + matekbd-indicator-config.c \ + matekbd-indicator.c \ + matekbd-status.c \ + matekbd-indicator-marshal.c \ + matekbd-keyboard-drawing-marshal.c \ + matekbd-keyboard-drawing-resources.c \ + matekbd-keyboard-drawing.c \ + $(NULL) +libmatekbdui_la_CFLAGS = \ + $(common_CFLAGS) \ + $(GTK_CFLAGS) \ + $(NULL) +libmatekbdui_la_LDFLAGS = \ + $(common_LDFLAGS) \ + $(NULL) +libmatekbdui_la_LIBADD = \ + libmatekbd.la \ + $(common_LIBADD) \ + $(GLIB_LIBS) \ + $(GMODULE_LIBS) \ + $(GTK_LIBS) \ + $(NULL) + +BUILT_SOURCES = \ + matekbd-indicator-marshal.c \ + matekbd-indicator-marshal.h \ + matekbd-keyboard-drawing-marshal.c \ + matekbd-keyboard-drawing-marshal.h \ + matekbd-keyboard-drawing-resources.c \ + matekbd-keyboard-drawing-resources.h \ + $(NULL) CLEANFILES = $(BUILT_SOURCES) matekbdincdir = $(includedir)/libmatekbd -matekbdinc_HEADERS = \ - matekbd-desktop-config.h \ - matekbd-keyboard-config.h \ - matekbd-indicator.h \ - matekbd-status.h \ - matekbd-indicator-config.h \ - matekbd-keyboard-drawing.h \ - matekbd-util.h - -noinst_HEADERS = $(extra_nih) \ - matekbd-config-private.h +matekbdinc_HEADERS = \ + matekbd-desktop-config.h \ + matekbd-keyboard-config.h \ + matekbd-indicator.h \ + matekbd-status.h \ + matekbd-indicator-config.h \ + matekbd-keyboard-drawing.h \ + matekbd-util.h \ + $(NULL) + +noinst_HEADERS = \ + $(extra_nih) \ + matekbd-config-private.h \ + $(NULL) gsettingsschema_in_files = org.mate.peripherals-keyboard-xkb.gschema.xml.in gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml) @GSETTINGS_RULES@ -EXTRA_DIST = matekbd-indicator-marshal.list \ - matekbd-keyboard-drawing-marshal.list \ - $(gsettingsschema_in_files) \ - $(ui_DATA) +EXTRA_DIST = \ + matekbd-indicator-marshal.list \ + matekbd-keyboard-drawing-marshal.list \ + $(gsettingsschema_in_files) \ + org.mate.peripherals.keyboard.gresource.xml \ + show-layout.ui \ + $(NULL) DISTCLEANFILES = $(gsettings_SCHEMAS) @@ -104,6 +124,9 @@ matekbd-keyboard-drawing-marshal.c: matekbd-keyboard-drawing-marshal.h || ( rm -f matekbd-keyboard-drawing-marshal.tmp && exit 1 ) +matekbd-keyboard-drawing-resources.h matekbd-keyboard-drawing-resources.c: org.mate.peripherals.keyboard.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir) $(srcdir)/org.mate.peripherals.keyboard.gresource.xml) + $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir) --generate --c-name matekbd $< + -include $(INTROSPECTION_MAKEFILE) INTROSPECTION_GIRS = Matekbd-1.0.gir INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --warn-all diff --git a/libmatekbd/matekbd-keyboard-drawing.c b/libmatekbd/matekbd-keyboard-drawing.c index bf280ef..4c880cc 100644 --- a/libmatekbd/matekbd-keyboard-drawing.c +++ b/libmatekbd/matekbd-keyboard-drawing.c @@ -2611,12 +2611,12 @@ matekbd_keyboard_drawing_new_dialog (gint group, gchar * group_name) XklEngine* engine = xkl_engine_get_instance(GDK_DISPLAY_XDISPLAY(gdk_display_get_default())); builder = gtk_builder_new (); - gtk_builder_add_from_file (builder, UIDIR "/show-layout.ui", - &error); + gtk_builder_add_from_resource (builder, + "/org/mate/peripherals/keyboard/show-layout.ui", + &error); if (error) { - g_error ("building ui from %s failed: %s", - UIDIR "/show-layout.ui", error->message); + g_error ("Could not load UI: %s", error->message); g_clear_error (&error); } diff --git a/libmatekbd/org.mate.peripherals.keyboard.gresource.xml b/libmatekbd/org.mate.peripherals.keyboard.gresource.xml new file mode 100644 index 0000000..58d4c9b --- /dev/null +++ b/libmatekbd/org.mate.peripherals.keyboard.gresource.xml @@ -0,0 +1,22 @@ + + + + + show-layout.ui + + -- cgit v1.2.1