X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FToolbarBackend.C;h=baa2ddfbcdfaf57865410b8aaaf1f53a02978fb4;hb=d9e6e32961860821ecc047039ae6c1a9dcc6e35d;hp=099d9cafaf7af9dfd885e7432587759d99662571;hpb=0be0fcfd5907d448cd51addf83ed7032719a0692;p=lyx.git diff --git a/src/ToolbarBackend.C b/src/ToolbarBackend.C index 099d9cafaf..baa2ddfbcd 100644 --- a/src/ToolbarBackend.C +++ b/src/ToolbarBackend.C @@ -12,10 +12,10 @@ #include #include "ToolbarBackend.h" +#include "funcrequest.h" #include "LyXAction.h" #include "lyxlex.h" #include "debug.h" -#include "lyxlex.h" #include "gettext.h" #include "support/lstrings.h" @@ -23,13 +23,16 @@ #include "frontends/controllers/ControlMath.h" -#include - -using namespace lyx::support; +using lyx::support::compare_ascii_no_case; +using lyx::support::getVectorFromString; +using lyx::support::LibFileSearch; +using lyx::support::subst; using std::endl; -using std::vector; using std::make_pair; +using std::string; +using std::vector; + ToolbarBackend toolbarbackend; @@ -72,6 +75,13 @@ void ToolbarBackend::read(LyXLex & lex) Toolbar tb; tb.name = lex.getString(); + lex.next(true); + if (!lex.isOK()) { + lyxerr << "ToolbarBackend::read: Malformed toolbar " + "description " << lex.getString() << endl; + return; + } + tb.gui_name = lex.getString(); bool quit = false; @@ -86,24 +96,27 @@ void ToolbarBackend::read(LyXLex & lex) if (lex.next(true)) { string const tooltip = _(lex.getString()); lex.next(true); - string const func = lex.getString(); + string const func_arg = lex.getString(); lyxerr[Debug::PARSER] << "ToolbarBackend::read TO_ADD func: `" - << func << '\'' << endl; + << func_arg << '\'' << endl; + + FuncRequest func = + lyxaction.lookupFunc(func_arg); add(tb, func, tooltip); } break; case TO_MINIBUFFER: - add(tb, MINIBUFFER); + add(tb, FuncRequest(kb_action(MINIBUFFER))); break; case TO_SEPARATOR: - add(tb, SEPARATOR); + add(tb, FuncRequest(kb_action(SEPARATOR))); break; case TO_LAYOUTS: - add(tb, LAYOUTS); + add(tb, FuncRequest(kb_action(LAYOUTS))); break; case TO_ENDTOOLBAR: @@ -190,29 +203,19 @@ void ToolbarBackend::readToolbars(LyXLex & lex) } -void ToolbarBackend::add(Toolbar & tb, int action, string const & tooltip) +void ToolbarBackend::add(Toolbar & tb, + FuncRequest const & func, string const & tooltip) { - tb.items.push_back(make_pair(action, tooltip)); + tb.items.push_back(make_pair(func, tooltip)); + tb.items.back().first.origin = FuncRequest::UI; } -void ToolbarBackend::add(Toolbar & tb, string const & func, string const & tooltip) +string const ToolbarBackend::getIcon(FuncRequest const & f) { - int const tf = lyxaction.LookupFunc(func); + using lyx::frontend::find_xpm; - if (tf == -1) { - lyxerr << "ToolbarBackend::add: no LyX command called `" - << func << "' exists!" << endl; - } else { - add(tb, tf, tooltip); - } -} - - -string const ToolbarBackend::getIcon(int action) -{ string fullname; - FuncRequest f = lyxaction.retrieveActionArg(action); if (f.action == LFUN_INSERT_MATH) { if (!f.argument.empty()) @@ -242,6 +245,6 @@ string const ToolbarBackend::getIcon(int action) lyxerr[Debug::GUI] << "Cannot find icon for command \"" << lyxaction.getActionName(f.action) - << ' ' << f.argument << '"' << endl; + << '(' << f.argument << ")\"" << endl; return LibFileSearch("images", "unknown", "xpm"); }