- c->view = WEBKIT_WEB_VIEW(webkit_web_view_new());
- g_signal_connect(G_OBJECT(c->view), "title-changed", G_CALLBACK(titlechange), c);
- g_signal_connect(G_OBJECT(c->view), "hovering-over-link", G_CALLBACK(linkhover), c);
- g_signal_connect(G_OBJECT(c->view), "create-web-view", G_CALLBACK(createwindow), c);
- g_signal_connect(G_OBJECT(c->view), "new-window-policy-decision-requested", G_CALLBACK(decidewindow), c);
- g_signal_connect(G_OBJECT(c->view), "mime-type-policy-decision-requested", G_CALLBACK(decidedownload), c);
- g_signal_connect(G_OBJECT(c->view), "window-object-cleared", G_CALLBACK(windowobjectcleared), c);
- g_signal_connect(G_OBJECT(c->view), "notify::load-status", G_CALLBACK(loadstatuschange), c);
- g_signal_connect(G_OBJECT(c->view), "notify::progress", G_CALLBACK(progresschange), c);
- g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c);
- g_signal_connect(G_OBJECT(c->view), "button-release-event", G_CALLBACK(buttonrelease), c);
- g_signal_connect(G_OBJECT(c->view), "populate-popup", G_CALLBACK(populatepopup), c);
-
- /* Indicator */
- c->indicator = gtk_drawing_area_new();
- gtk_widget_set_size_request(c->indicator, 0, 2);
- g_signal_connect (G_OBJECT (c->indicator), "expose_event",
- G_CALLBACK (exposeindicator), c);
+ if (rv) {
+ v = WEBKIT_WEB_VIEW(
+ webkit_web_view_new_with_related_view(rv));
+ } else {
+ settings = webkit_settings_new_with_settings(
+ "auto-load-images", loadimages,
+ "default-font-size", defaultfontsize,
+ "enable-caret-browsing", enablecaretbrowsing,
+ "enable-developer-extras", enableinspector,
+ "enable-dns-prefetching", enablednsprefetching,
+ "enable-frame-flattening", enableframeflattening,
+ "enable-html5-database", enablecache,
+ "enable-html5-local-storage", enablecache,
+ "enable-javascript", enablescripts,
+ "enable-plugins", enableplugins,
+ NULL);
+ if (!(ua = getenv("SURF_USERAGENT")))
+ ua = useragent;
+ webkit_settings_set_user_agent(settings, ua);
+ /* Have a look at http://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html
+ * for more interesting settings */
+
+ contentmanager = webkit_user_content_manager_new();
+
+ context = webkit_web_context_new_with_website_data_manager(
+ webkit_website_data_manager_new(
+ "base-cache-directory", cachedir,
+ "base-data-directory", cachedir,
+ NULL));
+
+ /* rendering process model, can be a shared unique one or one for each
+ * view */
+ webkit_web_context_set_process_model(context,
+ WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
+ /* ssl */
+ webkit_web_context_set_tls_errors_policy(context, strictssl ?
+ WEBKIT_TLS_ERRORS_POLICY_FAIL : WEBKIT_TLS_ERRORS_POLICY_IGNORE);
+ /* disk cache */
+ webkit_web_context_set_cache_model(context, enablecache ?
+ WEBKIT_CACHE_MODEL_WEB_BROWSER : WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
+
+ /* Currently only works with text file to be compatible with curl */
+ webkit_cookie_manager_set_persistent_storage(
+ webkit_web_context_get_cookie_manager(context), cookiefile,
+ WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT);
+ /* cookie policy */
+ webkit_cookie_manager_set_accept_policy(
+ webkit_web_context_get_cookie_manager(context),
+ cookiepolicy_get());
+
+ g_signal_connect(G_OBJECT(context), "download-started",
+ G_CALLBACK(downloadstarted), c);
+
+ v = g_object_new(WEBKIT_TYPE_WEB_VIEW,
+ "settings", settings,
+ "user-content-manager", contentmanager,
+ "web-context", context,
+ NULL);
+ }
+
+ g_signal_connect(G_OBJECT(v),
+ "notify::title",
+ G_CALLBACK(titlechanged), c);
+ g_signal_connect(G_OBJECT(v),
+ "mouse-target-changed",
+ G_CALLBACK(mousetargetchanged), c);
+ g_signal_connect(G_OBJECT(v),
+ "permission-request",
+ G_CALLBACK(permissionrequested), c);
+ g_signal_connect(G_OBJECT(v),
+ "create",
+ G_CALLBACK(createview), c);
+ g_signal_connect(G_OBJECT(v), "ready-to-show",
+ G_CALLBACK(showview), c);
+ g_signal_connect(G_OBJECT(v),
+ "decide-policy",
+ G_CALLBACK(decidepolicy), c);
+ g_signal_connect(G_OBJECT(v),
+ "load-changed",
+ G_CALLBACK(loadchanged), c);
+ g_signal_connect(G_OBJECT(v),
+ "notify::estimated-load-progress",
+ G_CALLBACK(progresschanged), c);
+ g_signal_connect(G_OBJECT(v),
+ "button-release-event",
+ G_CALLBACK(buttonreleased), c);
+ g_signal_connect(G_OBJECT(v), "close",
+ G_CALLBACK(closeview), c);
+
+ return v;
+}
+
+void
+showview(WebKitWebView *v, Client *c)
+{
+ GdkGeometry hints = { 1, 1 };
+ GdkRGBA bgcolor = { 0 };
+ GdkWindow *gwin;
+
+ c->win = createwindow(c);
+
+ if (!kioskmode)
+ addaccelgroup(c);