summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2012-01-16 11:29:14 +0100
committerportix <portix@gmx.net>2012-01-16 11:29:14 +0100
commit2b96f17a160a525ab926b653fb4685265f42f953 (patch)
tree3b49cb2a1c0ec30e13403e52869f139da4c95664
parentbd40496902ac578c8e45786a35c1377e161ef108 (diff)
parenta326c1960e4b8e96f601fb70c7e43b578dd981db (diff)
downloaddwb-2b96f17a160a525ab926b653fb4685265f42f953.zip
Merging head 976
-rw-r--r--doc/dwb.17
-rw-r--r--scripts/hints.js20
-rw-r--r--src/config.h2
-rw-r--r--src/download.c58
-rw-r--r--src/download.h2
-rw-r--r--src/dwb.c2
-rw-r--r--util/generate_keys.awk2
-rw-r--r--util/settings.in1
8 files changed, 61 insertions, 33 deletions
diff --git a/doc/dwb.1 b/doc/dwb.1
index ec026b70..0340da3b 100644
--- a/doc/dwb.1
+++ b/doc/dwb.1
@@ -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/scripts/hints.js b/scripts/hints.js
index 08e59502..d40dea90 100644
--- a/scripts/hints.js
+++ b/scripts/hints.js
@@ -70,20 +70,22 @@ var DwbHintObj = (function () {
this.element = element;
this.overlay = null;
this.win = win;
- var scrollY = win.scrollY;
- var scrollX = win.scrollX;
+ var br = document.body.getBoundingClientRect();
+ var bs = win.getComputedStyle(document.body, null);
var hint = __createElement("div");
- var toppos = rect.top + scrollY;
- var leftpos = rect.left + scrollX;
- var t = Math.max(toppos, scrollY);
- var l = Math.max(leftpos, scrollX);
+ var toppos = rect.top - br.top;
+ var leftpos = rect.left - br.left;
+ var t = Math.max(toppos, 0);
+ var l = Math.max(leftpos, 0);
hint.style.top = t + "px";
+ hint.style.marginTop = bs.marginTop;
hint.style.left = l + "px";
+ hint.style.marginLeft = bs.marginLeft;
hint.className = "dwb_hint";
this.createOverlay = function() {
- var comptop = toppos - scrollY;
- var compleft = leftpos - scrollX;
+ var comptop = toppos;
+ var compleft = leftpos;
var height = rect.height;
var width = rect.width;
var h = height + Math.max(0, comptop);
@@ -92,7 +94,9 @@ var DwbHintObj = (function () {
overlay.style.width = (compleft > 0 ? width : width + compleft) + "px";
overlay.style.height = (comptop > 0 ? height : height + comptop) + "px";
overlay.style.top = t + "px";
+ overlay.style.marginTop = bs.marginTop;
overlay.style.left = l + "px";
+ overlay.style.marginLeft = bs.marginLeft;
overlay.style.display = "block";
overlay.style.cursor = "pointer";
this.overlay = overlay;
diff --git a/src/config.h b/src/config.h
index 9d82995b..43cd9dee 100644
--- a/src/config.h
+++ b/src/config.h
@@ -927,6 +927,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..546f3151 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);
@@ -308,7 +309,7 @@ download_start() {
goto error_out;
}
fullpath = external ? g_strdup(path) : g_strconcat("file://", path, NULL);
- if ((last_slash = strrchr(path, '/'))) {
+ if (g_file_test(path, G_FILE_TEST_IS_DIR) && (last_slash = strrchr(path, '/'))) {
g_strlcpy(path_buffer, path, last_slash - path);
path = path_buffer;
}
@@ -354,20 +355,26 @@ static void
download_entry_set_directory() {
dwb_set_normal_message(dwb.state.fview, false, "Downloadpath:");
char *default_dir = GET_CHAR("download-directory");
- char *current_dir = NULL;
- if (default_dir != NULL)
- current_dir = g_strdup(default_dir);
- else if (lastdir != NULL)
- current_dir = g_strdup(lastdir);
+ char *current_dir = NULL, *new_dir = NULL;
+ if (default_dir != NULL) {
+ entry_set_text(default_dir);
+ return;
+ }
+ else if (lastdir != NULL) {
+ entry_set_text(lastdir);
+ return;
+ }
else
current_dir = g_get_current_dir();
- char *newdir = current_dir[strlen(current_dir) - 1] != '/' ? g_strdup_printf("%s/", current_dir) : g_strdup(current_dir);
-
- entry_set_text(newdir);
-
+ if (g_file_test(current_dir, G_FILE_TEST_IS_DIR) && current_dir[strlen(current_dir) - 1] != '/') {
+ new_dir = g_strdup_printf("%s/", current_dir);
+ entry_set_text(new_dir);
+ FREE(new_dir);
+ }
+ else
+ entry_set_text(current_dir);
FREE(current_dir);
- FREE(newdir);
}/*}}}*/
/* download_entry_set_spawn_command{{{*/
@@ -383,24 +390,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 *);
diff --git a/src/dwb.c b/src/dwb.c
index 387515fc..e9e226ec 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -1896,7 +1896,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/generate_keys.awk b/util/generate_keys.awk
index b1701bb7..3c07d8dc 100644
--- a/util/generate_keys.awk
+++ b/util/generate_keys.awk
@@ -17,7 +17,7 @@ NF > 0 {
END {
print "<tr class='dwb_table_row'><th class='dwb_table_headline' colspan='3'>Custom commands</th></tr>"
print "<td colspan='3'><div class='desc'>Custom commands can be defined in the following form:"
- print "</div><div class='commandLineContainer'><div class='commandline'>[shortcut]:[command];[command];...</div></div>"
+ print "</div><div class='commandLineContainer'><div class='commandline'>[shortcut]:[command];;[command];...</div></div>"
print "</td></tr>"
print "<tr class='dwb_table_row'><td colspan='3'><textarea rows='10' id='dwb_custom_keys_area'></textarea><td></tr>"
print "<tr class='dwb_table_row'>"
diff --git a/util/settings.in b/util/settings.in
index 8fe37f94..a464ea74 100644
--- a/util/settings.in
+++ b/util/settings.in
@@ -116,6 +116,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