mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 21:55:59 +01:00
Load D-Bus interface XML data during runtime
We already install the XML data anyway, so there is no reason to ship it twice (once in the binary and once as a file). Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
6c86855949
commit
4ee323a89a
4 changed files with 44 additions and 22 deletions
19
Makefile
19
Makefile
|
@ -6,8 +6,7 @@ include common.mk
|
||||||
|
|
||||||
# source files
|
# source files
|
||||||
OSOURCE = $(sort $(wildcard ${PROJECT}/*.c) \
|
OSOURCE = $(sort $(wildcard ${PROJECT}/*.c) \
|
||||||
${PROJECT}/css-definitions.c \
|
${PROJECT}/css-definitions.c)
|
||||||
${PROJECT}/dbus-interface-definitions.c)
|
|
||||||
|
|
||||||
ifneq (${WITH_SQLITE},0)
|
ifneq (${WITH_SQLITE},0)
|
||||||
INCS += $(SQLITE_INC)
|
INCS += $(SQLITE_INC)
|
||||||
|
@ -43,6 +42,13 @@ endif
|
||||||
ifeq (,$(findstring -DLOCALEDIR,${CPPFLAGS}))
|
ifeq (,$(findstring -DLOCALEDIR,${CPPFLAGS}))
|
||||||
CPPFLAGS += -DLOCALEDIR=\"${LOCALEDIR}\"
|
CPPFLAGS += -DLOCALEDIR=\"${LOCALEDIR}\"
|
||||||
endif
|
endif
|
||||||
|
ifeq (,$(findstring -DDBUSINTERFACEDIR,${CPPFLAGS}))
|
||||||
|
ifneq ($(WITH_LOCAL_DBUS_XML),0)
|
||||||
|
CPPFLAGS += -DDBUSINTERFACEDIR=\"${PWD}/data\"
|
||||||
|
else
|
||||||
|
CPPFLAGS += -DDBUSINTERFACEDIR=\"${DBUSINTERFACEDIR}\"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
OBJECTS = $(addprefix ${BUILDDIR_RELEASE}/,${SOURCE:.c=.o})
|
OBJECTS = $(addprefix ${BUILDDIR_RELEASE}/,${SOURCE:.c=.o})
|
||||||
OBJECTS_DEBUG = $(addprefix ${BUILDDIR_DEBUG}/,${SOURCE:.c=.o})
|
OBJECTS_DEBUG = $(addprefix ${BUILDDIR_DEBUG}/,${SOURCE:.c=.o})
|
||||||
|
@ -78,13 +84,6 @@ ${PROJECT}/version.h: ${PROJECT}/version.h.in config.mk
|
||||||
-e 's/ZVABI/${ZATHURA_ABI_VERSION}/' ${PROJECT}/version.h.in > ${PROJECT}/version.h.tmp
|
-e 's/ZVABI/${ZATHURA_ABI_VERSION}/' ${PROJECT}/version.h.in > ${PROJECT}/version.h.tmp
|
||||||
$(QUIET)mv ${PROJECT}/version.h.tmp ${PROJECT}/version.h
|
$(QUIET)mv ${PROJECT}/version.h.tmp ${PROJECT}/version.h
|
||||||
|
|
||||||
${PROJECT}/dbus-interface-definitions.c: data/org.pwmt.zathura.xml
|
|
||||||
$(QUIET)echo '#include "dbus-interface-definitions.h"' > $@.tmp
|
|
||||||
$(QUIET)echo 'const char* DBUS_INTERFACE_XML =' >> $@.tmp
|
|
||||||
$(QUIET)sed 's/^\(.*\)$$/"\1\\n"/' data/org.pwmt.zathura.xml >> $@.tmp
|
|
||||||
$(QUIET)echo ';' >> $@.tmp
|
|
||||||
$(QUIET)mv $@.tmp $@
|
|
||||||
|
|
||||||
${PROJECT}/css-definitions.c: data/zathura.css_t
|
${PROJECT}/css-definitions.c: data/zathura.css_t
|
||||||
$(QUIET)echo '#include "css-definitions.h"' > $@.tmp
|
$(QUIET)echo '#include "css-definitions.h"' > $@.tmp
|
||||||
$(QUIET)echo 'const char* CSS_TEMPLATE_INDEX =' >> $@.tmp
|
$(QUIET)echo 'const char* CSS_TEMPLATE_INDEX =' >> $@.tmp
|
||||||
|
@ -174,8 +173,6 @@ clean:
|
||||||
${PROJECT}.pc \
|
${PROJECT}.pc \
|
||||||
${PROJECT}/version.h \
|
${PROJECT}/version.h \
|
||||||
${PROJECT}/version.h.tmp \
|
${PROJECT}/version.h.tmp \
|
||||||
${PROJECT}/dbus-interface-definitions.c \
|
|
||||||
${PROJECT}/dbus-interface-definitions.c.tmp \
|
|
||||||
${PROJECT}/css-definitions.c \
|
${PROJECT}/css-definitions.c \
|
||||||
${PROJECT}/css-definitions.c.tmp \
|
${PROJECT}/css-definitions.c.tmp \
|
||||||
$(PROJECT).info \
|
$(PROJECT).info \
|
||||||
|
|
|
@ -44,6 +44,11 @@ WITH_SYNCTEX ?= $(shell (${PKG_CONFIG} synctex && echo 1) || echo 0)
|
||||||
# To disable support for mimetype detction with libmagic set WITH_MAGIC to 0.
|
# To disable support for mimetype detction with libmagic set WITH_MAGIC to 0.
|
||||||
WITH_MAGIC ?= 1
|
WITH_MAGIC ?= 1
|
||||||
|
|
||||||
|
# use local D-Bus interface
|
||||||
|
# Enable this if the D-Bus interface XML from data should be used (useful for
|
||||||
|
# development).
|
||||||
|
WITH_LOCAL_DBUS_XML ?= 0
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
PREFIX ?= /usr
|
PREFIX ?= /usr
|
||||||
MANPREFIX ?= ${PREFIX}/share/man
|
MANPREFIX ?= ${PREFIX}/share/man
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
/* See LICENSE file for license and copyright information */
|
|
||||||
|
|
||||||
#ifndef ZATHURA_DBUS_INTERFACE_DEFINITIONS
|
|
||||||
#define ZATHURA_DBUS_INTERFACE_DEFINITIONS
|
|
||||||
|
|
||||||
const char* DBUS_INTERFACE_XML;
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,7 +1,6 @@
|
||||||
/* See LICENSE file for license and copyright information */
|
/* See LICENSE file for license and copyright information */
|
||||||
|
|
||||||
#include "dbus-interface.h"
|
#include "dbus-interface.h"
|
||||||
#include "dbus-interface-definitions.h"
|
|
||||||
#include "synctex.h"
|
#include "synctex.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "zathura.h"
|
#include "zathura.h"
|
||||||
|
@ -17,6 +16,26 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
static const char DBUS_XML_FILENAME[] = "org.pwmt.zathura.xml";
|
||||||
|
|
||||||
|
static char* load_xml_data(void)
|
||||||
|
{
|
||||||
|
#ifdef DBUSINTERFACEDIR
|
||||||
|
char* file_path = g_build_filename(DBUSINTERFACEDIR, DBUS_XML_FILENAME, NULL);
|
||||||
|
if (file_path == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
girara_debug("Loading D-Bus interface data from %s.", file_path);
|
||||||
|
char* content = girara_file_read(file_path);
|
||||||
|
g_free(file_path);
|
||||||
|
return content;
|
||||||
|
#else
|
||||||
|
girara_error("DBUSINTERFACEDIR is not defined. D-Bus interface will not be available.");
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
G_DEFINE_TYPE(ZathuraDbus, zathura_dbus, G_TYPE_OBJECT)
|
G_DEFINE_TYPE(ZathuraDbus, zathura_dbus, G_TYPE_OBJECT)
|
||||||
|
|
||||||
/* template for bus name */
|
/* template for bus name */
|
||||||
|
@ -144,9 +163,18 @@ zathura_dbus_new(zathura_t* zathura)
|
||||||
private_t* priv = GET_PRIVATE(dbus);
|
private_t* priv = GET_PRIVATE(dbus);
|
||||||
priv->zathura = zathura;
|
priv->zathura = zathura;
|
||||||
|
|
||||||
|
char* xml_data = load_xml_data();
|
||||||
|
if (xml_data == NULL)
|
||||||
|
{
|
||||||
|
girara_warning("Failed to load introspection data.");
|
||||||
|
g_object_unref(obj);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
GError* error = NULL;
|
GError* error = NULL;
|
||||||
priv->introspection_data = g_dbus_node_info_new_for_xml(DBUS_INTERFACE_XML,
|
priv->introspection_data = g_dbus_node_info_new_for_xml(xml_data, &error);
|
||||||
&error);
|
g_free(xml_data);
|
||||||
|
|
||||||
if (priv->introspection_data == NULL) {
|
if (priv->introspection_data == NULL) {
|
||||||
girara_warning("Failed to parse introspection data: %s", error->message);
|
girara_warning("Failed to parse introspection data: %s", error->message);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
|
|
Loading…
Reference in a new issue