Adapt toggle statistics

Rename *togglestat to plural *togglestats, add frame flatenning
indicator, resize array in consequence.
Use a static index instead of a dynamic one as we always use all values
anyway.
This commit is contained in:
Quentin Rameau 2015-11-20 16:53:52 +01:00
parent 690118133d
commit b5096b1c8f

50
surf.c
View File

@ -107,7 +107,7 @@ static Client *clients = NULL;
static Window embed = 0; static Window embed = 0;
static gboolean showxid = FALSE; static gboolean showxid = FALSE;
static char winid[64]; static char winid[64];
static char togglestat[9]; static char togglestats[10];
static char pagestats[2]; static char pagestats[2];
static GTlsDatabase *tlsdb; static GTlsDatabase *tlsdb;
static int cookiepolicy; static int cookiepolicy;
@ -142,7 +142,7 @@ static void togglefullscreen(Client *c, const Arg *a);
static gboolean permissionrequested(WebKitWebView *v, static gboolean permissionrequested(WebKitWebView *v,
WebKitPermissionRequest *r, Client *c); WebKitPermissionRequest *r, Client *c);
static const char *getatom(Client *c, int a); static const char *getatom(Client *c, int a);
static void gettogglestat(Client *c); static void gettogglestats(Client *c);
static void getpagestats(Client *c); static void getpagestats(Client *c);
static char *geturi(Client *c); static char *geturi(Client *c);
static const gchar *getstyle(const char *uri); static const gchar *getstyle(const char *uri);
@ -1389,34 +1389,18 @@ togglestyle(Client *c, const Arg *arg)
} }
void void
gettogglestat(Client *c) gettogglestats(Client *c)
{ {
gboolean value; togglestats[0] = cookiepolicy_set(cookiepolicy_get());
int p = 0; togglestats[1] = enablecaretbrowsing ? 'C' : 'c';
WebKitWebSettings *settings = webkit_web_view_get_settings(c->view); togglestats[2] = allowgeolocation ? 'G' : 'g';
togglestats[3] = enablecache ? 'D' : 'd';
togglestat[p++] = cookiepolicy_set(cookiepolicy_get()); togglestats[4] = loadimages ? 'I' : 'i';
togglestats[5] = enablescripts ? 'S': 's';
g_object_get(G_OBJECT(settings), "enable-caret-browsing", &value, togglestats[6] = enableplugins ? 'V' : 'v';
NULL); togglestats[7] = enablestyle ? 'M' : 'm';
togglestat[p++] = value? 'C': 'c'; togglestats[8] = enableframeflattening ? 'F' : 'f';
togglestats[9] = '\0';
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';
} }
void void
@ -1433,18 +1417,18 @@ updatetitle(Client *c)
char *t; char *t;
if (showindicators) { if (showindicators) {
gettogglestat(c); gettogglestats(c);
getpagestats(c); getpagestats(c);
if (c->linkhover) { if (c->linkhover) {
t = g_strdup_printf("%s:%s | %s", togglestat, pagestats, t = g_strdup_printf("%s:%s | %s", togglestats, pagestats,
c->linkhover); c->linkhover);
} else if (c->progress != 100) { } else if (c->progress != 100) {
t = g_strdup_printf("[%i%%] %s:%s | %s", c->progress, t = g_strdup_printf("[%i%%] %s:%s | %s", c->progress,
togglestat, pagestats, togglestats, pagestats,
c->title == NULL ? "" : c->title); c->title == NULL ? "" : c->title);
} else { } else {
t = g_strdup_printf("%s:%s | %s", togglestat, pagestats, t = g_strdup_printf("%s:%s | %s", togglestats, pagestats,
c->title == NULL ? "" : c->title); c->title == NULL ? "" : c->title);
} }