X-Git-Url: https://git.danieliu.xyz/?p=surf.git;a=blobdiff_plain;f=surf.c;h=16ec39881eabcaef8b1167c4f2d136e030b88e51;hp=52d9cddfa5a66d1b09db2a54bcf7e79688074d41;hb=e6cefa584e605b8a9984b1a542098df1191adcb1;hpb=84611a5d29d9522fab954625349e5c5ee5572abb diff --git a/surf.c b/surf.c index 52d9cdd..16ec398 100644 --- a/surf.c +++ b/surf.c @@ -107,8 +107,8 @@ static Client *clients = NULL; static Window embed = 0; static gboolean showxid = FALSE; static char winid[64]; -static char togglestat[9]; -static char pagestat[3]; +static char togglestats[10]; +static char pagestats[2]; static GTlsDatabase *tlsdb; static int cookiepolicy; static char *stylefile = NULL; @@ -142,8 +142,8 @@ static void togglefullscreen(Client *c, const Arg *a); static gboolean permissionrequested(WebKitWebView *v, WebKitPermissionRequest *r, Client *c); static const char *getatom(Client *c, int a); -static void gettogglestat(Client *c); -static void getpagestat(Client *c); +static void gettogglestats(Client *c); +static void getpagestats(Client *c); static char *geturi(Client *c); static const gchar *getstyle(const char *uri); static void setstyle(Client *c, const char *stylefile); @@ -1389,72 +1389,52 @@ togglestyle(Client *c, const Arg *arg) } void -gettogglestat(Client *c) +gettogglestats(Client *c) { - gboolean value; - 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'; - - togglestat[p++] = enablecache? 'D': 'd'; - - 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'; - - togglestat[p++] = enablestyle ? 'M': 'm'; - - togglestat[p] = '\0'; + togglestats[0] = cookiepolicy_set(cookiepolicy_get()); + togglestats[1] = enablecaretbrowsing ? 'C' : 'c'; + togglestats[2] = allowgeolocation ? 'G' : 'g'; + togglestats[3] = enablecache ? 'D' : 'd'; + togglestats[4] = loadimages ? 'I' : 'i'; + togglestats[5] = enablescripts ? 'S': 's'; + togglestats[6] = enableplugins ? 'V' : 'v'; + togglestats[7] = enablestyle ? 'M' : 'm'; + togglestats[8] = enableframeflattening ? 'F' : 'f'; + togglestats[9] = '\0'; } void -getpagestat(Client *c) +getpagestats(Client *c) { - const char *uri = geturi(c); - pagestats[0] = c->tlsflags > G_TLS_CERTIFICATE_VALIDATE_ALL ? '-' : c->tlsflags > 0 ? 'U' : 'T'; - pagestat[1] = '\0'; + pagestats[1] = '\0'; } void updatetitle(Client *c) { - char *t; + char *title; 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); + gettogglestats(c); + getpagestats(c); + + if (c->progress != 100) { + title = g_strdup_printf("[%i%%] %s:%s | %s", + c->progress, togglestats, pagestats, + c->targeturi ? c->targeturi : c->title); } else { - t = g_strdup_printf("%s:%s | %s", togglestat, pagestat, - c->title == NULL ? "" : c->title); + title = g_strdup_printf("%s:%s | %s", + togglestats, pagestats, + c->targeturi ? c->targeturi : c->title); } - gtk_window_set_title(GTK_WINDOW(c->win), t); - g_free(t); + gtk_window_set_title(GTK_WINDOW(c->win), title); + g_free(title); } else { - gtk_window_set_title(GTK_WINDOW(c->win), (c->title == NULL) ? - "" : c->title); + gtk_window_set_title(GTK_WINDOW(c->win), c->title ? + c->title : ""); } }