The labels to the InsetCommand insets are generated in ::metrics and
are regenerated after the contents of the inset have changed:
void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
{
if (!set_label_) {
set_label_ = true;
button_.update(getScreenLabel(*mi.base.bv->buffer()),
editable() != NOT_EDITABLE);
}
button_.metrics(mi, dim);
dim_ = dim;
}
void InsetCommand::setParams(InsetCommandParams const & p)
{
p_ = p;
set_label_ = false;
}
That's fine but, in the case of the citation inset at least, the
displayed label depends also on the state of the BufferParams which
can be altered from the Document dialog.
The patch, attached, defines a new LFUN_INSET_BUTTONLABEL that is used
to force the label to be refreshed. It works perfectly, so is this Ok
to go in or can anyone think of a better way to reach the same goal?
--
Angus
Index: src/LyXAction.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v
retrieving revision 1.199
diff -u -p -r1.199 LyXAction.C
--- src/LyXAction.C 13 Apr 2004 10:36:04 -0000 1.199
+++ src/LyXAction.C 14 May 2004 16:18:00 -0000
@@ -336,6 +336,7 @@ void LyXAction::init()
{ LFUN_SAVE_AS_DEFAULT, "buffer-save-as-default", Noop },
{ LFUN_BUFFERPARAMS_APPLY, "buffer-params-apply", Noop },
{ LFUN_LYXRC_APPLY, "lyxrc-apply", NoBuffer },
+ { LFUN_INSET_BUTTONLABEL, "", Noop },
{ LFUN_NOACTION, "", Noop }
};
Index: src/lfuns.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lfuns.h,v
retrieving revision 1.35
diff -u -p -r1.35 lfuns.h
--- src/lfuns.h 13 Apr 2004 10:36:04 -0000 1.35
+++ src/lfuns.h 14 May 2004 16:18:01 -0000
@@ -349,6 +349,7 @@ enum kb_action {
// 265
LFUN_LYXRC_APPLY,
LFUN_GRAPHICS_EDIT,
+ LFUN_INSET_BUTTONLABEL,
LFUN_LASTACTION // end of the table
};
Index: src/lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.617
diff -u -p -r1.617 lyxfunc.C
--- src/lyxfunc.C 4 May 2004 14:12:50 -0000 1.617
+++ src/lyxfunc.C 14 May 2004 16:18:02 -0000
@@ -1313,6 +1313,9 @@ void LyXFunc::dispatch(FuncRequest const
}
case LFUN_BUFFERPARAMS_APPLY: {
+ biblio::CiteEngine const engine =
+ owner->buffer()->params().cite_engine;
+
istringstream ss(argument);
LyXLex lex(0,0);
lex.setStream(ss);
@@ -1325,6 +1328,18 @@ void LyXFunc::dispatch(FuncRequest const
<< (unknown_tokens == 1 ? "" : "s")
<< endl;
}
+ if (engine == owner->buffer()->params().cite_engine)
+ break;
+
+ LCursor & cur = view()->cursor();
+ FuncRequest fr(LFUN_INSET_BUTTONLABEL);
+
+ InsetBase & inset = owner->buffer()->inset();
+ InsetIterator it = inset_iterator_begin(inset);
+ InsetIterator const end = inset_iterator_end(inset);
+ for (; it != end; ++it)
+ if (it->lyxCode() == InsetBase::CITE_CODE)
+ it->dispatch(cur, fr);
break;
}
Index: src/insets/insetcommand.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcommand.C,v
retrieving revision 1.112
diff -u -p -r1.112 insetcommand.C
--- src/insets/insetcommand.C 3 Apr 2004 08:37:10 -0000 1.112
+++ src/insets/insetcommand.C 14 May 2004 16:18:04 -0000
@@ -101,6 +101,10 @@ int InsetCommand::docbook(Buffer const &
void InsetCommand::priv_dispatch(LCursor & cur, FuncRequest & cmd)
{
switch (cmd.action) {
+ case LFUN_INSET_BUTTONLABEL:
+ set_label_ = false;
+ break;
+
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
InsetCommandMailer::string2params(mailer_name_, cmd.argument, p);