#include "BufferView.h"
#include "dispatchresult.h"
#include "funcrequest.h"
+#include "FuncStatus.h"
#include "lyxlex.h"
#include "metricsinfo.h"
string const & mailer_name)
: p_(p.getCmdName(), p.getContents(), p.getOptions(), p.getSecOptions()),
mailer_name_(mailer_name),
- set_label_(false)
+ updateButtonLabel_(true)
{}
void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
{
- if (!set_label_) {
- set_label_ = true;
+ if (updateButtonLabel_) {
+ updateButtonLabel_ = false;
button_.update(getScreenLabel(*mi.base.bv->buffer()),
editable() != NOT_EDITABLE);
}
void InsetCommand::setParams(InsetCommandParams const & p)
{
p_ = p;
- set_label_ = false;
+ updateButtonLabel_ = true;
}
{
switch (cmd.action) {
case LFUN_INSET_REFRESH:
- set_label_ = false;
+ updateButtonLabel_ = true;
break;
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
InsetCommandMailer::string2params(mailer_name_, cmd.argument, p);
- if (p.getCmdName().empty()) {
- cur.undispatched();
- } else {
+ if (p.getCmdName().empty())
+ cur.noUpdate();
+ else
setParams(p);
- cur.bv().update();
- }
break;
}
}
+bool InsetCommand::getStatus(LCursor & cur, FuncRequest const & cmd,
+ FuncStatus & status) const
+{
+ switch (cmd.action) {
+ // suppress these
+ case LFUN_INSET_ERT:
+ status.enabled(false);
+ return true;
+ // we handle these
+ case LFUN_INSET_REFRESH:
+ case LFUN_INSET_MODIFY:
+ case LFUN_INSET_DIALOG_UPDATE:
+ case LFUN_INSET_DIALOG_SHOW:
+ status.enabled(true);
+ return true;
+ default:
+ return InsetBase::getStatus(cur, cmd, status);
+ }
+}
+
+
InsetCommandMailer::InsetCommandMailer(string const & name,
InsetCommand & inset)
: name_(name), inset_(inset)