diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-30 12:57:58 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-30 12:57:58 (EDT) |
commit | bab53ac616646ef9cda01377c4516a473c5f6582 (patch) | |
tree | 25fb643f0bf86279e5e4a1a0dfc223d477a84671 | |
parent | c7aef4e0b8290c83c4b086bc87d76e86d48dae14 (diff) | |
download | marquee-bab53ac616646ef9cda01377c4516a473c5f6582.zip marquee-bab53ac616646ef9cda01377c4516a473c5f6582.tar.gz marquee-bab53ac616646ef9cda01377c4516a473c5f6582.tar.bz2 |
mq_web_view_*_scheme_methods->match_uri(): New methods
-rw-r--r-- | src/web-view-schemes/normal.c | 9 | ||||
-rw-r--r-- | src/web-view-schemes/schemes.h | 1 | ||||
-rw-r--r-- | src/web-view-schemes/view-source.c | 7 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/web-view-schemes/normal.c b/src/web-view-schemes/normal.c index 4da54cc..0d96fea 100644 --- a/src/web-view-schemes/normal.c +++ b/src/web-view-schemes/normal.c @@ -528,6 +528,14 @@ save_html_replace_cb(GFile *file, GAsyncResult *result, guchar *data) g_free(data); } +static gboolean +match_uri(const gchar *uri) +{ + /* This is a catch-all scheme handler, so match any schemes not handled + * by another handler. */ + return !g_str_has_prefix(uri, "view-source:"); +} + static void save_html_get_data_cb(WebKitWebResource *resource, GAsyncResult *result, MqWebView *web_view) @@ -770,6 +778,7 @@ save_file(MqWebView *web_view, MqWebViewScheme *scheme) } const MqWebViewSchemeMethods mq_web_view_normal_scheme_methods = { + .match_uri = match_uri, .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 b3a5e74..1b52a9f 100644 --- a/src/web-view-schemes/schemes.h +++ b/src/web-view-schemes/schemes.h @@ -49,6 +49,7 @@ union _MqWebViewScheme { }; typedef struct { + gboolean (*match_uri) (const gchar *uri); 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 b9fb5a2..faea4d5 100644 --- a/src/web-view-schemes/view-source.c +++ b/src/web-view-schemes/view-source.c @@ -39,6 +39,12 @@ finalize(MqWebViewScheme *scheme) memset(&scheme->view_source, 0, sizeof(scheme->view_source)); } +static gboolean +match_uri(const gchar *uri) +{ + return g_str_has_prefix(uri, "view-source:"); +} + static gchar * rewrite_uri(MqWebView *web_view, MqWebViewScheme *scheme, const gchar *uri) { @@ -214,6 +220,7 @@ save_file(MqWebView *web_view, MqWebViewScheme *scheme) } const MqWebViewSchemeMethods mq_web_view_view_source_scheme_methods = { + .match_uri = match_uri, .finalize = finalize, .rewrite_uri = rewrite_uri, .display_uri = display_uri, |