adding surf-directory.
[surf.git] / surf.c
diff --git a/surf.c b/surf.c
index f820249..97981b7 100644 (file)
--- a/surf.c
+++ b/surf.c
@@ -28,6 +28,7 @@ typedef struct Client {
        gint progress;
        struct Client *next;
 } Client;
+SoupCookieJar *cookiejar;
 Client *clients = NULL;
 gboolean embed = FALSE;
 gboolean showxid = FALSE;
@@ -260,7 +261,7 @@ loadfile(const Client *c, const gchar *f) {
                g_string_prepend(uri, "file://");
                loaduri(c, uri->str);
        }
-       
+
 }
 
 void
@@ -367,7 +368,7 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d) {
        if(((XEvent *)e)->type == PropertyNotify) {
                ev = &((XEvent *)e)->xproperty;
                if(ignore_once == FALSE && ev->atom == urlprop && ev->state == PropertyNewValue) {
-                       XGetWindowProperty(dpy, ev->window, urlprop, 0L, BUFSIZ, False, XA_STRING, 
+                       XGetWindowProperty(dpy, ev->window, urlprop, 0L, BUFSIZ, False, XA_STRING,
                                &adummy, &idummy, &ldummy, &ldummy, &buf);
                        loaduri(c, (gchar *)buf);
                        XFree(buf);
@@ -422,8 +423,10 @@ updatetitle(Client *c) {
 
 int main(int argc, char *argv[]) {
        gchar *uri = NULL, *file = NULL;
+       SoupSession *s;
        Client *c;
        int o;
+       const gchar *home, *filename;
 
        gtk_init(NULL, NULL);
        if (!g_thread_supported())
@@ -465,6 +468,15 @@ int main(int argc, char *argv[]) {
                goto argerr;
        if(!clients)
                newclient();
+
+       /* cookie persistance */
+       s = webkit_get_default_session();
+       home = g_get_home_dir();
+       filename = g_build_filename(home, ".surf", "cookies", NULL);
+       g_mkdir(g_path_get_dirname(filename), 0755);
+       cookiejar = soup_cookie_jar_text_new(filename, FALSE);
+       soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookiejar));
+
        gtk_main();
        cleanup();
        return EXIT_SUCCESS;