public class WebTest : Gtk.Window {
private WebKit.WebView webview;
private int external_res = 0;
private string test_doc = "
arneArne
";
private bool decide_load_policy(WebKit.WebFrame frame, WebKit.NetworkRequest req, WebKit.WebNavigationAction action, WebKit.WebPolicyDecision dec) {
dec.ignore();
stdout.printf("uri: %s\n", req.uri);
this.external_res = 1;
return true;
}
private void decide_resource_load(WebKit.WebFrame frame, WebKit.WebResource res, WebKit.NetworkRequest req, WebKit.NetworkResponse? resp) {
stdout.printf("req uri: %s\n", res.uri);
req.uri = "about:blank";
}
private void set_policy() {
this.webview.settings.enable_plugins = false;
this.webview.settings.enable_scripts = false;
this.webview.settings.enable_private_browsing = true;
this.webview.navigation_policy_decision_requested.connect(this.decide_load_policy);
this.webview.resource_request_starting.connect(this.decide_resource_load);
}
public WebTest() {
this.webview = new WebKit.WebView();
set_policy();
var scroll_window = new Gtk.ScrolledWindow(null, null);
scroll_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
scroll_window.add(this.webview);
this.title = "Webtest";
this.add(scroll_window);
this.show_all();
this.webview.load_string(this.test_doc, "text/html", "utf-8", "");
// this.webview.open("http://google.se");
this.destroy.connect(Gtk.main_quit);
}
}
class Demo.HelloWorld : GLib.Object {
public static int main(string[] args) {
Gtk.init(ref args);
var webtest = new WebTest();
Gtk.main();
return 0;
}
}