diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-29 13:49:15 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-29 13:49:15 (EDT) |
commit | 6b25c8a994a84da1b629e14cc4ce149d43da9b3a (patch) | |
tree | cebea9c88dc8037e06865bea4f85ee2b3480558c | |
parent | 1725f15bc8ce2d5a16d77f482f143ce71c196a8e (diff) | |
download | marquee-6b25c8a994a84da1b629e14cc4ce149d43da9b3a.zip marquee-6b25c8a994a84da1b629e14cc4ce149d43da9b3a.tar.gz marquee-6b25c8a994a84da1b629e14cc4ce149d43da9b3a.tar.bz2 |
MqWebView: Download responses of undisplayable MIME types
-rw-r--r-- | src/web-view.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/web-view.c b/src/web-view.c index 74c9da6..10e96a3 100644 --- a/src/web-view.c +++ b/src/web-view.c @@ -567,6 +567,38 @@ button_press_cb(GtkWidget *widget, GdkEventButton *event) return TRUE; } +static gboolean +decide_response_policy(MqWebView G_GNUC_UNUSED *web_view, + WebKitResponsePolicyDecision *decision) +{ + if (webkit_response_policy_decision_is_mime_type_supported(decision)) { + webkit_policy_decision_use(WEBKIT_POLICY_DECISION(decision)); + } else { + webkit_policy_decision_download( + WEBKIT_POLICY_DECISION(decision)); + } + return TRUE; +} + +static gboolean +decide_policy_cb(MqWebView *web_view, WebKitPolicyDecision *decision, + WebKitPolicyDecisionType decision_type) +{ + switch (decision_type) { + case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: + /* TODO */ + return FALSE; + case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: + /* TODO */ + return FALSE; + case WEBKIT_POLICY_DECISION_TYPE_RESPONSE: + return decide_response_policy(web_view, + WEBKIT_RESPONSE_POLICY_DECISION(decision)); + default: + return FALSE; + } +} + static void constructed(GObject *object) { @@ -720,6 +752,8 @@ mq_web_view_init(MqWebView *web_view) G_CALLBACK(mouse_target_changed_cb), NULL); g_signal_connect(web_view, "button-press-event", G_CALLBACK(button_press_cb), NULL); + g_signal_connect(web_view, "decide-policy", + G_CALLBACK(decide_policy_cb), NULL); } MqWebView * |