From bdfb2fb35c4d6fa407361dcc99aefb00ff185e6d Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Tue, 12 Apr 2011 22:35:42 -0600 Subject: allow a second argument to the 'download' command that specifies a destination path --- src/uzbl-core.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/uzbl-core.c') diff --git a/src/uzbl-core.c b/src/uzbl-core.c index 3a96482..204c89c 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -745,15 +745,21 @@ void download(WebKitWebView *web_view, GArray *argv, GString *result) { (void) result; - const gchar *uri = NULL; + const gchar *uri = argv_idx(argv, 0); + const gchar *destination = NULL; + if(argv->len > 1) + destination = argv_idx(argv, 1); - if(argv->len > 0) - uri = argv_idx(argv, 0); + WebKitNetworkRequest *req = webkit_network_request_new(uri); + WebKitDownload *download = webkit_download_new(req); + + download_cb(web_view, download, destination); + + if(webkit_download_get_destination_uri(download)) + webkit_download_start(download); else - uri = uzbl.state.uri; + g_object_unref(download); - WebKitNetworkRequest *req = webkit_network_request_new(uri); - webkit_web_view_request_download(web_view, req); g_object_unref(req); } -- cgit v1.2.3