X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fcontrollers%2Fhelper_funcs.C;h=34ac0f1207a9a156061d489d7cd1f5c9a26cc61d;hb=120c89f24fae05379fbdc8539d3cfae574c2aecd;hp=e853bb6cdcfa59da6382bad2193f8f559fc28bd7;hpb=13349032cb4dc8ef44146aa652ff6bbff6698249;p=lyx.git diff --git a/src/frontends/controllers/helper_funcs.C b/src/frontends/controllers/helper_funcs.C index e853bb6cdc..34ac0f1207 100644 --- a/src/frontends/controllers/helper_funcs.C +++ b/src/frontends/controllers/helper_funcs.C @@ -10,9 +10,6 @@ #include -#ifdef __GNUG__ -#pragma implementation -#endif #include #include "LString.h" @@ -29,7 +26,7 @@ using std::vector; using std::make_pair; -string const browseFile(LyXView * lv, string const & filename, +string const browseFile(string const & filename, string const & title, string const & pattern, bool save, @@ -40,7 +37,7 @@ string const browseFile(LyXView * lv, string const & filename, if (!filename.empty()) lastPath = OnlyPath(filename); - FileDialog fileDlg(lv, title, LFUN_SELECT_FILE_SYNC, dir1, dir2); + FileDialog fileDlg(title, LFUN_SELECT_FILE_SYNC, dir1, dir2); FileDialog::Result result; @@ -69,7 +66,7 @@ string const browseFile(LyXView * lv, string const & filename, } -string const browseRelFile(LyXView * lv, string const & filename, +string const browseRelFile(string const & filename, string const & refpath, string const & title, string const & pattern, @@ -79,7 +76,7 @@ string const browseRelFile(LyXView * lv, string const & filename, { string const fname = MakeAbsPath(filename, refpath); - string const outname = browseFile(lv, fname, title, pattern, save, + string const outname = browseFile(fname, title, pattern, save, dir1, dir2); string const reloutname = MakeRelPath(outname, refpath); if (prefixIs(reloutname, "../")) @@ -89,6 +86,40 @@ string const browseRelFile(LyXView * lv, string const & filename, } +string const browseDir(string const & pathname, + string const & title, + pair const & dir1, + pair const & dir2) +{ + string lastPath("."); + if (!pathname.empty()) + lastPath = OnlyPath(pathname); + + FileDialog fileDlg(title, LFUN_SELECT_FILE_SYNC, dir1, dir2); + + FileDialog::Result result; + + while (true) { + result = fileDlg.opendir(lastPath, + OnlyFilename(pathname)); + + if (result.second.empty()) + return result.second; + + lastPath = OnlyPath(result.second); + + if (result.second.find_first_of("#~$% ") == string::npos) + break; + + Alert::alert(_("directory name can't contain any " + "of these characters:"), + _("space, '#', '~', '$' or '%'.")); + } + + return result.second; +} + + // sorry this is just a temporary hack we should include vspace.h! (Jug) extern const char * stringFromUnit(int);