diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-12 01:54:28 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-12 01:54:28 (EDT) |
commit | a88de0922f64982eb68b400acdb4b228a17c8f71 (patch) | |
tree | 037377b28cb8bbfc6423b6596b4581b90664cbd8 /src | |
parent | 21b33162eb397020ad97ef0cc8501edff36b6b01 (diff) | |
download | marquee-a88de0922f64982eb68b400acdb4b228a17c8f71.zip marquee-a88de0922f64982eb68b400acdb4b228a17c8f71.tar.gz marquee-a88de0922f64982eb68b400acdb4b228a17c8f71.tar.bz2 |
MqWebView: Connect to WebKitWebView's "notify::uri" signal
This causes a fun infinite loop of signal emissions.
Diffstat (limited to 'src')
-rw-r--r-- | src/web-view.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/web-view.c b/src/web-view.c index 32a8958..a5f9f85 100644 --- a/src/web-view.c +++ b/src/web-view.c @@ -502,6 +502,30 @@ context_menu_cb(WebKitWebView *wk_web_view, WebKitContextMenu *context_menu, } static void +uri_cb(WebKitWebView *wk_web_view, GParamSpec G_GNUC_UNUSED *paramspec) +{ + const gchar *uri; + MqWebView *web_view; + + web_view = MQ_WEB_VIEW(wk_web_view); + + if (web_view->uri) { + g_free(web_view->uri); + } + + uri = webkit_web_view_get_uri(wk_web_view); + + if (g_str_has_prefix(uri, "mq-about:")) { + web_view->uri = g_strconcat("about:", uri + strlen("mq-about:"), + NULL); + } else { + web_view->uri = g_strdup(uri); + } + + g_object_notify_by_pspec(G_OBJECT(web_view), obj_properties[PROP_URI]); +} + +static void clipboard_text_recv_cb(GtkClipboard G_GNUC_UNUSED *clipboard, const gchar *text, MqWebView *web_view) { @@ -644,6 +668,8 @@ mq_web_view_init(MqWebView *web_view) g_signal_connect(web_view, "context-menu", G_CALLBACK(context_menu_cb), NULL); + g_signal_connect(web_view, "notify::uri", + G_CALLBACK(uri_cb), NULL); g_signal_connect(web_view, "mouse-target-changed", G_CALLBACK(mouse_target_changed_cb), NULL); g_signal_connect(web_view, "button-press-event", |