aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/callbacks.c8
-rw-r--r--src/uzbl-core.c25
-rw-r--r--src/uzbl-core.h1
3 files changed, 33 insertions, 1 deletions
diff --git a/src/callbacks.c b/src/callbacks.c
index 360b0c4..703107b 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -837,6 +837,11 @@ download_cb(WebKitWebView *web_view, WebKitDownload *download, gpointer user_dat
/* get the URI being downloaded */
const gchar *uri = webkit_download_get_uri(download);
+ /* get the destination path, if specified.
+ * this is only intended to be set when this function is trigger by an
+ * explicit download using uzbl's 'download' action. */
+ const gchar *destination = user_data;
+
if (uzbl.state.verbose)
printf("Download requested -> %s\n", uri);
@@ -883,6 +888,9 @@ download_cb(WebKitWebView *web_view, WebKitDownload *download, gpointer user_dat
gchar *total_size_s = g_strdup_printf("%d", total_size);
g_array_append_val(a, total_size_s);
+ if(destination)
+ g_array_append_val(a, destination);
+
GString *result = g_string_new ("");
run_parsed_command(c, a, result);
diff --git a/src/uzbl-core.c b/src/uzbl-core.c
index e918451..c095a7f 100644
--- a/src/uzbl-core.c
+++ b/src/uzbl-core.c
@@ -552,7 +552,8 @@ CommandInfo cmdlist[] =
{ "show_inspector", show_inspector, 0 },
{ "add_cookie", add_cookie, 0 },
{ "delete_cookie", delete_cookie, 0 },
- { "clear_cookies", clear_cookies, 0 }
+ { "clear_cookies", clear_cookies, 0 },
+ { "download", download, 0 }
};
void
@@ -741,6 +742,28 @@ clear_cookies(WebKitWebView *page, GArray *argv, GString *result) {
}
void
+download(WebKitWebView *web_view, GArray *argv, GString *result) {
+ (void) result;
+
+ const gchar *uri = argv_idx(argv, 0);
+ const gchar *destination = NULL;
+ if(argv->len > 1)
+ destination = argv_idx(argv, 1);
+
+ 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
+ g_object_unref(download);
+
+ g_object_unref(req);
+}
+
+void
act_dump_config() {
dump_config();
}
diff --git a/src/uzbl-core.h b/src/uzbl-core.h
index affd334..be8fccd 100644
--- a/src/uzbl-core.h
+++ b/src/uzbl-core.h
@@ -325,6 +325,7 @@ void show_inspector(WebKitWebView *page, GArray *argv, GString *result);
void add_cookie(WebKitWebView *page, GArray *argv, GString *result);
void delete_cookie(WebKitWebView *page, GArray *argv, GString *result);
void clear_cookies(WebKitWebView *pag, GArray *argv, GString *result);
+void download(WebKitWebView *pag, GArray *argv, GString *result);
void builtins();
typedef void (*Command)(WebKitWebView*, GArray *argv, GString *result);