aboutsummaryrefslogtreecommitdiff
path: root/callbacks.c
diff options
context:
space:
mode:
authormutantturkey <crazycal00@gmail.com>2011-07-16 14:04:18 -0400
committermutantturkey <crazycal00@gmail.com>2011-07-16 14:04:18 -0400
commitaacfab616a43281d3517c83ea0b7129130708d77 (patch)
tree0cb788b4d9c5ab78236920f288149e2cc47f6e1c /callbacks.c
parent9ea4d89df0ccd9764579e745458466acaa810cfd (diff)
switched to using sprintf for download formatting, way cleaner
Diffstat (limited to 'callbacks.c')
-rw-r--r--callbacks.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/callbacks.c b/callbacks.c
index 5fa0747..39556f7 100644
--- a/callbacks.c
+++ b/callbacks.c
@@ -48,11 +48,16 @@ return FALSE;
/* download callback */
void cb_download(WebKitWebView *web_view, GObject *d, gpointer user_data) {
+ gchar *command;
-const gchar *c = webkit_download_get_uri(WEBKIT_DOWNLOAD(d));
-gchar *command = g_strconcat(DEFAULT_DOWNLOAD_COMMAND, DEFAULT_DOWNLOAD_LOCATION, "/ ", g_strdup(c), NULL);
+const gchar *download_url = webkit_download_get_uri(WEBKIT_DOWNLOAD(d));
+const gchar *requested_name = webkit_download_get_suggested_filename(WEBKIT_DOWNLOAD(d));
+command = g_new0(gchar, strlen(DEFAULT_DOWNLOAD_COMMAND) + strlen(DEFAULT_DOWNLOAD_LOCATION) + strlen(requested_name) + strlen(download_url) + 1);
+g_sprintf(command, DEFAULT_DOWNLOAD_COMMAND, DEFAULT_DOWNLOAD_LOCATION, requested_name, download_url);
+
g_spawn_command_line_async(command, NULL);
g_free(command);
+
}