whitespace fix.
[surf.git] / surf.c
diff --git a/surf.c b/surf.c
index 016610b..49c7c34 100644 (file)
--- a/surf.c
+++ b/surf.c
@@ -73,6 +73,7 @@ static char *progname;
 
 static const char *autouri(Client *c);
 static char *buildpath(const char *path);
+static void changecookie(SoupCookieJar *jar, SoupCookie *o, SoupCookie *n, gpointer p);
 static void cleanup(void);
 static void clipboard(Client *c, const Arg *arg);
 static void context(WebKitWebView *v, GtkMenu *m, Client *c);
@@ -155,6 +156,18 @@ buildpath(const char *path) {
        return apath;
 }
 
+void
+changecookie(SoupCookieJar *jar, SoupCookie *oc, SoupCookie *c, gpointer p) {
+       SoupDate *e;
+
+       if(c && c->expires == NULL) {
+               e = soup_date_new_from_time_t(time(NULL) + sessiontime);
+               c = soup_cookie_copy(c);
+               soup_cookie_set_expires(c, e);
+               soup_cookie_jar_add_cookie(cookiejar, c);
+       }
+}
+
 void
 cleanup(void) {
        while(clients)
@@ -187,8 +200,6 @@ context(WebKitWebView *v, GtkMenu *m, Client *c) {
                if(parent)
                        gtk_container_remove(parent, c->items[i]);
                gtk_menu_shell_append(GTK_MENU_SHELL(m), c->items[i]);
-               g_signal_connect(G_OBJECT(c->items[i]), "activate",
-                               G_CALLBACK(itemclick), c);
                gtk_widget_show(c->items[i]);
        }
 }
@@ -459,9 +470,11 @@ newclient(void) {
                die("Cannot malloc!\n");
 
        /* contextmenu */
-       for(i = 0; i < LENGTH(items); i++)
+       for(i = 0; i < LENGTH(items); i++) {
                c->items[i] = gtk_menu_item_new_with_label(items[i].label);
-
+               g_signal_connect(G_OBJECT(c->items[i]), "activate",
+                               G_CALLBACK(itemclick), c);
+       }
 
        /* VBox */
        c->vbox = gtk_vbox_new(FALSE, 0);
@@ -669,7 +682,7 @@ setup(void) {
 
        dpy = GDK_DISPLAY();
        session = webkit_get_default_session();
-       uriprop = XInternAtom(dpy, "_SURF_uri", False);
+       uriprop = XInternAtom(dpy, "_SURF_URI", False);
 
        /* create dirs and files */
        cookiefile = buildpath(cookiefile);
@@ -681,6 +694,7 @@ setup(void) {
        s = webkit_get_default_session();
        cookiejar = soup_cookie_jar_text_new(cookiefile, FALSE);
        soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookiejar));
+       g_signal_connect(cookiejar, "changed", G_CALLBACK(changecookie), NULL);
 }
 
 void
@@ -736,7 +750,7 @@ spawn(Client *c, const Arg *arg) {
                        close(ConnectionNumber(dpy));
                setsid();
                execvp(((char **)arg->v)[0], (char **)arg->v);
-               fprintf(stderr, "tabbed: execvp %s", ((char **)arg->v)[0]);
+               fprintf(stderr, "surf: execvp %s", ((char **)arg->v)[0]);
                perror(" failed");
                exit(0);
        }