#include "helper_funcs.h"
#include "gettext.h"
+#include "lyxlength.h"
-#include "frontends/Alert.h"
#include "frontends/FileDialog.h"
#include "support/filetools.h"
-#include "support/path_defines.h"
+#include "support/lstrings.h"
+#include "support/package.h"
using std::pair;
using std::vector;
using std::string;
-// sorry this is just a temporary hack we should include vspace.h! (Jug)
-extern const char * stringFromUnit(int);
-
namespace lyx {
using support::AddName;
using support::MakeRelPath;
using support::OnlyFilename;
using support::OnlyPath;
+using support::package;
using support::prefixIs;
-using support::system_lyxdir;
-using support::user_lyxdir;
namespace frontend {
FileDialog::Result result;
- while (true) {
- if (save)
- result = fileDlg.save(lastPath, filters,
- OnlyFilename(filename));
- else
- result = fileDlg.open(lastPath, filters,
- OnlyFilename(filename));
-
- if (result.second.empty())
- return result.second;
-
- lastPath = OnlyPath(result.second);
-
- if (result.second.find_first_of("#~$% ") == string::npos)
- break;
-
- Alert::error(_("Invalid filename"),
- _("Filename can't contain any "
- "of these characters:\n"
- "space, '#', '~', '$' or '%'."));
- }
+ if (save)
+ result = fileDlg.save(lastPath, filters,
+ OnlyFilename(filename));
+ else
+ result = fileDlg.open(lastPath, filters,
+ OnlyFilename(filename));
return result.second;
}
FileFilterList const & filters)
{
pair<string,string> const dir1(_("System files|#S#s"),
- AddName(system_lyxdir(), dir));
+ AddName(package().system_support(), dir));
pair<string,string> const dir2(_("User files|#U#u"),
- AddName(user_lyxdir(), dir));
+ AddName(package().user_support(), dir));
string const result = browseFile(LibFileSearch(dir, name, ext), title,
- filters, false, dir1, dir2);
+ filters, false, dir1, dir2);
// remove the extension if it is the default one
string noextresult;
string const browseDir(string const & pathname,
- string const & title,
- pair<string,string> const & dir1,
- pair<string,string> const & dir2)
+ string const & title,
+ pair<string,string> const & dir1,
+ pair<string,string> const & dir2)
{
string lastPath(".");
if (!pathname.empty())
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::error(_("Invalid filename"),
- _("Filename can't contain any "
- "of these characters:\n"
- "space, '#', '~', '$' or '%'."));
- }
+ FileDialog::Result const result =
+ fileDlg.opendir(lastPath, OnlyFilename(pathname));
return result.second;
}
vector<string> const getLatexUnits()
{
vector<string> units;
- char const * str;
- for (int i = 0; (str = stringFromUnit(i)); ++i)
- units.push_back(str);
+ int i = 0;
+ char const * str = stringFromUnit(i);
+ for (; str != 0; ++i, str = stringFromUnit(i))
+ units.push_back(str);
return units;
}