- /* Webview */
- c->view = WEBKIT_WEB_VIEW(webkit_web_view_new());
-
- g_signal_connect(G_OBJECT(c->view),
- "notify::title",
- 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),
- "geolocation-policy-decision-requested",
- G_CALLBACK(geopolicyrequested), 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),
- "context-menu",
- G_CALLBACK(contextmenu), c);
- g_signal_connect(G_OBJECT(c->view),
- "resource-request-starting",
- G_CALLBACK(beforerequest), c);
- g_signal_connect(G_OBJECT(c->view),
- "should-show-delete-interface-for-element",
- G_CALLBACK(deletion_interface), c);
-
- /* Arranging */
- gtk_container_add(GTK_CONTAINER(c->win), GTK_WIDGET(c->view));
-
- /* Setup */
- gtk_widget_grab_focus(GTK_WIDGET(c->view));
- gtk_widget_show(GTK_WIDGET(c->view));
- gtk_widget_show(c->win);
- gwin = gtk_widget_get_window(GTK_WIDGET(c->win));
- c->xid = gdk_x11_window_get_xid(gwin);
- gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints,
- GDK_HINT_MIN_SIZE);
- gdk_window_set_events(gwin, GDK_ALL_EVENTS_MASK);
- gdk_window_add_filter(gwin, processx, c);
- webkit_web_view_set_full_content_zoom(c->view, TRUE);
-
- runscript(frame);
-
- settings = webkit_web_view_get_settings(c->view);
- if (!(ua = getenv("SURF_USERAGENT")))
- ua = useragent;
- g_object_set(G_OBJECT(settings), "user-agent", ua, NULL);
- g_object_set(G_OBJECT(settings),
- "auto-load-images", loadimages, NULL);
- g_object_set(G_OBJECT(settings),
- "enable-plugins", enableplugins, NULL);
- g_object_set(G_OBJECT(settings),
- "enable-scripts", enablescripts, NULL);
- g_object_set(G_OBJECT(settings),
- "enable-spatial-navigation", enablespatialbrowsing, NULL);
- g_object_set(G_OBJECT(settings),
- "enable-developer-extras", enableinspector, NULL);
- g_object_set(G_OBJECT(settings),
- "enable-default-context-menu", kioskmode ^ 1, NULL);
- g_object_set(G_OBJECT(settings),
- "default-font-size", defaultfontsize, NULL);
- g_object_set(G_OBJECT(settings),
- "resizable-text-areas", 1, NULL);
- if (enablestyle)
- setstyle(c, getstyle("about:blank"));
-
- /* This might conflict with _zoomto96dpi_. */
- if (zoomlevel != 1.0)
- webkit_web_view_set_zoom_level(c->view, zoomlevel);
-
- if (enableinspector) {
- c->inspector = webkit_web_view_get_inspector(c->view);
- g_signal_connect(G_OBJECT(c->inspector), "inspect-web-view",
- G_CALLBACK(inspector_new), c);
- g_signal_connect(G_OBJECT(c->inspector), "show-window",
- G_CALLBACK(inspector_show), c);
- g_signal_connect(G_OBJECT(c->inspector), "close-window",
- G_CALLBACK(inspector_close), c);
- g_signal_connect(G_OBJECT(c->inspector), "finished",
- G_CALLBACK(inspector_finished), c);
- c->isinspecting = false;
+ g_signal_connect(G_OBJECT(v), "notify::estimated-load-progress",
+ G_CALLBACK(progresschanged), c);
+ g_signal_connect(G_OBJECT(v), "notify::title",
+ G_CALLBACK(titlechanged), 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);
+ g_signal_connect(G_OBJECT(v), "create",
+ G_CALLBACK(createview), c);
+ g_signal_connect(G_OBJECT(v), "decide-policy",
+ G_CALLBACK(decidepolicy), c);
+ g_signal_connect(G_OBJECT(v), "insecure-content-detected",
+ G_CALLBACK(insecurecontent), c);
+ g_signal_connect(G_OBJECT(v), "load-failed-with-tls-errors",
+ G_CALLBACK(loadfailedtls), c);
+ g_signal_connect(G_OBJECT(v), "load-changed",
+ G_CALLBACK(loadchanged), 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), "ready-to-show",
+ G_CALLBACK(showview), c);
+ g_signal_connect(G_OBJECT(v), "web-process-terminated",
+ G_CALLBACK(webprocessterminated), c);
+
+ return v;
+}
+
+static gboolean
+readpipe(GIOChannel *s, GIOCondition ioc, gpointer unused)
+{
+ static char msg[MSGBUFSZ], msgsz;
+ GError *gerr = NULL;
+
+ if (g_io_channel_read_chars(s, msg, sizeof(msg), NULL, &gerr) !=
+ G_IO_STATUS_NORMAL) {
+ fprintf(stderr, "surf: error reading pipe: %s\n",
+ gerr->message);
+ g_error_free(gerr);
+ return TRUE;
+ }
+ if ((msgsz = msg[0]) < 3) {
+ fprintf(stderr, "surf: message too short: %d\n", msgsz);
+ return TRUE;