- view = WEBKIT_WEB_VIEW(webkit_web_view_new());
- gtk_container_add(GTK_CONTAINER(browser), GTK_WIDGET(view));
-
- g_signal_connect(G_OBJECT(view), "title-changed", G_CALLBACK(titlechange), view);
- g_signal_connect(G_OBJECT(view), "load-progress-changed", G_CALLBACK(progresschange), view);
- g_signal_connect(G_OBJECT(view), "load-committed", G_CALLBACK(loadcommit), view);
- g_signal_connect(G_OBJECT(view), "load-started", G_CALLBACK(loadstart), view);
- g_signal_connect(G_OBJECT(view), "load-finished", G_CALLBACK(loadfinish), view);
- g_signal_connect(G_OBJECT(view), "hovering-over-link", G_CALLBACK(linkhover), view);
- g_signal_connect(G_OBJECT(view), "new-window-policy-decision-requested", G_CALLBACK(newwindow), view);
- g_signal_connect(G_OBJECT(view), "download-requested", G_CALLBACK(download), view);
- /* g_signal_connect(G_OBJECT(view), "create-web-view", G_CALLBACK(createwebview), view); */
-
- gtk_container_add(GTK_CONTAINER(win), browser);
- gtk_widget_grab_focus(GTK_WIDGET(view));
- gtk_widget_show_all(win);
+
+ /* Webview */
+ 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);
+
+ /* 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);
+
+ /* Arranging */
+ gtk_container_add(GTK_CONTAINER(c->scroll), GTK_WIDGET(c->view));
+ gtk_container_add(GTK_CONTAINER(c->win), c->vbox);
+ gtk_container_add(GTK_CONTAINER(c->vbox), c->scroll);
+ gtk_container_add(GTK_CONTAINER(c->vbox), c->indicator);
+
+ /* Setup */
+ gtk_box_set_child_packing(GTK_BOX(c->vbox), c->indicator, FALSE, FALSE, 0, GTK_PACK_START);
+ gtk_box_set_child_packing(GTK_BOX(c->vbox), c->scroll, TRUE, TRUE, 0, GTK_PACK_START);
+ gtk_widget_grab_focus(GTK_WIDGET(c->view));
+ gtk_widget_show(c->vbox);
+ gtk_widget_show(c->indicator);
+ gtk_widget_show(c->scroll);
+ gtk_widget_show(GTK_WIDGET(c->view));
+ gtk_widget_show(c->win);
+ gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints, GDK_HINT_MIN_SIZE);
+ gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK);
+ gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
+ webkit_web_view_set_full_content_zoom(c->view, TRUE);
+ frame = webkit_web_view_get_main_frame(c->view);
+ runscript(frame, webkit_web_frame_get_global_context(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);
+ uri = g_strconcat("file://", stylefile, NULL);
+ g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL);
+ g_object_set(G_OBJECT(settings), "auto-load-images", loadimage, NULL);
+ g_object_set(G_OBJECT(settings), "enable-plugins", plugin, NULL);
+ g_object_set(G_OBJECT(settings), "enable-scripts", script, NULL);
+ g_object_set(G_OBJECT(settings), "enable-spatial-navigation", true, NULL);
+
+ g_free(uri);
+
+ setatom(c, AtomFind, "");
+ setatom(c, AtomUri, "about:blank");
+ if(NOBACKGROUND)
+ webkit_web_view_set_transparent(c->view, TRUE);
+
+ c->title = NULL;
+ c->next = clients;
+ clients = c;
+ if(showxid) {
+ gdk_display_sync(gtk_widget_get_display(c->win));
+ printf("%u\n", (guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
+ fflush(NULL);
+ }
+ return c;
+}
+
+void
+newrequest(SoupSession *s, SoupMessage *msg, gpointer v) {
+ SoupMessageHeaders *h = msg->request_headers;
+ SoupURI *uri;
+ const char *c;
+
+ soup_message_headers_remove(h, "Cookie");
+ uri = soup_message_get_uri(msg);
+ if((c = getcookies(uri)))
+ soup_message_headers_append(h, "Cookie", c);
+ g_signal_connect_after(G_OBJECT(msg), "got-headers", G_CALLBACK(gotheaders), NULL);
+}
+
+void
+newwindow(Client *c, const Arg *arg) {
+ guint i = 0;
+ const char *cmd[10], *uri;
+ const Arg a = { .v = (void *)cmd };
+ char tmp[64];
+
+ cmd[i++] = progname;
+ if(embed) {
+ cmd[i++] = "-e";
+ snprintf(tmp, LENGTH(tmp), "%u\n", (int)embed);
+ cmd[i++] = tmp;
+ }
+ if(!script)
+ cmd[i++] = "-s";
+ if(!plugin)
+ cmd[i++] = "-p";
+ if(!loadimage)
+ cmd[i++] = "-i";