#include "ButtonController.h"
#include "BCView.h"
+#include "frontends/LyXView.h"
+
+#include "funcrequest.h"
+#include "FuncStatus.h"
+#include "lyxfunc.h"
+
+
+using std::string;
+
+namespace lyx {
+namespace frontend {
Dialog::Dialog(LyXView & lv, string const & name)
: is_closing_(false), kernel_(lv), name_(name),
if (!controller().initialiseParams(data)) {
lyxerr << "Dialog \"" << name_
- << "\" failed to translate the data "
- "string passed to update()" << std::endl;
+ << "\" could not be initialized" << std::endl;
return;
}
controller().clearParams();
view().hide();
+ kernel().disconnect(name());
}
void Dialog::apply()
{
- if (kernel().isBufferReadonly())
- return;
+ if (controller().isBufferDependent()) {
+ if (!kernel().isBufferAvailable() ||
+ kernel().isBufferReadonly())
+ return;
+ }
view().apply();
controller().dispatchParams();
}
+void Dialog::checkStatus()
+{
+ // buffer independant dialogs are always active.
+ // This check allows us leave canApply unimplemented for some dialogs.
+ if (!controller().isBufferDependent())
+ return;
+
+ // deactivate the dialog if we have no buffer
+ if (!kernel().isBufferAvailable()) {
+ bc().readOnly(true);
+ return;
+ }
+
+ // check whether this dialog may be active
+ if (controller().canApply())
+ bc().readOnly(kernel().isBufferReadonly());
+ else
+ bc().readOnly(true);
+}
+
+
Dialog::Controller::Controller(Dialog & parent)
: parent_(parent)
{}
+bool Dialog::Controller::canApply() const
+{
+ FuncRequest const fr(getLfun(), dialog().name());
+ FuncStatus const fs(kernel().lyxview().getLyXFunc().getStatus(fr));
+ return fs.enabled();
+}
+
+
Dialog::Controller & Dialog::controller() const
{
BOOST_ASSERT(controller_ptr_.get());
void Dialog::View::partialUpdate(int)
{}
+
+} // namespace frontend
+} // namespace lyx