commit: 481263d1730ef0c48a0fe56cf1838f44fe42021a
parent: d4cc6ec8531884c590614c6145d7404604b7010e
author: Chris Noxz <chris@noxz.tech>
date: Fri, 17 Mar 2023 16:29:59 +0100
add keybinding to toggle inspector
2 files changed, 18 insertions(+)
diff --git a/browser.c b/browser.c
@@ -385,6 +385,9 @@ key_common(struct Client *c, GdkEventKey *event)
case GDK_KEY_r: /* reload, while bypassing cache */
webkit_web_view_reload_bypass_cache(WEBKIT_WEB_VIEW(c->wv));
return TRUE;
+ case GDK_KEY_i:
+ toggle_inspector(c);
+ return TRUE;
case GDK_KEY_o: /* focus entry */
gtk_widget_grab_focus(c->entry);
return TRUE;
@@ -1058,6 +1061,20 @@ show_web_view(struct Client *c)
}
}
+void
+toggle_inspector(struct Client *c)
+{
+ WebKitWebInspector *i;
+
+ i = webkit_web_view_get_inspector(WEBKIT_WEB_VIEW(c->wv));
+
+ /* assumes that the inspector has not been detached by the user */
+ if (webkit_web_inspector_is_attached(i))
+ webkit_web_inspector_close(i);
+ else
+ webkit_web_inspector_show(i);
+}
+
void
toggle_tls_error_policy(struct Client *c)
{
diff --git a/browser.h b/browser.h
@@ -220,6 +220,7 @@ static void set_hover_uri(struct Client *, WebKitHitTestResult *);
static void set_javascript_policy(struct Client *, enum javascript_policy);
static void set_window_title(gint);
static void show_web_view(struct Client *);
+static void toggle_inspector(struct Client *);
static void toggle_tls_error_policy(struct Client *);
static gchar *resolve_uri(const gchar *);
static void update_download_button(WebKitDownload *, GtkButton *, gboolean);