+2004-04-05 Angus Leeming <leeming@lyx.org>
+
+ * LyXAction.C (init): set LFUN_DIALOG_UPDATE's atrib flag to NoBuffer.
+
+ * lyxfunc.C (getStatus): enable LFUN_DIALOG_UPDATE if no buffer is
+ present only for the preferences dialog.
+ (dispatch): handle LFUN_DIALOG_UPDATE for the preferences dialog.
+
2004-04-05 Angus Leeming <leeming@lyx.org>
* lyxrc.[Ch] (write): now takes a 'bool ignore_system_lyxrc' arg
{ LFUN_DIALOG_SHOW, "dialog-show", NoBuffer },
{ LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-new-inset", Noop },
{ LFUN_DIALOG_SHOW_NEXT_INSET, "dialog-show-next-inset", Noop },
- { LFUN_DIALOG_UPDATE, "dialog-update", Noop },
+ { LFUN_DIALOG_UPDATE, "dialog-update", NoBuffer },
{ LFUN_DIALOG_HIDE, "dialog-hide", Noop },
{ LFUN_DIALOG_DISCONNECT_INSET, "dialog-disconnect-inset", Noop },
{ LFUN_INSET_APPLY, "inset-apply", Noop },
#include "ButtonPolicies.h"
#include "debug.h"
+#include <string>
using std::endl;
+using std::string;
namespace {
+string const printState(ButtonPolicy::State const & state)
+{
+ string output;
+
+ switch(state) {
+ case ButtonPolicy::INITIAL:
+ output = "INITIAL";
+ break;
+ case ButtonPolicy::VALID:
+ output = "VALID";
+ break;
+ case ButtonPolicy::INVALID:
+ output = "INVALID";
+ break;
+ case ButtonPolicy::APPLIED:
+ output = "APPLIED";
+ break;
+ case ButtonPolicy::RO_INITIAL:
+ output = "RO_INITIAL";
+ break;
+ case ButtonPolicy::RO_VALID:
+ output = "RO_VALID";
+ break;
+ case ButtonPolicy::RO_INVALID:
+ output = "RO_INVALID";
+ break;
+ case ButtonPolicy::RO_APPLIED:
+ output = "RO_APPLIED";
+ break;
+ case ButtonPolicy::BOGUS:
+ output = "BOGUS";
+ break;
+ }
+
+ return output;
+}
+
+
+string const printInput(ButtonPolicy::SMInput const & input)
+{
+ string output;
+
+ switch (input) {
+ case ButtonPolicy::SMI_VALID:
+ output = "SMI_VALID";
+ break;
+ case ButtonPolicy::SMI_INVALID:
+ output = "SMI_INVALID";
+ break;
+ case ButtonPolicy::SMI_OKAY:
+ output = "SMI_OKAY";
+ break;
+ case ButtonPolicy::SMI_APPLY:
+ output = "SMI_APPLY";
+ break;
+ case ButtonPolicy::SMI_CANCEL:
+ output = "SMI_CANCEL";
+ break;
+ case ButtonPolicy::SMI_RESTORE:
+ output = "SMI_RESTORE";
+ break;
+ case ButtonPolicy::SMI_HIDE:
+ output = "SMI_HIDE";
+ break;
+ case ButtonPolicy::SMI_READ_ONLY:
+ output = "SMI_READ_ONLY";
+ break;
+ case ButtonPolicy::SMI_READ_WRITE:
+ output = "SMI_READ_WRITE";
+ break;
+ case ButtonPolicy::SMI_NOOP:
+ output = "SMI_NOOP";
+ break;
+ case ButtonPolicy::SMI_TOTAL:
+ output = "SMI_TOTAL";
+ break;
+ }
+
+ return output;
+}
+
+
/// Helper function
-inline
void nextState(ButtonPolicy::State & state,
ButtonPolicy::SMInput in,
ButtonPolicy::StateMachine const & s_m,
ButtonPolicy::State tmp = s_m[state][in];
lyxerr[Debug::GUI] << "Transition from state "
- << state << " to state " << tmp << " after input "
- << in << std::endl;
+ << printState(state) << " to state "
+ << printState(tmp) << " after input "
+ << printInput(in) << std::endl;
if (ButtonPolicy::BOGUS != tmp) {
state = tmp;
} else {
lyxerr << function_name
<< ": No transition for input "
- << in
+ << printInput(in)
<< " from state "
- << state
+ << printState(state)
<< endl;
}
}
void PreferencesPolicy::input(SMInput input)
{
- //lyxerr << "PreferencesPolicy::input" << endl;
- // CANCEL and HIDE always take us to INITIAL for all cases.
- // Note that I didn't put that special case in the helper function
- // because it doesn't belong there. Some other
- // This is probably optimising for the wrong case since it occurs as the
- // dialog will be hidden. It would have saved a little memory in the
- // state machine if I could have gotten map working. ARRae 20000813
+ // The APPLIED state is persistent. Next time the dialog is opened,
+ // the user will be able to press 'Save'.
if (SMI_CANCEL == input
|| SMI_HIDE == input) {
- state_ = INITIAL;
+ if (state_ != APPLIED)
+ state_ = INITIAL;
} else {
nextState(state_,
input,
+2004-04-05 Angus Leeming <leeming@lyx.org>
+
+ * ButtonPolicies.C (printState, printInput): human-readable output
+ of ButtonPolicy::State, ButtonPolicy::SMInput.
+ (PreferencesPolicy::input): change the behaviour of the Preferences
+ state machine on receipt of SMI_CANCEL/SMI_HIDE if the existing
+ state is APPLIED, then let this state persist. Next time that the
+ dialog is opened, the user will be able to press 'Save'.
+
2004-04-05 Angus Leeming <leeming@lyx.org>
* ControlPrefs.C (dispatchParams): ignore system_lyxrc when writing
+2004-04-05 Angus Leeming <leeming@lyx.org>
+
+ * Dialogs.C (build): set the preferences dialog button policy to
+ PreferencesPolicy.
+
2004-04-05 Angus Leeming <leeming@lyx.org>
* GMenubar.C: wrap #warning calls inside #ifdef WITH_WARNINGS blocks.
} else if (name == "prefs") {
dialog->setController(new ControlPrefs(*dialog));
dialog->setView(new FormPreferences(*dialog));
- dialog->bc().bp(new OkApplyCancelPolicy);
+ dialog->bc().bp(new PreferencesPolicy);
} else if (name == "print") {
dialog->setController(new ControlPrint(*dialog));
dialog->setView(new FormPrint(*dialog));
+2004-04-05 Angus Leeming <leeming@lyx.org>
+
+ * Dialogs.C (build): set the preferences dialog button policy to
+ PreferencesPolicy.
+
2004-04-05 Angus Leeming <leeming@lyx.org>
* QGraphics.C (getUnitNo): const-correct.
} else if (name == "prefs") {
dialog->setController(new ControlPrefs(*dialog));
dialog->setView(new QPrefs(*dialog));
- dialog->bc().bp(new OkApplyCancelPolicy);
+ dialog->bc().bp(new PreferencesPolicy);
} else if (name == "print") {
dialog->setController(new ControlPrint(*dialog));
dialog->setView(new QPrint(*dialog));
+2004-04-05 Angus Leeming <leeming@lyx.org>
+
+ * Dialogs.C (build): set the preferences dialog button policy to
+ PreferencesPolicy.
+
2004-05-04 Angus Leeming <leeming@lyx.org>
* FormExternal.C (build):
} else if (name == "prefs") {
dialog->setController(new ControlPrefs(*dialog));
dialog->setView(new FormPreferences(*dialog));
- dialog->bc().bp(new OkApplyCancelPolicy);
+ dialog->bc().bp(new PreferencesPolicy);
} else if (name == "print") {
dialog->setController(new ControlPrint(*dialog));
dialog->setView(new FormPrint(*dialog));
break;
}
+ case LFUN_DIALOG_UPDATE: {
+ string const name = cmd.getArg(0);
+ if (!buf)
+ enable = name == "prefs";
+ break;
+ }
+
case LFUN_MENUNEW:
case LFUN_MENUNEWTMPLT:
case LFUN_WORDFINDFORWARD:
case LFUN_GOTO_PARAGRAPH:
case LFUN_DIALOG_SHOW_NEW_INSET:
case LFUN_DIALOG_SHOW_NEXT_INSET:
- case LFUN_DIALOG_UPDATE:
case LFUN_DIALOG_HIDE:
case LFUN_DIALOG_DISCONNECT_INSET:
case LFUN_CHILDOPEN:
inset->dispatch(view()->cursor(), fr);
} else if (name == "paragraph") {
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
+ } else if (name == "prefs") {
+ owner->getDialogs().update(name, string());
}
break;
}