Signed-off-by: Christoph Lohmann <20h@r-36.net>
-#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 COOKIEJAR_TYPE (cookiejar_get_type ())
#define COOKIEJAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COOKIEJAR_TYPE, CookieJar))
#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK))
#define COOKIEJAR_TYPE (cookiejar_get_type ())
#define COOKIEJAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COOKIEJAR_TYPE, CookieJar))
GtkAccelGroup *group = gtk_accel_group_new();
GClosure *closure;
GtkAccelGroup *group = gtk_accel_group_new();
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);
gtk_accel_group_connect(group, keys[i].keyval, keys[i].mod,
0, closure);
closure = g_cclosure_new(G_CALLBACK(keypress), c, NULL);
gtk_accel_group_connect(group, keys[i].keyval, keys[i].mod,
0, closure);
const gchar *uri = webkit_network_request_get_uri(req);
int i, isascii = 1;
const gchar *uri = webkit_network_request_get_uri(req);
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, "about:") \
&& !g_str_has_prefix(uri, "file://") \
&& !g_str_has_prefix(uri, "https://") \
&& !g_str_has_prefix(uri, "about:") \
&& !g_str_has_prefix(uri, "file://") \
&& !g_str_has_prefix(uri, "blob:") \
&& strlen(uri) > 0) {
&& !g_str_has_prefix(uri, "blob:") \
&& strlen(uri) > 0) {
- for(i = 0; i < strlen(uri); i++) {
- if(!g_ascii_isprint(uri[i])) {
+ for (i = 0; i < strlen(uri); i++) {
+ if (!g_ascii_isprint(uri[i])) {
handleplumb(c, w, uri);
}
}
handleplumb(c, w, uri);
}
}
fpath = g_build_filename(bpath, bname, NULL);
g_free(bname);
fpath = g_build_filename(bpath, bname, NULL);
g_free(bname);
- if(!(f = fopen(fpath, "a")))
+ if (!(f = fopen(fpath, "a")))
die("Could not open file: %s\n", fpath);
g_chmod(fpath, 0600); /* always */
die("Could not open file: %s\n", fpath);
g_chmod(fpath, 0600); /* always */
struct passwd *pw;
char *apath, *name, *p, *fpath;
struct passwd *pw;
char *apath, *name, *p, *fpath;
- if(path[0] == '~') {
- if(path[1] == '/' || path[1] == '\0') {
+ if (path[0] == '~') {
+ if (path[1] == '/' || path[1] == '\0') {
p = (char *)&path[1];
pw = getpwuid(getuid());
} else {
p = (char *)&path[1];
pw = getpwuid(getuid());
} else {
- if((p = strchr(path, '/')))
+ if ((p = strchr(path, '/')))
name = g_strndup(&path[1], --p - path);
else
name = g_strdup(&path[1]);
name = g_strndup(&path[1], --p - path);
else
name = g_strdup(&path[1]);
- if(!(pw = getpwnam(name))) {
+ if (!(pw = getpwnam(name))) {
die("Can't get user %s home directory: %s.\n",
name, path);
}
die("Can't get user %s home directory: %s.\n",
name, 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);
fpath = realpath(apath, NULL);
die("Could not access directory: %s\n", apath);
fpath = realpath(apath, NULL);
g_object_get(result, "context", &context, NULL);
g_object_get(result, "link-uri", &arg.v, NULL);
g_object_get(result, "context", &context, NULL);
g_object_get(result, "link-uri", &arg.v, NULL);
- for(i = 0; i < LENGTH(buttons); i++) {
- if(context & buttons[i].click && e->button == buttons[i].button &&
+ for (i = 0; i < LENGTH(buttons); i++) {
+ if (context & buttons[i].click && e->button == buttons[i].button &&
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);
return true;
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);
return true;
static void
cleanup(void) {
static void
cleanup(void) {
soup_cache_flush(diskcache);
soup_cache_dump(diskcache);
}
soup_cache_flush(diskcache);
soup_cache_dump(diskcache);
}
destroyclient(clients);
g_free(cookiefile);
g_free(scriptfile);
destroyclient(clients);
g_free(cookiefile);
g_free(scriptfile);
cookiejar_changed(SoupCookieJar *self, SoupCookie *old_cookie,
SoupCookie *new_cookie) {
flock(COOKIEJAR(self)->lock, LOCK_EX);
cookiejar_changed(SoupCookieJar *self, SoupCookie *old_cookie,
SoupCookie *new_cookie) {
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_date_new_from_now(sessiontime));
}
soup_cookie_set_expires(new_cookie,
soup_date_new_from_now(sessiontime));
}
static SoupCookieJarAcceptPolicy
cookiepolicy_get(void) {
static SoupCookieJarAcceptPolicy
cookiepolicy_get(void) {
- switch(cookiepolicies[policysel]) {
+ switch (cookiepolicies[policysel]) {
case 'a':
return SOUP_COOKIE_JAR_ACCEPT_NEVER;
case '@':
case 'a':
return SOUP_COOKIE_JAR_ACCEPT_NEVER;
case '@':
static char
cookiepolicy_set(const SoupCookieJarAcceptPolicy ep) {
static char
cookiepolicy_set(const SoupCookieJarAcceptPolicy ep) {
case SOUP_COOKIE_JAR_ACCEPT_NEVER:
return 'a';
case SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY:
case SOUP_COOKIE_JAR_ACCEPT_NEVER:
return 'a';
case SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY:
char *script;
GError *error;
char *script;
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),
script, scriptfile);
}
evalscript(webkit_web_frame_get_global_context(frame),
script, scriptfile);
}
clipboard(Client *c, const Arg *arg) {
gboolean paste = *(gboolean *)arg;
clipboard(Client *c, const Arg *arg) {
gboolean paste = *(gboolean *)arg;
gtk_clipboard_request_text(
gtk_clipboard_get(GDK_SELECTION_PRIMARY),
pasteuri, c);
gtk_clipboard_request_text(
gtk_clipboard_get(GDK_SELECTION_PRIMARY),
pasteuri, c);
char *tmp;
tmp = g_strdup(src);
char *tmp;
tmp = g_strdup(src);
g_free(*str);
*str = tmp;
}
g_free(*str);
*str = tmp;
}
static gboolean
decidedownload(WebKitWebView *v, WebKitWebFrame *f, WebKitNetworkRequest *r,
gchar *m, WebKitWebPolicyDecision *p, Client *c) {
static gboolean
decidedownload(WebKitWebView *v, WebKitWebFrame *f, WebKitNetworkRequest *r,
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);
return TRUE;
}
webkit_web_policy_decision_download(p);
return TRUE;
}
- if(webkit_web_navigation_action_get_reason(n) ==
+ if (webkit_web_navigation_action_get_reason(n) ==
WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
webkit_web_policy_decision_ignore(p);
arg.v = (void *)webkit_network_request_get_uri(r);
WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
webkit_web_policy_decision_ignore(p);
arg.v = (void *)webkit_network_request_get_uri(r);
gtk_widget_destroy(c->vbox);
gtk_widget_destroy(c->win);
gtk_widget_destroy(c->vbox);
gtk_widget_destroy(c->win);
- for(p = clients; p && p->next != c; p = p->next);
- if(p) {
+ for (p = clients; p && p->next != c; p = p->next);
+ if (p) {
p->next = c->next;
} else {
clients = c->next;
}
free(c);
p->next = c->next;
} else {
clients = c->next;
}
free(c);
static void
fullscreen(Client *c, const Arg *arg) {
static void
fullscreen(Client *c, const Arg *arg) {
gtk_window_unfullscreen(GTK_WINDOW(c->win));
} else {
gtk_window_fullscreen(GTK_WINDOW(c->win));
gtk_window_unfullscreen(GTK_WINDOW(c->win));
} else {
gtk_window_fullscreen(GTK_WINDOW(c->win));
static void
geopolicyrequested(WebKitWebView *v, WebKitWebFrame *f,
WebKitGeolocationPolicyDecision *d, Client *c) {
static void
geopolicyrequested(WebKitWebView *v, WebKitWebFrame *f,
WebKitGeolocationPolicyDecision *d, Client *c) {
+ if (allowgeolocation) {
webkit_geolocation_policy_allow(d);
} else {
webkit_geolocation_policy_deny(d);
webkit_geolocation_policy_allow(d);
} else {
webkit_geolocation_policy_deny(d);
XGetWindowProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window),
atoms[a], 0L, BUFSIZ, False, XA_STRING,
&adummy, &idummy, &ldummy, &ldummy, &p);
XGetWindowProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window),
atoms[a], 0L, BUFSIZ, False, XA_STRING,
&adummy, &idummy, &ldummy, &ldummy, &p);
strncpy(buf, (char *)p, LENGTH(buf)-1);
} else {
buf[0] = '\0';
strncpy(buf, (char *)p, LENGTH(buf)-1);
} else {
buf[0] = '\0';
geturi(Client *c) {
char *uri;
geturi(Client *c) {
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";
return uri;
}
uri = "about:blank";
return uri;
}
getstyle(const char *uri) {
int i;
getstyle(const char *uri) {
int i;
return g_strconcat("file://", stylefile, NULL);
return g_strconcat("file://", stylefile, NULL);
- for(i = 0; i < LENGTH(styles); i++) {
- if(styles[i].regex && !regexec(&(styles[i].re), uri, 0,
+ for (i = 0; i < LENGTH(styles); i++) {
+ if (styles[i].regex && !regexec(&(styles[i].re), uri, 0,
NULL, 0)) {
return g_strconcat("file://", styles[i].style, NULL);
}
NULL, 0)) {
return g_strconcat("file://", styles[i].style, NULL);
}
static void
inspector(Client *c, const Arg *arg) {
static void
inspector(Client *c, const Arg *arg) {
webkit_web_inspector_close(c->inspector);
} else {
webkit_web_inspector_show(c->inspector);
webkit_web_inspector_close(c->inspector);
} else {
webkit_web_inspector_show(c->inspector);
inspector_show(WebKitWebInspector *i, Client *c) {
WebKitWebView *w;
inspector_show(WebKitWebInspector *i, Client *c) {
WebKitWebView *w;
return false;
w = webkit_web_inspector_get_web_view(i);
return false;
w = webkit_web_inspector_get_web_view(i);
inspector_close(WebKitWebInspector *i, Client *c) {
GtkWidget *w;
inspector_close(WebKitWebInspector *i, Client *c) {
GtkWidget *w;
return false;
w = GTK_WIDGET(webkit_web_inspector_get_web_view(i));
return false;
w = GTK_WIDGET(webkit_web_inspector_get_web_view(i));
mods = CLEANMASK(mods);
key = gdk_keyval_to_lower(key);
updatewinid(c);
mods = CLEANMASK(mods);
key = gdk_keyval_to_lower(key);
updatewinid(c);
- for(i = 0; i < LENGTH(keys); i++) {
- if(key == keys[i].keyval
+ for (i = 0; i < LENGTH(keys); i++) {
+ if (key == keys[i].keyval
&& mods == keys[i].mod
&& keys[i].func) {
keys[i].func(c, &(keys[i].arg));
&& mods == keys[i].mod
&& keys[i].func) {
keys[i].func(c, &(keys[i].arg));
static void
linkhover(WebKitWebView *v, const char* t, const char* l, Client *c) {
static void
linkhover(WebKitWebView *v, const char* t, const char* l, Client *c) {
c->linkhover = copystr(&c->linkhover, l);
c->linkhover = copystr(&c->linkhover, l);
- } else if(c->linkhover) {
+ } else if (c->linkhover) {
free(c->linkhover);
c->linkhover = NULL;
}
free(c->linkhover);
c->linkhover = NULL;
}
SoupMessage *msg;
char *uri;
SoupMessage *msg;
char *uri;
- switch(webkit_web_view_get_load_status (c->view)) {
+ switch (webkit_web_view_get_load_status (c->view)) {
case WEBKIT_LOAD_COMMITTED:
uri = geturi(c);
case WEBKIT_LOAD_COMMITTED:
uri = geturi(c);
- if(strstr(uri, "https://") == uri) {
+ if (strstr(uri, "https://") == uri) {
frame = webkit_web_view_get_main_frame(c->view);
src = webkit_web_frame_get_data_source(frame);
request = webkit_web_data_source_get_request(src);
frame = webkit_web_view_get_main_frame(c->view);
src = webkit_web_frame_get_data_source(frame);
request = webkit_web_data_source_get_request(src);
}
setatom(c, AtomUri, uri);
}
setatom(c, AtomUri, uri);
g_object_set(G_OBJECT(set), "user-stylesheet-uri",
getstyle(uri), NULL);
}
g_object_set(G_OBJECT(set), "user-stylesheet-uri",
getstyle(uri), NULL);
}
case WEBKIT_LOAD_FINISHED:
c->progress = 100;
updatetitle(c);
case WEBKIT_LOAD_FINISHED:
c->progress = 100;
updatetitle(c);
soup_cache_flush(diskcache);
soup_cache_dump(diskcache);
}
soup_cache_flush(diskcache);
soup_cache_dump(diskcache);
}
Arg a = { .b = FALSE };
struct stat st;
Arg a = { .b = FALSE };
struct stat st;
- if(strcmp(uri, "") == 0)
+ if (strcmp(uri, "") == 0)
return;
/* In case it's a file path. */
return;
/* In case it's a file path. */
- if(stat(uri, &st) == 0) {
+ if (stat(uri, &st) == 0) {
rp = realpath(uri, NULL);
u = g_strdup_printf("file://%s", rp);
free(rp);
rp = realpath(uri, NULL);
u = g_strdup_printf("file://%s", rp);
free(rp);
setatom(c, AtomUri, uri);
/* prevents endless loop */
setatom(c, AtomUri, uri);
/* prevents endless loop */
- if(strcmp(u, geturi(c)) == 0) {
+ if (strcmp(u, geturi(c)) == 0) {
reload(c, &a);
} else {
webkit_web_view_load_uri(c->view, u);
reload(c, &a);
} else {
webkit_web_view_load_uri(c->view, u);
- if(!(c = calloc(1, sizeof(Client))))
+ if (!(c = calloc(1, sizeof(Client))))
die("Cannot malloc!\n");
c->title = NULL;
c->progress = 100;
/* Window */
die("Cannot malloc!\n");
c->title = NULL;
c->progress = 100;
/* Window */
c->win = gtk_plug_new(embed);
} else {
c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
c->win = gtk_plug_new(embed);
} else {
c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
"leave_notify_event",
G_CALLBACK(titlechangeleave), c);
"leave_notify_event",
G_CALLBACK(titlechangeleave), c);
addaccelgroup(c);
/* Pane */
addaccelgroup(c);
/* Pane */
g_signal_connect(G_OBJECT(frame), "scrollbars-policy-changed",
G_CALLBACK(gtk_true), NULL);
g_signal_connect(G_OBJECT(frame), "scrollbars-policy-changed",
G_CALLBACK(gtk_true), NULL);
- if(!enablescrollbars) {
+ if (!enablescrollbars) {
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
GTK_POLICY_NEVER, GTK_POLICY_NEVER);
} else {
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
GTK_POLICY_NEVER, GTK_POLICY_NEVER);
} else {
runscript(frame);
settings = webkit_web_view_get_settings(c->view);
runscript(frame);
settings = webkit_web_view_get_settings(c->view);
- if(!(ua = getenv("SURF_USERAGENT")))
+ if (!(ua = getenv("SURF_USERAGENT")))
ua = useragent;
g_object_set(G_OBJECT(settings), "user-agent", ua, NULL);
if (enablestyles) {
ua = useragent;
g_object_set(G_OBJECT(settings), "user-agent", ua, NULL);
if (enablestyles) {
* This ensures websites are not unusably small with a high DPI screen.
* It is equivalent to firefox's "layout.css.devPixelsPerPx" setting.
*/
* This ensures websites are not unusably small with a high DPI screen.
* It is equivalent to firefox's "layout.css.devPixelsPerPx" setting.
*/
screen = gdk_window_get_screen(GTK_WIDGET(c->win)->window);
dpi = gdk_screen_get_resolution(screen);
screen = gdk_window_get_screen(GTK_WIDGET(c->win)->window);
dpi = gdk_screen_get_resolution(screen);
g_object_set(G_OBJECT(settings), "enforce-96-dpi", true,
NULL);
webkit_web_view_set_zoom_level(c->view, dpi/96);
}
}
/* This might conflict with _zoomto96dpi_. */
g_object_set(G_OBJECT(settings), "enforce-96-dpi", true,
NULL);
webkit_web_view_set_zoom_level(c->view, dpi/96);
}
}
/* This might conflict with _zoomto96dpi_. */
webkit_web_view_set_zoom_level(c->view, zoomlevel);
webkit_web_view_set_zoom_level(c->view, zoomlevel);
c->inspector = WEBKIT_WEB_INSPECTOR(
webkit_web_view_get_inspector(c->view));
g_signal_connect(G_OBJECT(c->inspector), "inspect-web-view",
c->inspector = WEBKIT_WEB_INSPECTOR(
webkit_web_view_get_inspector(c->view));
g_signal_connect(G_OBJECT(c->inspector), "inspect-web-view",
c->isinspecting = false;
}
c->isinspecting = false;
}
c->fullscreen = 0;
fullscreen(c, NULL);
}
setatom(c, AtomFind, "");
setatom(c, AtomUri, "about:blank");
c->fullscreen = 0;
fullscreen(c, NULL);
}
setatom(c, AtomFind, "");
setatom(c, AtomUri, "about:blank");
webkit_web_view_set_transparent(c->view, TRUE);
c->next = clients;
clients = c;
webkit_web_view_set_transparent(c->view, TRUE);
c->next = clients;
clients = c;
gdk_display_sync(gtk_widget_get_display(c->win));
printf("%u\n",
(guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
gdk_display_sync(gtk_widget_get_display(c->win));
printf("%u\n",
(guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
cmd[i++] = argv0;
cmd[i++] = "-a";
cmd[i++] = cookiepolicies;
cmd[i++] = argv0;
cmd[i++] = "-a";
cmd[i++] = cookiepolicies;
- if(embed && !noembed) {
+ if (embed && !noembed) {
cmd[i++] = "-e";
snprintf(tmp, LENGTH(tmp), "%u", (int)embed);
cmd[i++] = tmp;
}
cmd[i++] = "-e";
snprintf(tmp, LENGTH(tmp), "%u", (int)embed);
cmd[i++] = tmp;
}
cmd[i++] = "-D";
cmd[i++] = "-c";
cmd[i++] = cookiefile;
cmd[i++] = "--";
uri = arg->v ? (char *)arg->v : c->linkhover;
cmd[i++] = "-D";
cmd[i++] = "-c";
cmd[i++] = cookiefile;
cmd[i++] = "--";
uri = arg->v ? (char *)arg->v : c->linkhover;
cmd[i++] = uri;
cmd[i++] = NULL;
spawn(NULL, &a);
cmd[i++] = uri;
cmd[i++] = NULL;
spawn(NULL, &a);
gboolean keyboard, Client *c) {
GList *items = gtk_container_get_children(GTK_CONTAINER(GTK_MENU(menu)));
gboolean keyboard, Client *c) {
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);
}
GtkClipboard *prisel, *clpbrd;
a = gtk_activatable_get_related_action(GTK_ACTIVATABLE(item));
GtkClipboard *prisel, *clpbrd;
a = gtk_activatable_get_related_action(GTK_ACTIVATABLE(item));
return;
name = gtk_action_get_name(a);
return;
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);
gtk_clipboard_set_text(prisel, c->linkhover, -1);
prisel = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
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);
clpbrd = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
uri = gtk_clipboard_wait_for_text(clpbrd);
prisel = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
clpbrd = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
uri = gtk_clipboard_wait_for_text(clpbrd);
gtk_clipboard_set_text(prisel, uri, -1);
}
}
gtk_clipboard_set_text(prisel, uri, -1);
}
}
static void
pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) {
Arg arg = {.v = text };
static void
pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) {
Arg arg = {.v = text };
loaduri((Client *) d, &arg);
}
loaduri((Client *) d, &arg);
}
XPropertyEvent *ev;
Arg arg;
XPropertyEvent *ev;
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->atom == atoms[AtomFind]) {
+ if (ev->state == PropertyNewValue) {
+ if (ev->atom == atoms[AtomFind]) {
arg.b = TRUE;
find(c, &arg);
return GDK_FILTER_REMOVE;
arg.b = TRUE;
find(c, &arg);
return GDK_FILTER_REMOVE;
- } else if(ev->atom == atoms[AtomGo]) {
+ } else if (ev->atom == atoms[AtomGo]) {
arg.v = getatom(c, AtomGo);
loaduri(c, &arg);
arg.v = getatom(c, AtomGo);
loaduri(c, &arg);
static void
reload(Client *c, const Arg *arg) {
gboolean nocache = *(gboolean *)arg;
static void
reload(Client *c, const Arg *arg) {
gboolean nocache = *(gboolean *)arg;
webkit_web_view_reload_bypass_cache(c->view);
} else {
webkit_web_view_reload(c->view);
webkit_web_view_reload_bypass_cache(c->view);
} else {
webkit_web_view_reload(c->view);
gdouble v;
v = gtk_adjustment_get_value(a);
gdouble v;
v = gtk_adjustment_get_value(a);
case +10000:
case -10000:
v += gtk_adjustment_get_page_increment(a) *
case +10000:
case -10000:
v += gtk_adjustment_get_page_increment(a) *
scriptfile = buildfile(scriptfile);
cachefolder = buildpath(cachefolder);
styledir = buildpath(styledir);
scriptfile = buildfile(scriptfile);
cachefolder = buildpath(cachefolder);
styledir = buildpath(styledir);
- if(stylefile == NULL) {
- for(i = 0; i < LENGTH(styles); i++) {
- if(regcomp(&(styles[i].re), styles[i].regex,
+ if (stylefile == NULL) {
+ for (i = 0; i < LENGTH(styles); i++) {
+ if (regcomp(&(styles[i].re), styles[i].regex,
REG_EXTENDED)) {
fprintf(stderr,
"Could not compile regex: %s\n",
REG_EXTENDED)) {
fprintf(stderr,
"Could not compile regex: %s\n",
cookiepolicy_get())));
/* disk cache */
cookiepolicy_get())));
/* disk cache */
diskcache = soup_cache_new(cachefolder, SOUP_CACHE_SINGLE_USER);
soup_cache_set_max_size(diskcache, diskcachebytes);
soup_cache_load(diskcache);
diskcache = soup_cache_new(cachefolder, SOUP_CACHE_SINGLE_USER);
soup_cache_set_max_size(diskcache, diskcachebytes);
soup_cache_load(diskcache);
/* ssl */
tlsdb = g_tls_file_database_new(cafile, &error);
/* ssl */
tlsdb = g_tls_file_database_new(cafile, &error);
g_warning("Error loading SSL database %s: %s", cafile, error->message);
g_error_free(error);
}
g_warning("Error loading SSL database %s: %s", cafile, error->message);
g_error_free(error);
}
g_object_set(G_OBJECT(s), "ssl-strict", strictssl, NULL);
/* proxy */
g_object_set(G_OBJECT(s), "ssl-strict", strictssl, NULL);
/* proxy */
- if((proxy = getenv("http_proxy")) && strcmp(proxy, "")) {
+ if ((proxy = getenv("http_proxy")) && strcmp(proxy, "")) {
new_proxy = g_strrstr(proxy, "http://")
|| g_strrstr(proxy, "socks://")
|| g_strrstr(proxy, "socks4://")
new_proxy = g_strrstr(proxy, "http://")
|| g_strrstr(proxy, "socks://")
|| g_strrstr(proxy, "socks4://")
static void
sigchld(int unused) {
static void
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
spawn(Client *c, const Arg *arg) {
static void
spawn(Client *c, const Arg *arg) {
- if(fork() == 0) {
- if(dpy)
+ if (fork() == 0) {
+ if (dpy)
close(ConnectionNumber(dpy));
setsid();
execvp(((char **)arg->v)[0], (char **)arg->v);
close(ConnectionNumber(dpy));
setsid();
execvp(((char **)arg->v)[0], (char **)arg->v);
g_object_get(G_OBJECT(jar), "accept-policy", &policy, NULL);
policysel++;
g_object_get(G_OBJECT(jar), "accept-policy", &policy, NULL);
policysel++;
- if(policysel >= strlen(cookiepolicies))
+ if (policysel >= strlen(cookiepolicies))
policysel = 0;
g_object_set(G_OBJECT(jar), "accept-policy",
policysel = 0;
g_object_set(G_OBJECT(jar), "accept-policy",
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_POLICY_NEVER, GTK_POLICY_NEVER);
} else {
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
GTK_POLICY_NEVER, GTK_POLICY_NEVER);
} else {
getpagestat(Client *c) {
const char *uri = geturi(c);
getpagestat(Client *c) {
const char *uri = geturi(c);
- if(strstr(uri, "https://") == uri) {
+ if (strstr(uri, "https://") == uri) {
pagestat[0] = c->sslfailed ? 'U' : 'T';
} else {
pagestat[0] = '-';
pagestat[0] = c->sslfailed ? 'U' : 'T';
} else {
pagestat[0] = '-';
updatetitle(Client *c) {
char *t;
updatetitle(Client *c) {
char *t;
gettogglestat(c);
getpagestat(c);
gettogglestat(c);
getpagestat(c);
t = g_strdup_printf("%s:%s | %s", togglestat,
pagestat, c->linkhover);
t = g_strdup_printf("%s:%s | %s", togglestat,
pagestat, c->linkhover);
- } else if(c->progress != 100) {
+ } else if (c->progress != 100) {
t = g_strdup_printf("[%i%%] %s:%s | %s", c->progress,
togglestat, pagestat,
(c->title == NULL)? "" : c->title);
t = g_strdup_printf("[%i%%] %s:%s | %s", c->progress,
togglestat, pagestat,
(c->title == NULL)? "" : c->title);
static void
zoom(Client *c, const Arg *arg) {
c->zoomed = TRUE;
static void
zoom(Client *c, const Arg *arg) {
c->zoomed = TRUE;
/* zoom out */
webkit_web_view_zoom_out(c->view);
/* zoom out */
webkit_web_view_zoom_out(c->view);
- } else if(arg->i > 0) {
+ } else if (arg->i > 0) {
/* zoom in */
webkit_web_view_zoom_in(c->view);
} else {
/* zoom in */
webkit_web_view_zoom_in(c->view);
} else {
default:
usage();
} ARGEND;
default:
usage();
} ARGEND;
arg.v = argv[0];
setup();
c = newclient();
arg.v = argv[0];
setup();
c = newclient();
loaduri(clients, &arg);
} else {
updatetitle(c);
loaduri(clients, &arg);
} else {
updatetitle(c);