From 22580f24bfa375ecccb54422a4aaa0292bd7209e Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 6 Sep 2020 19:24:04 +0200 Subject: [PATCH] Add DBus method to execute commands on the inputbar --- data/org.pwmt.zathura.xml | 5 +++++ zathura/dbus-interface.c | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/data/org.pwmt.zathura.xml b/data/org.pwmt.zathura.xml index 945f6b4..51ffd76 100644 --- a/data/org.pwmt.zathura.xml +++ b/data/org.pwmt.zathura.xml @@ -44,5 +44,10 @@ + + + + + diff --git a/zathura/dbus-interface.c b/zathura/dbus-interface.c index c788aa1..e7f4c5b 100644 --- a/zathura/dbus-interface.c +++ b/zathura/dbus-interface.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -379,6 +380,20 @@ handle_synctex_view(zathura_t* zathura, GVariant* parameters, g_dbus_method_invocation_return_value(invocation, result); } +static void +handle_execute_command(zathura_t* zathura, GVariant* parameters, + GDBusMethodInvocation* invocation) +{ + gchar* input = NULL; + g_variant_get(parameters, "(s)", &input); + + const bool ret = girara_command_run(zathura->ui.session, input); + g_free(input); + + GVariant* result = g_variant_new("(b)", ret); + g_dbus_method_invocation_return_value(invocation, result); +} + static void handle_method_call(GDBusConnection* UNUSED(connection), const gchar* UNUSED(sender), const gchar* object_path, @@ -402,7 +417,8 @@ handle_method_call(GDBusConnection* UNUSED(connection), { "CloseDocument", handle_close_document, false, false }, { "GotoPage", handle_goto_page, true, true }, { "HighlightRects", handle_highlight_rects, true, true }, - { "SynctexView", handle_synctex_view, true, true } + { "SynctexView", handle_synctex_view, true, true }, + { "ExecuteCommand", handle_execute_command, false, false } }; for (size_t idx = 0; idx != sizeof(handlers) / sizeof(handlers[0]); ++idx) {