static gboolean download_dest(WebKitDownload *download, gchar *suggested_filename, gpointer user_data) { webkit_download_set_destination(download, g_build_filename("file:///tmp/cache", suggested_filename, NULL)); return true; }
gboolean download_handle(WebKitDownload *download, gchar *suggested_filename, gpointer data) { gchar *sug_clean, *path, *path2 = NULL, *uri; GtkToolItem *tb; int suffix = 1; size_t i; sug_clean = g_strdup(suggested_filename); for (i = 0; i < strlen(sug_clean); i++) if (sug_clean[i] == G_DIR_SEPARATOR) sug_clean[i] = '_'; path = g_build_filename(download_dir, sug_clean, NULL); path2 = g_strdup(path); while (g_file_test(path2, G_FILE_TEST_EXISTS) && suffix < 1000) { g_free(path2); path2 = g_strdup_printf("%s.%d", path, suffix); suffix++; } if (suffix == 1000) { fprintf(stderr, __NAME__": Suffix reached limit for download.\n"); webkit_download_cancel(download); } else { uri = g_filename_to_uri(path2, NULL, NULL); webkit_download_set_destination(download, uri); g_free(uri); tb = gtk_tool_button_new(NULL, NULL); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(tb), "gtk-delete"); gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb), sug_clean); gtk_toolbar_insert(GTK_TOOLBAR(dm.toolbar), tb, 0); gtk_widget_show_all(dm.win); g_signal_connect(G_OBJECT(download), "notify::estimated-progress", G_CALLBACK(changed_download_progress), tb); g_object_ref(download); g_signal_connect(G_OBJECT(tb), "clicked", G_CALLBACK(downloadmanager_cancel), download); } g_free(sug_clean); g_free(path); g_free(path2); /* Propagate -- to whom it may concern. */ return FALSE; }
static gboolean download_decide_destination_cb (WebKitDownload *wk_download, const gchar *suggested_filename, EphyDownload *download) { char *dest; if (download->priv->destination) { webkit_download_set_destination (wk_download, download->priv->destination); return TRUE; } dest = define_destination_uri (download, suggested_filename); if (!dest) return FALSE; ephy_download_set_destination_uri (download, dest); webkit_download_set_destination (wk_download, dest); g_free (dest); return TRUE; }
virtual void decideDestination(WebKitDownload* download, const gchar* suggestedFilename) { GOwnPtr<char> destination(g_build_filename(kTempDirectory, suggestedFilename, NULL)); GOwnPtr<char> destinationURI(g_filename_to_uri(destination.get(), 0, 0)); webkit_download_set_destination(download, destinationURI.get()); }