-searchtext(Client *c, const Arg *arg) {
- gboolean forward = *(gboolean *)arg;
- webkit_web_view_search_text(c->view,
- gtk_entry_get_text(GTK_ENTRY(c->searchbar)),
- FALSE,
- forward,
- TRUE);
+setup(void) {
+ char *proxy;
+ char *new_proxy;
+ SoupURI *puri;
+ SoupSession *s;
+
+ /* clean up any zombies immediately */
+ sigchld(0);
+ gtk_init(NULL, NULL);
+ if (!g_thread_supported())
+ g_thread_init(NULL);
+
+ dpy = GDK_DISPLAY();
+ s = webkit_get_default_session();
+ uriprop = XInternAtom(dpy, "_SURF_URI", False);
+ findprop = XInternAtom(dpy, "_SURF_FIND", False);
+
+ /* dirs and files */
+ cookiefile = buildpath(cookiefile);
+ dldir = buildpath(dldir);
+ scriptfile = buildpath(scriptfile);
+ stylefile = buildpath(stylefile);
+
+ /* request handler */
+ s = webkit_get_default_session();
+ soup_session_remove_feature_by_type(s, soup_cookie_get_type());
+ soup_session_remove_feature_by_type(s, soup_cookie_jar_get_type());
+ g_signal_connect_after(G_OBJECT(s), "request-started", G_CALLBACK(newrequest), NULL);
+
+ /* proxy */
+ if((proxy = getenv("http_proxy")) && strcmp(proxy, "")) {
+ new_proxy = g_strrstr(proxy, "http://") ? g_strdup(proxy) :
+ g_strdup_printf("http://%s", proxy);
+
+ puri = soup_uri_new(new_proxy);
+ g_object_set(G_OBJECT(s), "proxy-uri", puri, NULL);
+ soup_uri_free(puri);
+ g_free(new_proxy);
+ }
+}
+
+void
+sigchld(int unused) {
+ if(signal(SIGCHLD, sigchld) == SIG_ERR)
+ die("Can't install SIGCHLD handler");
+ while(0 < waitpid(-1, NULL, WNOHANG));