1 /* See LICENSE file for copyright and license details.
3 * To understand surf, start reading main().
11 #include <gdk/gdkkeysyms.h>
13 #include <sys/types.h>
18 #include <webkit/webkit.h>
19 #include <glib/gstdio.h>
20 #include <JavaScriptCore/JavaScript.h>
23 #define LENGTH(x) (sizeof x / sizeof x[0])
24 #define CLEANMASK(mask) (mask & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
26 enum { AtomFind, AtomGo, AtomUri, AtomLast };
28 typedef union Arg Arg;
35 typedef struct Client {
36 GtkWidget *win, *scroll, *vbox, *indicator;
38 char *title, *linkhover;
39 const char *uri, *needle;
48 void (*func)(Client *c, const Arg *arg);
55 void (*func)(Client *c, const Arg *arg);
60 static Atom atoms[AtomLast];
61 static Client *clients = NULL;
62 static GdkNativeWindow embed = 0;
63 static gboolean showxid = FALSE;
64 static char winid[64];
65 static char *progname;
66 static gboolean loadimage = 1, plugin = 1, script = 1;
68 static char *buildpath(const char *path);
69 static gboolean buttonrelease(WebKitWebView *web, GdkEventButton *e, GList *gl);
70 static void cleanup(void);
71 static void clipboard(Client *c, const Arg *arg);
72 static char *copystr(char **str, const char *src);
73 static WebKitWebView *createwindow(WebKitWebView *v, WebKitWebFrame *f, Client *c);
74 static gboolean decidedownload(WebKitWebView *v, WebKitWebFrame *f, WebKitNetworkRequest *r, gchar *m, WebKitWebPolicyDecision *p, Client *c);
75 static gboolean decidewindow(WebKitWebView *v, WebKitWebFrame *f, WebKitNetworkRequest *r, WebKitWebNavigationAction *n, WebKitWebPolicyDecision *p, Client *c);
76 static void destroyclient(Client *c);
77 static void destroywin(GtkWidget* w, Client *c);
78 static void die(char *str);
79 static void drawindicator(Client *c);
80 static gboolean exposeindicator(GtkWidget *w, GdkEventExpose *e, Client *c);
81 static void find(Client *c, const Arg *arg);
82 static const char *getatom(Client *c, int a);
83 static const char *getcookies(SoupURI *uri);
84 static char *geturi(Client *c);
85 void gotheaders(SoupMessage *msg, gpointer user_data);
86 static gboolean initdownload(WebKitWebView *v, WebKitDownload *o, Client *c);
87 static gboolean keypress(GtkWidget *w, GdkEventKey *ev, Client *c);
88 static void linkhover(WebKitWebView *v, const char* t, const char* l, Client *c);
89 static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c);
90 static void loaduri(Client *c, const Arg *arg);
91 static void navigate(Client *c, const Arg *arg);
92 static Client *newclient(void);
93 static void newwindow(Client *c, const Arg *arg, gboolean noembed);
94 static void newrequest(SoupSession *s, SoupMessage *msg, gpointer v);
95 static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
96 static void print(Client *c, const Arg *arg);
97 static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d);
98 static void progresschange(WebKitWebView *view, GParamSpec *pspec, Client *c);
99 static void reload(Client *c, const Arg *arg);
100 static void scroll_h(Client *c, const Arg *arg);
101 static void scroll_v(Client *c, const Arg *arg);
102 static void scroll(GtkAdjustment *a, const Arg *arg);
103 static void setatom(Client *c, int a, const char *v);
104 static void setcookie(SoupCookie *c);
105 static void setup(void);
106 static void sigchld(int unused);
107 static void source(Client *c, const Arg *arg);
108 static void spawn(Client *c, const Arg *arg);
109 static void eval(Client *c, const Arg *arg);
110 static void stop(Client *c, const Arg *arg);
111 static void titlechange(WebKitWebView *v, WebKitWebFrame* frame, const char* title, Client *c);
112 static void update(Client *c);
113 static void updatewinid(Client *c);
114 static void usage(void);
115 static void windowobjectcleared(GtkWidget *w, WebKitWebFrame *frame, JSContextRef js, JSObjectRef win, Client *c);
116 static void zoom(Client *c, const Arg *arg);
118 /* configuration, allows nested code to access above variables */
122 buildpath(const char *path) {
126 /* creating directory */
128 apath = g_strdup(path);
130 apath = g_strconcat(g_get_home_dir(), "/", path, NULL);
131 if((p = strrchr(apath, '/'))) {
133 g_mkdir_with_parents(apath, 0700);
134 g_chmod(apath, 0700); /* in case it existed */
137 /* creating file (gives error when apath ends with "/") */
138 if((f = fopen(apath, "a"))) {
139 g_chmod(apath, 0600); /* always */
146 buttonrelease(WebKitWebView *web, GdkEventButton *e, GList *gl) {
147 WebKitHitTestResultContext context;
148 WebKitHitTestResult *result = webkit_web_view_get_hit_test_result(web, e);
151 g_object_get(result, "context", &context, NULL);
152 if(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) {
154 g_object_get(result, "link-uri", &arg.v, NULL);
155 newwindow(NULL, &arg, e->state & GDK_CONTROL_MASK);
165 destroyclient(clients);
172 evalscript(JSContextRef js, char *script, char* scriptname) {
173 JSStringRef jsscript, jsscriptname;
174 JSValueRef exception = NULL;
176 jsscript = JSStringCreateWithUTF8CString(script);
177 jsscriptname = JSStringCreateWithUTF8CString(scriptname);
178 JSEvaluateScript(js, jsscript, JSContextGetGlobalObject(js), jsscriptname, 0, &exception);
179 JSStringRelease(jsscript);
180 JSStringRelease(jsscriptname);
184 runscript(WebKitWebFrame *frame) {
188 if(g_file_get_contents(scriptfile, &script, NULL, &error)) {
189 evalscript(webkit_web_frame_get_global_context(frame), script, scriptfile);
194 clipboard(Client *c, const Arg *arg) {
195 gboolean paste = *(gboolean *)arg;
198 gtk_clipboard_request_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), pasteuri, c);
200 gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), c->linkhover ? c->linkhover : geturi(c), -1);
204 copystr(char **str, const char *src) {
216 createwindow(WebKitWebView *v, WebKitWebFrame *f, Client *c) {
217 Client *n = newclient();
222 decidedownload(WebKitWebView *v, WebKitWebFrame *f, WebKitNetworkRequest *r, gchar *m, WebKitWebPolicyDecision *p, Client *c) {
223 if(!webkit_web_view_can_show_mime_type(v, m)) {
224 webkit_web_policy_decision_download(p);
231 decidewindow(WebKitWebView *view, WebKitWebFrame *f, WebKitNetworkRequest *r, WebKitWebNavigationAction *n, WebKitWebPolicyDecision *p, Client *c) {
234 if(webkit_web_navigation_action_get_reason(n) == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
235 webkit_web_policy_decision_ignore(p);
236 arg.v = (void *)webkit_network_request_get_uri(r);
237 newwindow(NULL, &arg, 0);
244 destroyclient(Client *c) {
247 webkit_web_view_stop_loading(c->view);
248 gtk_widget_destroy(c->indicator);
249 gtk_widget_destroy(GTK_WIDGET(c->view));
250 gtk_widget_destroy(c->scroll);
251 gtk_widget_destroy(c->vbox);
252 gtk_widget_destroy(c->win);
254 for(p = clients; p && p->next != c; p = p->next);
265 destroywin(GtkWidget* w, Client *c) {
276 drawindicator(Client *c) {
285 width = c->progress * w->allocation.width / 100;
286 gc = gdk_gc_new(w->window);
287 if(strstr(uri, "https://") == uri)
288 gdk_color_parse(c->sslfailed ?
289 progress_untrust : progress_trust, &fg);
291 gdk_color_parse(progress, &fg);
292 gdk_gc_set_rgb_fg_color(gc, &fg);
293 gdk_draw_rectangle(w->window,
294 w->style->bg_gc[GTK_WIDGET_STATE(w)],
295 TRUE, 0, 0, w->allocation.width, w->allocation.height);
296 gdk_draw_rectangle(w->window, gc, TRUE, 0, 0, width,
297 w->allocation.height);
302 exposeindicator(GtkWidget *w, GdkEventExpose *e, Client *c) {
308 find(Client *c, const Arg *arg) {
311 s = getatom(c, AtomFind);
312 gboolean forward = *(gboolean *)arg;
313 webkit_web_view_search_text(c->view, s, FALSE, forward, TRUE);
317 getcookies(SoupURI *uri) {
319 SoupCookieJar *j = soup_cookie_jar_text_new(cookiefile, TRUE);
320 c = soup_cookie_jar_get_cookies(j, uri, TRUE);
326 getatom(Client *c, int a) {
327 static char buf[BUFSIZ];
330 unsigned long ldummy;
331 unsigned char *p = NULL;
333 XGetWindowProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window),
334 atoms[a], 0L, BUFSIZ, False, XA_STRING,
335 &adummy, &idummy, &ldummy, &ldummy, &p);
337 strncpy(buf, (char *)p, LENGTH(buf)-1);
348 if(!(uri = (char *)webkit_web_view_get_uri(c->view)))
354 gotheaders(SoupMessage *msg, gpointer v) {
357 for(p = l = soup_cookies_from_response(msg); p;
358 p = g_slist_next(p)) {
359 setcookie((SoupCookie *)p->data);
361 soup_cookies_free(l);
365 initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) {
369 arg = (Arg)DOWNLOAD((char *)webkit_download_get_uri(o));
375 keypress(GtkWidget* w, GdkEventKey *ev, Client *c) {
377 gboolean processed = FALSE;
380 for(i = 0; i < LENGTH(keys); i++) {
381 if(gdk_keyval_to_lower(ev->keyval) == keys[i].keyval
382 && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)
384 keys[i].func(c, &(keys[i].arg));
392 linkhover(WebKitWebView *v, const char* t, const char* l, Client *c) {
394 c->linkhover = copystr(&c->linkhover, l);
396 else if(c->linkhover) {
404 loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c) {
405 WebKitWebFrame *frame;
406 WebKitWebDataSource *src;
407 WebKitNetworkRequest *request;
411 switch(webkit_web_view_get_load_status (c->view)) {
412 case WEBKIT_LOAD_COMMITTED:
414 if(strstr(uri, "https://") == uri) {
415 frame = webkit_web_view_get_main_frame(c->view);
416 src = webkit_web_frame_get_data_source(frame);
417 request = webkit_web_data_source_get_request(src);
418 msg = webkit_network_request_get_message(request);
419 c->sslfailed = soup_message_get_flags(msg)
420 ^ SOUP_MESSAGE_CERTIFICATE_TRUSTED;
422 setatom(c, AtomUri, uri);
424 case WEBKIT_LOAD_FINISHED:
434 loaduri(Client *c, const Arg *arg) {
436 const char *uri = (char *)arg->v;
437 Arg a = { .b = FALSE };
439 if(strcmp(uri, "") == 0)
441 u = g_strrstr(uri, "://") ? g_strdup(uri)
442 : g_strdup_printf("http://%s", uri);
443 /* prevents endless loop */
444 if(c->uri && strcmp(u, c->uri) == 0) {
448 webkit_web_view_load_uri(c->view, u);
450 c->title = copystr(&c->title, u);
457 navigate(Client *c, const Arg *arg) {
458 int steps = *(int *)arg;
459 webkit_web_view_go_back_or_forward(c->view, steps);
465 WebKitWebSettings *settings;
466 WebKitWebFrame *frame;
467 GdkGeometry hints = { 1, 1 };
470 if(!(c = calloc(1, sizeof(Client))))
471 die("Cannot malloc!\n");
474 c->win = gtk_plug_new(embed);
477 c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
478 /* TA: 20091214: Despite what the GNOME docs say, the ICCCM
479 * is always correct, so we should still call this function.
480 * But when doing so, we *must* differentiate between a
481 * WM_CLASS and a resource on the window. By convention, the
482 * window class (WM_CLASS) is capped, while the resource is in
483 * lowercase. Both these values come as a pair.
485 gtk_window_set_wmclass(GTK_WINDOW(c->win), "surf", "Surf");
487 /* TA: 20091214: And set the role here as well -- so that
488 * sessions can pick this up.
490 gtk_window_set_role(GTK_WINDOW(c->win), "Surf");
492 gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
493 g_signal_connect(G_OBJECT(c->win), "destroy", G_CALLBACK(destroywin), c);
494 g_signal_connect(G_OBJECT(c->win), "key-press-event", G_CALLBACK(keypress), c);
497 c->vbox = gtk_vbox_new(FALSE, 0);
499 /* Scrolled Window */
500 c->scroll = gtk_scrolled_window_new(NULL, NULL);
501 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
502 GTK_POLICY_NEVER, GTK_POLICY_NEVER);
505 c->view = WEBKIT_WEB_VIEW(webkit_web_view_new());
506 g_signal_connect(G_OBJECT(c->view), "title-changed", G_CALLBACK(titlechange), c);
507 g_signal_connect(G_OBJECT(c->view), "hovering-over-link", G_CALLBACK(linkhover), c);
508 g_signal_connect(G_OBJECT(c->view), "create-web-view", G_CALLBACK(createwindow), c);
509 g_signal_connect(G_OBJECT(c->view), "new-window-policy-decision-requested", G_CALLBACK(decidewindow), c);
510 g_signal_connect(G_OBJECT(c->view), "mime-type-policy-decision-requested", G_CALLBACK(decidedownload), c);
511 g_signal_connect(G_OBJECT(c->view), "window-object-cleared", G_CALLBACK(windowobjectcleared), c);
512 g_signal_connect(G_OBJECT(c->view), "notify::load-status", G_CALLBACK(loadstatuschange), c);
513 g_signal_connect(G_OBJECT(c->view), "notify::progress", G_CALLBACK(progresschange), c);
514 g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c);
515 g_signal_connect(G_OBJECT(c->view), "button-release-event", G_CALLBACK(buttonrelease), c);
518 c->indicator = gtk_drawing_area_new();
519 gtk_widget_set_size_request(c->indicator, 0, 2);
520 g_signal_connect (G_OBJECT (c->indicator), "expose_event",
521 G_CALLBACK (exposeindicator), c);
524 gtk_container_add(GTK_CONTAINER(c->scroll), GTK_WIDGET(c->view));
525 gtk_container_add(GTK_CONTAINER(c->win), c->vbox);
526 gtk_container_add(GTK_CONTAINER(c->vbox), c->scroll);
527 gtk_container_add(GTK_CONTAINER(c->vbox), c->indicator);
530 gtk_box_set_child_packing(GTK_BOX(c->vbox), c->indicator, FALSE, FALSE, 0, GTK_PACK_START);
531 gtk_box_set_child_packing(GTK_BOX(c->vbox), c->scroll, TRUE, TRUE, 0, GTK_PACK_START);
532 gtk_widget_grab_focus(GTK_WIDGET(c->view));
533 gtk_widget_show(c->vbox);
534 gtk_widget_show(c->indicator);
535 gtk_widget_show(c->scroll);
536 gtk_widget_show(GTK_WIDGET(c->view));
537 gtk_widget_show(c->win);
538 gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints, GDK_HINT_MIN_SIZE);
539 gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK);
540 gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
541 webkit_web_view_set_full_content_zoom(c->view, TRUE);
542 frame = webkit_web_view_get_main_frame(c->view);
544 settings = webkit_web_view_get_settings(c->view);
545 if(!(ua = getenv("SURF_USERAGENT")))
547 g_object_set(G_OBJECT(settings), "user-agent", ua, NULL);
548 uri = g_strconcat("file://", stylefile, NULL);
549 g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL);
550 g_object_set(G_OBJECT(settings), "auto-load-images", loadimage, NULL);
551 g_object_set(G_OBJECT(settings), "enable-plugins", plugin, NULL);
552 g_object_set(G_OBJECT(settings), "enable-scripts", script, NULL);
553 g_object_set(G_OBJECT(settings), "enable-spatial-navigation", SPATIAL_BROWSING, NULL);
557 setatom(c, AtomFind, "");
558 setatom(c, AtomUri, "about:blank");
560 webkit_web_view_set_transparent(c->view, TRUE);
566 gdk_display_sync(gtk_widget_get_display(c->win));
567 printf("%u\n", (guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
569 if (fclose(stdout) != 0) {
570 die("Error closing stdout");
577 newrequest(SoupSession *s, SoupMessage *msg, gpointer v) {
578 SoupMessageHeaders *h = msg->request_headers;
582 soup_message_headers_remove(h, "Cookie");
583 uri = soup_message_get_uri(msg);
584 if((c = getcookies(uri)))
585 soup_message_headers_append(h, "Cookie", c);
586 g_signal_connect_after(G_OBJECT(msg), "got-headers", G_CALLBACK(gotheaders), NULL);
590 newwindow(Client *c, const Arg *arg, gboolean noembed) {
592 const char *cmd[10], *uri;
593 const Arg a = { .v = (void *)cmd };
597 if(embed && !noembed) {
599 snprintf(tmp, LENGTH(tmp), "%u\n", (int)embed);
611 uri = arg->v ? (char *)arg->v : c->linkhover;
619 pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) {
620 Arg arg = {.v = text };
622 loaduri((Client *) d, &arg);
626 print(Client *c, const Arg *arg) {
627 webkit_web_frame_print(webkit_web_view_get_main_frame(c->view));
631 processx(GdkXEvent *e, GdkEvent *event, gpointer d) {
632 Client *c = (Client *)d;
636 if(((XEvent *)e)->type == PropertyNotify) {
637 ev = &((XEvent *)e)->xproperty;
638 if(ev->state == PropertyNewValue) {
639 if(ev->atom == atoms[AtomFind]) {
642 return GDK_FILTER_REMOVE;
644 else if(ev->atom == atoms[AtomGo]) {
645 arg.v = getatom(c, AtomGo);
647 return GDK_FILTER_REMOVE;
651 return GDK_FILTER_CONTINUE;
655 progresschange(WebKitWebView *view, GParamSpec *pspec, Client *c) {
656 c->progress = webkit_web_view_get_progress(c->view) * 100;
661 reload(Client *c, const Arg *arg) {
662 gboolean nocache = *(gboolean *)arg;
664 webkit_web_view_reload_bypass_cache(c->view);
666 webkit_web_view_reload(c->view);
670 scroll_h(Client *c, const Arg *arg) {
671 scroll(gtk_scrolled_window_get_hadjustment(
672 GTK_SCROLLED_WINDOW(c->scroll)), arg);
676 scroll_v(Client *c, const Arg *arg) {
677 scroll(gtk_scrolled_window_get_vadjustment(
678 GTK_SCROLLED_WINDOW(c->scroll)), arg);
682 scroll(GtkAdjustment *a, const Arg *arg) {
685 v = gtk_adjustment_get_value(a);
689 v += gtk_adjustment_get_page_increment(a) *
695 v += gtk_adjustment_get_step_increment(a) * arg->i;
699 v = MIN(v, gtk_adjustment_get_upper(a) -
700 gtk_adjustment_get_page_size(a));
701 gtk_adjustment_set_value(a, v);
705 setcookie(SoupCookie *c) {
708 lock = open(cookiefile, 0);
709 flock(lock, LOCK_EX);
711 SoupCookieJar *j = soup_cookie_jar_text_new(cookiefile, FALSE);
712 c = soup_cookie_copy(c);
713 if(c->expires == NULL && sessiontime) {
714 e = soup_date_new_from_time_t(time(NULL) + sessiontime);
715 soup_cookie_set_expires(c, e);
717 soup_cookie_jar_add_cookie(j, c);
719 flock(lock, LOCK_UN);
724 setatom(Client *c, int a, const char *v) {
726 XChangeProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window), atoms[a],
727 XA_STRING, 8, PropModeReplace, (unsigned char *)v,
738 /* clean up any zombies immediately */
740 gtk_init(NULL, NULL);
741 if (!g_thread_supported())
745 s = webkit_get_default_session();
748 atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False);
749 atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False);
750 atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False);
753 cookiefile = buildpath(cookiefile);
754 scriptfile = buildpath(scriptfile);
755 stylefile = buildpath(stylefile);
757 /* request handler */
758 s = webkit_get_default_session();
759 soup_session_remove_feature_by_type(s, soup_cookie_get_type());
760 soup_session_remove_feature_by_type(s, soup_cookie_jar_get_type());
761 g_signal_connect_after(G_OBJECT(s), "request-started", G_CALLBACK(newrequest), NULL);
764 g_object_set(G_OBJECT(s), "ssl-ca-file", cafile, NULL);
765 g_object_set(G_OBJECT(s), "ssl-strict", strictssl, NULL);
768 if((proxy = getenv("http_proxy")) && strcmp(proxy, "")) {
769 new_proxy = g_strrstr(proxy, "http://") ? g_strdup(proxy) :
770 g_strdup_printf("http://%s", proxy);
771 puri = soup_uri_new(new_proxy);
772 g_object_set(G_OBJECT(s), "proxy-uri", puri, NULL);
779 sigchld(int unused) {
780 if(signal(SIGCHLD, sigchld) == SIG_ERR)
781 die("Can't install SIGCHLD handler");
782 while(0 < waitpid(-1, NULL, WNOHANG));
786 source(Client *c, const Arg *arg) {
787 Arg a = { .b = FALSE };
790 s = webkit_web_view_get_view_source_mode(c->view);
791 webkit_web_view_set_view_source_mode(c->view, !s);
796 spawn(Client *c, const Arg *arg) {
799 close(ConnectionNumber(dpy));
801 execvp(((char **)arg->v)[0], (char **)arg->v);
802 fprintf(stderr, "surf: execvp %s", ((char **)arg->v)[0]);
809 eval(Client *c, const Arg *arg) {
810 WebKitWebFrame *frame = webkit_web_view_get_main_frame(c->view);
811 evalscript(webkit_web_frame_get_global_context(frame),
812 ((char **)arg->v)[0], "");
816 stop(Client *c, const Arg *arg) {
817 webkit_web_view_stop_loading(c->view);
821 titlechange(WebKitWebView *v, WebKitWebFrame *f, const char *t, Client *c) {
822 c->title = copystr(&c->title, t);
831 t = g_strdup(c->linkhover);
832 else if(c->progress != 100)
833 t = g_strdup_printf("[%i%%] %s", c->progress, c->title);
835 t = g_strdup(c->title);
837 gtk_window_set_title(GTK_WINDOW(c->win), t);
842 updatewinid(Client *c) {
843 snprintf(winid, LENGTH(winid), "%u",
844 (int)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
849 fputs("surf - simple browser\n", stderr);
850 die("usage: surf [-e xid] [-i] [-p] [-s] [-v] [-x] [uri]\n");
854 windowobjectcleared(GtkWidget *w, WebKitWebFrame *frame, JSContextRef js, JSObjectRef win, Client *c) {
859 zoom(Client *c, const Arg *arg) {
861 if(arg->i < 0) /* zoom out */
862 webkit_web_view_zoom_out(c->view);
863 else if(arg->i > 0) /* zoom in */
864 webkit_web_view_zoom_in(c->view);
867 webkit_web_view_set_zoom_level(c->view, 1.0);
872 main(int argc, char *argv[]) {
877 /* command line args */
878 for(i = 1, arg.v = NULL; i < argc && argv[i][0] == '-' &&
879 argv[i][1] != '\0' && argv[i][2] == '\0'; i++) {
880 if(!strcmp(argv[i], "--")) {
887 embed = strtol(argv[i], NULL, 0);
904 die("surf-"VERSION", ©2009-2012 surf engineers, see LICENSE for details\n");
914 loaduri(clients, &arg);