Expose more properties via D-Bus

Thanks to Ork for the initial patch.

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2014-01-28 18:32:07 +01:00
parent 935964bbf5
commit 76e456ef4c
2 changed files with 12 additions and 5 deletions

View File

@ -26,5 +26,7 @@
<arg type='b' name='return' direction='out' />
</method>
<property type='s' name='filename' access='read' />
<property type='u' name='pagenumber' access='read' />
<property type='u' name='numberofpages' access='read' />
</interface>
</node>

View File

@ -379,12 +379,17 @@ handle_get_property(GDBusConnection* UNUSED(connection),
ZathuraDbus* dbus = data;
private_t* priv = GET_PRIVATE(dbus);
if (priv->zathura->document == NULL) {
g_set_error(error, G_IO_ERROR, G_IO_ERROR_FAILED, "No document open.");
return NULL;
}
if (g_strcmp0(property_name, "filename") == 0) {
if (priv->zathura->document == NULL) {
g_set_error(error, G_IO_ERROR, G_IO_ERROR_FAILED, "No document open.");
} else {
return g_variant_new_string(zathura_document_get_path(priv->zathura->document));
}
return g_variant_new_string(zathura_document_get_path(priv->zathura->document));
} else if (g_strcmp0(property_name, "pagenumber") == 0) {
return g_variant_new_uint32(zathura_document_get_current_page_number(priv->zathura->document));
} else if (g_strcmp0(property_name, "numberofpages") == 0) {
return g_variant_new_uint32(zathura_document_get_number_of_pages(priv->zathura->document));
}
return NULL;