From c82bc2f0d457499782d6225d715abd015c44886b Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 22 Aug 2014 20:09:32 +0200 Subject: [PATCH] Add Edit signal --- data/org.pwmt.zathura.xml | 6 ++++++ dbus-interface.c | 27 +++++++++++++++++++++++++++ dbus-interface.h | 10 ++++++++++ 3 files changed, 43 insertions(+) diff --git a/data/org.pwmt.zathura.xml b/data/org.pwmt.zathura.xml index bfa81a2..b4d2b9a 100644 --- a/data/org.pwmt.zathura.xml +++ b/data/org.pwmt.zathura.xml @@ -28,5 +28,11 @@ + + + + + + diff --git a/dbus-interface.c b/dbus-interface.c index 6f6bf61..0cee730 100644 --- a/dbus-interface.c +++ b/dbus-interface.c @@ -163,6 +163,33 @@ zathura_dbus_new(zathura_t* zathura) return dbus; } +void +zathura_dbus_edit(ZathuraDbus* edit, unsigned int page, unsigned int x, unsigned int y) { + private_t* priv = GET_PRIVATE(edit); + + const char* filename = zathura_document_get_path(priv->zathura->document); + + char* input_file = NULL; + unsigned int line = 0; + unsigned int column = 0; + + if (synctex_get_input_line_column(filename, page, x, y, &input_file, &line, + &column) == false) { + return; + } + + GError* error = NULL; + g_dbus_connection_emit_signal(priv->connection, NULL, DBUS_OBJPATH, + DBUS_INTERFACE, "Edit", g_variant_new("(suu)", input_file, x, y), &error); + + g_free(input_file); + + if (error != NULL) { + girara_debug("Failed to emit 'Edit' signal: %s", error->message); + g_error_free(error); + } +} + /* D-Bus handler */ static void diff --git a/dbus-interface.h b/dbus-interface.h index 1f5b2c5..3edc3a2 100644 --- a/dbus-interface.h +++ b/dbus-interface.h @@ -41,6 +41,16 @@ GType zathura_dbus_get_type(void); ZathuraDbus* zathura_dbus_new(zathura_t* zathura); +/** + * Emit the 'Edit' signal on the D-Bus connection. + * + * @param dbus ZathuraDbus instance + * @param page page + * @param x x coordinate + * @param y y coordinate + */ +void zathura_dbus_edit(ZathuraDbus* dbus, unsigned int page, unsigned int x, unsigned int y); + /** * Look for zathura instance having filename open and cause it to open give page * and highlight rectangles on the given page