Commit 22580f24 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Add DBus method to execute commands on the inputbar

parent dc5ade9a
Pipeline #316 failed with stages
in 1 minute and 20 seconds
...@@ -44,5 +44,10 @@ ...@@ -44,5 +44,10 @@
<arg type='u' name='column' direction='in' /> <arg type='u' name='column' direction='in' />
<arg type='b' name='return' direction='out' /> <arg type='b' name='return' direction='out' />
</method> </method>
<!-- Execute a command as if entered in the inputbar. -->
<method name='ExecuteCommand'>
<arg type='s' name='input' direction='in' />
<arg type='b' name='return' direction='out' />
</method>
</interface> </interface>
</node> </node>
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <girara/session.h> #include <girara/session.h>
#include <girara/utils.h> #include <girara/utils.h>
#include <girara/settings.h> #include <girara/settings.h>
#include <girara/commands.h>
#include <gio/gio.h> #include <gio/gio.h>
#include <sys/types.h> #include <sys/types.h>
#include <string.h> #include <string.h>
...@@ -379,6 +380,20 @@ handle_synctex_view(zathura_t* zathura, GVariant* parameters, ...@@ -379,6 +380,20 @@ handle_synctex_view(zathura_t* zathura, GVariant* parameters,
g_dbus_method_invocation_return_value(invocation, result); 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 static void
handle_method_call(GDBusConnection* UNUSED(connection), handle_method_call(GDBusConnection* UNUSED(connection),
const gchar* UNUSED(sender), const gchar* object_path, const gchar* UNUSED(sender), const gchar* object_path,
...@@ -402,7 +417,8 @@ handle_method_call(GDBusConnection* UNUSED(connection), ...@@ -402,7 +417,8 @@ handle_method_call(GDBusConnection* UNUSED(connection),
{ "CloseDocument", handle_close_document, false, false }, { "CloseDocument", handle_close_document, false, false },
{ "GotoPage", handle_goto_page, true, true }, { "GotoPage", handle_goto_page, true, true },
{ "HighlightRects", handle_highlight_rects, 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) { for (size_t idx = 0; idx != sizeof(handlers) / sizeof(handlers[0]); ++idx) {
......
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