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"
32 string const browseFile(LyXView * lv, string const & filename,
34 string const & pattern,
35 pair<string,string> const & dir1,
36 pair<string,string> const & dir2)
39 if (!filename.empty())
40 lastPath = OnlyPath(filename);
42 FileDialog fileDlg(lv, title, LFUN_SELECT_FILE_SYNC, dir1, dir2);
44 FileDialog::Result result;
47 result = fileDlg.Select(lastPath, pattern,
48 OnlyFilename(filename));
50 if (result.second.empty())
53 lastPath = OnlyPath(result.second);
55 if (result.second.find_first_of("#~$% ") == string::npos)
58 Alert::alert(_("Filename can't contain any "
59 "of these characters:"),
60 _("space, '#', '~', '$' or '%'."));
67 string const browseRelFile(LyXView * lv, string const & filename,
68 string const & refpath,
70 string const & pattern,
71 pair<string,string> const & dir1,
72 pair<string,string> const & dir2)
74 string const fname = MakeAbsPath(filename, refpath);
76 string const outname = browseFile(lv, fname, title, pattern,
78 string const reloutname = MakeRelPath(outname, refpath);
79 if (prefixIs(reloutname, "../"))
86 // sorry this is just a temporary hack we should include vspace.h! (Jug)
87 extern const char * stringFromUnit(int);
89 vector<string> const getLatexUnits()
93 for (int i = 0; (str = stringFromUnit(i)); ++i)