From 5a8b8d77415780ef63817fd9dda857de4079314d Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Sat, 1 Dec 2012 14:47:15 +0100 Subject: [PATCH] Added command 'inspect' to open the web inspector. --- src/command.c | 17 +++++++++++++++++ src/command.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/command.c b/src/command.c index b09e368..e1c7bb0 100644 --- a/src/command.c +++ b/src/command.c @@ -61,6 +61,7 @@ static CommandInfo cmd_list[] = { {"set", command_set, {0}, VP_MODE_NORMAL}, {"complete", command_complete, {0}, VP_MODE_COMMAND | VP_MODE_COMPLETE}, {"complete-back", command_complete, {1}, VP_MODE_COMMAND | VP_MODE_COMPLETE}, + {"inspect", command_inspect, {0}, VP_MODE_NORMAL}, }; void command_init(void) @@ -256,3 +257,19 @@ gboolean command_complete(const Arg* arg) return TRUE; } + +gboolean command_inspect(const Arg* arg) +{ + gboolean enabled; + WebKitWebSettings* settings = NULL; + + settings = webkit_web_view_get_settings(vp.gui.webview); + g_object_get(G_OBJECT(settings), "enable-developer-extras", &enabled, NULL); + if (enabled) { + webkit_web_inspector_show(vp.gui.inspector); + return TRUE; + } else { + vp_echo(VP_MSG_ERROR, TRUE, "enable-developer-extras not enabled"); + return FALSE; + } +} diff --git a/src/command.h b/src/command.h index 1f10a49..8d8d569 100644 --- a/src/command.h +++ b/src/command.h @@ -45,5 +45,6 @@ gboolean command_map(const Arg* arg); gboolean command_unmap(const Arg* arg); gboolean command_set(const Arg* arg); gboolean command_complete(const Arg* arg); +gboolean command_inspect(const Arg* arg); #endif /* end of include guard: COMMAND_H */ -- 2.20.1