X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyx_main.C;h=84378364bcb54d74483b7e37c7e24688723855fe;hb=ebfcf1c0e72288b7131607af0330500c8739cead;hp=48d0072268a6dc259e1402b61de63996ad915ada;hpb=4b2a999762c83627476428e595d3c1e3704a3da0;p=lyx.git diff --git a/src/lyx_main.C b/src/lyx_main.C index 48d0072268..84378364bc 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -35,15 +35,14 @@ #include "layout.h" #include "gettext.h" #include "kbmap.h" -#ifdef NEW_MENUBAR -# include "MenuBackend.h" -#endif +#include "MenuBackend.h" #include "ToolbarDefaults.h" #include "lyxlex.h" using std::endl; extern void LoadLyXFile(string const &); +extern void QuitLyX(); string system_lyxdir; string build_lyxdir; @@ -138,7 +137,8 @@ LyX::LyX(int * argc, char * argv[]) // Execute batch commands if available if (!batch_command.empty()) { - lyxerr << "About to handle -x '" << batch_command << "'" << endl; + lyxerr << "About to handle -x '" + << batch_command << "'" << endl; // no buffer loaded, create one if (!last_loaded) @@ -151,6 +151,7 @@ LyX::LyX(int * argc, char * argv[]) // Maybe we could do something more clever than aborting... if (dispatched) { lyxerr << "We are done!" << endl; + QuitLyX(); return; } @@ -403,7 +404,11 @@ void LyX::init(int */*argc*/, char **argv, bool gui) // ReadRcFile("lyxrc.defaults"); - ReadRcFile("lyxrc"); +// system_lyxrc = lyxrc; + // If there is a preferences file we read that instead + // of the old lyxrc file. + if (!ReadRcFile("preferences")) + ReadRcFile("lyxrc"); // Ensure that we have really read a bind file, so that LyX is // usable. @@ -560,13 +565,13 @@ void LyX::queryUserLyXDir(bool explicit_userdir) // Run configure in user lyx directory Path p(user_lyxdir); - system(AddName(system_lyxdir, "configure").c_str()); + ::system(AddName(system_lyxdir, "configure").c_str()); lyxerr << "LyX: " << _("Done!") << endl; } // Read the rc file `name' -void LyX::ReadRcFile(string const & name) +bool LyX::ReadRcFile(string const & name) { lyxerr[Debug::INIT] << "About to read " << name << "..." << endl; @@ -578,9 +583,12 @@ void LyX::ReadRcFile(string const & name) WriteAlert(_("LyX Warning!"), _("Error while reading ")+lyxrc_path+".", _("Using built-in defaults.")); + return false; } + return true; } else lyxerr[Debug::INIT] << "Could not find " << name << endl; + return false; } @@ -611,24 +619,19 @@ void LyX::ReadUIFile(string const & name) << " in " << ui_path << endl; LyXLex lex(uitags, ui_last - 1); lex.setFile(ui_path); + if (!lex.IsOK()) { + lyxerr << "Unable to set LyXLeX for ui file: " << ui_path + << endl; + } + if (lyxerr.debugging(Debug::PARSER)) lex.printTable(lyxerr); while (lex.IsOK()) { switch(lex.lex()) { case ui_menuset: -#ifdef NEW_MENUBAR menubackend.read(lex); break; -#else - // Skip any menu definition and fall over to toolbar. - // This is a hack, but it is supposed to go away... - do { - lex.next(); - if (!lex.IsOK()) return; - } - while (lex.lex() != ui_toolbar); -#endif case ui_toolbar: toolbardefaults.read(lex); @@ -738,22 +741,8 @@ bool LyX::easyParse(int * argc, char * argv[]) if (i + 1 < *argc) { string type(argv[i+1]); removeargs = 2; - - if (type == "tex") - type = "latex"; - else if (type == "ps") - type = "postscript"; - else if (type == "text" || type == "txt") - type = "ascii"; - - if (type == "latex" || type == "postscript" - || type == "linuxdoc" || type == "docbook" - || type == "ascii" || type == "html") - batch_command = "buffer-export " + type; - else - lyxerr << _("Unknown file type '") - << type << _("' after ") - << arg << _(" switch!") << endl; + batch_command = "buffer-export " + type; + gui = false; } else lyxerr << _("Missing file type [eg latex, " "ps...] after ")