Added command 'inspect' to open the web inspector.
authorDaniel Carl <danielcarl@gmx.de>
Sat, 1 Dec 2012 13:47:15 +0000 (14:47 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 1 Dec 2012 13:47:15 +0000 (14:47 +0100)
src/command.c
src/command.h

index b09e368..e1c7bb0 100644 (file)
@@ -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;
+    }
+}
index 1f10a49..8d8d569 100644 (file)
@@ -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 */