diff options
author | jcid <devnull@localhost> | 2007-11-11 14:04:20 +0100 |
---|---|---|
committer | jcid <devnull@localhost> | 2007-11-11 14:04:20 +0100 |
commit | 942374b59eaf0988eac789e9ae415bf2beb9cbdc (patch) | |
tree | eb43c1ebefcafdb9ef57200ee1820bf56c8b2df0 | |
parent | 7d40462d35d3bf825a0ee142cb9e83f52a59e3fc (diff) |
Added a save-directory preference (save_dir in dillorc2).
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | dillorc2 | 3 | ||||
-rw-r--r-- | src/prefs.c | 6 | ||||
-rw-r--r-- | src/prefs.h | 2 | ||||
-rw-r--r-- | src/uicmd.cc | 13 |
5 files changed, 18 insertions, 7 deletions
@@ -52,6 +52,7 @@ dillo-fltk2 - Hooked the page and link menus. - Added a image-loading toggle button to the UI. - Enabled hiding widgets of the control panel from dillorc2. + - Added a save-directory preference (save_dir in dillorc2). Patches: place +- Fixed a problem with locally-installed dpis. - Added code for optional image loading (nice interface) very advanced! @@ -20,6 +20,9 @@ use_dicache=NO # (there's a toggle button near the bug meter to change this on-the-fly) #load_images=NO +# Set your default directory for download/save operations +#save_dir=/tmp + #------------------------------------------------------------------------- # RENDERING SECTION #------------------------------------------------------------------------- diff --git a/src/prefs.c b/src/prefs.c index f1947801..431b721a 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -66,6 +66,7 @@ SymNode_t symbols[] = { { "load_images", DRC_TOKEN_LOAD_IMAGES }, { "no_proxy", DRC_TOKEN_NOPROXY }, { "panel_size", DRC_TOKEN_PANEL_SIZE }, + { "save_dir", DRC_TOKEN_SAVE_DIR }, { "search_url", DRC_TOKEN_SEARCH_URL }, { "show_back", DRC_TOKEN_SHOW_BACK }, { "show_bookmarks", DRC_TOKEN_SHOW_BOOKMARKS }, @@ -307,6 +308,9 @@ static int Prefs_parse_pair(char *name, char *value) dFree(prefs.search_url); prefs.search_url = dStrdup(value); break; + case DRC_TOKEN_SAVE_DIR: + dFree(prefs.save_dir); + prefs.save_dir = dStrdup(value); case DRC_TOKEN_SHOW_MSG: prefs.show_msg = (strcmp(value, "YES") == 0); break; @@ -408,6 +412,7 @@ void a_Prefs_init(void) prefs.generate_submit = FALSE; prefs.enterpress_forces_submit = FALSE; prefs.search_url = dStrdup("http://www.google.com/search?q=%s"); + prefs.save_dir = dStrdup("/tmp/"); prefs.show_msg = TRUE; prefs.show_extra_warnings = FALSE; @@ -436,4 +441,5 @@ void a_Prefs_freeall(void) a_Url_free(prefs.start_page); a_Url_free(prefs.home); dFree(prefs.search_url); + dFree(prefs.save_dir); } diff --git a/src/prefs.h b/src/prefs.h index 92d69a1f..49d3f3f0 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -41,6 +41,7 @@ typedef enum { DRC_TOKEN_PANEL_SIZE, DRC_TOKEN_PROXY, DRC_TOKEN_PROXYUSER, + DRC_TOKEN_SAVE_DIR, DRC_TOKEN_SEARCH_URL, DRC_TOKEN_SHOW_BACK, DRC_TOKEN_SHOW_BOOKMARKS, @@ -115,6 +116,7 @@ struct _DilloPrefs { bool_t generate_submit; bool_t enterpress_forces_submit; char *search_url; + char *save_dir; bool_t show_msg; bool_t show_extra_warnings; }; diff --git a/src/uicmd.cc b/src/uicmd.cc index 204f8ead..69ca517a 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -245,21 +245,21 @@ void a_UIcmd_reload(void *vbw) } /* - * Return a suitable filename for a given URL. + * Return a suitable filename for a given URL path. */ -char *UIcmd_make_save_filename(const char *urlstr) +char *UIcmd_make_save_filename(const char *pathstr) { size_t MaxLen = 64; char *FileName, *name; const char *dir = a_UIcmd_get_save_dir(); - if ((name = strrchr(urlstr, '/'))) { + if ((name = strrchr(pathstr, '/'))) { if (strlen(++name) > MaxLen) { name = name + strlen(name) - MaxLen; } FileName = dStrconcat(dir ? dir : "", name, NULL); } else { - FileName = dStrconcat(dir ? dir : "", urlstr, NULL); + FileName = dStrconcat(dir ? dir : "", pathstr, NULL); } return FileName; } @@ -295,12 +295,11 @@ void a_UIcmd_save(void *vbw) char *SuggestedName, *urlstr; DilloUrl *url; - // BUG: this should be set by preferences. - a_UIcmd_set_save_dir("/tmp/k/"); + a_UIcmd_set_save_dir(prefs.save_dir); urlstr = a_UIcmd_get_location_text((BrowserWindow*)vbw); url = a_Url_new(urlstr, NULL, 0, 0, 0); - SuggestedName = UIcmd_make_save_filename(urlstr); + SuggestedName = UIcmd_make_save_filename(URL_PATH(url)); name = a_Dialog_save_file("Save Page as File", NULL, SuggestedName); MSG("a_UIcmd_save: %s\n", name); dFree(SuggestedName); |