diff options
author | portix <portix@gmx.net> | 2012-01-15 12:48:47 +0100 |
---|---|---|
committer | portix <portix@gmx.net> | 2012-01-15 12:48:47 +0100 |
commit | 6bfba814f8966b62d439e78feec4df0ff9e25ecd (patch) | |
tree | 47e73cfff159b0c24bb20ce95e984417c2ae1b3b | |
parent | cce281d2b03ee03701d697ac28f005884c226b71 (diff) | |
download | dwb-6bfba814f8966b62d439e78feec4df0ff9e25ecd.zip |
New option download-no-confirm
-rw-r--r-- | doc/dwb.1 | 7 | ||||
-rw-r--r-- | src/config.h | 2 | ||||
-rw-r--r-- | src/download.c | 30 | ||||
-rw-r--r-- | src/download.h | 2 | ||||
-rw-r--r-- | src/dwb.c | 2 | ||||
-rw-r--r-- | util/settings.in | 1 |
6 files changed, 31 insertions, 13 deletions
@@ -1440,6 +1440,13 @@ or the last download path is used. default value: .IR NULL . .TP +.BR download-no-confirm +Whether to start downloads immediately without asking for a path, +.I download-directory +needs to be set to an existing path. +default value: +.IR false . +.TP .BR download-use-external-program Whether to use an external download program specified in \'download-external-programm\' or the builtin download helper. diff --git a/src/config.h b/src/config.h index 807397eb..f4d4d122 100644 --- a/src/config.h +++ b/src/config.h @@ -925,6 +925,8 @@ static WebSettings DWB_SETTINGS[] = { /* downloads */ { { "download-external-command", "External program used for downloads", }, SETTING_GLOBAL, CHAR, { .p = "xterm -e wget 'dwb_uri' -O 'dwb_output' --load-cookies 'dwb_cookies'" }, NULL, }, + { { "download-no-confirm", "Wheter to confirm download directory", }, + SETTING_GLOBAL, BOOLEAN, { .b = false }, NULL, }, { { "download-directory", "Default download directory", }, SETTING_GLOBAL, CHAR, { .p = NULL }, NULL, }, { { "download-use-external-program", "Whether to use an external download program", }, diff --git a/src/download.c b/src/download.c index 515d2d9a..696aab97 100644 --- a/src/download.c +++ b/src/download.c @@ -247,8 +247,9 @@ download_add_progress_label(GList *gl, const char *filename) { /* download_start {{{*/ void -download_start() { - const char *path = GET_TEXT(); +download_start(const char *path) { + if (path == NULL) + path = GET_TEXT(); char *fullpath = NULL; const char *filename = webkit_download_get_suggested_filename(dwb.state.download); const char *uri = webkit_download_get_uri(dwb.state.download); @@ -383,24 +384,31 @@ download_entry_set_spawn_command(const char *command) { /* download_get_path {{{*/ void download_get_path(GList *gl, WebKitDownload *d) { + const char *path, *command; const char *uri = webkit_download_get_uri(d) + 7; if (g_file_test(uri, G_FILE_TEST_IS_EXECUTABLE)) { g_spawn_command_line_async(uri, NULL); return; } - - char *command = download_get_command_from_mimetype(dwb.state.mimetype_request); - entry_focus(); - dwb.state.mode = DOWNLOAD_GET_PATH; dwb.state.download = d; - if ( lastaction != DL_ACTION_DOWNLOAD && - ( command != NULL || g_file_test(uri, G_FILE_TEST_EXISTS)) ) { - dwb.state.dl_action = DL_ACTION_EXECUTE; - download_entry_set_spawn_command(command); + path = GET_CHAR("download-directory"); + if (path != NULL && g_file_test(path, G_FILE_TEST_IS_DIR) && GET_BOOL("download-no-confirm")) { + download_start(path); } else { - download_entry_set_directory(); + command = download_get_command_from_mimetype(dwb.state.mimetype_request); + entry_focus(); + dwb.state.mode = DOWNLOAD_GET_PATH; + dwb.state.download = d; + if ( lastaction != DL_ACTION_DOWNLOAD && + ( command != NULL || g_file_test(uri, G_FILE_TEST_EXISTS)) ) { + dwb.state.dl_action = DL_ACTION_EXECUTE; + download_entry_set_spawn_command(command); + } + else { + download_entry_set_directory(); + } } }/*}}}*/ diff --git a/src/download.h b/src/download.h index 29f5541b..6c14fc0b 100644 --- a/src/download.h +++ b/src/download.h @@ -21,7 +21,7 @@ void download_get_path(GList *, WebKitDownload *); -void download_start(void); +void download_start(const char *); void download_set_execute(Arg *); @@ -1879,7 +1879,7 @@ dwb_entry_activate(GdkEventKey *e) { return true; case COMMAND_MODE: dwb_parse_command_line(GET_TEXT(), false); return true; - case DOWNLOAD_GET_PATH: download_start(); + case DOWNLOAD_GET_PATH: download_start(NULL); return true; case SAVE_SESSION: session_save(GET_TEXT()); dwb_end(); diff --git a/util/settings.in b/util/settings.in index 4f1fd455..5e671ea9 100644 --- a/util/settings.in +++ b/util/settings.in @@ -115,6 +115,7 @@ cache-model select @webbrowser @documentviewer The cache-model used by webkit custom-encoding text The custom encoding of the view download-external-command text External application used for downloads download-directory text Default download directory +download-no-confirm checkbox Whether to immediately start a download if download-directory is set download-use-external-program checkbox Whether to use an external download helper editor text External editor used for inputs/textareas editable checkbox Whether content can be modified |