X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FToolbarBackend.C;h=b12fed44df1b0f956d33e2acc45285935a02072b;hb=e7f4618bcce770369cf46335c2c7f0164b4b8857;hp=cebf1262bd759ea66a4f49474e7a2e95ab0c54df;hpb=44cd0fc9a1687cc63911c7f98d978594458e7813;p=lyx.git diff --git a/src/ToolbarBackend.C b/src/ToolbarBackend.C index cebf1262bd..b12fed44df 100644 --- a/src/ToolbarBackend.C +++ b/src/ToolbarBackend.C @@ -23,10 +23,13 @@ #include "frontends/controllers/ControlMath.h" -using lyx::support::compare_ascii_no_case; -using lyx::support::getVectorFromString; -using lyx::support::LibFileSearch; -using lyx::support::subst; + +namespace lyx { + +using support::compare_ascii_no_case; +using support::getVectorFromString; +using support::libFileSearch; +using support::subst; using std::endl; using std::make_pair; @@ -55,7 +58,7 @@ struct keyword_item toolTags[TO_LAST - 1] = { { "separator", TO_SEPARATOR } }; -} // end of anon namespace +} // namespace anon ToolbarBackend::ToolbarBackend() @@ -75,6 +78,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; @@ -87,7 +97,7 @@ void ToolbarBackend::read(LyXLex & lex) switch (lex.lex()) { case TO_ADD: if (lex.next(true)) { - string const tooltip = _(lex.getString()); + docstring const tooltip = translateIfPossible(lex.getDocString()); lex.next(true); string const func_arg = lex.getString(); lyxerr[Debug::PARSER] @@ -176,6 +186,8 @@ void ToolbarBackend::readToolbars(LyXLex & lex) flag = MATH; else if (!compare_ascii_no_case(*cit, "table")) flag = TABLE; + else if (!compare_ascii_no_case(*cit, "review")) + flag = REVIEW; else if (!compare_ascii_no_case(*cit, "top")) flag = TOP; else if (!compare_ascii_no_case(*cit, "bottom")) @@ -197,33 +209,40 @@ void ToolbarBackend::readToolbars(LyXLex & lex) void ToolbarBackend::add(Toolbar & tb, - FuncRequest const & func, string const & tooltip) + FuncRequest const & func, docstring const & tooltip) { tb.items.push_back(make_pair(func, tooltip)); + tb.items.back().first.origin = FuncRequest::TOOLBAR; } string const ToolbarBackend::getIcon(FuncRequest const & f) { + using frontend::find_xpm; + string fullname; - if (f.action == LFUN_INSERT_MATH) { - if (!f.argument.empty()) - fullname = find_xpm(f.argument.substr(1)); - } else if (f.action == LFUN_MATH_DELIM) { - fullname = find_xpm(f.argument); - } else { + switch (f.action) { + case LFUN_MATH_INSERT: + if (!f.argument().empty()) + fullname = find_xpm(to_utf8(f.argument()).substr(1)); + break; + case LFUN_MATH_DELIM: + case LFUN_MATH_BIGDELIM: + fullname = find_xpm(to_utf8(f.argument())); + break; + default: string const name = lyxaction.getActionName(f.action); string xpm_name(name); - if (!f.argument.empty()) - xpm_name = subst(name + ' ' + f.argument, ' ', '_'); + if (!f.argument().empty()) + xpm_name = subst(name + ' ' + to_utf8(f.argument()), ' ', '_'); - fullname = LibFileSearch("images", xpm_name, "xpm"); + fullname = libFileSearch("images", xpm_name, "xpm").absFilename(); if (fullname.empty()) { // try without the argument - fullname = LibFileSearch("images", name, "xpm"); + fullname = libFileSearch("images", name, "xpm").absFilename(); } } @@ -235,6 +254,9 @@ string const ToolbarBackend::getIcon(FuncRequest const & f) lyxerr[Debug::GUI] << "Cannot find icon for command \"" << lyxaction.getActionName(f.action) - << '(' << f.argument << ")\"" << endl; - return LibFileSearch("images", "unknown", "xpm"); + << '(' << to_utf8(f.argument()) << ")\"" << endl; + return libFileSearch("images", "unknown", "xpm").absFilename(); } + + +} // namespace lyx