X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=surf.c;h=2e9c38d2660f3168ae95875c27bcd71b7300b077;hb=637902b452c723e8d5fdb714e8a38861e9c9f64e;hp=906d1452ae6fa84c6cf597f5bc347753d39ed903;hpb=780cca964ca0cf622746ad6e8cae8beb8047d1df;p=surf.git diff --git a/surf.c b/surf.c index 906d145..2e9c38d 100644 --- a/surf.c +++ b/surf.c @@ -656,7 +656,7 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c) { static void loaduri(Client *c, const Arg *arg) { - char *u, *rp; + char *u = NULL, *rp; const char *uri = (char *)arg->v; Arg a = { .b = FALSE }; struct stat st; @@ -683,9 +683,9 @@ loaduri(Client *c, const Arg *arg) { webkit_web_view_load_uri(c->view, u); c->progress = 0; c->title = copystr(&c->title, u); - g_free(u); updatetitle(c); } + g_free(u); } static void @@ -707,6 +707,9 @@ newclient(void) { if(!(c = calloc(1, sizeof(Client)))) die("Cannot malloc!\n"); + c->title = NULL; + c->progress = 100; + /* Window */ if(embed) { c->win = gtk_plug_new(embed); @@ -890,7 +893,6 @@ newclient(void) { if(hidebackground) webkit_web_view_set_transparent(c->view, TRUE); - c->title = NULL; c->next = clients; clients = c; @@ -910,11 +912,13 @@ newclient(void) { static void newwindow(Client *c, const Arg *arg, gboolean noembed) { guint i = 0; - const char *cmd[14], *uri; + const char *cmd[16], *uri; const Arg a = { .v = (void *)cmd }; char tmp[64]; cmd[i++] = argv0; + cmd[i++] = "-a"; + cmd[i++] = cookiepolicies; if(!enablescrollbars) cmd[i++] = "-b"; if(embed && !noembed) { @@ -1333,16 +1337,18 @@ updatetitle(Client *c) { pagestat, c->linkhover); } else if(c->progress != 100) { t = g_strdup_printf("[%i%%] %s:%s | %s", c->progress, - togglestat, pagestat, c->title); + togglestat, pagestat, + (c->title == NULL)? "" : c->title); } else { t = g_strdup_printf("%s:%s | %s", togglestat, pagestat, - c->title); + (c->title == NULL)? "" : c->title); } gtk_window_set_title(GTK_WINDOW(c->win), t); g_free(t); } else { - gtk_window_set_title(GTK_WINDOW(c->win), c->title); + gtk_window_set_title(GTK_WINDOW(c->win), + (c->title == NULL)? "" : c->title); } } @@ -1386,11 +1392,15 @@ zoom(Client *c, const Arg *arg) { int main(int argc, char *argv[]) { Arg arg; + Client *c; memset(&arg, 0, sizeof(arg)); /* command line args */ ARGBEGIN { + case 'a': + cookiepolicies = EARGF(usage()); + break; case 'b': enablescrollbars = 0; break; @@ -1455,7 +1465,7 @@ main(int argc, char *argv[]) { useragent = EARGF(usage()); break; case 'v': - die("surf-"VERSION", ©2009-2012 surf engineers, " + die("surf-"VERSION", ©2009-2014 surf engineers, " "see LICENSE for details\n"); case 'x': showxid = TRUE; @@ -1470,9 +1480,12 @@ main(int argc, char *argv[]) { arg.v = argv[0]; setup(); - newclient(); - if(arg.v) + c = newclient(); + if(arg.v) { loaduri(clients, &arg); + } else { + updatetitle(c); + } gtk_main(); cleanup();