From 6a4fb1c24d8bdb2c17ddb153c95f899f6bb339c4 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Mon, 30 Oct 2017 15:09:32 -0400 Subject: mq_web_view_*_scheme_methods->initialize(): New methods --- diff --git a/src/web-view-schemes/normal.c b/src/web-view-schemes/normal.c index 9b64b5d..5641a9c 100644 --- a/src/web-view-schemes/normal.c +++ b/src/web-view-schemes/normal.c @@ -41,6 +41,12 @@ match_uri(const gchar *uri) } static void +initialize(MqWebView G_GNUC_UNUSED *web_view, + MqWebViewScheme G_GNUC_UNUSED *scheme, const gchar G_GNUC_UNUSED *uri) +{ +} + +static void finalize(MqWebViewScheme *scheme) { memset(&scheme->normal, 0, sizeof(scheme->normal)); @@ -779,6 +785,7 @@ save_file(MqWebView *web_view, MqWebViewScheme *scheme) MqWebViewSchemeMethods mq_web_view_normal_scheme_methods = { .match_uri = match_uri, + .initialize = initialize, .finalize = finalize, .rewrite_uri = rewrite_uri, .display_uri = display_uri, diff --git a/src/web-view-schemes/schemes.h b/src/web-view-schemes/schemes.h index 555f30b..e6f82d4 100644 --- a/src/web-view-schemes/schemes.h +++ b/src/web-view-schemes/schemes.h @@ -50,6 +50,7 @@ union _MqWebViewScheme { typedef struct { gboolean (*match_uri) (const gchar *uri); + void (*initialize) (MqWebView *, MqWebViewScheme *, const gchar *); void (*finalize) (MqWebViewScheme *); gchar * (*rewrite_uri) (MqWebView *, MqWebViewScheme *, const gchar *); gchar * (*display_uri) (MqWebView *, MqWebViewScheme *, const gchar *); diff --git a/src/web-view-schemes/view-source.c b/src/web-view-schemes/view-source.c index 7ed062d..a654e5d 100644 --- a/src/web-view-schemes/view-source.c +++ b/src/web-view-schemes/view-source.c @@ -40,13 +40,7 @@ match_uri(const gchar *uri) } static void -finalize(MqWebViewScheme *scheme) -{ - memset(&scheme->view_source, 0, sizeof(scheme->view_source)); -} - -static gchar * -rewrite_uri(MqWebView *web_view, MqWebViewScheme *scheme, const gchar *uri) +initialize(MqWebView *web_view, MqWebViewScheme *scheme, const gchar *uri) { MqTabPage *origin_tab; @@ -65,8 +59,18 @@ rewrite_uri(MqWebView *web_view, MqWebViewScheme *scheme, const gchar *uri) scheme->view_source.uri = mq_web_view_get_uri( mq_tab_page_get_web_view(origin_tab)); /* TODO: Get data. */ +} + +static void +finalize(MqWebViewScheme *scheme) +{ + memset(&scheme->view_source, 0, sizeof(scheme->view_source)); +} - /* Rewrite URI. */ +static gchar * +rewrite_uri(MqWebView *web_view, MqWebViewScheme G_GNUC_UNUSED *scheme, + const gchar G_GNUC_UNUSED *uri) +{ return g_strdup_printf("view-source:view-tab=%" PRId64, mq_tab_page_get_id(mq_web_view_get_tab_page(web_view))); } @@ -221,6 +225,7 @@ save_file(MqWebView *web_view, MqWebViewScheme *scheme) MqWebViewSchemeMethods mq_web_view_view_source_scheme_methods = { .match_uri = match_uri, + .initialize = initialize, .finalize = finalize, .rewrite_uri = rewrite_uri, .display_uri = display_uri, -- cgit v0.9.1