]> git.lyx.org Git - features.git/commitdiff
remove defaults stuff, let Qt handle no toolbar
authorJohn Levon <levon@movementarian.org>
Wed, 2 Apr 2003 18:08:05 +0000 (18:08 +0000)
committerJohn Levon <levon@movementarian.org>
Wed, 2 Apr 2003 18:08:05 +0000 (18:08 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6685 a592a061-630c-0410-9148-cb99ea01b6c8

21 files changed:
src/ChangeLog
src/Makefile.am
src/MenuBackend.C
src/MenuBackend.h
src/ToolbarBackend.C [new file with mode: 0644]
src/ToolbarBackend.h [new file with mode: 0644]
src/ToolbarDefaults.C [deleted file]
src/ToolbarDefaults.h [deleted file]
src/frontends/ChangeLog
src/frontends/Toolbar.C
src/frontends/Toolbar.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/QtView.C
src/frontends/qt2/Toolbar_pimpl.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/Toolbar_pimpl.C
src/frontends/xforms/XFormsView.C
src/language.C
src/language.h
src/lyx_main.C
src/lyx_main.h

index 0b93bee26846552a358db9e980c01b1286caee6e..dd7f32e31e5053df89f37ea7e9b502d07e36a530 100644 (file)
@@ -1,3 +1,18 @@
+2003-04-01  John Levon  <levon@movementarian.org>
+
+       * 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  <levon@movementarian.org>
 
        * text2.C: make incDepth() use parlist
index 264fcd1741d2bb2786ce94e14c8065e6b6ad045e..6b82c08be177cb1a295bb9c8d8c4c8dce184380f 100644 (file)
@@ -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 \
index 86c79e24850b5f90c54b89eb613fccd35a5ede03..a6a47b27d741d4090e17c43b32d02021c6a35401 100644 (file)
@@ -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);
index c768623d4b07240c530eec38f18ec34cd0021ba0..f5450cec0f704b0602604eaa5034e7cebfb60335 100644 (file)
@@ -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/ToolbarBackend.C b/src/ToolbarBackend.C
new file mode 100644 (file)
index 0000000..3c2a8d0
--- /dev/null
@@ -0,0 +1,120 @@
+/**
+ * \file ToolbarBackend.C
+ * 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
+ */
+
+#include <config.h>
+
+#include "ToolbarBackend.h"
+#include "LyXAction.h"
+#include "lyxlex.h"
+#include "debug.h"
+#include "lyxlex.h"
+#include "support/lstrings.h"
+
+using std::endl;
+
+ToolbarBackend toolbarbackend;
+
+namespace {
+
+enum _tooltags {
+       TO_ADD = 1,
+       TO_ENDTOOLBAR,
+       TO_SEPARATOR,
+       TO_LAYOUTS,
+       TO_NEWLINE,
+       TO_LAST
+};
+
+
+struct keyword_item toolTags[TO_LAST - 1] = {
+       { "end", TO_ENDTOOLBAR },
+       { "icon", TO_ADD },
+       { "layouts", TO_LAYOUTS },
+       { "newline", TO_NEWLINE },
+       { "separator", TO_SEPARATOR }
+};
+
+} // end of anon namespace
+
+
+ToolbarBackend::ToolbarBackend()
+{
+}
+
+
+void ToolbarBackend::add(int action)
+{
+       items.push_back(action);
+}
+
+
+void ToolbarBackend::read(LyXLex & lex)
+{
+       //consistency check
+       if (compare_ascii_no_case(lex.getString(), "toolbar")) {
+               lyxerr << "ToolbarBackend::read: ERROR wrong token:`"
+                      << lex.getString() << '\'' << endl;
+       }
+
+       bool quit = false;
+
+       lex.pushTable(toolTags, TO_LAST - 1);
+
+       if (lyxerr.debugging(Debug::PARSER))
+               lex.printTable(lyxerr);
+
+       while (lex.isOK() && !quit) {
+               switch (lex.lex()) {
+               case TO_ADD:
+                       if (lex.next(true)) {
+                               string const func = lex.getString();
+                               lyxerr[Debug::PARSER]
+                                       << "ToolbarBackend::read TO_ADD func: `"
+                                       << func << '\'' << endl;
+                               add(func);
+                       }
+                       break;
+
+               case TO_SEPARATOR:
+                       add(SEPARATOR);
+                       break;
+
+               case TO_LAYOUTS:
+                       add(LAYOUTS);
+                       break;
+
+               case TO_NEWLINE:
+                       add(NEWLINE);
+                       break;
+
+               case TO_ENDTOOLBAR:
+                       quit = true;
+                       break;
+               default:
+                       lex.printError("ToolbarBackend::read: "
+                                      "Unknown toolbar tag: `$$Token'");
+                       break;
+               }
+       }
+       lex.popTable();
+}
+
+
+void ToolbarBackend::add(string const & func)
+{
+       int const tf = lyxaction.LookupFunc(func);
+
+       if (tf == -1) {
+               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 (file)
index 0000000..7e609ac
--- /dev/null
@@ -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 <vector>
+
+#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<int> 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.C b/src/ToolbarDefaults.C
deleted file mode 100644 (file)
index b26a0dc..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/* This file is part of
- * ======================================================
- *
- *           LyX, The Document Processor
- *
- *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2001 The LyX Team.
- *
- *
- * ====================================================== */
-
-#include <config.h>
-
-#include "ToolbarDefaults.h"
-#include "LyXAction.h"
-#include "lyxlex.h"
-#include "debug.h"
-#include "lyxlex.h"
-#include "support/lstrings.h"
-
-using std::endl;
-
-ToolbarDefaults toolbardefaults;
-
-namespace {
-
-enum _tooltags {
-       TO_ADD = 1,
-       TO_ENDTOOLBAR,
-       TO_SEPARATOR,
-       TO_LAYOUTS,
-       TO_NEWLINE,
-       TO_LAST
-};
-
-
-struct keyword_item toolTags[TO_LAST - 1] = {
-       { "end", TO_ENDTOOLBAR },
-       { "icon", TO_ADD },
-       { "layouts", TO_LAYOUTS },
-       { "newline", TO_NEWLINE },
-       { "separator", TO_SEPARATOR }
-};
-
-} // end of anon namespace
-
-
-ToolbarDefaults::ToolbarDefaults()
-{
-       init();
-}
-
-
-void ToolbarDefaults::add(int action)
-{
-       defaults.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)
-{
-       //consistency check
-       if (compare_ascii_no_case(lex.getString(), "toolbar")) {
-               lyxerr << "Toolbar::read: ERROR wrong token:`"
-                      << lex.getString() << '\'' << endl;
-       }
-
-       defaults.clear();
-
-       bool quit = false;
-
-       lex.pushTable(toolTags, TO_LAST - 1);
-
-       if (lyxerr.debugging(Debug::PARSER))
-               lex.printTable(lyxerr);
-
-       while (lex.isOK() && !quit) {
-               switch (lex.lex()) {
-               case TO_ADD:
-                       if (lex.next(true)) {
-                               string const func = lex.getString();
-                               lyxerr[Debug::PARSER]
-                                       << "Toolbar::read TO_ADD func: `"
-                                       << func << '\'' << endl;
-                               add(func);
-                       }
-                       break;
-
-               case TO_SEPARATOR:
-                       add(SEPARATOR);
-                       break;
-
-               case TO_LAYOUTS:
-                       add(LAYOUTS);
-                       break;
-
-               case TO_NEWLINE:
-                       add(NEWLINE);
-                       break;
-
-               case TO_ENDTOOLBAR:
-                       quit = true;
-                       break;
-               default:
-                       lex.printError("Toolbar::read: "
-                                      "Unknown toolbar tag: `$$Token'");
-                       break;
-               }
-       }
-       lex.popTable();
-}
-
-
-void ToolbarDefaults::add(string const & func)
-{
-       int const tf = lyxaction.LookupFunc(func);
-
-       if (tf == -1) {
-               lyxerr << "Toolbar::add: no LyX command called `"
-                      << func << "' exists!" << endl;
-       } else {
-               add(tf);
-       }
-}
diff --git a/src/ToolbarDefaults.h b/src/ToolbarDefaults.h
deleted file mode 100644 (file)
index dc25418..0000000
+++ /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 <vector>
-
-#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<int> 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
index ef6ddc62a57d0aa926f40af1d062f3384cf5a76e..4e822b4f1bd7193edd280bb2b17d1d1046ac8898 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-01  John Levon  <levon@movementarian.org>
+
+       * Toolbar.h:
+       * Toolbar.C: ToolbarDefaults got renamed
+
 2003-04-01  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        screen.[Ch]: adjust
index b8740baf1340292be1a6679406629ec894814534..9f4bfecc7f8ed224a3426898420260ee969f6f70 100644 (file)
 
 
 #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;
        }
index 7e48092f17d46ef6693001dbfb5c1fa0bec7f8e3..e59af253f214a157c3391af029c1555f71aa8f34 100644 (file)
@@ -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();
index 28aec0801a77143a5d271849eabe1303de43207c..80824d267fad3a41ceee9beb7a0255d8d0a04af6 100644 (file)
@@ -1,3 +1,9 @@
+2003-04-01  John Levon  <levon@movementarian.org>
+
+       * QtView.C:
+       * Toolbar_pimpl.C: ToolbarDefaults got renamed,
+       handle no toolbar
+
 2003-03-31  John Levon  <levon@movementarian.org>
 
        * lyx_gui.C: return useful default font names, add use_gui
index 9a65d483af4e781f13ab7696d172b102eadb5c03..d51e8e1b32f653f5494157d8e47ee9ce85fbea63 100644 (file)
@@ -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);
 
