+static void
+togglestyle(Client *c, const Arg *arg) {
+ WebKitWebSettings *settings = webkit_web_view_get_settings(c->view);
+ char *uri;
+
+ g_object_get(G_OBJECT(settings), "user-stylesheet-uri", &uri, NULL);
+ if(stylefile == NULL && enablestyles) {
+ uri = (uri && uri[0])? g_strdup("") : getstyle(geturi(c));
+ } else {
+ uri = uri[0]? g_strdup("") : g_strconcat("file://",
+ stylefile, NULL);
+ }
+ g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL);
+
+ updatetitle(c);
+}
+
+static void
+gettogglestat(Client *c){
+ gboolean value;
+ char *uri;
+ int p = 0;
+ WebKitWebSettings *settings = webkit_web_view_get_settings(c->view);
+
+ togglestat[p++] = cookiepolicy_set(cookiepolicy_get());
+
+ g_object_get(G_OBJECT(settings), "enable-caret-browsing",
+ &value, NULL);
+ togglestat[p++] = value? 'C': 'c';
+
+ togglestat[p++] = allowgeolocation? 'G': 'g';
+
+ g_object_get(G_OBJECT(settings), "auto-load-images", &value, NULL);
+ togglestat[p++] = value? 'I': 'i';
+
+ g_object_get(G_OBJECT(settings), "enable-scripts", &value, NULL);
+ togglestat[p++] = value? 'S': 's';
+
+ g_object_get(G_OBJECT(settings), "enable-plugins", &value, NULL);
+ togglestat[p++] = value? 'V': 'v';
+
+ g_object_get(G_OBJECT(settings), "user-stylesheet-uri", &uri, NULL);
+ togglestat[p++] = (uri && uri[0]) ? 'M': 'm';
+
+ togglestat[p] = '\0';
+}
+
+static void
+getpagestat(Client *c) {
+ const char *uri = geturi(c);
+
+ if(strstr(uri, "https://") == uri) {
+ pagestat[0] = c->sslfailed ? 'U' : 'T';
+ } else {
+ pagestat[0] = '-';
+ }
+
+ pagestat[1] = usingproxy ? 'P' : '-';
+ pagestat[2] = '\0';
+
+}
+
+static void
+updatetitle(Client *c) {
+ char *t;
+
+ if(showindicators) {
+ gettogglestat(c);
+ getpagestat(c);
+
+ if(c->linkhover) {
+ t = g_strdup_printf("%s:%s | %s", togglestat,
+ pagestat, c->linkhover);
+ } else if(c->progress != 100) {
+ t = g_strdup_printf("[%i%%] %s:%s | %s", c->progress,
+ togglestat, pagestat,
+ (c->title == NULL)? "" : c->title);
+ } else {
+ t = g_strdup_printf("%s:%s | %s", togglestat, pagestat,
+ (c->title == NULL)? "" : c->title);
+ }
+
+ gtk_window_set_title(GTK_WINDOW(c->win), t);
+ g_free(t);
+ } else {
+ gtk_window_set_title(GTK_WINDOW(c->win),
+ (c->title == NULL)? "" : c->title);
+ }
+}
+
+static void
+updatewinid(Client *c) {
+ snprintf(winid, LENGTH(winid), "%u",
+ (int)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
+}
+
+static void
+usage(void) {
+ die("usage: %s [-bBfFgGiIkKnNpPsSvx]"
+ " [-a cookiepolicies ] "
+ " [-c cookiefile] [-e xid] [-r scriptfile]"
+ " [-t stylefile] [-u useragent] [-z zoomlevel]"
+ " [uri]\n", basename(argv0));
+}
+
+static void
+windowobjectcleared(GtkWidget *w, WebKitWebFrame *frame, JSContextRef js,
+ JSObjectRef win, Client *c) {
+ runscript(frame);
+}
+
+static void