]> git.lyx.org Git - features.git/commitdiff
Realize Allan Rae's PreferencesPolicy correctly and return the
authorAngus Leeming <leeming@lyx.org>
Mon, 5 Apr 2004 18:34:36 +0000 (18:34 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 5 Apr 2004 18:34:36 +0000 (18:34 +0000)
preferences dialogs of all three frontends to it. The 'Save' button
should now behave as expected when the dialog is closed and reopened.
Squashes bug 1274 for the 1.4.x tree.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8612 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/LyXAction.C
src/frontends/controllers/ButtonPolicies.C
src/frontends/controllers/ChangeLog
src/frontends/gtk/ChangeLog
src/frontends/gtk/Dialogs.C
src/frontends/qt2/ChangeLog
src/frontends/qt2/Dialogs.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/Dialogs.C
src/lyxfunc.C

index 618d0467dd7f4c23599e0bbf8f80a46ed4c4e105..e5c1ca6b62247fe73550bd61944385169c040662 100644 (file)
@@ -1,3 +1,11 @@
+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
index fcf85954d433d9905bd60a0740c2d94dd294e6f3..5d2d637065b4cfe18d593ddc8b1036b9e0d47d99 100644 (file)
@@ -313,7 +313,7 @@ void LyXAction::init()
                { 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 },
index a3f75b11cb265a5f54596a09ab769bb4ca5bdbea..1b5e2ca9cc9013171c053bb12c3cba6bd118ed96 100644 (file)
 
 #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,
@@ -29,17 +112,18 @@ void nextState(ButtonPolicy::State & state,
        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;
        }
 }
@@ -102,16 +186,12 @@ PreferencesPolicy::PreferencesPolicy()
 
 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,
index 207db79c34e9ba09358df847dcbcf85b182c5e37..0729b3599b63eed5be4d599a6b8e161170a998d9 100644 (file)
@@ -1,3 +1,12 @@
+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
index efae326009ea39eea9c697e02a3d3939182b4c6a..9d13f0c15c038f8124dd2df1bc1283c8b99062d5 100644 (file)
@@ -1,3 +1,8 @@
+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.
index 493dbf9bf82432a1a23ac0f38be7547644845013..e78b0ae72d2e8d406df84887ee5640d1bfcc6acf 100644 (file)
@@ -459,7 +459,7 @@ Dialogs::DialogPtr Dialogs::build(string const & name)
        } 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));
index 4e41133d5ac349694340f6dd4c02d63ee1a3aa32..0c30e049cf2a9519a67c8f522862f301b36bb8a4 100644 (file)
@@ -1,3 +1,8 @@
+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.
index 7d652bb99a9548445ac3632d63402f51b6e427cf..24189d6a9dccd3d91c766559b4a2e77d8ed91cb9 100644 (file)
@@ -263,7 +263,7 @@ Dialogs::DialogPtr Dialogs::build(string const & name)
        } 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));
index edbcf9c5049154a312993bdb59a42a79846daabc..f1d4393a213c4804091c1a8e3eedfd1f6b6d97d5 100644 (file)
@@ -1,3 +1,8 @@
+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):
index 1c0b78b1c6a1b1e7c4ae978dac310b03c9b8659b..e2b4a1360f5ffa6106ab19c6f7b62b5ad86cfd6a 100644 (file)
@@ -450,7 +450,7 @@ Dialogs::DialogPtr Dialogs::build(string const & name)
        } 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));
index 35cf569e33f59deec8f83d259671c96d45a5acc4..a73ecde36a3e5de3c3ee3a775ae154094d8d1677 100644 (file)
@@ -430,6 +430,13 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                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:
@@ -459,7 +466,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        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:
@@ -1115,6 +1121,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
                                inset->dispatch(view()->cursor(), fr);
                        } else if (name == "paragraph") {
                                dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
+                       } else if (name == "prefs") {
+                               owner->getDialogs().update(name, string());
                        }
                        break;
                }