From 1423bdb7a7615b0af878188c9a36b07cbd2421e6 Mon Sep 17 00:00:00 2001 From: John Levon Date: Wed, 2 Apr 2003 18:08:05 +0000 Subject: [PATCH] remove defaults stuff, let Qt handle no toolbar git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6685 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 15 ++++ src/Makefile.am | 4 +- src/MenuBackend.C | 45 ------------ src/MenuBackend.h | 2 - src/{ToolbarDefaults.C => ToolbarBackend.C} | 73 +++++-------------- src/ToolbarBackend.h | 73 +++++++++++++++++++ src/ToolbarDefaults.h | 77 --------------------- src/frontends/ChangeLog | 5 ++ src/frontends/Toolbar.C | 10 +-- src/frontends/Toolbar.h | 4 +- src/frontends/qt2/ChangeLog | 6 ++ src/frontends/qt2/QtView.C | 4 +- src/frontends/qt2/Toolbar_pimpl.C | 20 ++++-- src/frontends/xforms/ChangeLog | 5 ++ src/frontends/xforms/Toolbar_pimpl.C | 10 +-- src/frontends/xforms/XFormsView.C | 4 +- src/language.C | 14 ---- src/language.h | 2 - src/lyx_main.C | 69 +++++++++--------- src/lyx_main.h | 4 +- 20 files changed, 195 insertions(+), 251 deletions(-) rename src/{ToolbarDefaults.C => ToolbarBackend.C} (52%) create mode 100644 src/ToolbarBackend.h delete mode 100644 src/ToolbarDefaults.h diff --git a/src/ChangeLog b/src/ChangeLog index 0b93bee268..dd7f32e31e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2003-04-01 John Levon + + * ToolbarBackend.h: + * ToolbarBackend.C: + * Makefile.am: rename, remove defaults gunk + + * MenuBackend.h: + * MenuBackend.C: remove defaults gunk + + * Languages.h: + * Languages.C: remove defaults gunk + + * lyx_main.h: + * lyx_main.C: error out if files couldn't be found. + 2003-04-02 John Levon * text2.C: make incDepth() use parlist diff --git a/src/Makefile.am b/src/Makefile.am index 264fcd1741..6b82c08be1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -84,8 +84,8 @@ lyx_SOURCES = \ TextCache.h \ Thesaurus.C \ Thesaurus.h \ - ToolbarDefaults.C \ - ToolbarDefaults.h \ + ToolbarBackend.C \ + ToolbarBackend.h \ WordLangTuple.h \ aspell.C \ aspell_local.h \ diff --git a/src/MenuBackend.C b/src/MenuBackend.C index 86c79e2485..a6a47b27d7 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -731,51 +731,6 @@ void MenuBackend::read(LyXLex & lex) } -void MenuBackend::defaults() -{ - menulist_.clear(); - - lyxerr[Debug::GUI] << "MenuBackend::defaults: using default values" - << endl; - - Menu file("file"); - file - .add(MenuItem(MenuItem::Command, _("New...|N"), "buffer-new")) - .add(MenuItem(MenuItem::Command, _("Open...|O"), "file-open")) - .add(MenuItem(MenuItem::Submenu, _("Import|I"), "import")) - .add(MenuItem(MenuItem::Command, _("Quit|Q"), "lyx-quit")) - .add(MenuItem(MenuItem::Separator)) - .add(MenuItem(MenuItem::Lastfiles)); - add(file); - - Menu import("import"); - import - .add(MenuItem(MenuItem::Command, - _("LaTeX...|L"), "buffer-import latex")) - .add(MenuItem(MenuItem::Command, - _("LinuxDoc...|L"), "buffer-import linuxdoc")); - add(import); - - Menu edit("edit"); - edit - .add(MenuItem(MenuItem::Command, _("Cut"), "cut")) - .add(MenuItem(MenuItem::Command, _("Copy"), "copy")) - .add(MenuItem(MenuItem::Command, _("Paste"), "paste")) - .add(MenuItem(MenuItem::Command, _("Emphasize"), "font-emph")); - add(edit); - - Menu documents("documents"); - documents.add(MenuItem(MenuItem::Documents)); - add(documents); - - menubar_.add(MenuItem(MenuItem::Submenu, _("File|F"), "file")) - .add(MenuItem(MenuItem::Submenu, _("Edit|E"), "edit")) - .add(MenuItem(MenuItem::Submenu, - _("Documents|D"), "documents")); - -} - - void MenuBackend::add(Menu const & menu) { menulist_.push_back(menu); diff --git a/src/MenuBackend.h b/src/MenuBackend.h index c768623d4b..f5450cec0f 100644 --- a/src/MenuBackend.h +++ b/src/MenuBackend.h @@ -178,8 +178,6 @@ public: typedef MenuList::const_iterator const_iterator; /// void read(LyXLex &); - /// Set default values for menu structure. - void defaults(); /// void add(Menu const &); /// diff --git a/src/ToolbarDefaults.C b/src/ToolbarBackend.C similarity index 52% rename from src/ToolbarDefaults.C rename to src/ToolbarBackend.C index b26a0dcf5a..3c2a8d08b9 100644 --- a/src/ToolbarDefaults.C +++ b/src/ToolbarBackend.C @@ -1,17 +1,16 @@ -/* This file is part of - * ====================================================== +/** + * \file ToolbarBackend.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * LyX, The Document Processor + * \author unknown * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * - * ====================================================== */ + * Full author contact details are available in file CREDITS + */ #include -#include "ToolbarDefaults.h" +#include "ToolbarBackend.h" #include "LyXAction.h" #include "lyxlex.h" #include "debug.h" @@ -20,7 +19,7 @@ using std::endl; -ToolbarDefaults toolbardefaults; +ToolbarBackend toolbarbackend; namespace { @@ -45,61 +44,25 @@ struct keyword_item toolTags[TO_LAST - 1] = { } // end of anon namespace -ToolbarDefaults::ToolbarDefaults() +ToolbarBackend::ToolbarBackend() { - init(); } -void ToolbarDefaults::add(int action) +void ToolbarBackend::add(int action) { - defaults.push_back(action); + items.push_back(action); } -void ToolbarDefaults::init() -{ - add(LAYOUTS); - add(LFUN_FILE_OPEN); - //add(LFUN_CLOSEBUFFER); - add(LFUN_MENUWRITE); - add(LFUN_MENUPRINT); - add(SEPARATOR); - - add(LFUN_CUT); - add(LFUN_COPY); - add(LFUN_PASTE); - add(SEPARATOR); - - add(LFUN_EMPH); - add(LFUN_NOUN); - add(LFUN_FREEFONT_APPLY); - add(SEPARATOR); - - add(LFUN_INSET_FOOTNOTE); - add(LFUN_INSET_MARGINAL); - - add(LFUN_DEPTH_PLUS); - add(SEPARATOR); - - add(LFUN_MATH_MODE); - add(SEPARATOR); - -// add(LFUN_INSET_GRAPHICS); - add(LFUN_TABULAR_INSERT); -} - - -void ToolbarDefaults::read(LyXLex & lex) +void ToolbarBackend::read(LyXLex & lex) { //consistency check if (compare_ascii_no_case(lex.getString(), "toolbar")) { - lyxerr << "Toolbar::read: ERROR wrong token:`" + lyxerr << "ToolbarBackend::read: ERROR wrong token:`" << lex.getString() << '\'' << endl; } - defaults.clear(); - bool quit = false; lex.pushTable(toolTags, TO_LAST - 1); @@ -113,7 +76,7 @@ void ToolbarDefaults::read(LyXLex & lex) if (lex.next(true)) { string const func = lex.getString(); lyxerr[Debug::PARSER] - << "Toolbar::read TO_ADD func: `" + << "ToolbarBackend::read TO_ADD func: `" << func << '\'' << endl; add(func); } @@ -135,7 +98,7 @@ void ToolbarDefaults::read(LyXLex & lex) quit = true; break; default: - lex.printError("Toolbar::read: " + lex.printError("ToolbarBackend::read: " "Unknown toolbar tag: `$$Token'"); break; } @@ -144,12 +107,12 @@ void ToolbarDefaults::read(LyXLex & lex) } -void ToolbarDefaults::add(string const & func) +void ToolbarBackend::add(string const & func) { int const tf = lyxaction.LookupFunc(func); if (tf == -1) { - lyxerr << "Toolbar::add: no LyX command called `" + lyxerr << "ToolbarBackend::add: no LyX command called `" << func << "' exists!" << endl; } else { add(tf); diff --git a/src/ToolbarBackend.h b/src/ToolbarBackend.h new file mode 100644 index 0000000000..7e609ac8c4 --- /dev/null +++ b/src/ToolbarBackend.h @@ -0,0 +1,73 @@ +// -*- C++ -*- +/** + * \file ToolbarBackend.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author unknown + * + * Full author contact details are available in file CREDITS + */ + +#ifndef TOOLBAR_BACKEND_H +#define TOOLBAR_BACKEND_H + +#include + +#include "LString.h" + +class LyXLex; + +/// +class ToolbarBackend { +public: + /// The special toolbar actions + enum ItemType { + /// adds space between buttons in the toolbar + SEPARATOR = -3, + /// a special combox insead of a button + LAYOUTS = -2, + /// begin a new line of button (not working) + NEWLINE = -1 + }; + + /// + typedef std::vector Items; + /// + typedef Items::iterator iterator; + /// + typedef Items::const_iterator const_iterator; + /// + ToolbarBackend(); + /// + iterator begin() { + return items.begin(); + } + /// + const_iterator begin() const { + return items.begin(); + } + /// + iterator end() { + return items.end(); + } + /// + const_iterator end() const { + return items.end(); + } + /// + void read(LyXLex &); +private: + /// This func is just to make it easy for me... + void add(int); + /// + void add(string const &); + /// + Items items; +}; + +/// The global instance +extern ToolbarBackend toolbarbackend; + + +#endif // TOOLBAR_BACKEND_H diff --git a/src/ToolbarDefaults.h b/src/ToolbarDefaults.h deleted file mode 100644 index dc254187d8..0000000000 --- a/src/ToolbarDefaults.h +++ /dev/null @@ -1,77 +0,0 @@ -// -*- C++ -*- -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * - * ====================================================== */ - - -#ifndef TOOLBARDEFAULTS_H -#define TOOLBARDEFAULTS_H - -#include - -#include "LString.h" - -class LyXLex; - -/// -class ToolbarDefaults { -public: - /// The special toolbar actions - enum ItemType { - /// adds space between buttons in the toolbar - SEPARATOR = -3, - /// a special combox insead of a button - LAYOUTS = -2, - /// begin a new line of button (not working) - NEWLINE = -1 - }; - - /// - typedef std::vector Defaults; - /// - typedef Defaults::iterator iterator; - /// - typedef Defaults::const_iterator const_iterator; - /// - ToolbarDefaults(); - /// - iterator begin() { - return defaults.begin(); - } - /// - const_iterator begin() const { - return defaults.begin(); - } - /// - iterator end() { - return defaults.end(); - } - /// - const_iterator end() const { - return defaults.end(); - } - /// - void read(LyXLex &); -private: - /// - void init(); - /// This func is just to make it easy for me... - void add(int); - /// - void add(string const &); - /// - Defaults defaults; -}; - -/// The global instance -extern ToolbarDefaults toolbardefaults; - - -#endif diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index ef6ddc62a5..4e822b4f1b 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,8 @@ +2003-04-01 John Levon + + * Toolbar.h: + * Toolbar.C: ToolbarDefaults got renamed + 2003-04-01 Lars Gullik Bjønnes screen.[Ch]: adjust diff --git a/src/frontends/Toolbar.C b/src/frontends/Toolbar.C index b8740baf13..9f4bfecc7f 100644 --- a/src/frontends/Toolbar.C +++ b/src/frontends/Toolbar.C @@ -12,21 +12,21 @@ #include "Toolbar.h" -#include "ToolbarDefaults.h" +#include "ToolbarBackend.h" #include "Toolbar_pimpl.h" #include "debug.h" #include "LyXAction.h" using std::endl; -Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarDefaults const &tbd) +Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarBackend const & backend) : last_textclass_(-1) { pimpl_ = new Pimpl(o, x, y); - // extracts the toolbar actions from tbd - for (ToolbarDefaults::const_iterator cit = tbd.begin(); - cit != tbd.end(); ++cit) { + // extracts the toolbar actions from the backend + for (ToolbarBackend::const_iterator cit = backend.begin(); + cit != backend.end(); ++cit) { pimpl_->add((*cit)); lyxerr[Debug::GUI] << "tool action: " << (*cit) << endl; } diff --git a/src/frontends/Toolbar.h b/src/frontends/Toolbar.h index 7e48092f17..e59af253f2 100644 --- a/src/frontends/Toolbar.h +++ b/src/frontends/Toolbar.h @@ -16,7 +16,7 @@ #include "LString.h" class LyXView; -class ToolbarDefaults; +class ToolbarBackend; /** The LyX GUI independent toolbar class @@ -25,7 +25,7 @@ class ToolbarDefaults; class Toolbar { public: /// - Toolbar(LyXView * o, int x, int y, ToolbarDefaults const &); + Toolbar(LyXView * o, int x, int y, ToolbarBackend const &); /// ~Toolbar(); diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 28aec0801a..80824d267f 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,9 @@ +2003-04-01 John Levon + + * QtView.C: + * Toolbar_pimpl.C: ToolbarDefaults got renamed, + handle no toolbar + 2003-03-31 John Levon * lyx_gui.C: return useful default font names, add use_gui diff --git a/src/frontends/qt2/QtView.C b/src/frontends/qt2/QtView.C index 9a65d483af..d51e8e1b32 100644 --- a/src/frontends/qt2/QtView.C +++ b/src/frontends/qt2/QtView.C @@ -17,7 +17,7 @@ #include "lyx_cb.h" #include "support/filetools.h" #include "MenuBackend.h" -#include "ToolbarDefaults.h" +#include "ToolbarBackend.h" #include "lyxfunc.h" #include "bufferview_funcs.h" #include "BufferView.h" @@ -65,7 +65,7 @@ QtView::QtView(unsigned int width, unsigned int height) ::current_view = bufferview_.get(); menubar_.reset(new Menubar(this, menubackend)); - toolbar_.reset(new Toolbar(this, 0, 0, toolbardefaults)); + toolbar_.reset(new Toolbar(this, 0, 0, toolbarbackend)); statusBar()->setSizeGripEnabled(false); diff --git a/src/frontends/qt2/Toolbar_pimpl.C b/src/frontends/qt2/Toolbar_pimpl.C index 0c3bdc875e..534ec09eae 100644 --- a/src/frontends/qt2/Toolbar_pimpl.C +++ b/src/frontends/qt2/Toolbar_pimpl.C @@ -12,7 +12,7 @@ #include -#include "ToolbarDefaults.h" +#include "ToolbarBackend.h" #include "debug.h" #include "gettext.h" #include "lyxfunc.h" @@ -157,6 +157,9 @@ void Toolbar::Pimpl::changed_layout(string const & sel) void Toolbar::Pimpl::setLayout(string const & layout) { + if (!combo_) + return; + LyXTextClass const & tc = owner_->buffer()->params.getLyXTextClass(); @@ -180,6 +183,9 @@ void Toolbar::Pimpl::setLayout(string const & layout) void Toolbar::Pimpl::updateLayoutList(bool force) { + if (!combo_) + return; + // if we don't need an update, don't ... if (combo_->count() && !force) return; @@ -211,12 +217,18 @@ void Toolbar::Pimpl::updateLayoutList(bool force) void Toolbar::Pimpl::clearLayoutList() { + if (!combo_) + return; + combo_->clear(); } void Toolbar::Pimpl::openLayoutList() { + if (!combo_) + return; + combo_->popup(); } @@ -228,13 +240,13 @@ void Toolbar::Pimpl::add(int action) } switch (action) { - case ToolbarDefaults::SEPARATOR: + case ToolbarBackend::SEPARATOR: toolbars_.back()->addSeparator(); break; - case ToolbarDefaults::NEWLINE: + case ToolbarBackend::NEWLINE: toolbars_.push_back(new QToolBar(owner_)); break; - case ToolbarDefaults::LAYOUTS: { + case ToolbarBackend::LAYOUTS: { combo_ = new QLComboBox(toolbars_.back()); QSizePolicy p(QSizePolicy::Minimum, QSizePolicy::Fixed); combo_->setSizePolicy(p); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 07515142a4..f1f1c304cd 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -53,6 +53,11 @@ but rather use the new controller method. Means that XMinibuffer knows nothing about the LyX kernel. +2003-04-01 John Levon + + * XFormsView.C: + * Toolbar_pimpl.C: ToolbarDefaults got renamed + 2003-04-01 John Levon * Alert_pimpl.C: format error messages diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index e5b38575de..021f56e7a7 100644 --- a/src/frontends/xforms/Toolbar_pimpl.C +++ b/src/frontends/xforms/Toolbar_pimpl.C @@ -26,9 +26,9 @@ #include "Tooltips.h" #include FORMS_H_LOCATION #include "combox.h" +#include "ToolbarBackend.h" #include "xforms_helpers.h" -#include "ToolbarDefaults.h" #include "LyXAction.h" #include "support/LAssert.h" @@ -110,7 +110,7 @@ void Toolbar::Pimpl::update() ToolbarList::const_iterator p = toollist_.begin(); ToolbarList::const_iterator end = toollist_.end(); for (; p != end; ++p) { - if (p->action == ToolbarDefaults::LAYOUTS && combox_) { + if (p->action == ToolbarBackend::LAYOUTS && combox_) { LyXFunc const & lf = owner_->getLyXFunc(); bool const disable = lf.getStatus(LFUN_LAYOUT).disabled(); @@ -307,13 +307,13 @@ void Toolbar::Pimpl::add(int action) item.action = action; switch (action) { - case ToolbarDefaults::SEPARATOR: + case ToolbarBackend::SEPARATOR: xpos += sepspace; break; - case ToolbarDefaults::NEWLINE: + case ToolbarBackend::NEWLINE: // Not supported yet. break; - case ToolbarDefaults::LAYOUTS: + case ToolbarBackend::LAYOUTS: xpos += standardspacing; if (combox_) break; diff --git a/src/frontends/xforms/XFormsView.C b/src/frontends/xforms/XFormsView.C index c93f9d32a3..7971cf91ff 100644 --- a/src/frontends/xforms/XFormsView.C +++ b/src/frontends/xforms/XFormsView.C @@ -24,7 +24,7 @@ #include "frontends/Timeout.h" #include "frontends/Dialogs.h" #include "MenuBackend.h" -#include "ToolbarDefaults.h" +#include "ToolbarBackend.h" #include "lyxfunc.h" #include "bufferview_funcs.h" #include "BufferView.h" @@ -142,7 +142,7 @@ void XFormsView::create_form_form_main(int width, int height) menubar_.reset(new Menubar(this, menubackend)); - toolbar_.reset(new Toolbar(this, air, 30 + air + bw, toolbardefaults)); + toolbar_.reset(new Toolbar(this, air, 30 + air + bw, toolbarbackend)); int const ywork = 60 + 2 * air + bw; int const workheight = height - ywork - (25 + 2 * air); diff --git a/src/language.C b/src/language.C index 248361e85c..24cb2b6a1f 100644 --- a/src/language.C +++ b/src/language.C @@ -27,20 +27,6 @@ Language const * ignore_language = &ignore_lang; Language latex_lang("latex", "latex", "Latex", false, 0, "latex", ""); Language const * latex_language = &latex_lang; -void Languages::setDefaults() -{ - // We need to set the encoding of latex_lang - latex_lang = Language("latex", "latex", "Latex", false, - encodings.getEncoding("iso8859-1"), - "latex", ""); - - languagelist["english"] = Language("english", "english", N_("English"), - false, - encodings.getEncoding("iso8859-1"), - "en", ""); - english_language = default_language = &languagelist["english"]; -} - void Languages::read(string const & filename) { // We need to set the encoding of latex_lang diff --git a/src/language.h b/src/language.h index a043c0af83..200bc922c3 100644 --- a/src/language.h +++ b/src/language.h @@ -86,8 +86,6 @@ public: /// void read(string const & filename); /// - void setDefaults(); - /// Language const * getLanguage(string const & language) const; /// size_type size() const { diff --git a/src/lyx_main.C b/src/lyx_main.C index 83f6cfa897..168b299a9f 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -27,7 +27,7 @@ #include "lyxserver.h" #include "kbmap.h" #include "lyxfunc.h" -#include "ToolbarDefaults.h" +#include "ToolbarBackend.h" #include "MenuBackend.h" #include "language.h" #include "lastfiles.h" @@ -74,6 +74,24 @@ BufferList bufferlist; // convenient to have it here. boost::scoped_ptr toplevel_keymap; +namespace { + +void showFileError(string const & error) +{ +#if USE_BOOST_FORMAT + Alert::warning(_("Could not read configuration file"), + boost::io::str(boost::format( + _("Error while reading the configuration file\n%1$s.\n" + "Please check your installation.")) % error)); +#else + Alert::warning(_("Could not read configuration file"), + string(_("Error while reading the configuration file\n")) + + error + _(".\nPlease check your installation.")); +#endif + exit(EXIT_FAILURE); +} + +} LyX::LyX(int & argc, char * argv[]) { @@ -126,9 +144,8 @@ LyX::LyX(int & argc, char * argv[]) files.push_back(argv[argi]); } - if (first_start) { + if (first_start) files.push_back(i18nLibFileSearch("examples", "splash.lyx")); - } // Execute batch commands if available if (!batch_command.empty()) { @@ -441,10 +458,12 @@ void LyX::init(bool gui) system_converters = converters; system_lcolor = lcolor; - // If there is a preferences file we read that instead - // of the old lyxrc file. - if (!readRcFile("preferences")) - readRcFile("lyxrc"); + string prefsfile = "preferences"; + // back compatibility to lyxs < 1.1.6 + if (LibFileSearch(string(), prefsfile).empty()) + prefsfile = "lyxrc"; + if (!LibFileSearch(string(), prefsfile).empty()) + readRcFile(prefsfile); readEncodingsFile("encodings"); readLanguagesFile("languages"); @@ -460,9 +479,8 @@ void LyX::init(bool gui) // Read menus readUIFile(lyxrc.ui_file); - if (lyxerr.debugging(Debug::LYXRC)) { + if (lyxerr.debugging(Debug::LYXRC)) lyxrc.print(); - } os::setTmpDir(CreateLyXTmpDir(lyxrc.tempdir_path)); system_tempdir = os::getTmpDir(); @@ -631,33 +649,21 @@ void LyX::queryUserLyXDir(bool explicit_userdir) } -bool LyX::readRcFile(string const & name) +void LyX::readRcFile(string const & name) { lyxerr[Debug::INIT] << "About to read " << name << "..." << endl; string const lyxrc_path = LibFileSearch(string(), name); if (!lyxrc_path.empty()) { + lyxerr[Debug::INIT] << "Found " << name << " in " << lyxrc_path << endl; - if (lyxrc.read(lyxrc_path) < 0) { -#if USE_BOOST_FORMAT - Alert::warning(_("Could not read configuration file"), - boost::io::str(boost::format( - _("Error while reading the configuration file\n%1$s.\n" - ".\nLyX will use the built-in defaults.")) % lyxrc_path)); -#else - Alert::warning(_("Could not read configuration file"), - string(_("Error while reading the configuration file\n")) - + lyxrc_path + _(".\nLyX will use the built-in defaults.")); -#endif - return false; - } - return true; - } else { - lyxerr[Debug::INIT] << "Could not find " << name << endl; + + if (lyxrc.read(lyxrc_path) >= 0) + return; } - return false; + showFileError(name); } @@ -681,7 +687,7 @@ void LyX::readUIFile(string const & name) if (ui_path.empty()) { lyxerr[Debug::INIT] << "Could not find " << name << endl; - menubackend.defaults(); + showFileError(name); return; } @@ -704,7 +710,7 @@ void LyX::readUIFile(string const & name) break; case ui_toolbar: - toolbardefaults.read(lex); + toolbarbackend.read(lex); break; default: @@ -724,8 +730,7 @@ void LyX::readLanguagesFile(string const & name) string const lang_path = LibFileSearch(string(), name); if (lang_path.empty()) { - lyxerr[Debug::INIT] << "Could not find " << name << endl; - languages.setDefaults(); + showFileError(name); return; } languages.read(lang_path); @@ -739,7 +744,7 @@ void LyX::readEncodingsFile(string const & name) string const enc_path = LibFileSearch(string(), name); if (enc_path.empty()) { - lyxerr[Debug::INIT] << "Could not find " << name << endl; + showFileError(name); return; } encodings.read(enc_path); diff --git a/src/lyx_main.h b/src/lyx_main.h index f3b0f3c3b9..e8769300fe 100644 --- a/src/lyx_main.h +++ b/src/lyx_main.h @@ -50,8 +50,8 @@ private: void deadKeyBindings(kb_keymap * kbmap); /// check, set up and configure the user dir if necessary void queryUserLyXDir(bool explicit_userdir); - /// return true if the given prefs file was successfully read - bool readRcFile(string const & name); + /// read lyxrc/preferences + void readRcFile(string const & name); /// read the given ui (menu/toolbar) file void readUIFile(string const & name); /// read the given languages file -- 2.39.2