mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-28 22:54:55 +01:00
Add DBus method to execute commands on the inputbar
This commit is contained in:
parent
dc5ade9aeb
commit
22580f24bf
2 changed files with 22 additions and 1 deletions
|
@ -44,5 +44,10 @@
|
|||
<arg type='u' name='column' direction='in' />
|
||||
<arg type='b' name='return' direction='out' />
|
||||
</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>
|
||||
</node>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <girara/session.h>
|
||||
#include <girara/utils.h>
|
||||
#include <girara/settings.h>
|
||||
#include <girara/commands.h>
|
||||
#include <gio/gio.h>
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue