style fixes: space after keywords, () with sizeof

Signed-off-by: Christoph Lohmann <20h@r-36.net>
This commit is contained in:
Markus Teich 2015-10-18 22:52:16 +02:00 committed by Christoph Lohmann
parent c2bb8d0325
commit 9f5c6ff8d7
1 changed files with 103 additions and 103 deletions

206
surf.c
View File

@ -31,7 +31,7 @@
char *argv0; char *argv0;
#define LENGTH(x) (sizeof x / sizeof x[0]) #define LENGTH(x) (sizeof(x) / sizeof(x[0]))
#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK)) #define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK))
#define COOKIEJAR_TYPE (cookiejar_get_type ()) #define COOKIEJAR_TYPE (cookiejar_get_type ())
#define COOKIEJAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COOKIEJAR_TYPE, CookieJar)) #define COOKIEJAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COOKIEJAR_TYPE, CookieJar))
@ -222,7 +222,7 @@ addaccelgroup(Client *c) {
GtkAccelGroup *group = gtk_accel_group_new(); GtkAccelGroup *group = gtk_accel_group_new();
GClosure *closure; GClosure *closure;
for(i = 0; i < LENGTH(keys); i++) { for (i = 0; i < LENGTH(keys); i++) {
closure = g_cclosure_new(G_CALLBACK(keypress), c, NULL); closure = g_cclosure_new(G_CALLBACK(keypress), c, NULL);
gtk_accel_group_connect(group, keys[i].keyval, keys[i].mod, gtk_accel_group_connect(group, keys[i].keyval, keys[i].mod,
0, closure); 0, closure);
@ -237,10 +237,10 @@ beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r,
const gchar *uri = webkit_network_request_get_uri(req); const gchar *uri = webkit_network_request_get_uri(req);
int i, isascii = 1; int i, isascii = 1;
if(g_str_has_suffix(uri, "/favicon.ico")) if (g_str_has_suffix(uri, "/favicon.ico"))
webkit_network_request_set_uri(req, "about:blank"); webkit_network_request_set_uri(req, "about:blank");
if(!g_str_has_prefix(uri, "http://") \ if (!g_str_has_prefix(uri, "http://") \
&& !g_str_has_prefix(uri, "https://") \ && !g_str_has_prefix(uri, "https://") \
&& !g_str_has_prefix(uri, "about:") \ && !g_str_has_prefix(uri, "about:") \
&& !g_str_has_prefix(uri, "file://") \ && !g_str_has_prefix(uri, "file://") \
@ -248,13 +248,13 @@ beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r,
&& !g_str_has_prefix(uri, "blob:") \ && !g_str_has_prefix(uri, "blob:") \
&& strlen(uri) > 0) { && strlen(uri) > 0) {
for(i = 0; i < strlen(uri); i++) { for (i = 0; i < strlen(uri); i++) {
if(!g_ascii_isprint(uri[i])) { if (!g_ascii_isprint(uri[i])) {
isascii = 0; isascii = 0;
break; break;
} }
} }
if(isascii) if (isascii)
handleplumb(c, w, uri); handleplumb(c, w, uri);
} }
} }
@ -273,7 +273,7 @@ buildfile(const char *path) {
fpath = g_build_filename(bpath, bname, NULL); fpath = g_build_filename(bpath, bname, NULL);
g_free(bname); g_free(bname);
if(!(f = fopen(fpath, "a"))) if (!(f = fopen(fpath, "a")))
die("Could not open file: %s\n", fpath); die("Could not open file: %s\n", fpath);
g_chmod(fpath, 0600); /* always */ g_chmod(fpath, 0600); /* always */
@ -287,17 +287,17 @@ buildpath(const char *path) {
struct passwd *pw; struct passwd *pw;
char *apath, *name, *p, *fpath; char *apath, *name, *p, *fpath;
if(path[0] == '~') { if (path[0] == '~') {
if(path[1] == '/' || path[1] == '\0') { if (path[1] == '/' || path[1] == '\0') {
p = (char *)&path[1]; p = (char *)&path[1];
pw = getpwuid(getuid()); pw = getpwuid(getuid());
} else { } else {
if((p = strchr(path, '/'))) if ((p = strchr(path, '/')))
name = g_strndup(&path[1], --p - path); name = g_strndup(&path[1], --p - path);
else else
name = g_strdup(&path[1]); name = g_strdup(&path[1]);
if(!(pw = getpwnam(name))) { if (!(pw = getpwnam(name))) {
die("Can't get user %s home directory: %s.\n", die("Can't get user %s home directory: %s.\n",
name, path); name, path);
} }
@ -309,7 +309,7 @@ buildpath(const char *path) {
} }
/* creating directory */ /* creating directory */
if(g_mkdir_with_parents(apath, 0700) < 0) if (g_mkdir_with_parents(apath, 0700) < 0)
die("Could not access directory: %s\n", apath); die("Could not access directory: %s\n", apath);
fpath = realpath(apath, NULL); fpath = realpath(apath, NULL);
@ -328,8 +328,8 @@ buttonrelease(WebKitWebView *web, GdkEventButton *e, Client *c) {
g_object_get(result, "context", &context, NULL); g_object_get(result, "context", &context, NULL);
g_object_get(result, "link-uri", &arg.v, NULL); g_object_get(result, "link-uri", &arg.v, NULL);
for(i = 0; i < LENGTH(buttons); i++) { for (i = 0; i < LENGTH(buttons); i++) {
if(context & buttons[i].click && e->button == buttons[i].button && if (context & buttons[i].click && e->button == buttons[i].button &&
CLEANMASK(e->state) == CLEANMASK(buttons[i].mask) && buttons[i].func) { CLEANMASK(e->state) == CLEANMASK(buttons[i].mask) && buttons[i].func) {
buttons[i].func(c, buttons[i].click == ClkLink && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); buttons[i].func(c, buttons[i].click == ClkLink && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
return true; return true;
@ -340,11 +340,11 @@ buttonrelease(WebKitWebView *web, GdkEventButton *e, Client *c) {
static void static void
cleanup(void) { cleanup(void) {
if(diskcache) { if (diskcache) {
soup_cache_flush(diskcache); soup_cache_flush(diskcache);
soup_cache_dump(diskcache); soup_cache_dump(diskcache);
} }
while(clients) while (clients)
destroyclient(clients); destroyclient(clients);
g_free(cookiefile); g_free(cookiefile);
g_free(scriptfile); g_free(scriptfile);
@ -355,7 +355,7 @@ static void
cookiejar_changed(SoupCookieJar *self, SoupCookie *old_cookie, cookiejar_changed(SoupCookieJar *self, SoupCookie *old_cookie,
SoupCookie *new_cookie) { SoupCookie *new_cookie) {
flock(COOKIEJAR(self)->lock, LOCK_EX); flock(COOKIEJAR(self)->lock, LOCK_EX);
if(new_cookie && !new_cookie->expires && sessiontime) { if (new_cookie && !new_cookie->expires && sessiontime) {
soup_cookie_set_expires(new_cookie, soup_cookie_set_expires(new_cookie,
soup_date_new_from_now(sessiontime)); soup_date_new_from_now(sessiontime));
} }
@ -405,7 +405,7 @@ cookiejar_set_property(GObject *self, guint prop_id, const GValue *value,
static SoupCookieJarAcceptPolicy static SoupCookieJarAcceptPolicy
cookiepolicy_get(void) { cookiepolicy_get(void) {
switch(cookiepolicies[policysel]) { switch (cookiepolicies[policysel]) {
case 'a': case 'a':
return SOUP_COOKIE_JAR_ACCEPT_NEVER; return SOUP_COOKIE_JAR_ACCEPT_NEVER;
case '@': case '@':
@ -420,7 +420,7 @@ cookiepolicy_get(void) {
static char static char
cookiepolicy_set(const SoupCookieJarAcceptPolicy ep) { cookiepolicy_set(const SoupCookieJarAcceptPolicy ep) {
switch(ep) { switch (ep) {
case SOUP_COOKIE_JAR_ACCEPT_NEVER: case SOUP_COOKIE_JAR_ACCEPT_NEVER:
return 'a'; return 'a';
case SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY: case SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY:
@ -451,7 +451,7 @@ runscript(WebKitWebFrame *frame) {
char *script; char *script;
GError *error; GError *error;
if(g_file_get_contents(scriptfile, &script, NULL, &error)) { if (g_file_get_contents(scriptfile, &script, NULL, &error)) {
evalscript(webkit_web_frame_get_global_context(frame), evalscript(webkit_web_frame_get_global_context(frame),
script, scriptfile); script, scriptfile);
} }
@ -461,7 +461,7 @@ static void
clipboard(Client *c, const Arg *arg) { clipboard(Client *c, const Arg *arg) {
gboolean paste = *(gboolean *)arg; gboolean paste = *(gboolean *)arg;
if(paste) { if (paste) {
gtk_clipboard_request_text( gtk_clipboard_request_text(
gtk_clipboard_get(GDK_SELECTION_PRIMARY), gtk_clipboard_get(GDK_SELECTION_PRIMARY),
pasteuri, c); pasteuri, c);
@ -477,7 +477,7 @@ copystr(char **str, const char *src) {
char *tmp; char *tmp;
tmp = g_strdup(src); tmp = g_strdup(src);
if(str && *str) { if (str && *str) {
g_free(*str); g_free(*str);
*str = tmp; *str = tmp;
} }
@ -493,7 +493,7 @@ createwindow(WebKitWebView *v, WebKitWebFrame *f, Client *c) {
static gboolean static gboolean
decidedownload(WebKitWebView *v, WebKitWebFrame *f, WebKitNetworkRequest *r, decidedownload(WebKitWebView *v, WebKitWebFrame *f, WebKitNetworkRequest *r,
gchar *m, WebKitWebPolicyDecision *p, Client *c) { gchar *m, WebKitWebPolicyDecision *p, Client *c) {
if(!webkit_web_view_can_show_mime_type(v, m)) { if (!webkit_web_view_can_show_mime_type(v, m)) {
webkit_web_policy_decision_download(p); webkit_web_policy_decision_download(p);
return TRUE; return TRUE;
} }
@ -506,7 +506,7 @@ decidewindow(WebKitWebView *view, WebKitWebFrame *f, WebKitNetworkRequest *r,
Client *c) { Client *c) {
Arg arg; Arg arg;
if(webkit_web_navigation_action_get_reason(n) == if (webkit_web_navigation_action_get_reason(n) ==
WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) { WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
webkit_web_policy_decision_ignore(p); webkit_web_policy_decision_ignore(p);
arg.v = (void *)webkit_network_request_get_uri(r); arg.v = (void *)webkit_network_request_get_uri(r);
@ -532,14 +532,14 @@ destroyclient(Client *c) {
gtk_widget_destroy(c->vbox); gtk_widget_destroy(c->vbox);
gtk_widget_destroy(c->win); gtk_widget_destroy(c->win);
for(p = clients; p && p->next != c; p = p->next); for (p = clients; p && p->next != c; p = p->next);
if(p) { if (p) {
p->next = c->next; p->next = c->next;
} else { } else {
clients = c->next; clients = c->next;
} }
free(c); free(c);
if(clients == NULL) if (clients == NULL)
gtk_main_quit(); gtk_main_quit();
} }
@ -569,7 +569,7 @@ find(Client *c, const Arg *arg) {
static void static void
fullscreen(Client *c, const Arg *arg) { fullscreen(Client *c, const Arg *arg) {
if(c->fullscreen) { if (c->fullscreen) {
gtk_window_unfullscreen(GTK_WINDOW(c->win)); gtk_window_unfullscreen(GTK_WINDOW(c->win));
} else { } else {
gtk_window_fullscreen(GTK_WINDOW(c->win)); gtk_window_fullscreen(GTK_WINDOW(c->win));
@ -580,7 +580,7 @@ fullscreen(Client *c, const Arg *arg) {
static void static void
geopolicyrequested(WebKitWebView *v, WebKitWebFrame *f, geopolicyrequested(WebKitWebView *v, WebKitWebFrame *f,
WebKitGeolocationPolicyDecision *d, Client *c) { WebKitGeolocationPolicyDecision *d, Client *c) {
if(allowgeolocation) { if (allowgeolocation) {
webkit_geolocation_policy_allow(d); webkit_geolocation_policy_allow(d);
} else { } else {
webkit_geolocation_policy_deny(d); webkit_geolocation_policy_deny(d);
@ -598,7 +598,7 @@ getatom(Client *c, int a) {
XGetWindowProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window), XGetWindowProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window),
atoms[a], 0L, BUFSIZ, False, XA_STRING, atoms[a], 0L, BUFSIZ, False, XA_STRING,
&adummy, &idummy, &ldummy, &ldummy, &p); &adummy, &idummy, &ldummy, &ldummy, &p);
if(p) { if (p) {
strncpy(buf, (char *)p, LENGTH(buf)-1); strncpy(buf, (char *)p, LENGTH(buf)-1);
} else { } else {
buf[0] = '\0'; buf[0] = '\0';
@ -612,7 +612,7 @@ static char *
geturi(Client *c) { geturi(Client *c) {
char *uri; char *uri;
if(!(uri = (char *)webkit_web_view_get_uri(c->view))) if (!(uri = (char *)webkit_web_view_get_uri(c->view)))
uri = "about:blank"; uri = "about:blank";
return uri; return uri;
} }
@ -621,11 +621,11 @@ static gchar *
getstyle(const char *uri) { getstyle(const char *uri) {
int i; int i;
if(stylefile != NULL) if (stylefile != NULL)
return g_strconcat("file://", stylefile, NULL); return g_strconcat("file://", stylefile, NULL);
for(i = 0; i < LENGTH(styles); i++) { for (i = 0; i < LENGTH(styles); i++) {
if(styles[i].regex && !regexec(&(styles[i].re), uri, 0, if (styles[i].regex && !regexec(&(styles[i].re), uri, 0,
NULL, 0)) { NULL, 0)) {
return g_strconcat("file://", styles[i].style, NULL); return g_strconcat("file://", styles[i].style, NULL);
} }
@ -654,7 +654,7 @@ initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) {
static void static void
inspector(Client *c, const Arg *arg) { inspector(Client *c, const Arg *arg) {
if(c->isinspecting) { if (c->isinspecting) {
webkit_web_inspector_close(c->inspector); webkit_web_inspector_close(c->inspector);
} else { } else {
webkit_web_inspector_show(c->inspector); webkit_web_inspector_show(c->inspector);
@ -670,7 +670,7 @@ static gboolean
inspector_show(WebKitWebInspector *i, Client *c) { inspector_show(WebKitWebInspector *i, Client *c) {
WebKitWebView *w; WebKitWebView *w;
if(c->isinspecting) if (c->isinspecting)
return false; return false;
w = webkit_web_inspector_get_web_view(i); w = webkit_web_inspector_get_web_view(i);
@ -685,7 +685,7 @@ static gboolean
inspector_close(WebKitWebInspector *i, Client *c) { inspector_close(WebKitWebInspector *i, Client *c) {
GtkWidget *w; GtkWidget *w;
if(!c->isinspecting) if (!c->isinspecting)
return false; return false;
w = GTK_WIDGET(webkit_web_inspector_get_web_view(i)); w = GTK_WIDGET(webkit_web_inspector_get_web_view(i));
@ -710,8 +710,8 @@ keypress(GtkAccelGroup *group, GObject *obj,
mods = CLEANMASK(mods); mods = CLEANMASK(mods);
key = gdk_keyval_to_lower(key); key = gdk_keyval_to_lower(key);
updatewinid(c); updatewinid(c);
for(i = 0; i < LENGTH(keys); i++) { for (i = 0; i < LENGTH(keys); i++) {
if(key == keys[i].keyval if (key == keys[i].keyval
&& mods == keys[i].mod && mods == keys[i].mod
&& keys[i].func) { && keys[i].func) {
keys[i].func(c, &(keys[i].arg)); keys[i].func(c, &(keys[i].arg));
@ -724,9 +724,9 @@ keypress(GtkAccelGroup *group, GObject *obj,
static void static void
linkhover(WebKitWebView *v, const char* t, const char* l, Client *c) { linkhover(WebKitWebView *v, const char* t, const char* l, Client *c) {
if(l) { if (l) {
c->linkhover = copystr(&c->linkhover, l); c->linkhover = copystr(&c->linkhover, l);
} else if(c->linkhover) { } else if (c->linkhover) {
free(c->linkhover); free(c->linkhover);
c->linkhover = NULL; c->linkhover = NULL;
} }
@ -742,10 +742,10 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c) {
SoupMessage *msg; SoupMessage *msg;
char *uri; char *uri;
switch(webkit_web_view_get_load_status (c->view)) { switch (webkit_web_view_get_load_status (c->view)) {
case WEBKIT_LOAD_COMMITTED: case WEBKIT_LOAD_COMMITTED:
uri = geturi(c); uri = geturi(c);
if(strstr(uri, "https://") == uri) { if (strstr(uri, "https://") == uri) {
frame = webkit_web_view_get_main_frame(c->view); frame = webkit_web_view_get_main_frame(c->view);
src = webkit_web_frame_get_data_source(frame); src = webkit_web_frame_get_data_source(frame);
request = webkit_web_data_source_get_request(src); request = webkit_web_data_source_get_request(src);
@ -755,7 +755,7 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c) {
} }
setatom(c, AtomUri, uri); setatom(c, AtomUri, uri);
if(enablestyles) { if (enablestyles) {
g_object_set(G_OBJECT(set), "user-stylesheet-uri", g_object_set(G_OBJECT(set), "user-stylesheet-uri",
getstyle(uri), NULL); getstyle(uri), NULL);
} }
@ -763,7 +763,7 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c) {
case WEBKIT_LOAD_FINISHED: case WEBKIT_LOAD_FINISHED:
c->progress = 100; c->progress = 100;
updatetitle(c); updatetitle(c);
if(diskcache) { if (diskcache) {
soup_cache_flush(diskcache); soup_cache_flush(diskcache);
soup_cache_dump(diskcache); soup_cache_dump(diskcache);
} }
@ -780,11 +780,11 @@ loaduri(Client *c, const Arg *arg) {
Arg a = { .b = FALSE }; Arg a = { .b = FALSE };
struct stat st; struct stat st;
if(strcmp(uri, "") == 0) if (strcmp(uri, "") == 0)
return; return;
/* In case it's a file path. */ /* In case it's a file path. */
if(stat(uri, &st) == 0) { if (stat(uri, &st) == 0) {
rp = realpath(uri, NULL); rp = realpath(uri, NULL);
u = g_strdup_printf("file://%s", rp); u = g_strdup_printf("file://%s", rp);
free(rp); free(rp);
@ -796,7 +796,7 @@ loaduri(Client *c, const Arg *arg) {
setatom(c, AtomUri, uri); setatom(c, AtomUri, uri);
/* prevents endless loop */ /* prevents endless loop */
if(strcmp(u, geturi(c)) == 0) { if (strcmp(u, geturi(c)) == 0) {
reload(c, &a); reload(c, &a);
} else { } else {
webkit_web_view_load_uri(c->view, u); webkit_web_view_load_uri(c->view, u);
@ -823,14 +823,14 @@ newclient(void) {
gdouble dpi; gdouble dpi;
char *ua; char *ua;
if(!(c = calloc(1, sizeof(Client)))) if (!(c = calloc(1, sizeof(Client))))
die("Cannot malloc!\n"); die("Cannot malloc!\n");
c->title = NULL; c->title = NULL;
c->progress = 100; c->progress = 100;
/* Window */ /* Window */
if(embed) { if (embed) {
c->win = gtk_plug_new(embed); c->win = gtk_plug_new(embed);
} else { } else {
c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL); c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@ -857,7 +857,7 @@ newclient(void) {
"leave_notify_event", "leave_notify_event",
G_CALLBACK(titlechangeleave), c); G_CALLBACK(titlechangeleave), c);
if(!kioskmode) if (!kioskmode)
addaccelgroup(c); addaccelgroup(c);
/* Pane */ /* Pane */
@ -920,7 +920,7 @@ newclient(void) {
g_signal_connect(G_OBJECT(frame), "scrollbars-policy-changed", g_signal_connect(G_OBJECT(frame), "scrollbars-policy-changed",
G_CALLBACK(gtk_true), NULL); G_CALLBACK(gtk_true), NULL);
if(!enablescrollbars) { if (!enablescrollbars) {
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll), gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
GTK_POLICY_NEVER, GTK_POLICY_NEVER); GTK_POLICY_NEVER, GTK_POLICY_NEVER);
} else { } else {
@ -951,7 +951,7 @@ newclient(void) {
runscript(frame); runscript(frame);
settings = webkit_web_view_get_settings(c->view); settings = webkit_web_view_get_settings(c->view);
if(!(ua = getenv("SURF_USERAGENT"))) if (!(ua = getenv("SURF_USERAGENT")))
ua = useragent; ua = useragent;
g_object_set(G_OBJECT(settings), "user-agent", ua, NULL); g_object_set(G_OBJECT(settings), "user-agent", ua, NULL);
if (enablestyles) { if (enablestyles) {
@ -980,20 +980,20 @@ newclient(void) {
* This ensures websites are not unusably small with a high DPI screen. * This ensures websites are not unusably small with a high DPI screen.
* It is equivalent to firefox's "layout.css.devPixelsPerPx" setting. * It is equivalent to firefox's "layout.css.devPixelsPerPx" setting.
*/ */
if(zoomto96dpi) { if (zoomto96dpi) {
screen = gdk_window_get_screen(GTK_WIDGET(c->win)->window); screen = gdk_window_get_screen(GTK_WIDGET(c->win)->window);
dpi = gdk_screen_get_resolution(screen); dpi = gdk_screen_get_resolution(screen);
if(dpi != -1) { if (dpi != -1) {
g_object_set(G_OBJECT(settings), "enforce-96-dpi", true, g_object_set(G_OBJECT(settings), "enforce-96-dpi", true,
NULL); NULL);
webkit_web_view_set_zoom_level(c->view, dpi/96); webkit_web_view_set_zoom_level(c->view, dpi/96);
} }
} }
/* This might conflict with _zoomto96dpi_. */ /* This might conflict with _zoomto96dpi_. */
if(zoomlevel != 1.0) if (zoomlevel != 1.0)
webkit_web_view_set_zoom_level(c->view, zoomlevel); webkit_web_view_set_zoom_level(c->view, zoomlevel);
if(enableinspector) { if (enableinspector) {
c->inspector = WEBKIT_WEB_INSPECTOR( c->inspector = WEBKIT_WEB_INSPECTOR(
webkit_web_view_get_inspector(c->view)); webkit_web_view_get_inspector(c->view));
g_signal_connect(G_OBJECT(c->inspector), "inspect-web-view", g_signal_connect(G_OBJECT(c->inspector), "inspect-web-view",
@ -1007,20 +1007,20 @@ newclient(void) {
c->isinspecting = false; c->isinspecting = false;
} }
if(runinfullscreen) { if (runinfullscreen) {
c->fullscreen = 0; c->fullscreen = 0;
fullscreen(c, NULL); fullscreen(c, NULL);
} }
setatom(c, AtomFind, ""); setatom(c, AtomFind, "");
setatom(c, AtomUri, "about:blank"); setatom(c, AtomUri, "about:blank");
if(hidebackground) if (hidebackground)
webkit_web_view_set_transparent(c->view, TRUE); webkit_web_view_set_transparent(c->view, TRUE);
c->next = clients; c->next = clients;
clients = c; clients = c;
if(showxid) { if (showxid) {
gdk_display_sync(gtk_widget_get_display(c->win)); gdk_display_sync(gtk_widget_get_display(c->win));
printf("%u\n", printf("%u\n",
(guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window)); (guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
@ -1043,32 +1043,32 @@ newwindow(Client *c, const Arg *arg, gboolean noembed) {
cmd[i++] = argv0; cmd[i++] = argv0;
cmd[i++] = "-a"; cmd[i++] = "-a";
cmd[i++] = cookiepolicies; cmd[i++] = cookiepolicies;
if(!enablescrollbars) if (!enablescrollbars)
cmd[i++] = "-b"; cmd[i++] = "-b";
if(embed && !noembed) { if (embed && !noembed) {
cmd[i++] = "-e"; cmd[i++] = "-e";
snprintf(tmp, LENGTH(tmp), "%u", (int)embed); snprintf(tmp, LENGTH(tmp), "%u", (int)embed);
cmd[i++] = tmp; cmd[i++] = tmp;
} }
if(!allowgeolocation) if (!allowgeolocation)
cmd[i++] = "-g"; cmd[i++] = "-g";
if(!loadimages) if (!loadimages)
cmd[i++] = "-i"; cmd[i++] = "-i";
if(kioskmode) if (kioskmode)
cmd[i++] = "-k"; cmd[i++] = "-k";
if(!enableplugins) if (!enableplugins)
cmd[i++] = "-p"; cmd[i++] = "-p";
if(!enablescripts) if (!enablescripts)
cmd[i++] = "-s"; cmd[i++] = "-s";
if(showxid) if (showxid)
cmd[i++] = "-x"; cmd[i++] = "-x";
if(enablediskcache) if (enablediskcache)
cmd[i++] = "-D"; cmd[i++] = "-D";
cmd[i++] = "-c"; cmd[i++] = "-c";
cmd[i++] = cookiefile; cmd[i++] = cookiefile;
cmd[i++] = "--"; cmd[i++] = "--";
uri = arg->v ? (char *)arg->v : c->linkhover; uri = arg->v ? (char *)arg->v : c->linkhover;
if(uri) if (uri)
cmd[i++] = uri; cmd[i++] = uri;
cmd[i++] = NULL; cmd[i++] = NULL;
spawn(NULL, &a); spawn(NULL, &a);
@ -1079,7 +1079,7 @@ contextmenu(WebKitWebView *view, GtkWidget *menu, WebKitHitTestResult *target,
gboolean keyboard, Client *c) { gboolean keyboard, Client *c) {
GList *items = gtk_container_get_children(GTK_CONTAINER(GTK_MENU(menu))); GList *items = gtk_container_get_children(GTK_CONTAINER(GTK_MENU(menu)));
for(GList *l = items; l; l = l->next) { for (GList *l = items; l; l = l->next) {
g_signal_connect(l->data, "activate", G_CALLBACK(menuactivate), c); g_signal_connect(l->data, "activate", G_CALLBACK(menuactivate), c);
} }
@ -1106,18 +1106,18 @@ menuactivate(GtkMenuItem *item, Client *c) {
GtkClipboard *prisel, *clpbrd; GtkClipboard *prisel, *clpbrd;
a = gtk_activatable_get_related_action(GTK_ACTIVATABLE(item)); a = gtk_activatable_get_related_action(GTK_ACTIVATABLE(item));
if(a == NULL) if (a == NULL)
return; return;
name = gtk_action_get_name(a); name = gtk_action_get_name(a);
if(!g_strcmp0(name, "context-menu-action-3")) { if (!g_strcmp0(name, "context-menu-action-3")) {
prisel = gtk_clipboard_get(GDK_SELECTION_PRIMARY); prisel = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
gtk_clipboard_set_text(prisel, c->linkhover, -1); gtk_clipboard_set_text(prisel, c->linkhover, -1);
} else if(!g_strcmp0(name, "context-menu-action-7")) { } else if (!g_strcmp0(name, "context-menu-action-7")) {
prisel = gtk_clipboard_get(GDK_SELECTION_PRIMARY); prisel = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
clpbrd = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); clpbrd = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
uri = gtk_clipboard_wait_for_text(clpbrd); uri = gtk_clipboard_wait_for_text(clpbrd);
if(uri) if (uri)
gtk_clipboard_set_text(prisel, uri, -1); gtk_clipboard_set_text(prisel, uri, -1);
} }
} }
@ -1125,7 +1125,7 @@ menuactivate(GtkMenuItem *item, Client *c) {
static void static void
pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) { pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) {
Arg arg = {.v = text }; Arg arg = {.v = text };
if(text != NULL) if (text != NULL)
loaduri((Client *) d, &arg); loaduri((Client *) d, &arg);
} }
@ -1140,15 +1140,15 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d) {
XPropertyEvent *ev; XPropertyEvent *ev;
Arg arg; Arg arg;
if(((XEvent *)e)->type == PropertyNotify) { if (((XEvent *)e)->type == PropertyNotify) {
ev = &((XEvent *)e)->xproperty; ev = &((XEvent *)e)->xproperty;
if(ev->state == PropertyNewValue) { if (ev->state == PropertyNewValue) {
if(ev->atom == atoms[AtomFind]) { if (ev->atom == atoms[AtomFind]) {
arg.b = TRUE; arg.b = TRUE;
find(c, &arg); find(c, &arg);
return GDK_FILTER_REMOVE; return GDK_FILTER_REMOVE;
} else if(ev->atom == atoms[AtomGo]) { } else if (ev->atom == atoms[AtomGo]) {
arg.v = getatom(c, AtomGo); arg.v = getatom(c, AtomGo);
loaduri(c, &arg); loaduri(c, &arg);
@ -1178,7 +1178,7 @@ linkopenembed(Client *c, const Arg *arg) {
static void static void
reload(Client *c, const Arg *arg) { reload(Client *c, const Arg *arg) {
gboolean nocache = *(gboolean *)arg; gboolean nocache = *(gboolean *)arg;
if(nocache) { if (nocache) {
webkit_web_view_reload_bypass_cache(c->view); webkit_web_view_reload_bypass_cache(c->view);
} else { } else {
webkit_web_view_reload(c->view); webkit_web_view_reload(c->view);
@ -1202,7 +1202,7 @@ scroll(GtkAdjustment *a, const Arg *arg) {
gdouble v; gdouble v;
v = gtk_adjustment_get_value(a); v = gtk_adjustment_get_value(a);
switch(arg->i) { switch (arg->i) {
case +10000: case +10000:
case -10000: case -10000:
v += gtk_adjustment_get_page_increment(a) * v += gtk_adjustment_get_page_increment(a) *
@ -1253,9 +1253,9 @@ setup(void) {
scriptfile = buildfile(scriptfile); scriptfile = buildfile(scriptfile);
cachefolder = buildpath(cachefolder); cachefolder = buildpath(cachefolder);
styledir = buildpath(styledir); styledir = buildpath(styledir);
if(stylefile == NULL) { if (stylefile == NULL) {
for(i = 0; i < LENGTH(styles); i++) { for (i = 0; i < LENGTH(styles); i++) {
if(regcomp(&(styles[i].re), styles[i].regex, if (regcomp(&(styles[i].re), styles[i].regex,
REG_EXTENDED)) { REG_EXTENDED)) {
fprintf(stderr, fprintf(stderr,
"Could not compile regex: %s\n", "Could not compile regex: %s\n",
@ -1279,7 +1279,7 @@ setup(void) {
cookiepolicy_get()))); cookiepolicy_get())));
/* disk cache */ /* disk cache */
if(enablediskcache) { if (enablediskcache) {
diskcache = soup_cache_new(cachefolder, SOUP_CACHE_SINGLE_USER); diskcache = soup_cache_new(cachefolder, SOUP_CACHE_SINGLE_USER);
soup_cache_set_max_size(diskcache, diskcachebytes); soup_cache_set_max_size(diskcache, diskcachebytes);
soup_cache_load(diskcache); soup_cache_load(diskcache);
@ -1289,7 +1289,7 @@ setup(void) {
/* ssl */ /* ssl */
tlsdb = g_tls_file_database_new(cafile, &error); tlsdb = g_tls_file_database_new(cafile, &error);
if(error) { if (error) {
g_warning("Error loading SSL database %s: %s", cafile, error->message); g_warning("Error loading SSL database %s: %s", cafile, error->message);
g_error_free(error); g_error_free(error);
} }
@ -1297,7 +1297,7 @@ setup(void) {
g_object_set(G_OBJECT(s), "ssl-strict", strictssl, NULL); g_object_set(G_OBJECT(s), "ssl-strict", strictssl, NULL);
/* proxy */ /* proxy */
if((proxy = getenv("http_proxy")) && strcmp(proxy, "")) { if ((proxy = getenv("http_proxy")) && strcmp(proxy, "")) {
new_proxy = g_strrstr(proxy, "http://") new_proxy = g_strrstr(proxy, "http://")
|| g_strrstr(proxy, "socks://") || g_strrstr(proxy, "socks://")
|| g_strrstr(proxy, "socks4://") || g_strrstr(proxy, "socks4://")
@ -1314,9 +1314,9 @@ setup(void) {
static void static void
sigchld(int unused) { sigchld(int unused) {
if(signal(SIGCHLD, sigchld) == SIG_ERR) if (signal(SIGCHLD, sigchld) == SIG_ERR)
die("Can't install SIGCHLD handler"); die("Can't install SIGCHLD handler");
while(0 < waitpid(-1, NULL, WNOHANG)); while (0 < waitpid(-1, NULL, WNOHANG));
} }
static void static void
@ -1331,8 +1331,8 @@ source(Client *c, const Arg *arg) {
static void static void
spawn(Client *c, const Arg *arg) { spawn(Client *c, const Arg *arg) {
if(fork() == 0) { if (fork() == 0) {
if(dpy) if (dpy)
close(ConnectionNumber(dpy)); close(ConnectionNumber(dpy));
setsid(); setsid();
execvp(((char **)arg->v)[0], (char **)arg->v); execvp(((char **)arg->v)[0], (char **)arg->v);
@ -1395,7 +1395,7 @@ togglecookiepolicy(Client *c, const Arg *arg) {
g_object_get(G_OBJECT(jar), "accept-policy", &policy, NULL); g_object_get(G_OBJECT(jar), "accept-policy", &policy, NULL);
policysel++; policysel++;
if(policysel >= strlen(cookiepolicies)) if (policysel >= strlen(cookiepolicies))
policysel = 0; policysel = 0;
g_object_set(G_OBJECT(jar), "accept-policy", g_object_set(G_OBJECT(jar), "accept-policy",
@ -1439,7 +1439,7 @@ togglescrollbars(Client *c, const Arg *arg) {
gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(c->scroll), NULL, &vspolicy); gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(c->scroll), NULL, &vspolicy);
if(vspolicy == GTK_POLICY_AUTOMATIC) { if (vspolicy == GTK_POLICY_AUTOMATIC) {
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll), gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
GTK_POLICY_NEVER, GTK_POLICY_NEVER); GTK_POLICY_NEVER, GTK_POLICY_NEVER);
} else { } else {
@ -1498,7 +1498,7 @@ static void
getpagestat(Client *c) { getpagestat(Client *c) {
const char *uri = geturi(c); const char *uri = geturi(c);
if(strstr(uri, "https://") == uri) { if (strstr(uri, "https://") == uri) {
pagestat[0] = c->sslfailed ? 'U' : 'T'; pagestat[0] = c->sslfailed ? 'U' : 'T';
} else { } else {
pagestat[0] = '-'; pagestat[0] = '-';
@ -1513,14 +1513,14 @@ static void
updatetitle(Client *c) { updatetitle(Client *c) {
char *t; char *t;
if(showindicators) { if (showindicators) {
gettogglestat(c); gettogglestat(c);
getpagestat(c); getpagestat(c);
if(c->linkhover) { if (c->linkhover) {
t = g_strdup_printf("%s:%s | %s", togglestat, t = g_strdup_printf("%s:%s | %s", togglestat,
pagestat, c->linkhover); pagestat, 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, pagestat, togglestat, pagestat,
(c->title == NULL)? "" : c->title); (c->title == NULL)? "" : c->title);
@ -1561,10 +1561,10 @@ windowobjectcleared(GtkWidget *w, WebKitWebFrame *frame, JSContextRef js,
static void static void
zoom(Client *c, const Arg *arg) { zoom(Client *c, const Arg *arg) {
c->zoomed = TRUE; c->zoomed = TRUE;
if(arg->i < 0) { if (arg->i < 0) {
/* zoom out */ /* zoom out */
webkit_web_view_zoom_out(c->view); webkit_web_view_zoom_out(c->view);
} else if(arg->i > 0) { } else if (arg->i > 0) {
/* zoom in */ /* zoom in */
webkit_web_view_zoom_in(c->view); webkit_web_view_zoom_in(c->view);
} else { } else {
@ -1673,12 +1673,12 @@ main(int argc, char *argv[]) {
default: default:
usage(); usage();
} ARGEND; } ARGEND;
if(argc > 0) if (argc > 0)
arg.v = argv[0]; arg.v = argv[0];
setup(); setup();
c = newclient(); c = newclient();
if(arg.v) { if (arg.v) {
loaduri(clients, &arg); loaduri(clients, &arg);
} else { } else {
updatetitle(c); updatetitle(c);