2003-04-02 18:08:05 +00:00
|
|
|
/**
|
2008-05-25 08:30:06 +00:00
|
|
|
* \file Toolbars.cpp
|
2003-04-02 18:08:05 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
* \author John Levon
|
2000-07-24 13:53:19 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-04-02 18:08:05 +00:00
|
|
|
*/
|
2000-07-24 13:53:19 +00:00
|
|
|
|
2000-03-12 10:36:28 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2008-05-25 08:30:06 +00:00
|
|
|
#include "Toolbars.h"
|
2009-05-02 08:43:22 +00:00
|
|
|
#include "Converter.h"
|
|
|
|
#include "Format.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "FuncRequest.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
#include "Lexer.h"
|
2007-04-19 19:43:15 +00:00
|
|
|
#include "LyXAction.h"
|
2008-08-15 10:56:53 +00:00
|
|
|
#include "qt_helpers.h"
|
2003-04-08 19:17:00 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
|
|
|
#include "support/gettext.h"
|
2008-08-15 10:56:53 +00:00
|
|
|
#include "support/lstrings.h"
|
2008-02-18 07:14:42 +00:00
|
|
|
|
2007-04-19 21:26:38 +00:00
|
|
|
#include <algorithm>
|
2000-03-12 10:36:28 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
using namespace lyx::support;
|
2007-12-12 10:16:00 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
2008-05-25 08:30:06 +00:00
|
|
|
namespace frontend {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2000-11-21 15:46:13 +00:00
|
|
|
|
2008-04-02 23:06:22 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// ToolbarItem
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
ToolbarItem::ToolbarItem(Type type, FuncRequest const & func, docstring const & label)
|
|
|
|
: type_(type), func_(func), label_(label)
|
2000-03-12 10:36:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
ToolbarItem::ToolbarItem(Type type, string const & name, docstring const & label)
|
2007-08-10 20:14:54 +00:00
|
|
|
: type_(type), label_(label), name_(name)
|
2000-03-12 10:36:28 +00:00
|
|
|
{
|
2007-04-19 19:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ToolbarInfo::add(ToolbarItem const & item)
|
|
|
|
{
|
|
|
|
items.push_back(item);
|
2010-04-09 19:00:42 +00:00
|
|
|
items.back().func_.setOrigin(FuncRequest::TOOLBAR);
|
2007-04-19 19:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
ToolbarInfo & ToolbarInfo::read(Lexer & lex)
|
2007-04-19 19:43:15 +00:00
|
|
|
{
|
2008-04-02 23:06:22 +00:00
|
|
|
enum {
|
2007-04-19 19:43:15 +00:00
|
|
|
TO_COMMAND = 1,
|
|
|
|
TO_ENDTOOLBAR,
|
|
|
|
TO_SEPARATOR,
|
|
|
|
TO_LAYOUTS,
|
|
|
|
TO_MINIBUFFER,
|
|
|
|
TO_TABLEINSERT,
|
2007-04-19 20:29:27 +00:00
|
|
|
TO_POPUPMENU,
|
2009-04-18 10:44:44 +00:00
|
|
|
TO_STICKYPOPUPMENU,
|
2007-04-19 20:29:27 +00:00
|
|
|
TO_ICONPALETTE,
|
2009-05-02 08:43:22 +00:00
|
|
|
TO_EXPORTFORMATS,
|
|
|
|
TO_IMPORTFORMATS,
|
|
|
|
TO_UPDATEFORMATS,
|
2010-12-17 19:56:51 +00:00
|
|
|
TO_VIEWFORMATS
|
2007-04-19 19:43:15 +00:00
|
|
|
};
|
2007-05-28 22:27:45 +00:00
|
|
|
|
2008-04-02 23:06:22 +00:00
|
|
|
struct LexerKeyword toolTags[] = {
|
2007-04-19 19:43:15 +00:00
|
|
|
{ "end", TO_ENDTOOLBAR },
|
2009-05-02 08:43:22 +00:00
|
|
|
{ "exportformats", TO_EXPORTFORMATS },
|
2007-04-19 20:29:27 +00:00
|
|
|
{ "iconpalette", TO_ICONPALETTE },
|
2009-05-02 08:43:22 +00:00
|
|
|
{ "importformats", TO_IMPORTFORMATS },
|
2007-04-19 19:43:15 +00:00
|
|
|
{ "item", TO_COMMAND },
|
|
|
|
{ "layouts", TO_LAYOUTS },
|
|
|
|
{ "minibuffer", TO_MINIBUFFER },
|
2007-04-19 20:29:27 +00:00
|
|
|
{ "popupmenu", TO_POPUPMENU },
|
2007-04-19 19:43:15 +00:00
|
|
|
{ "separator", TO_SEPARATOR },
|
2009-04-18 10:44:44 +00:00
|
|
|
{ "stickypopupmenu", TO_STICKYPOPUPMENU },
|
2009-05-02 08:43:22 +00:00
|
|
|
{ "tableinsert", TO_TABLEINSERT },
|
|
|
|
{ "updateformats", TO_UPDATEFORMATS },
|
|
|
|
{ "viewformats", TO_VIEWFORMATS },
|
2007-04-19 19:43:15 +00:00
|
|
|
};
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
//consistency check
|
2002-07-16 21:17:10 +00:00
|
|
|
if (compare_ascii_no_case(lex.getString(), "toolbar")) {
|
2007-11-28 22:12:03 +00:00
|
|
|
LYXERR0("ToolbarInfo::read: ERROR wrong token:`"
|
|
|
|
<< lex.getString() << '\'');
|
2001-08-06 19:12:46 +00:00
|
|
|
}
|
2000-03-12 10:36:28 +00:00
|
|
|
|
2003-04-09 19:53:10 +00:00
|
|
|
lex.next(true);
|
2007-04-19 19:43:15 +00:00
|
|
|
name = lex.getString();
|
2003-04-09 19:53:10 +00:00
|
|
|
|
2004-04-21 00:19:27 +00:00
|
|
|
lex.next(true);
|
2008-08-15 18:43:46 +00:00
|
|
|
gui_name = _(lex.getString());
|
2007-04-19 19:43:15 +00:00
|
|
|
|
|
|
|
// FIXME what to do here?
|
2007-03-26 13:43:49 +00:00
|
|
|
if (!lex) {
|
2007-11-28 22:12:03 +00:00
|
|
|
LYXERR0("ToolbarInfo::read: Malformed toolbar "
|
|
|
|
"description " << lex.getString());
|
2007-04-19 19:43:15 +00:00
|
|
|
return *this;
|
2004-04-21 00:19:27 +00:00
|
|
|
}
|
2003-06-17 15:33:49 +00:00
|
|
|
|
2000-03-12 10:36:28 +00:00
|
|
|
bool quit = false;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2008-04-02 23:06:22 +00:00
|
|
|
lex.pushTable(toolTags);
|
2000-03-12 10:36:28 +00:00
|
|
|
|
|
|
|
if (lyxerr.debugging(Debug::PARSER))
|
|
|
|
lex.printTable(lyxerr);
|
|
|
|
|
2001-08-06 19:12:46 +00:00
|
|
|
while (lex.isOK() && !quit) {
|
2009-05-02 08:43:22 +00:00
|
|
|
int const code = lex.lex();
|
|
|
|
switch (code) {
|
2007-04-19 19:43:15 +00:00
|
|
|
case TO_COMMAND:
|
2001-07-23 09:11:14 +00:00
|
|
|
if (lex.next(true)) {
|
2006-11-23 16:31:48 +00:00
|
|
|
docstring const tooltip = translateIfPossible(lex.getDocString());
|
2003-04-08 19:17:00 +00:00
|
|
|
lex.next(true);
|
2003-09-21 18:57:15 +00:00
|
|
|
string const func_arg = lex.getString();
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::PARSER, "ToolbarInfo::read TO_COMMAND func: `"
|
|
|
|
<< func_arg << '\'');
|
2003-09-21 18:57:15 +00:00
|
|
|
|
2003-09-21 23:00:47 +00:00
|
|
|
FuncRequest func =
|
|
|
|
lyxaction.lookupFunc(func_arg);
|
2007-04-19 19:43:15 +00:00
|
|
|
add(ToolbarItem(ToolbarItem::COMMAND, func, tooltip));
|
2000-03-12 10:36:28 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2003-04-15 01:06:13 +00:00
|
|
|
case TO_MINIBUFFER:
|
2007-04-19 19:43:15 +00:00
|
|
|
add(ToolbarItem(ToolbarItem::MINIBUFFER,
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest(FuncCode(ToolbarItem::MINIBUFFER))));
|
2003-04-15 01:06:13 +00:00
|
|
|
break;
|
|
|
|
|
2000-03-12 10:36:28 +00:00
|
|
|
case TO_SEPARATOR:
|
2007-04-19 19:43:15 +00:00
|
|
|
add(ToolbarItem(ToolbarItem::SEPARATOR,
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest(FuncCode(ToolbarItem::SEPARATOR))));
|
2000-03-12 10:36:28 +00:00
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2007-04-19 20:29:27 +00:00
|
|
|
case TO_POPUPMENU:
|
|
|
|
if (lex.next(true)) {
|
|
|
|
string const name = lex.getString();
|
|
|
|
lex.next(true);
|
|
|
|
docstring const label = lex.getDocString();
|
|
|
|
add(ToolbarItem(ToolbarItem::POPUPMENU, name, label));
|
|
|
|
}
|
|
|
|
break;
|
2009-05-07 12:40:35 +00:00
|
|
|
|
2009-04-18 10:44:44 +00:00
|
|
|
case TO_STICKYPOPUPMENU:
|
|
|
|
if (lex.next(true)) {
|
|
|
|
string const name = lex.getString();
|
|
|
|
lex.next(true);
|
|
|
|
docstring const label = lex.getDocString();
|
|
|
|
add(ToolbarItem(ToolbarItem::STICKYPOPUPMENU, name, label));
|
|
|
|
}
|
|
|
|
break;
|
2007-05-28 22:27:45 +00:00
|
|
|
|
2007-04-19 20:29:27 +00:00
|
|
|
case TO_ICONPALETTE:
|
|
|
|
if (lex.next(true)) {
|
|
|
|
string const name = lex.getString();
|
|
|
|
lex.next(true);
|
|
|
|
docstring const label = lex.getDocString();
|
|
|
|
add(ToolbarItem(ToolbarItem::ICONPALETTE, name, label));
|
|
|
|
}
|
|
|
|
break;
|
2007-05-28 22:27:45 +00:00
|
|
|
|
2000-03-12 10:36:28 +00:00
|
|
|
case TO_LAYOUTS:
|
2007-04-19 19:43:15 +00:00
|
|
|
add(ToolbarItem(ToolbarItem::LAYOUTS,
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest(FuncCode(ToolbarItem::LAYOUTS))));
|
2000-03-12 10:36:28 +00:00
|
|
|
break;
|
2007-05-28 22:27:45 +00:00
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
case TO_TABLEINSERT:
|
2007-05-06 07:26:51 +00:00
|
|
|
if (lex.next(true)) {
|
|
|
|
docstring const tooltip = lex.getDocString();
|
|
|
|
add(ToolbarItem(ToolbarItem::TABLEINSERT,
|
2008-03-15 01:20:36 +00:00
|
|
|
FuncRequest(FuncCode(ToolbarItem::TABLEINSERT)), tooltip));
|
2007-05-06 07:26:51 +00:00
|
|
|
}
|
2007-04-19 19:43:15 +00:00
|
|
|
break;
|
2007-05-28 22:27:45 +00:00
|
|
|
|
2000-03-12 10:36:28 +00:00
|
|
|
case TO_ENDTOOLBAR:
|
|
|
|
quit = true;
|
|
|
|
break;
|
2007-04-19 19:43:15 +00:00
|
|
|
|
2009-05-02 08:43:22 +00:00
|
|
|
case TO_EXPORTFORMATS:
|
|
|
|
case TO_IMPORTFORMATS:
|
|
|
|
case TO_UPDATEFORMATS:
|
|
|
|
case TO_VIEWFORMATS: {
|
|
|
|
vector<Format const *> formats = (code == TO_IMPORTFORMATS) ?
|
|
|
|
theConverters().importableFormats() :
|
2016-08-28 00:27:37 +00:00
|
|
|
theConverters().exportableFormats(true);
|
2009-05-02 08:43:22 +00:00
|
|
|
sort(formats.begin(), formats.end());
|
2016-08-28 00:27:37 +00:00
|
|
|
for (Format const * f : formats) {
|
|
|
|
if (f->dummy())
|
2009-05-02 08:43:22 +00:00
|
|
|
continue;
|
|
|
|
if (code != TO_IMPORTFORMATS &&
|
2016-08-28 00:27:37 +00:00
|
|
|
!f->documentFormat())
|
2009-05-02 08:43:22 +00:00
|
|
|
continue;
|
|
|
|
|
2016-08-28 00:27:37 +00:00
|
|
|
docstring const prettyname = f->prettyname();
|
2009-05-02 08:43:22 +00:00
|
|
|
docstring tooltip;
|
2009-05-07 12:40:35 +00:00
|
|
|
FuncCode lfun = LFUN_NOACTION;
|
2009-05-02 08:43:22 +00:00
|
|
|
switch (code) {
|
|
|
|
case TO_EXPORTFORMATS:
|
|
|
|
lfun = LFUN_BUFFER_EXPORT;
|
|
|
|
tooltip = _("Export %1$s");
|
|
|
|
break;
|
|
|
|
case TO_IMPORTFORMATS:
|
|
|
|
lfun = LFUN_BUFFER_IMPORT;
|
2009-06-07 16:19:40 +00:00
|
|
|
tooltip = _("Import %1$s");
|
2009-05-02 08:43:22 +00:00
|
|
|
break;
|
|
|
|
case TO_UPDATEFORMATS:
|
|
|
|
lfun = LFUN_BUFFER_UPDATE;
|
|
|
|
tooltip = _("Update %1$s");
|
|
|
|
break;
|
|
|
|
case TO_VIEWFORMATS:
|
|
|
|
lfun = LFUN_BUFFER_VIEW;
|
|
|
|
tooltip = _("View %1$s");
|
|
|
|
break;
|
|
|
|
}
|
2016-08-28 00:27:37 +00:00
|
|
|
FuncRequest func(lfun, f->name(),
|
2009-05-02 08:43:22 +00:00
|
|
|
FuncRequest::TOOLBAR);
|
|
|
|
add(ToolbarItem(ToolbarItem::COMMAND, func,
|
|
|
|
bformat(tooltip, prettyname)));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-03-12 10:36:28 +00:00
|
|
|
default:
|
2007-04-19 19:43:15 +00:00
|
|
|
lex.printError("ToolbarInfo::read: "
|
2000-03-12 10:36:28 +00:00
|
|
|
"Unknown toolbar tag: `$$Token'");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-04-09 19:53:10 +00:00
|
|
|
|
2000-03-12 10:36:28 +00:00
|
|
|
lex.popTable();
|
2007-04-19 19:43:15 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-04-02 23:06:22 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2008-05-25 08:30:06 +00:00
|
|
|
// Toolbars
|
2008-04-02 23:06:22 +00:00
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-06-25 18:03:38 +00:00
|
|
|
void Toolbars::reset()
|
|
|
|
{
|
|
|
|
toolbar_info_.clear();
|
|
|
|
toolbar_visibility_.clear();
|
|
|
|
}
|
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
|
2008-05-25 08:30:06 +00:00
|
|
|
void Toolbars::readToolbars(Lexer & lex)
|
2007-04-19 19:43:15 +00:00
|
|
|
{
|
2008-04-02 23:06:22 +00:00
|
|
|
enum {
|
2007-04-19 19:43:15 +00:00
|
|
|
TO_TOOLBAR = 1,
|
2010-12-17 19:56:51 +00:00
|
|
|
TO_ENDTOOLBARSET
|
2007-04-19 19:43:15 +00:00
|
|
|
};
|
2007-05-28 22:27:45 +00:00
|
|
|
|
2008-04-02 23:06:22 +00:00
|
|
|
struct LexerKeyword toolTags[] = {
|
2007-04-19 19:43:15 +00:00
|
|
|
{ "end", TO_ENDTOOLBARSET },
|
|
|
|
{ "toolbar", TO_TOOLBAR }
|
|
|
|
};
|
|
|
|
|
|
|
|
//consistency check
|
|
|
|
if (compare_ascii_no_case(lex.getString(), "toolbarset")) {
|
2008-05-25 08:30:06 +00:00
|
|
|
LYXERR0("Toolbars::readToolbars: ERROR wrong token:`"
|
2007-11-28 22:12:03 +00:00
|
|
|
<< lex.getString() << '\'');
|
2007-04-19 19:43:15 +00:00
|
|
|
}
|
|
|
|
|
2008-04-02 23:06:22 +00:00
|
|
|
lex.pushTable(toolTags);
|
2007-04-19 19:43:15 +00:00
|
|
|
|
|
|
|
if (lyxerr.debugging(Debug::PARSER))
|
|
|
|
lex.printTable(lyxerr);
|
|
|
|
|
|
|
|
bool quit = false;
|
|
|
|
while (lex.isOK() && !quit) {
|
|
|
|
switch (lex.lex()) {
|
|
|
|
case TO_TOOLBAR: {
|
2007-04-21 17:38:43 +00:00
|
|
|
ToolbarInfo tbinfo;
|
|
|
|
tbinfo.read(lex);
|
2008-05-27 11:15:17 +00:00
|
|
|
toolbar_info_.push_back(tbinfo);
|
2007-04-19 19:43:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TO_ENDTOOLBARSET:
|
|
|
|
quit = true;
|
|
|
|
break;
|
|
|
|
default:
|
2008-05-25 08:30:06 +00:00
|
|
|
lex.printError("Toolbars::readToolbars: "
|
2007-04-19 19:43:15 +00:00
|
|
|
"Unknown toolbar tag: `$$Token'");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lex.popTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-25 08:30:06 +00:00
|
|
|
void Toolbars::readToolbarSettings(Lexer & lex)
|
2003-06-11 19:21:46 +00:00
|
|
|
{
|
|
|
|
//consistency check
|
|
|
|
if (compare_ascii_no_case(lex.getString(), "toolbars")) {
|
2008-05-25 08:30:06 +00:00
|
|
|
LYXERR0("Toolbars::readToolbarSettings: ERROR wrong token:`"
|
2007-11-28 22:12:03 +00:00
|
|
|
<< lex.getString() << '\'');
|
2003-06-11 19:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lex.next(true);
|
|
|
|
|
|
|
|
while (lex.isOK()) {
|
|
|
|
string name = lex.getString();
|
|
|
|
lex.next(true);
|
|
|
|
|
|
|
|
if (!compare_ascii_no_case(name, "end"))
|
|
|
|
return;
|
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
int visibility = 0;
|
2003-06-11 19:21:46 +00:00
|
|
|
string flagstr = lex.getString();
|
|
|
|
lex.next(true);
|
|
|
|
vector<string> flags = getVectorFromString(flagstr);
|
|
|
|
|
|
|
|
vector<string>::const_iterator cit = flags.begin();
|
|
|
|
vector<string>::const_iterator end = flags.end();
|
|
|
|
|
|
|
|
for (; cit != end; ++cit) {
|
2008-05-27 11:15:17 +00:00
|
|
|
Visibility flag = ON;
|
2003-06-11 19:21:46 +00:00
|
|
|
if (!compare_ascii_no_case(*cit, "off"))
|
2008-05-27 11:15:17 +00:00
|
|
|
flag = OFF;
|
2003-06-11 19:21:46 +00:00
|
|
|
else if (!compare_ascii_no_case(*cit, "on"))
|
2008-05-27 11:15:17 +00:00
|
|
|
flag = ON;
|
2003-06-11 19:21:46 +00:00
|
|
|
else if (!compare_ascii_no_case(*cit, "math"))
|
2008-05-27 11:15:17 +00:00
|
|
|
flag = MATH;
|
2003-06-11 19:21:46 +00:00
|
|
|
else if (!compare_ascii_no_case(*cit, "table"))
|
2008-05-27 11:15:17 +00:00
|
|
|
flag = TABLE;
|
2007-12-23 00:47:37 +00:00
|
|
|
else if (!compare_ascii_no_case(*cit, "mathmacrotemplate"))
|
2008-05-27 11:15:17 +00:00
|
|
|
flag = MATHMACROTEMPLATE;
|
2006-10-29 11:13:46 +00:00
|
|
|
else if (!compare_ascii_no_case(*cit, "review"))
|
2008-05-27 11:15:17 +00:00
|
|
|
flag = REVIEW;
|
2015-04-18 17:10:33 +00:00
|
|
|
else if (!compare_ascii_no_case(*cit, "minibuffer"))
|
|
|
|
flag = MINIBUFFER;
|
2003-06-11 19:21:46 +00:00
|
|
|
else if (!compare_ascii_no_case(*cit, "top"))
|
2008-05-27 11:15:17 +00:00
|
|
|
flag = TOP;
|
2003-06-11 19:21:46 +00:00
|
|
|
else if (!compare_ascii_no_case(*cit, "bottom"))
|
2008-05-27 11:15:17 +00:00
|
|
|
flag = BOTTOM;
|
2003-06-11 19:21:46 +00:00
|
|
|
else if (!compare_ascii_no_case(*cit, "left"))
|
2008-05-27 11:15:17 +00:00
|
|
|
flag = LEFT;
|
2003-06-11 19:21:46 +00:00
|
|
|
else if (!compare_ascii_no_case(*cit, "right"))
|
2008-05-27 11:15:17 +00:00
|
|
|
flag = RIGHT;
|
2008-01-22 22:56:10 +00:00
|
|
|
else if (!compare_ascii_no_case(*cit, "auto"))
|
2008-05-27 11:15:17 +00:00
|
|
|
flag = AUTO;
|
2010-01-27 17:19:14 +00:00
|
|
|
else if (!compare_ascii_no_case(*cit, "samerow"))
|
|
|
|
flag = SAMEROW;
|
2012-08-21 12:56:34 +00:00
|
|
|
else if (!compare_ascii_no_case(*cit, "ipa"))
|
|
|
|
flag = IPA;
|
2003-06-11 19:21:46 +00:00
|
|
|
else {
|
2007-11-28 22:12:03 +00:00
|
|
|
LYXERR(Debug::ANY,
|
2008-05-25 08:30:06 +00:00
|
|
|
"Toolbars::readToolbarSettings: unrecognised token:`"
|
2007-11-28 22:12:03 +00:00
|
|
|
<< *cit << '\'');
|
2008-05-27 11:15:17 +00:00
|
|
|
continue;
|
2003-06-11 19:21:46 +00:00
|
|
|
}
|
2008-05-27 11:15:17 +00:00
|
|
|
visibility |= flag;
|
2003-06-11 19:21:46 +00:00
|
|
|
}
|
2008-05-27 11:15:17 +00:00
|
|
|
toolbar_visibility_[name] = visibility;
|
2003-06-11 19:21:46 +00:00
|
|
|
|
2011-01-03 12:14:44 +00:00
|
|
|
if (visibility & ALLOWAUTO) {
|
2008-05-27 11:15:17 +00:00
|
|
|
if (ToolbarInfo const * ti = info(name))
|
2008-08-15 10:56:53 +00:00
|
|
|
const_cast<ToolbarInfo *>(ti)->gui_name +=
|
2008-08-15 18:43:46 +00:00
|
|
|
" (" + _("auto") + ")";
|
2008-05-27 11:15:17 +00:00
|
|
|
}
|
2003-06-11 19:21:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
ToolbarInfo const * Toolbars::info(std::string const & name) const
|
2000-03-12 10:36:28 +00:00
|
|
|
{
|
2008-05-27 11:15:17 +00:00
|
|
|
Infos::const_iterator end = toolbar_info_.end();
|
|
|
|
for (Infos::const_iterator it = toolbar_info_.begin(); it != end; ++it)
|
|
|
|
if (it->name == name)
|
|
|
|
return &(*it);
|
|
|
|
return 0;
|
2000-03-12 10:36:28 +00:00
|
|
|
}
|
2003-04-08 19:17:00 +00:00
|
|
|
|
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
int Toolbars::defaultVisibility(std::string const & name) const
|
2003-04-08 19:17:00 +00:00
|
|
|
{
|
2008-05-27 11:15:17 +00:00
|
|
|
map<string, int>::const_iterator it = toolbar_visibility_.find(name);
|
|
|
|
if (it != toolbar_visibility_.end())
|
|
|
|
return it->second;
|
|
|
|
return OFF | BOTTOM;
|
2003-04-08 19:17:00 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
|
2008-06-02 12:51:36 +00:00
|
|
|
bool Toolbars::isMainToolbar(std::string const & name) const
|
|
|
|
{
|
|
|
|
return toolbar_visibility_.find(name) != toolbar_visibility_.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-25 08:30:06 +00:00
|
|
|
} // namespace frontend
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|