mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 00:10:59 +00:00
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
This commit is contained in:
parent
436098170f
commit
1423bdb7a7
@ -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
|
||||
|
@ -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 \
|
||||
|
@ -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);
|
||||
|
@ -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 &);
|
||||
///
|
||||
|
@ -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 <config.h>
|
||||
|
||||
#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);
|
73
src/ToolbarBackend.h
Normal file
73
src/ToolbarBackend.h
Normal file
@ -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
|
@ -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
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 <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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -86,8 +86,6 @@ public:
|
||||
///
|
||||
void read(string const & filename);
|
||||
///
|
||||
void setDefaults();
|
||||
///
|
||||
Language const * getLanguage(string const & language) const;
|
||||
///
|
||||
size_type size() const {
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user