3 * See the file COPYING.
5 * \author Angus Leeming
7 * Full author contact details are available in file CREDITS
13 #pragma implementation
18 #include "helper_funcs.h"
20 #include "frontends/FileDialog.h"
21 #include "support/filetools.h" // OnlyPath, OnlyFilename
22 #include "support/lstrings.h"
23 #include "gettext.h" // _()
24 #include "frontends/Alert.h"
30 string const browseFile(LyXView * lv, string const & filename,
32 string const & pattern,
33 pair<string,string> const & dir1,
34 pair<string,string> const & dir2)
36 string lastPath = ".";
37 if (!filename.empty())
38 lastPath = OnlyPath(filename);
40 FileDialog fileDlg(lv, title, LFUN_SELECT_FILE_SYNC, dir1, dir2);
42 FileDialog::Result result;
45 result = fileDlg.Select(lastPath, pattern, OnlyFilename(filename));
47 if (result.second.empty())
50 lastPath = OnlyPath(result.second);
52 if (result.second.find_first_of("#~$% ") == string::npos)
55 Alert::alert(_("Filename can't contain any "
56 "of these characters:"),
57 _("space, '#', '~', '$' or '%'."));
64 string const browseRelFile(LyXView * lv, string const & filename,
65 string const & refpath,
67 string const & pattern,
68 pair<string,string> const & dir1,
69 pair<string,string> const & dir2)
71 string const fname = MakeAbsPath(filename, refpath);
73 string const outname = browseFile(lv, fname, title, pattern,
75 string const reloutname = MakeRelPath(outname, refpath);
76 if (prefixIs(reloutname, "../"))
83 // sorry this is just a temporary hack we should include vspace.h! (Jug)
84 extern const char * stringFromUnit(int);
86 vector<string> const getLatexUnits()
90 for(int i=0; (str = stringFromUnit(i)); ++i)