using support::createDirectory;
using support::createLyXTmpDir;
using support::destroyDir;
+using support::FileName;
using support::fileSearch;
using support::getEnv;
using support::i18nLibFileSearch;
if (!use_gui) {
// FIXME: create a ConsoleApplication
- return execBatchCommands(argc, argv, files);
+ int exit_status = loadFiles(argc, argv, files);
+ if (exit_status) {
+ prepareExit();
+ return exit_status;
+ }
+
+ if (batch_command.empty() || pimpl_->buffer_list_.empty()) {
+ prepareExit();
+ return EXIT_SUCCESS;
+ }
+
+ BufferList::iterator begin = pimpl_->buffer_list_.begin();
+ BufferList::iterator end = pimpl_->buffer_list_.end();
+
+ bool final_success = false;
+ for (BufferList::iterator I = begin; I != end; ++I) {
+ Buffer * buf = *I;
+ bool success = false;
+ buf->dispatch(batch_command, &success);
+ final_success |= success;
+ }
+ prepareExit();
+ return !final_success;
}
// Force adding of font path _before_ Application is initialized
// Let the frontend parse and remove all arguments that it knows
pimpl_->application_.reset(createApplication(argc, argv));
+ // FIXME: this global pointer should probably go.
+ theApp = pimpl_->application_.get();
+
+ initGuiFont();
// Parse and remove all known arguments in the LyX singleton
// Give an error for all remaining ones.
- int exit_status = execBatchCommands(argc, argv, files);
+ int exit_status = loadFiles(argc, argv, files);
if (exit_status) {
// Kill the application object before exiting.
pimpl_->application_.reset();
return exit_status;
}
- initGuiFont();
- // FIXME: this global pointer should probably go.
- theApp = pimpl_->application_.get();
restoreGuiSession(files);
// Start the real execution loop.
pimpl_->lyx_socket_.reset(new LyXServerSocket(&pimpl_->lyxfunc_,
support::os::internal_path(package().temp_dir() + "/lyxsocket")));
- // handle the batch commands the user asked for
- if (!batch_command.empty()) {
- pimpl_->lyxfunc_.dispatch(lyxaction.lookupFunc(batch_command));
- }
-
- exit_status = pimpl_->application_->start(batch_command);
+ exit_status = pimpl_->application_->exec();
// Kill the application object before exiting. This avoid crash
// on exit on Linux.
pimpl_->application_.reset();
}
-int LyX::execBatchCommands(int & argc, char * argv[],
+int LyX::loadFiles(int & argc, char * argv[],
vector<string> & files)
{
// check for any spurious extra arguments
}
if (first_start)
- files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
+ files.push_back(i18nLibFileSearch("examples", "splash.lyx").absFilename());
- // Execute batch commands if available
- if (!batch_command.empty()) {
-
- lyxerr[Debug::INIT] << "About to handle -x '"
- << batch_command << '\'' << endl;
-
- Buffer * last_loaded = 0;
-
- vector<string>::const_iterator it = files.begin();
- vector<string>::const_iterator end = files.end();
-
- for (; it != end; ++it) {
- // get absolute path of file and add ".lyx" to
- // the filename if necessary
- string s = fileSearch(string(), *it, "lyx");
- if (s.empty()) {
- Buffer * const b = newFile(*it, string(), true);
- if (b)
- last_loaded = b;
- } else {
- Buffer * buf = pimpl_->buffer_list_.newBuffer(s, false);
- if (loadLyXFile(buf, s)) {
- last_loaded = buf;
- ErrorList const & el = buf->errorList("Parse");
- if (!el.empty())
- for_each(el.begin(), el.end(),
- boost::bind(&LyX::printError, this, _1));
- }
- else
- pimpl_->buffer_list_.release(buf);
- }
- }
+ Buffer * last_loaded = 0;
+
+ vector<string>::const_iterator it = files.begin();
+ vector<string>::const_iterator end = files.end();
- // try to dispatch to last loaded buffer first
- if (last_loaded) {
- success = false;
- if (last_loaded->dispatch(batch_command, &success)) {
- prepareExit();
- return !success;
+ for (; it != end; ++it) {
+ // get absolute path of file and add ".lyx" to
+ // the filename if necessary
+ string s = fileSearch(string(), *it, "lyx").absFilename();
+ if (s.empty()) {
+ Buffer * const b = newFile(*it, string(), true);
+ if (b)
+ last_loaded = b;
+ } else {
+ Buffer * buf = pimpl_->buffer_list_.newBuffer(s, false);
+ if (loadLyXFile(buf, s)) {
+ last_loaded = buf;
+ ErrorList const & el = buf->errorList("Parse");
+ if (!el.empty())
+ for_each(el.begin(), el.end(),
+ boost::bind(&LyX::printError, this, _1));
}
+ else
+ pimpl_->buffer_list_.release(buf);
}
- files.clear(); // the files are already loaded
}
+ files.clear(); // the files are already loaded
+
return EXIT_SUCCESS;
}
+void LyX::execBatchCommands()
+{
+ // Execute batch commands if available
+ if (batch_command.empty())
+ return;
+
+ lyxerr[Debug::INIT] << "About to handle -x '"
+ << batch_command << '\'' << endl;
+
+ pimpl_->lyxfunc_.dispatch(lyxaction.lookupFunc(batch_command));
+}
+
+
void LyX::restoreGuiSession(vector<string> const & files)
{
LyXView * view = newLyXView();
// initial geometry
unsigned int width = 690;
unsigned int height = 510;
+ // default icon size, will be overwritten by stored session value
+ unsigned int iconSizeXY = 26;
bool maximize = false;
// first try lyxrc
if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) {
height = convert<unsigned int>(val);
if (session().sessionInfo().load("WindowIsMaximized") == "yes")
maximize = true;
+ val = session().sessionInfo().load("IconSizeXY");
+ if (!val.empty())
+ iconSizeXY = convert<unsigned int>(val);
}
// if user wants to restore window position
height = 0;
}
// create the main window
- LyXView * view = &pimpl_->application_->createView(width, height, posx, posy, maximize);
+ LyXView * view = &pimpl_->application_->createView(width, height, posx, posy, maximize, iconSizeXY);
return view;
}
fs::is_directory(lyxrc.document_path))
package().document_dir() = lyxrc.document_path;
- package().temp_dir() = createLyXTmpDir(lyxrc.tempdir_path);
+ package().temp_dir() = createLyXTmpDir(FileName(lyxrc.tempdir_path)).absFilename();
if (package().temp_dir().empty()) {
Alert::error(_("Could not create temporary directory"),
bformat(_("Could not create a temporary directory in\n"
{
lyxerr[Debug::INIT] << "About to read " << name << "... ";
- string const lyxrc_path = libFileSearch(string(), name);
+ FileName const lyxrc_path = libFileSearch(string(), name);
if (!lyxrc_path.empty()) {
lyxerr[Debug::INIT] << "Found in " << lyxrc_path << endl;
lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
- string const ui_path = libFileSearch("ui", name, "ui");
+ FileName const ui_path = libFileSearch("ui", name, "ui");
if (ui_path.empty()) {
lyxerr[Debug::INIT] << "Could not find " << name << endl;
{
lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
- string const lang_path = libFileSearch(string(), name);
+ FileName const lang_path = libFileSearch(string(), name);
if (lang_path.empty()) {
showFileError(name);
return false;
{
lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
- string const enc_path = libFileSearch(string(), name);
+ FileName const enc_path = libFileSearch(string(), name);
if (enc_path.empty()) {
showFileError(name);
return false;