Backed out changeset ed121082f103
[surf.git] / surf.c
diff --git a/surf.c b/surf.c
index 64f2a75..318d694 100644 (file)
--- a/surf.c
+++ b/surf.c
@@ -40,7 +40,7 @@ static gboolean decidewindow(WebKitWebView *view, WebKitWebFrame *f,
 static void destroyclient(Client *c);
 static void destroywin(GtkWidget* w, gpointer d);
 static void die(char *str);
-static gboolean download(WebKitWebView *view, GObject *o, gpointer d);
+static gboolean download(WebKitWebView *view, WebKitDownload *o, gpointer d);
 static gchar *geturi(Client *c);
 static void hidesearch(Client *c);
 static void hideurl(Client *c);
@@ -107,9 +107,20 @@ void die(char *str) {
 }
 
 gboolean
-download(WebKitWebView *view, GObject *o, gpointer d) {
+download(WebKitWebView *view, WebKitDownload *o, gpointer d) {
        /* TODO */
-       return FALSE;
+       const gchar *home;
+       gchar *uri, *filename;
+
+       home = g_get_home_dir();
+       filename = g_build_filename(home, "Desktop",
+                       webkit_download_get_suggested_filename(o), NULL);
+       uri = g_strconcat("file://", filename, NULL);
+       webkit_download_set_destination_uri(o, uri);
+       g_free(filename);
+       g_free(uri);
+       webkit_download_start(o);
+       return TRUE;
 }
 
 gchar *
@@ -245,7 +256,7 @@ loadfile(const Client *c, const gchar *f) {
                g_string_prepend(uri, "file://");
                loaduri(c, uri->str);
        }
-       
+
 }
 
 void
@@ -353,7 +364,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);