2 * \file ToolbarBackend.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
13 #include "ToolbarBackend.h"
14 #include "LyXAction.h"
20 #include "support/lstrings.h"
21 #include "support/filetools.h"
23 #include "frontends/controllers/ControlMath.h"
27 ToolbarBackend toolbarbackend;
41 struct keyword_item toolTags[TO_LAST - 1] = {
42 { "end", TO_ENDTOOLBAR },
44 { "layouts", TO_LAYOUTS },
45 { "newline", TO_NEWLINE },
46 { "separator", TO_SEPARATOR }
49 } // end of anon namespace
52 ToolbarBackend::ToolbarBackend()
57 void ToolbarBackend::add(int action, string const & tooltip)
59 items.push_back(make_pair(action, tooltip));
63 void ToolbarBackend::read(LyXLex & lex)
66 if (compare_ascii_no_case(lex.getString(), "toolbar")) {
67 lyxerr << "ToolbarBackend::read: ERROR wrong token:`"
68 << lex.getString() << '\'' << endl;
73 lex.pushTable(toolTags, TO_LAST - 1);
75 if (lyxerr.debugging(Debug::PARSER))
76 lex.printTable(lyxerr);
78 while (lex.isOK() && !quit) {
82 string const tooltip = _(lex.getString());
84 string const func = lex.getString();
86 << "ToolbarBackend::read TO_ADD func: `"
87 << func << '\'' << endl;
108 lex.printError("ToolbarBackend::read: "
109 "Unknown toolbar tag: `$$Token'");
117 void ToolbarBackend::add(string const & func, string const & tooltip)
119 int const tf = lyxaction.LookupFunc(func);
122 lyxerr << "ToolbarBackend::add: no LyX command called `"
123 << func << "' exists!" << endl;
130 string const ToolbarBackend::getIcon(int action)
133 FuncRequest f = lyxaction.retrieveActionArg(action);
135 if (f.action == LFUN_INSERT_MATH && !f.argument.empty()) {
136 fullname = find_xpm(f.argument.substr(1));
138 string const name = lyxaction.getActionName(f.action);
139 string xpm_name(name);
141 if (!f.argument.empty())
142 xpm_name = subst(name + ' ' + f.argument, ' ', '_');
144 fullname = LibFileSearch("images", xpm_name, "xpm");
146 if (fullname.empty()) {
147 // try without the argument
148 fullname = LibFileSearch("images", name, "xpm");
152 if (!fullname.empty()) {
153 lyxerr[Debug::GUI] << "Full icon name is `"
154 << fullname << '\'' << endl;
158 return LibFileSearch("images", "unknown", "xpm");