index 0c3bdc875ee0f49bb0cfb1138535b0b6176f2620..534ec09eae9fee2cae23fcc68bda6e0b84576a91 100644 (file)
@@ -12,7 +12,7 @@
 #include <config.h>
 
 
-#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);
index 07515142a4754a204a84f7a2078031f73b617250..f1f1c304cd1e6e23af69f9fabf6e208d14c954ad 100644 (file)
        but rather use the new controller method. Means that XMinibuffer
        knows nothing about the LyX kernel.
 
+2003-04-01  John Levon  <levon@movementarian.org>
+
+       * XFormsView.C:
+       * Toolbar_pimpl.C: ToolbarDefaults got renamed
+
 2003-04-01  John Levon  <levon@movementarian.org>
 
        * Alert_pimpl.C: format error messages
index e5b38575de54635c81a17c0b1a32aeeb7468519d..021f56e7a7a7a9dbc75d0de8c63eeb52e8a2cffa 100644 (file)
@@ -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;
index c93f9d32a3f97b42d1b1fba341e31195b6c29f79..7971cf91ffe87e883c6b69480745732a653f0ae5 100644 (file)
@@ -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);
index 248361e85c78d2ec77264c77ba2bd959a26685ce..24cb2b6a1fa7d56ce019ef29d67c5304e5b886f0 100644 (file)
@@ -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
index a043c0af83c3488c64ff477e3eaeda39eed9e746..200bc922c3ca82b439c760a55c8fa5c168a7898d 100644 (file)
@@ -86,8 +86,6 @@ public:
        ///
        void read(string const & filename);
        ///
-       void setDefaults();
-       ///
        Language const * getLanguage(string const & language) const;
        ///
        size_type size() const {
index 83f6cfa897864e03cc4b6f7aaf07d3e306eac5f0..168b299a9f067b255c9eaf7215cf9fa832897273 100644 (file)
@@ -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<kb_keymap> 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);
index f3b0f3c3b900a5554f4434e2685baf2a3d0e88ad..e8769300feb4e646446f24e53e71938c9186ff7c 100644 (file)
@@ -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