+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
TextCache.h \
Thesaurus.C \
Thesaurus.h \
- ToolbarDefaults.C \
- ToolbarDefaults.h \
+ ToolbarBackend.C \
+ ToolbarBackend.h \
WordLangTuple.h \
aspell.C \
aspell_local.h \
}
-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);
typedef MenuList::const_iterator const_iterator;
///
void read(LyXLex &);
- /// Set default values for menu structure.
- void defaults();
///
void add(Menu const &);
///
--- /dev/null
+/**
+ * \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);
+ }
+}
--- /dev/null
+// -*- 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
+++ /dev/null
-/* 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);
- }
-}
+++ /dev/null
-// -*- 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
+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
#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;
}
#include "LString.h"
class LyXView;
-class ToolbarDefaults;
+class ToolbarBackend;
/** The LyX GUI independent toolbar class
class Toolbar {
public:
///
- Toolbar(LyXView * o, int x, int y, ToolbarDefaults const &);
+ Toolbar(LyXView * o, int x, int y, ToolbarBackend const &);
///
~Toolbar();
+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
#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"
::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);
#include <config.h>
-#include "ToolbarDefaults.h"
+#include "ToolbarBackend.h"
#include "debug.h"
#include "gettext.h"
#include "lyxfunc.h"
void Toolbar::Pimpl::setLayout(string const & layout)
{
+ if (!combo_)
+ return;
+
LyXTextClass const & tc =
owner_->buffer()->params.getLyXTextClass();
void Toolbar::Pimpl::updateLayoutList(bool force)
{
+ if (!combo_)
+ return;
+
// if we don't need an update, don't ...
if (combo_->count() && !force)
return;
void Toolbar::Pimpl::clearLayoutList()
{
+ if (!combo_)
+ return;
+
combo_->clear();
}
void Toolbar::Pimpl::openLayoutList()
{
+ if (!combo_)
+ return;
+
combo_->popup();
}
}
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);
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
#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"
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();
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;
#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"
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);
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
///
void read(string const & filename);
///
- void setDefaults();
- ///
Language const * getLanguage(string const & language) const;
///
size_type size() const {
#include "lyxserver.h"
#include "kbmap.h"
#include "lyxfunc.h"
-#include "ToolbarDefaults.h"
+#include "ToolbarBackend.h"
#include "MenuBackend.h"
#include "language.h"
#include "lastfiles.h"
// 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[])
{
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()) {
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");
// 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();
}
-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);
}
if (ui_path.empty()) {
lyxerr[Debug::INIT] << "Could not find " << name << endl;
- menubackend.defaults();
+ showFileError(name);
return;
}
break;
case ui_toolbar:
- toolbardefaults.read(lex);
+ toolbarbackend.read(lex);
break;
default:
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);
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);
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