diff options
-rw-r--r-- | src/dillo.cc | 1 | ||||
-rw-r--r-- | src/uicmd.cc | 24 | ||||
-rw-r--r-- | src/uicmd.hh | 3 |
3 files changed, 8 insertions, 20 deletions
diff --git a/src/dillo.cc b/src/dillo.cc index 7fa471c8..faad050f 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -366,6 +366,7 @@ int main(int argc, char **argv) a_Bw_init(); a_Cookies_init(); a_Auth_init(); + a_UIcmd_init(); dw::Textblock::setPenaltyHyphen (prefs.penalty_hyphen); dw::Textblock::setPenaltyHyphen2 (prefs.penalty_hyphen_2); diff --git a/src/uicmd.cc b/src/uicmd.cc index 5ba565c5..4677b414 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -61,7 +61,7 @@ using namespace dw::fltk; /* * Local data */ -static char *save_dir = NULL; +static const char *save_dir = ""; /* * Forward declarations @@ -806,7 +806,7 @@ static char *UIcmd_make_save_filename(const char *pathstr) { size_t MaxLen = 64; char *FileName, *newname, *o, *n; - const char *name, *dir = a_UIcmd_get_save_dir(); + const char *name, *dir = save_dir; if ((name = strrchr(pathstr, '/'))) { if (strlen(++name) > MaxLen) { @@ -820,31 +820,22 @@ static char *UIcmd_make_save_filename(const char *pathstr) i+=2, '_' : o[i]; } *n = 0; - FileName = dStrconcat(dir ? dir : "", newname, NULL); + FileName = dStrconcat(dir, newname, NULL); dFree(newname); } else { - FileName = dStrconcat(dir ? dir : "", pathstr, NULL); + FileName = dStrconcat(dir, pathstr, NULL); } return FileName; } /* - * Get the default directory for saving files. - */ -const char *a_UIcmd_get_save_dir() -{ - return save_dir; -} - -/* * Set the default directory for saving files. */ -void a_UIcmd_set_save_dir(const char *dir) +void a_UIcmd_init(void) { - const char *p; + const char *p, *dir = prefs.save_dir; if (dir && (p = strrchr(dir, '/'))) { - dFree(save_dir); // assert a trailing '/' save_dir = dStrconcat(dir, (p[1] != 0) ? "/" : "", NULL); } @@ -861,7 +852,6 @@ void a_UIcmd_save(void *vbw) const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw)); if (url) { - a_UIcmd_set_save_dir(prefs.save_dir); 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); @@ -993,8 +983,6 @@ void a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url) const char *name; char *SuggestedName; - a_UIcmd_set_save_dir(prefs.save_dir); - SuggestedName = UIcmd_make_save_filename(URL_STR(url)); name = a_Dialog_save_file("Dillo: Save Link as File", NULL, SuggestedName); if (name) { diff --git a/src/uicmd.hh b/src/uicmd.hh index c859ba9c..a1af6335 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -59,8 +59,7 @@ void a_UIcmd_nav_jump(BrowserWindow *bw, int offset, int new_bw); void a_UIcmd_close_bw(void *vbw); void a_UIcmd_close_all_bw(void *p); -const char *a_UIcmd_get_save_dir(); -void a_UIcmd_set_save_dir(const char *dir); +void a_UIcmd_init(void); // UI binding functions ------------------------------------------------------- |