From 074fc5a66cb9f93f00535fe6dce4542d0a4e9dc2 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 12 Oct 2017 01:00:30 -0400 Subject: mq_web_view_load_uri(): New function --- (limited to 'src') diff --git a/src/web-view.c b/src/web-view.c index 5c34694..c3eb483 100644 --- a/src/web-view.c +++ b/src/web-view.c @@ -89,7 +89,8 @@ set_property(GObject *object, guint property_id, const GValue *value, web_view->tab = g_value_get_pointer(value); break; case PROP_URI: - web_view->uri = g_value_get_string(value); + mq_web_view_load_uri(web_view, + g_value_get_string(value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, @@ -659,6 +660,29 @@ mq_web_view_new(MqTab *tab, const gchar *uri) NULL); } +void +mq_web_view_load_uri(MqWebView *web_view, const gchar *uri) +{ + gchar *rw_uri; + + /* Unlike webkit_web_view_load_uri(), allow NULL. */ + if (!uri) { + return; + } + + web_view->uri = uri; + + if (g_str_has_prefix(uri, "about:")) { + rw_uri = g_strconcat("mq-about:", uri + strlen("about:"), NULL); + webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view), rw_uri); + g_free(rw_uri); + } else { + webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view), uri); + } + + g_object_notify_by_pspec(G_OBJECT(web_view), obj_properties[PROP_URI]); +} + GtkWidget * mq_web_view_get_container(MqWebView *web_view) { diff --git a/src/web-view.h b/src/web-view.h index 36c5638..7f1de44 100644 --- a/src/web-view.h +++ b/src/web-view.h @@ -54,6 +54,9 @@ mq_web_view_get_type(void); MqWebView * mq_web_view_new(MqTab *tab, const gchar *uri); +void +mq_web_view_load_uri(MqWebView *web_view, const gchar *uri); + /* Temporary compatibility methods */ GtkWidget * -- cgit v0.9.1