summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-30 15:47:50 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-30 15:52:46 (EDT)
commite6296ec527b7cd3b9de0197cf48cbfb590a26fd7 (patch)
treee54a005503892fca6f559451cccd59447227032d /src
parent8b7a38c4c58df7cdc5de4daf0991ae794eb1b96d (diff)
downloadmarquee-e6296ec527b7cd3b9de0197cf48cbfb590a26fd7.zip
marquee-e6296ec527b7cd3b9de0197cf48cbfb590a26fd7.tar.gz
marquee-e6296ec527b7cd3b9de0197cf48cbfb590a26fd7.tar.bz2
MqWebView: Connect scheme ready callback
Diffstat (limited to 'src')
-rw-r--r--src/web-view.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/src/web-view.c b/src/web-view.c
index f688cf5..91ead87 100644
--- a/src/web-view.c
+++ b/src/web-view.c
@@ -60,6 +60,32 @@ struct _MqWebViewClass {
G_DEFINE_TYPE(MqWebView, mq_web_view, WEBKIT_TYPE_WEB_VIEW)
+static void
+ready_cb(MqWebViewScheme *scheme, MqWebView *web_view)
+{
+ gchar *rw_uri;
+ gchar *new_tab_page;
+
+ if (web_view->uri) {
+ rw_uri = web_view->scheme_methods->rewrite_uri(
+ web_view, scheme, web_view->uri);
+ webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view), rw_uri);
+ g_free(rw_uri);
+ } else {
+ new_tab_page = mq_config_get_string(web_view->config,
+ "tabs.new");
+ if (g_strcmp0(new_tab_page, "home") == 0) {
+ webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view),
+ mq_config_get_string(web_view->config,
+ "tabs.home"));
+ } else if (g_strcmp0(new_tab_page, "blank") == 0) {
+ /* Don't load any URI. */
+ } else {
+ g_assert_not_reached();
+ }
+ }
+}
+
static gboolean
context_menu_cb(MqWebView *web_view, WebKitContextMenu *context_menu,
GdkEvent *event, WebKitHitTestResult *hit_test_result)
@@ -189,8 +215,6 @@ static void
constructed(GObject *object)
{
MqWebView *web_view;
- gchar *rw_uri;
- gchar *new_tab_page;
if (G_OBJECT_CLASS(mq_web_view_parent_class)->constructed) {
G_OBJECT_CLASS(mq_web_view_parent_class)->constructed(object);
@@ -205,24 +229,8 @@ constructed(GObject *object)
mq_application_get_webkit_settings(
mq_tab_page_get_application(web_view->tab_page)));
- if (web_view->uri) {
- rw_uri = web_view->scheme_methods->rewrite_uri(
- web_view, &web_view->scheme, web_view->uri);
- webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view), rw_uri);
- g_free(rw_uri);
- } else {
- new_tab_page = mq_config_get_string(web_view->config,
- "tabs.new");
- if (g_strcmp0(new_tab_page, "home") == 0) {
- webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web_view),
- mq_config_get_string(web_view->config,
- "tabs.home"));
- } else if (g_strcmp0(new_tab_page, "blank") == 0) {
- /* Don't load any URI. */
- } else {
- g_assert_not_reached();
- }
- }
+ mq_web_view_scheme_set_methods(&web_view->scheme_methods,
+ &web_view->scheme, web_view->uri);
mq_web_view_zoom_reset(web_view);
@@ -324,6 +332,8 @@ mq_web_view_init(MqWebView *web_view)
{
web_view->hit_test_result = NULL;
+ mq_web_view_scheme_connect_ready_callback(&web_view->scheme, ready_cb);
+
g_signal_connect(web_view, "context-menu",
G_CALLBACK(context_menu_cb), NULL);
g_signal_connect(web_view, "notify::uri",