Jean-Marc Lasgouttes wrote:
>>>>>> "Angus" == Angus Leeming <[EMAIL PROTECTED]>
>>>>>> writes:
>
> Angus> However, I wonder if it would not be nicer to have:
> [a getLFUN method]
Yes.
> Agreed. Also, I'd rather have a signature like
> virtual FuncStatus getStatus() const;
> since it is more in line with what LyXFunc does.
Yes, but we need only the boolean value here. Things like
virtual bool getStatus() const { return true; }
in ControlChanges.h would become more complicated, and we would need to
include FuncStatus.h in Dialog.h. Therefore I want to keep the current
signature.
I am going to apply the attached patch unless you insist on the FuncStatus
version.
Georg
Index: src/frontends/controllers/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ChangeLog,v
retrieving revision 1.473
diff -u -p -r1.473 ChangeLog
--- src/frontends/controllers/ChangeLog 19 Apr 2005 08:56:15 -0000 1.473
+++ src/frontends/controllers/ChangeLog 25 Apr 2005 15:50:20 -0000
@@ -1,3 +1,12 @@
+2005-04-25 Georg Baum <[EMAIL PROTECTED]>
+
+ * Dialog.h, ControlCharacter.h, ControlPrint.h, ControlSendto.h,
+ ControlTabular.h, ControlTabularCreate.h (getLfun): new, return the
+ lfun for applying the data
+ * Control*.C (dispatchParams): use getLfun where appropriate
+ * Dialog.[Ch], ControlChanges.h, ControlDocument.h (getStatus): new,
+ check wether the dialog data may be applied
+
2005-04-11 Jean-Marc Lasgouttes <[EMAIL PROTECTED]>
* ControlDocument.C (dispatchParams): update the counters if
Index: src/frontends/controllers/ControlBox.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlBox.C,v
retrieving revision 1.3
diff -u -p -r1.3 ControlBox.C
--- src/frontends/controllers/ControlBox.C 19 May 2004 15:11:30 -0000 1.3
+++ src/frontends/controllers/ControlBox.C 25 Apr 2005 15:50:20 -0000
@@ -47,7 +47,7 @@ void ControlBox::clearParams()
void ControlBox::dispatchParams()
{
string const lfun = InsetBoxMailer::params2string(params());
- kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
+ kernel().dispatch(FuncRequest(getLfun(), lfun));
}
Index: src/frontends/controllers/ControlBranch.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlBranch.C,v
retrieving revision 1.8
diff -u -p -r1.8 ControlBranch.C
--- src/frontends/controllers/ControlBranch.C 19 May 2004 15:11:30 -0000 1.8
+++ src/frontends/controllers/ControlBranch.C 25 Apr 2005 15:50:20 -0000
@@ -49,7 +49,7 @@ void ControlBranch::clearParams()
void ControlBranch::dispatchParams()
{
string const lfun = InsetBranchMailer::params2string(params());
- kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
+ kernel().dispatch(FuncRequest(getLfun(), lfun));
}
Index: src/frontends/controllers/ControlChanges.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlChanges.h,v
retrieving revision 1.10
diff -u -p -r1.10 ControlChanges.h
--- src/frontends/controllers/ControlChanges.h 11 Oct 2004 14:29:14 -0000 1.10
+++ src/frontends/controllers/ControlChanges.h 25 Apr 2005 15:50:20 -0000
@@ -32,6 +32,8 @@ public:
virtual void dispatchParams() {}
///
virtual bool isBufferDependent() const { return true; }
+ /// always true since dispatchParams() is empty
+ virtual bool getStatus() const { return true; }
/// find the next merge chunk and highlight it
bool find();
Index: src/frontends/controllers/ControlCharacter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlCharacter.C,v
retrieving revision 1.50
diff -u -p -r1.50 ControlCharacter.C
--- src/frontends/controllers/ControlCharacter.C 5 Oct 2004 10:11:39 -0000 1.50
+++ src/frontends/controllers/ControlCharacter.C 25 Apr 2005 15:50:20 -0000
@@ -65,7 +65,7 @@ void ControlCharacter::dispatchParams()
string data;
if (font2string(*font_.get(), toggleall_, data)) {
- kernel().dispatch(FuncRequest(LFUN_FREEFONT_UPDATE, data));
+ kernel().dispatch(FuncRequest(getLfun(), data));
}
}
Index: src/frontends/controllers/ControlCharacter.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlCharacter.h,v
retrieving revision 1.20
diff -u -p -r1.20 ControlCharacter.h
--- src/frontends/controllers/ControlCharacter.h 19 May 2004 15:11:30 -0000 1.20
+++ src/frontends/controllers/ControlCharacter.h 25 Apr 2005 15:50:20 -0000
@@ -34,6 +34,8 @@ public:
virtual void dispatchParams();
///
virtual bool isBufferDependent() const { return true; }
+ ///
+ virtual kb_action getLfun() const { return LFUN_TABULAR_INSERT; }
///
void setFamily(LyXFont::FONT_FAMILY);
Index: src/frontends/controllers/ControlCommand.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlCommand.C,v
retrieving revision 1.35
diff -u -p -r1.35 ControlCommand.C
--- src/frontends/controllers/ControlCommand.C 19 May 2004 15:11:30 -0000 1.35
+++ src/frontends/controllers/ControlCommand.C 25 Apr 2005 15:50:20 -0000
@@ -49,7 +49,7 @@ void ControlCommand::dispatchParams()
string const lfun = InsetCommandMailer::params2string(lfun_name_,
params_);
- kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
+ kernel().dispatch(FuncRequest(getLfun(), lfun));
}
} // namespace frontend
Index: src/frontends/controllers/ControlDocument.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlDocument.h,v
retrieving revision 1.14
diff -u -p -r1.14 ControlDocument.h
--- src/frontends/controllers/ControlDocument.h 19 May 2004 15:11:30 -0000 1.14
+++ src/frontends/controllers/ControlDocument.h 25 Apr 2005 15:50:20 -0000
@@ -38,6 +38,8 @@ public:
virtual void dispatchParams();
///
virtual bool isBufferDependent() const { return true; }
+ /// always true since we don't manipulate document contents
+ virtual bool getStatus() const { return true; }
///
LyXTextClass const & textClass() const;
///
Index: src/frontends/controllers/ControlERT.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlERT.C,v
retrieving revision 1.20
diff -u -p -r1.20 ControlERT.C
--- src/frontends/controllers/ControlERT.C 19 May 2004 15:11:30 -0000 1.20
+++ src/frontends/controllers/ControlERT.C 25 Apr 2005 15:50:20 -0000
@@ -41,7 +41,7 @@ void ControlERT::clearParams()
void ControlERT::dispatchParams()
{
string const lfun = InsetERTMailer::params2string(status_);
- kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
+ kernel().dispatch(FuncRequest(getLfun(), lfun));
}
} // namespace frontend
Index: src/frontends/controllers/ControlExternal.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlExternal.C,v
retrieving revision 1.59
diff -u -p -r1.59 ControlExternal.C
--- src/frontends/controllers/ControlExternal.C 6 Jan 2005 16:39:33 -0000 1.59
+++ src/frontends/controllers/ControlExternal.C 25 Apr 2005 15:50:20 -0000
@@ -69,7 +69,7 @@ void ControlExternal::dispatchParams()
string const lfun = InsetExternalMailer::params2string(params(),
kernel().buffer());
- kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
+ kernel().dispatch(FuncRequest(getLfun(), lfun));
}
Index: src/frontends/controllers/ControlFloat.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlFloat.C,v
retrieving revision 1.22
diff -u -p -r1.22 ControlFloat.C
--- src/frontends/controllers/ControlFloat.C 19 May 2004 15:11:30 -0000 1.22
+++ src/frontends/controllers/ControlFloat.C 25 Apr 2005 15:50:20 -0000
@@ -43,7 +43,7 @@ void ControlFloat::clearParams()
void ControlFloat::dispatchParams()
{
string const lfun = InsetFloatMailer::params2string(params());
- kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
+ kernel().dispatch(FuncRequest(getLfun(), lfun));
}
} // namespace frontend
Index: src/frontends/controllers/ControlGraphics.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlGraphics.C,v
retrieving revision 1.89
diff -u -p -r1.89 ControlGraphics.C
--- src/frontends/controllers/ControlGraphics.C 31 Jan 2005 10:42:22 -0000 1.89
+++ src/frontends/controllers/ControlGraphics.C 25 Apr 2005 15:50:20 -0000
@@ -77,7 +77,7 @@ void ControlGraphics::dispatchParams()
InsetGraphicsParams tmp_params(params());
string const lfun =
InsetGraphicsMailer::params2string(tmp_params, kernel().buffer());
- kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
+ kernel().dispatch(FuncRequest(getLfun(), lfun));
}
Index: src/frontends/controllers/ControlInclude.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlInclude.C,v
retrieving revision 1.49
diff -u -p -r1.49 ControlInclude.C
--- src/frontends/controllers/ControlInclude.C 25 Nov 2004 11:08:30 -0000 1.49
+++ src/frontends/controllers/ControlInclude.C 25 Apr 2005 15:50:20 -0000
@@ -62,7 +63,7 @@ void ControlInclude::clearParams()
void ControlInclude::dispatchParams()
{
string const lfun = InsetIncludeMailer::params2string(params_);
- kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
+ kernel().dispatch(FuncRequest(getLfun(), lfun));
}
Index: src/frontends/controllers/ControlNote.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlNote.C,v
retrieving revision 1.9
diff -u -p -r1.9 ControlNote.C
--- src/frontends/controllers/ControlNote.C 19 May 2004 15:11:30 -0000 1.9
+++ src/frontends/controllers/ControlNote.C 25 Apr 2005 15:50:20 -0000
@@ -44,7 +44,7 @@ void ControlNote::clearParams()
void ControlNote::dispatchParams()
{
string const lfun = InsetNoteMailer::params2string(params());
- kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
+ kernel().dispatch(FuncRequest(getLfun(), lfun));
}
} // namespace frontend
Index: src/frontends/controllers/ControlPrint.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlPrint.C,v
retrieving revision 1.52
diff -u -p -r1.52 ControlPrint.C
--- src/frontends/controllers/ControlPrint.C 6 Jan 2005 16:39:33 -0000 1.52
+++ src/frontends/controllers/ControlPrint.C 25 Apr 2005 15:50:20 -0000
@@ -139,7 +139,7 @@ void ControlPrint::dispatchParams()
pp.file_name;
string const data = target + " " + target_name + " " + command;
- kernel().dispatch(FuncRequest(LFUN_PRINT, data));
+ kernel().dispatch(FuncRequest(getLfun(), data));
}
} // namespace frontend
Index: src/frontends/controllers/ControlPrint.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlPrint.h,v
retrieving revision 1.16
diff -u -p -r1.16 ControlPrint.h
--- src/frontends/controllers/ControlPrint.h 19 May 2004 15:11:30 -0000 1.16
+++ src/frontends/controllers/ControlPrint.h 25 Apr 2005 15:50:20 -0000
@@ -35,6 +35,8 @@ public:
virtual void dispatchParams();
///
virtual bool isBufferDependent() const { return true; }
+ ///
+ virtual kb_action getLfun() const { return LFUN_PRINT; }
/// Browse for a file
std::string const browse(std::string const &) const;
Index: src/frontends/controllers/ControlSendto.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlSendto.C,v
retrieving revision 1.26
diff -u -p -r1.26 ControlSendto.C
--- src/frontends/controllers/ControlSendto.C 19 May 2004 15:11:30 -0000 1.26
+++ src/frontends/controllers/ControlSendto.C 25 Apr 2005 15:50:21 -0000
@@ -11,6 +11,7 @@
#include <config.h>
#include "ControlSendto.h"
+
#include "buffer.h"
#include "converter.h"
#include "format.h"
@@ -50,7 +51,7 @@ void ControlSendto::dispatchParams()
return;
string const data = format_->name() + " " + command_;
- kernel().dispatch(FuncRequest(LFUN_EXPORT_CUSTOM, data));
+ kernel().dispatch(FuncRequest(getLfun(), data));
}
Index: src/frontends/controllers/ControlSendto.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlSendto.h,v
retrieving revision 1.12
diff -u -p -r1.12 ControlSendto.h
--- src/frontends/controllers/ControlSendto.h 19 May 2004 15:11:30 -0000 1.12
+++ src/frontends/controllers/ControlSendto.h 25 Apr 2005 15:50:21 -0000
@@ -34,6 +34,8 @@ public:
virtual void dispatchParams();
///
virtual bool isBufferDependent() const { return true; }
+ ///
+ virtual kb_action getLfun() const { return LFUN_EXPORT_CUSTOM; }
/// Return a vector of those formats that can be exported from "lyx".
std::vector<Format const *> const allFormats() const;
Index: src/frontends/controllers/ControlTabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlTabular.C,v
retrieving revision 1.23
diff -u -p -r1.23 ControlTabular.C
--- src/frontends/controllers/ControlTabular.C 8 Feb 2005 13:18:03 -0000 1.23
+++ src/frontends/controllers/ControlTabular.C 25 Apr 2005 15:50:21 -0000
@@ -73,7 +73,7 @@ LyXTabular const & ControlTabular::tabul
void ControlTabular::set(LyXTabular::Feature f, string const & arg)
{
string const data = featureAsString(f) + ' ' + arg;
- kernel().dispatch(FuncRequest(LFUN_TABULAR_FEATURE, data));
+ kernel().dispatch(FuncRequest(getLfun(), data));
}
Index: src/frontends/controllers/ControlTabular.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlTabular.h,v
retrieving revision 1.12
diff -u -p -r1.12 ControlTabular.h
--- src/frontends/controllers/ControlTabular.h 3 Dec 2004 13:57:48 -0000 1.12
+++ src/frontends/controllers/ControlTabular.h 25 Apr 2005 15:50:21 -0000
@@ -34,6 +34,8 @@ public:
virtual void dispatchParams() {};
///
virtual bool isBufferDependent() const { return true; }
+ ///
+ virtual kb_action getLfun() const { return LFUN_TABULAR_FEATURE; }
///
LyXTabular::idx_type getActiveCell() const;
Index: src/frontends/controllers/ControlTabularCreate.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlTabularCreate.C,v
retrieving revision 1.26
diff -u -p -r1.26 ControlTabularCreate.C
--- src/frontends/controllers/ControlTabularCreate.C 6 Jan 2005 16:39:33 -0000 1.26
+++ src/frontends/controllers/ControlTabularCreate.C 25 Apr 2005 15:50:21 -0000
@@ -44,7 +45,7 @@ void ControlTabularCreate::clearParams()
void ControlTabularCreate::dispatchParams()
{
string const data = convert<string>(params().first) + ' ' + convert<string>(params().second);
- kernel().dispatch(FuncRequest(LFUN_TABULAR_INSERT, data));
+ kernel().dispatch(FuncRequest(getLfun(), data));
}
} // namespace frontend
Index: src/frontends/controllers/ControlTabularCreate.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlTabularCreate.h,v
retrieving revision 1.16
diff -u -p -r1.16 ControlTabularCreate.h
--- src/frontends/controllers/ControlTabularCreate.h 3 Dec 2004 13:57:48 -0000 1.16
+++ src/frontends/controllers/ControlTabularCreate.h 25 Apr 2005 15:50:21 -0000
@@ -32,6 +32,8 @@ public:
virtual void dispatchParams();
///
virtual bool isBufferDependent() const { return true; }
+ ///
+ virtual kb_action getLfun() const { return LFUN_TABULAR_INSERT; }
///
typedef std::pair<size_t, size_t> rowsCols;
Index: src/frontends/controllers/ControlVSpace.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlVSpace.C,v
retrieving revision 1.3
diff -u -p -r1.3 ControlVSpace.C
--- src/frontends/controllers/ControlVSpace.C 19 May 2004 15:11:31 -0000 1.3
+++ src/frontends/controllers/ControlVSpace.C 25 Apr 2005 15:50:21 -0000
@@ -49,7 +49,7 @@ void ControlVSpace::clearParams()
void ControlVSpace::dispatchParams()
{
string const str = InsetVSpaceMailer::params2string(params_);
- kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, str));
+ kernel().dispatch(FuncRequest(getLfun(), str));
}
Index: src/frontends/controllers/ControlWrap.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlWrap.C,v
retrieving revision 1.10
diff -u -p -r1.10 ControlWrap.C
--- src/frontends/controllers/ControlWrap.C 19 May 2004 15:11:31 -0000 1.10
+++ src/frontends/controllers/ControlWrap.C 25 Apr 2005 15:50:21 -0000
@@ -43,7 +43,7 @@ void ControlWrap::clearParams()
void ControlWrap::dispatchParams()
{
string const lfun = InsetWrapMailer::params2string(params());
- kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
+ kernel().dispatch(FuncRequest(getLfun(), lfun));
}
} // namespace frontend
Index: src/frontends/controllers/Dialog.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/Dialog.C,v
retrieving revision 1.17
diff -u -p -r1.17 Dialog.C
--- src/frontends/controllers/Dialog.C 13 Apr 2005 09:43:58 -0000 1.17
+++ src/frontends/controllers/Dialog.C 25 Apr 2005 15:50:21 -0000
@@ -175,9 +175,19 @@ void Dialog::setView(View * v)
void Dialog::checkStatus()
{
- FuncRequest const fr(LFUN_INSET_APPLY, name());
- FuncStatus const fs(kernel().lyxview().getLyXFunc().getStatus(fr));
- if (fs.enabled())
+ // buffer independant dialogs are always active.
+ // This check allows us leave getStatus unimplemented for some dialogs.
+ if (!controller().isBufferDependent())
+ return;
+
+ // deactivate the dialog if we have no buffer
+ if (!kernel().isBufferAvailable()) {
+ bc().readOnly(true);
+ return;
+ }
+
+ // check wether this dialog may be active
+ if (controller().getStatus())
bc().readOnly(kernel().isBufferReadonly());
else
bc().readOnly(true);
@@ -187,6 +197,14 @@ void Dialog::checkStatus()
Dialog::Controller::Controller(Dialog & parent)
: parent_(parent)
{}
+
+
+bool Dialog::Controller::getStatus() const
+{
+ FuncRequest const fr(getLfun(), dialog().name());
+ FuncStatus const fs(kernel().lyxview().getLyXFunc().getStatus(fr));
+ return fs.enabled();
+}
Dialog::Controller & Dialog::controller() const
Index: src/frontends/controllers/Dialog.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/Dialog.h,v
retrieving revision 1.14
diff -u -p -r1.14 Dialog.h
--- src/frontends/controllers/Dialog.h 13 Apr 2005 09:43:58 -0000 1.14
+++ src/frontends/controllers/Dialog.h 25 Apr 2005 15:50:21 -0000
@@ -13,6 +13,7 @@
#define DIALOG_H
#include "Kernel.h"
+#include "lfuns.h"
#include <boost/utility.hpp>
#include <boost/scoped_ptr.hpp>
@@ -157,6 +158,25 @@ public:
* a buffer is open.
*/
virtual bool isBufferDependent() const = 0;
+
+ /** The lfun that is sent for applying the data.
+ *
+ * This method is used by the default implementation of getStatus()
+ * for buffer dependant dialogs that send one lfun when applying the
+ * data.
+ * It should be used in dispatchParams(), too for consistency reasons.
+ * \returns the lfun that is sent for applying the data.
+ */
+ virtual kb_action getLfun() const { return LFUN_INSET_APPLY; }
+
+ /** Check wether we may apply our data.
+ *
+ * The default implementation works for all dialogs that send one
+ * lfun when applying the data. Dialogs that send none or more than
+ * one lfun need to reimplement it.
+ * \returns wether the data can be applied or not.
+ */
+ virtual bool getStatus() const;
/** \return true if the kernel should disconnect the dialog from
* a particular inset after the data has been applied to it.