+initdownload(WebKitWebView *view, WebKitDownload *o, gpointer d) {
+ Client *c = (Client *) d;
+ const gchar *home, *filename;
+ gchar *uri, *path;
+ GString *html = g_string_new("");
+
+ stop(c);
+ c->download = o;
+ home = g_get_home_dir();
+ filename = webkit_download_get_suggested_filename(o);
+ path = g_build_filename(home, ".surf", "dl",
+ filename, NULL);
+ uri = g_strconcat("file://", path, NULL);
+ webkit_download_set_destination_uri(c->download, uri);
+ c->progress = 0;
+ g_free(uri);
+ html = g_string_append(html, "Downloading <b>");
+ html = g_string_append(html, filename);
+ html = g_string_append(html, "</b>...");
+ webkit_web_view_load_html_string(c->view, html->str,
+ webkit_download_get_uri(c->download));
+ g_signal_connect(c->download, "notify::progress", G_CALLBACK(download), c);
+ g_signal_connect(c->download, "notify::status", G_CALLBACK(download), c);
+ webkit_download_start(c->download);
+ updatetitle(c, filename);
+ return TRUE;