#include "ToolbarBackend.h"
#include "FuncRequest.h"
-#include "LyXLex.h"
+#include "Lexer.h"
#include "debug.h"
#include "gettext.h"
#include "LyXAction.h"
#include <boost/bind.hpp>
#include <algorithm>
-#include "frontends/controllers/ControlMath.h"
-
namespace lyx {
using support::compare_ascii_no_case;
ToolbarItem::ToolbarItem(Type type, string const & name, docstring const & label)
- : type_(type), name_(name), label_(label)
+ : type_(type), label_(label), name_(name)
{
}
}
-ToolbarInfo & ToolbarInfo::read(LyXLex & lex)
+ToolbarInfo & ToolbarInfo::read(Lexer & lex)
{
enum tooltags {
TO_COMMAND = 1,
TO_ICONPALETTE,
TO_LAST
};
-
+
struct keyword_item toolTags[TO_LAST - 1] = {
{ "end", TO_ENDTOOLBAR },
{ "iconpalette", TO_ICONPALETTE },
add(ToolbarItem(ToolbarItem::POPUPMENU, name, label));
}
break;
-
+
case TO_ICONPALETTE:
if (lex.next(true)) {
string const name = lex.getString();
add(ToolbarItem(ToolbarItem::ICONPALETTE, name, label));
}
break;
-
+
case TO_LAYOUTS:
add(ToolbarItem(ToolbarItem::LAYOUTS,
FuncRequest(kb_action(ToolbarItem::LAYOUTS))));
break;
-
+
case TO_TABLEINSERT:
- add(ToolbarItem(ToolbarItem::TABLEINSERT,
- FuncRequest(kb_action(ToolbarItem::TABLEINSERT))));
+ if (lex.next(true)) {
+ docstring const tooltip = lex.getDocString();
+ add(ToolbarItem(ToolbarItem::TABLEINSERT,
+ FuncRequest(kb_action(ToolbarItem::TABLEINSERT)), tooltip));
+ }
break;
-
+
case TO_ENDTOOLBAR:
quit = true;
break;
}
-void ToolbarBackend::readToolbars(LyXLex & lex)
+void ToolbarBackend::readToolbars(Lexer & lex)
{
enum tooltags {
TO_TOOLBAR = 1,
TO_ENDTOOLBARSET,
TO_LAST
};
-
+
struct keyword_item toolTags[TO_LAST - 1] = {
{ "end", TO_ENDTOOLBARSET },
{ "toolbar", TO_TOOLBAR }
}
-void ToolbarBackend::readToolbarSettings(LyXLex & lex)
+void ToolbarBackend::readToolbarSettings(Lexer & lex)
{
//consistency check
if (compare_ascii_no_case(lex.getString(), "toolbars")) {
}
-ToolbarInfo const & ToolbarBackend::getToolbar(string const & name) const
+ToolbarInfo const * ToolbarBackend::getDefinedToolbarInfo(string const & name) const
{
- Toolbars::const_iterator cit = find_if(toolbars.begin(), toolbars.end(), ToolbarNamesEqual(name));
- if (cit == toolbars.end())
- lyxerr << "No toolbar named " << name << endl;
- BOOST_ASSERT(cit != toolbars.end());
- return (*cit);
+ Toolbars::const_iterator it = find_if(toolbars.begin(), toolbars.end(), ToolbarNamesEqual(name));
+ if (it == toolbars.end())
+ return 0;
+ return &(*it);
}
-ToolbarInfo & ToolbarBackend::getToolbar(string const & name)
+ToolbarInfo * ToolbarBackend::getUsedToolbarInfo(string const &name)
{
- Toolbars::iterator it = find_if(toolbars.begin(), toolbars.end(), ToolbarNamesEqual(name));
- if (it == toolbars.end())
- lyxerr << "No toolbar named " << name << endl;
- BOOST_ASSERT(it != toolbars.end());
- return (*it);
+ Toolbars::iterator it = find_if(usedtoolbars.begin(), usedtoolbars.end(), ToolbarNamesEqual(name));
+ if (it == usedtoolbars.end())
+ return 0;
+ return &(*it);
}
-
} // namespace lyx