3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
19 #include "helper_funcs.h"
21 #include "frontends/FileDialog.h"
22 #include "support/filetools.h" // OnlyPath, OnlyFilename
23 #include "support/lstrings.h"
24 #include "gettext.h" // _()
25 #include "frontends/Alert.h"
31 string const browseFile(LyXView * lv, string const & filename,
33 string const & pattern,
34 pair<string,string> const & dir1,
35 pair<string,string> const & dir2)
37 string lastPath = ".";
38 if (!filename.empty())
39 lastPath = OnlyPath(filename);
41 FileDialog fileDlg(lv, title, LFUN_SELECT_FILE_SYNC, dir1, dir2);
43 FileDialog::Result result;
46 result = fileDlg.Select(lastPath, pattern, OnlyFilename(filename));
48 if (result.second.empty())
51 lastPath = OnlyPath(result.second);
53 if (result.second.find_first_of("#~$% ") == string::npos)
56 Alert::alert(_("Filename can't contain any "
57 "of these characters:"),
58 _("space, '#', '~', '$' or '%'."));
65 string const browseRelFile(LyXView * lv, string const & filename,
66 string const & refpath,
68 string const & pattern,
69 pair<string,string> const & dir1,
70 pair<string,string> const & dir2)
72 string const fname = MakeAbsPath(filename, refpath);
74 string const outname = browseFile(lv, fname, title, pattern,
76 string const reloutname = MakeRelPath(outname, refpath);
77 if (prefixIs(reloutname, "../"))
84 // sorry this is just a temporary hack we should include vspace.h! (Jug)
85 extern const char * stringFromUnit(int);
87 vector<string> const getLatexUnits()
91 for(int i=0; (str = stringFromUnit(i)); ++i)