using std::system;
#endif
-extern void LoadLyXFile(string const &);
extern void QuitLyX();
extern LyXServer * lyxserver;
-extern string system_lyxdir;
-extern string user_lyxdir;
-
DebugStream lyxerr;
boost::scoped_ptr<LastFiles> lastfiles;
// #include "graphics/GraphicsTypes.h" at the top -- Rob Lahaye.
lyx::graphics::setDisplayTranslator();
- if (want_gui) {
+ if (want_gui)
lyx_gui::parse_init(argc, argv);
- }
// check for any spurious extra arguments
// other than documents
init(want_gui);
lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
- if (want_gui) {
+ if (want_gui)
lyx_gui::parse_lyxrc();
- }
vector<string> files;
- for (int argi = argc - 1; argi >= 1; --argi) {
+ for (int argi = argc - 1; argi >= 1; --argi)
files.push_back(argv[argi]);
- }
if (first_start)
files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
// the filename if necessary
string s = FileSearch(string(), *it, "lyx");
if (s.empty()) {
- last_loaded = newFile(*it, "");
+ last_loaded = newFile(*it, string(), true);
} else {
- last_loaded = bufferlist.newBuffer(s, false);
- last_loaded->error.connect(boost::bind(&LyX::printError, this, _1));
- if (!loadLyXFile(last_loaded, s)) {
- bufferlist.release(last_loaded);
- last_loaded = newFile(*it, string());
- }
+ Buffer * buf = bufferlist.newBuffer(s, false);
+ buf->error.connect(boost::bind(&LyX::printError, this, _1));
+ if (loadLyXFile(buf, s))
+ last_loaded = buf;
+ else
+ bufferlist.release(buf);
}
}
lyx_gui::use_gui = gui;
if (lyxrc.template_path.empty()) {
- lyxrc.template_path = AddPath(system_lyxdir, "templates");
+ lyxrc.template_path = AddPath(system_lyxdir(), "templates");
}
if (lyxrc.lastfiles.empty()) {
- lyxrc.lastfiles = AddName(user_lyxdir, "lastfiles");
+ lyxrc.lastfiles = AddName(user_lyxdir(), "lastfiles");
}
if (lyxrc.roman_font_name.empty())
void LyX::queryUserLyXDir(bool explicit_userdir)
{
- string const configure_script = AddName(system_lyxdir, "configure");
+ string const configure_script = AddName(system_lyxdir(), "configure");
// Does user directory exist?
- FileInfo fileInfo(user_lyxdir);
+ FileInfo fileInfo(user_lyxdir());
if (fileInfo.isOK() && fileInfo.isDir()) {
first_start = false;
FileInfo script(configure_script);
- FileInfo defaults(AddName(user_lyxdir, "lyxrc.defaults"));
+ FileInfo defaults(AddName(user_lyxdir(), "lyxrc.defaults"));
if (defaults.isOK() && script.isOK()
&& defaults.getModificationTime() < script.getModificationTime()) {
lyxerr << _("LyX: reconfiguring user directory")
<< endl;
- Path p(user_lyxdir);
+ Path p(user_lyxdir());
::system(configure_script.c_str());
lyxerr << "LyX: " << _("Done!") << endl;
}
first_start = !explicit_userdir;
lyxerr << bformat(_("LyX: Creating directory %1$s"
- " and running configure..."), user_lyxdir) << endl;
+ " and running configure..."), user_lyxdir()) << endl;
- if (!createDirectory(user_lyxdir, 0755)) {
+ if (!createDirectory(user_lyxdir(), 0755)) {
// Failed, let's use $HOME instead.
- user_lyxdir = GetEnvPath("HOME");
+ user_lyxdir(GetEnvPath("HOME"));
lyxerr << bformat(_("Failed. Will use %1$s instead."),
- user_lyxdir) << endl;
+ user_lyxdir()) << endl;
return;
}
// Run configure in user lyx directory
- Path p(user_lyxdir);
+ Path p(user_lyxdir());
::system(configure_script.c_str());
lyxerr << "LyX: " << _("Done!") << endl;
}
lyxerr << _("Missing directory for -sysdir switch") << endl;
exit(1);
}
- system_lyxdir = arg;
+ system_lyxdir(arg);
return 1;
}
lyxerr << _("Missing directory for -userdir switch") << endl;
exit(1);
}
- user_lyxdir = arg;
+ user_lyxdir(arg);
return 1;
}