* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
- * \author unknown
+ * \author Jean-Marc Lasgouttes
+ * \author John Levon
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
#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"
#include "frontends/controllers/ControlMath.h"
-#include <vector>
-
-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;
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:
}
-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));
-}
-
-
-void ToolbarBackend::add(Toolbar & tb, string const & func, string const & tooltip)
-{
- int const tf = lyxaction.LookupFunc(func);
-
- if (tf == -1) {
- lyxerr << "ToolbarBackend::add: no LyX command called `"
- << func << "' exists!" << endl;
- } else {
- add(tb, tf, tooltip);
- }
+ tb.items.push_back(make_pair(func, tooltip));
}
-string const ToolbarBackend::getIcon(int action)
+string const ToolbarBackend::getIcon(FuncRequest const & f)
{
string fullname;
- FuncRequest f = lyxaction.retrieveActionArg(action);
if (f.action == LFUN_INSERT_MATH) {
if (!f.argument.empty())
lyxerr[Debug::GUI] << "Cannot find icon for command \""
<< lyxaction.getActionName(f.action)
- << ' ' << f.argument << '"' << endl;
+ << '(' << f.argument << ")\"" << endl;
return LibFileSearch("images", "unknown", "xpm");
}