virtual bool searchMenu(FuncRequest const & func,
docstring_list & names) const = 0;
+ virtual bool hasBufferView() const = 0;
+
/// \return the icon file name for the given action.
static docstring iconName(FuncRequest const & f, bool unknown);
/// \return the math icon name for the given command.
bool GuiApplication::searchMenu(FuncRequest const & func,
docstring_list & names) const
{
- return d->menus_.searchMenu(func, names);
+ BufferView * bv = 0;
+ if (current_view_)
+ bv = current_view_->currentBufferView();
+ return d->menus_.searchMenu(func, names, bv);
+}
+
+
+bool GuiApplication::hasBufferView() const
+{
+ return (current_view_ && current_view_->currentBufferView());
}
void registerSocketCallback(int fd, SocketCallback func);
void unregisterSocketCallback(int fd);
bool searchMenu(FuncRequest const & func, docstring_list & names) const;
+ bool hasBufferView() const;
void handleKeyFunc(FuncCode action);
bool unhide(Buffer * buf); //override
//@}
docstring lbl = (kind == MenuItem::ViewFormats
? bformat(_("View [%1$s]|V"), label)
: bformat(_("Update [%1$s]|U"), label));
- add(MenuItem(MenuItem::Command, toqstr(lbl), FuncRequest(action)));
+ add(MenuItem(MenuItem::Command, toqstr(lbl), FuncRequest(action, f->name())));
continue;
}
break;
bool Menus::searchMenu(FuncRequest const & func,
- docstring_list & names) const
+ docstring_list & names, BufferView const * bv) const
{
MenuDefinition menu;
- d->expand(d->menubar_, menu, 0);
+ d->expand(d->menubar_, menu, bv);
return menu.searchMenu(func, names);
}
#define MENUS_H
#include <QMenu>
+#include "BufferView.h"
class QString;
class QMenuBar;
///
bool searchMenu(FuncRequest const & func,
- docstring_list & names) const;
+ docstring_list & names, BufferView const * bv = 0) const;
///
void fillMenuBar(QMenuBar * qmb, GuiView * view, bool initial = false);
// only need to do this once.
if (initialized_)
break;
- // and we will not keep trying if we fail
- initialized_ = true;
docstring_list names;
FuncRequest const func = lyxaction.lookupFunc(params_.name);
if (func.action() == LFUN_UNKNOWN_ACTION) {
if (!theApp()) {
gui = _("Can't determine menu entry for action %1$s in batch mode");
error(from_ascii("Can't determine menu entry for action %1$s in batch mode"), params_.lang);
+ initialized_ = true;
break;
}
+ // and we will not keep trying if we fail
+ initialized_ = theApp()->hasBufferView();
if (!theApp()->searchMenu(func, names)) {
gui = _("No menu entry for action %1$s");
error(from_ascii("No menu entry for action %1$s"), params_.lang);