diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-09-29 04:22:28 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-09-29 04:37:04 (EDT) |
commit | bdbcce6141fdf67a1bd1a9015b683eec8954b11d (patch) | |
tree | f01b73d07dc9f39f09480240f22fef32cf4ab72f | |
parent | 3c0f92a0fddfc9c3d8d30c83e010073db1fdb22c (diff) | |
download | marquee-bdbcce6141fdf67a1bd1a9015b683eec8954b11d.zip marquee-bdbcce6141fdf67a1bd1a9015b683eec8954b11d.tar.gz marquee-bdbcce6141fdf67a1bd1a9015b683eec8954b11d.tar.bz2 |
MqTabBody: Try to rewrite "about:" URIs
-rw-r--r-- | src/tab-body.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tab-body.c b/src/tab-body.c index 4f46a9e..46d655c 100644 --- a/src/tab-body.c +++ b/src/tab-body.c @@ -20,6 +20,7 @@ */ #include <stdlib.h> +#include <string.h> #include <gtk/gtk.h> #include <webkit2/webkit2.h> @@ -469,6 +470,25 @@ button_press_cb(WebKitWebView __attribute__((unused)) *web_view, return TRUE; } +static void +resource_load_started_cb(WebKitWebView *web_view, + WebKitWebResource __attribute__((unused)) *resource, + WebKitURIRequest *request) +{ + const gchar *uri; + gchar *rw_uri; + + uri = webkit_uri_request_get_uri(request); + g_print("resource-load-started, uri = %s\n", uri); + + if (g_str_has_prefix(uri, "about:")) { + rw_uri = g_strconcat("mq-about:", uri + strlen("about:"), NULL); + webkit_uri_request_set_uri(request, rw_uri); + g_free(rw_uri); + webkit_web_view_load_request(web_view, request); + } +} + MqTabBody * mq_tab_body_new(MqTab *tab, const gchar *uri) { @@ -494,6 +514,8 @@ mq_tab_body_new(MqTab *tab, const gchar *uri) G_CALLBACK(mouse_target_changed_cb), body); g_signal_connect(body->web_view, "button-press-event", G_CALLBACK(button_press_cb), body); + g_signal_connect(body->web_view, "resource-load-started", + G_CALLBACK(resource_load_started_cb), NULL); return body; } |