Commit 0fb57ad1 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Include interface specification in resource

This commit essentially reverts
4ee323a8. We now duplicate the data
again, but loading the interface specification from somewhere else does
not make much sense, since the specification must match the actually
implemented interface.
Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent e28598a0
......@@ -36,13 +36,6 @@ endif
ifeq (,$(findstring -DLOCALEDIR,${CPPFLAGS}))
CPPFLAGS += -DLOCALEDIR=\"${LOCALEDIR}\"
endif
ifeq (,$(findstring -DDBUSINTERFACEDIR,${CPPFLAGS}))
ifneq ($(WITH_LOCAL_DBUS_XML),0)
CPPFLAGS += -DDBUSINTERFACEDIR=\"$(abspath data)\"
else
CPPFLAGS += -DDBUSINTERFACEDIR=\"${DBUSINTERFACEDIR}\"
endif
endif
SOURCE = $(filter-out $(SOURCE_FILTER),$(OSOURCE))
OBJECTS = $(addprefix ${BUILDDIR_RELEASE}/,${SOURCE:.c=.o})
......
......@@ -47,11 +47,6 @@ WITH_SYNCTEX ?= $(shell (${PKG_CONFIG} synctex && echo 1) || echo 0)
# To disable support for mimetype detction with libmagic set WITH_MAGIC to 0.
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
PREFIX ?= /usr
MANPREFIX ?= ${PREFIX}/share/man
......
......@@ -3,4 +3,7 @@
<gresource prefix="/org/pwmt/zathura/CSS">
<file compressed="true">zathura.css_t</file>
</gresource>
<gresource prefix="/org/pwmt/zathura/DBus">
<file compressed="true">org.pwmt.zathura.xml</file>
</gresource>
</gresources>
......@@ -7,6 +7,7 @@
#include "document.h"
#include "utils.h"
#include "adjustment.h"
#include "resources.h"
#include <girara/session.h>
#include <girara/utils.h>
......@@ -16,24 +17,17 @@
#include <string.h>
#include <unistd.h>
static const char DBUS_XML_FILENAME[] = "org.pwmt.zathura.xml";
static const char DBUS_XML_FILENAME[] = "/org/pwmt/zathura/DBus/org.pwmt.zathura.xml";
static char* load_xml_data(void)
static GBytes* load_xml_data(void)
{
#ifdef DBUSINTERFACEDIR
char* file_path = g_build_filename(DBUSINTERFACEDIR, DBUS_XML_FILENAME, NULL);
if (file_path == NULL) {
return NULL;
GResource* resource = zathura_resources_get_resource();
if (resource != NULL) {
return g_resource_lookup_data(resource, DBUS_XML_FILENAME,
G_RESOURCE_LOOKUP_FLAGS_NONE, 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)
......@@ -163,7 +157,7 @@ zathura_dbus_new(zathura_t* zathura)
private_t* priv = GET_PRIVATE(dbus);
priv->zathura = zathura;
char* xml_data = load_xml_data();
GBytes* xml_data = load_xml_data();
if (xml_data == NULL)
{
girara_warning("Failed to load introspection data.");
......@@ -172,8 +166,8 @@ zathura_dbus_new(zathura_t* zathura)
}
GError* error = NULL;
priv->introspection_data = g_dbus_node_info_new_for_xml(xml_data, &error);
g_free(xml_data);
priv->introspection_data = g_dbus_node_info_new_for_xml((const char*) g_bytes_get_data(xml_data, NULL), &error);
g_bytes_unref(xml_data);
if (priv->introspection_data == NULL) {
girara_warning("Failed to parse introspection data: %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