]> git.lyx.org Git - lyx.git/commitdiff
Implemented controller-view split for FormError and FormInclude.
authorAngus Leeming <leeming@lyx.org>
Fri, 23 Mar 2001 17:09:34 +0000 (17:09 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 23 Mar 2001 17:09:34 +0000 (17:09 +0000)
Cleaned up code in controllers in the process; I think that the interface
is stabilising now.
Cleaned up code in InsetInclude a little.

Mental note (to me?!): the Bibitem, Bibtex and Include insets create an
inset when the appropriate menu item is selected. This is incorrect;
the inset should only be created when "Ok" is pressed, as with the
majority of insets. CREATE_XXX flags and associated code are needed.

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

41 files changed:
src/BufferView_pimpl.C
src/ChangeLog
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlBibitem.C
src/frontends/controllers/ControlBibitem.h
src/frontends/controllers/ControlBibtex.C
src/frontends/controllers/ControlBibtex.h
src/frontends/controllers/ControlCharacter.h
src/frontends/controllers/ControlCitation.C
src/frontends/controllers/ControlCitation.h
src/frontends/controllers/ControlCommand.C
src/frontends/controllers/ControlCommand.h
src/frontends/controllers/ControlConnections.h
src/frontends/controllers/ControlDialogs.h
src/frontends/controllers/ControlError.C [new file with mode: 0644]
src/frontends/controllers/ControlError.h [new file with mode: 0644]
src/frontends/controllers/ControlInclude.C [new file with mode: 0644]
src/frontends/controllers/ControlInclude.h [new file with mode: 0644]
src/frontends/controllers/ControlInset.h [new file with mode: 0644]
src/frontends/controllers/ControlLog.h
src/frontends/controllers/ControlVCLog.h
src/frontends/controllers/GUI.h
src/frontends/controllers/Makefile.am
src/frontends/xforms/ChangeLog
src/frontends/xforms/Dialogs.C
src/frontends/xforms/FormBibitem.h
src/frontends/xforms/FormBibtex.h
src/frontends/xforms/FormCitation.h
src/frontends/xforms/FormError.C
src/frontends/xforms/FormError.h
src/frontends/xforms/FormInclude.C
src/frontends/xforms/FormInclude.h
src/frontends/xforms/form_error.C
src/frontends/xforms/form_error.h
src/frontends/xforms/form_include.C
src/frontends/xforms/form_include.h
src/frontends/xforms/forms/form_error.fd
src/frontends/xforms/forms/form_include.fd
src/insets/ChangeLog
src/insets/insetinclude.C
src/insets/insetinclude.h

index d6a3df7345a8c64638292f34ae41ee4bc3dd24bf..9f114f463ccc89915143dc00b3453a1e90936a65 100644 (file)
@@ -2928,13 +2928,14 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                if (!bv_->insertInset(inset, "Standard", true))
                        delete inset;
        }
+                
        break;
 
        case LFUN_CHILD_INSERT:
        {
-               InsetInclude::InsetIncludeParams p;
+               InsetInclude::Params p;
                p.cparams.setFromString(argument);
-               p.buffer = buffer_;
+               p.masterFilename_ = buffer_->fileName();
 
                InsetInclude * inset = new InsetInclude(p);
                if (!bv_->insertInset(inset))
index 99b6fcee4713ea7738515885b9e7ea2b258fab1c..9403b0b79b0a683b7a4c9fa49fc281783793535a 100644 (file)
@@ -2,6 +2,9 @@
 
        * LString.h: removed "using std::getline"!
 
+       * BufferView_pimpl.C (Dispatch): changes due to changes in
+       InsetInclude::Params.
+
        * buffer.C (tag_name): removed redundant break statements as they were
        producing lots of warnings with my compiler.
 
index 118fabaa348b0d2d6281d5be1f871d423f7f9f4e..84638ba95d975e669e85c8b62702ebc58f38a652 100644 (file)
@@ -1,3 +1,25 @@
+2001-03-23  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * ControlDialogs.h: moved class ControlInset into its own file.
+
+       * ControlInset.h: new file. class ControlInset has been expanded to take
+       two template parameters, Inset and Params. Believe that all inset
+       controllers can be derived from this with the minimum of effort.
+
+       * ControlBibitem.[Ch]:
+       * ControlBibtex.[Ch]:
+       * ControlCitation.[Ch]:
+       * ControlCommand.[Ch]: moved most code into ControlInset.
+
+       * lots of files. Moved protected stuff into private where possible.
+
+       * ControlError.[Ch]:
+       * ControlInclude.[Ch]: new files; controllers for the LaTeX error and
+       Include popups, respectively.
+
+       * GUI.h:
+       * Makefile.am: associated changes.
+
 2001-03-23  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * ControlCredits.[Ch] (getCredits): returns a stringstream not a
index 3ca711a592e9f9df8b386aa4856943fee9e1082d..3e2779051023f68a932057bcc3484d869b8a0721 100644 (file)
@@ -23,7 +23,7 @@
 #include "ControlBibitem.h"
 #include "Dialogs.h"
 #include "LyXView.h"
-#include "BufferView.h"
+#include "buffer.h"
 
 using SigC::slot;
 
@@ -33,24 +33,19 @@ ControlBibitem::ControlBibitem(LyXView & lv, Dialogs & d)
        d_.showBibitem.connect(slot(this, &ControlBibitem::showInset));
 }
 
-void ControlBibitem::apply()
+void ControlBibitem::applyParamsToInset()
 {
-       view().apply();
-
-       if (inset_ && params() != inset_->params()) {
-               // FIXME:
-               // confirm, is this only necessary for FormBibTeX ???
-               if (params().getContents() != inset_->params().getContents())
-                       lv_.view()->ChangeCitationsIfUnique(
-                               inset_->params().getContents(),
-                               params().getContents());
-
-               inset_->setParams(params());
-               lv_.view()->updateInset(inset_, true);
-
-               // We need to do a redraw because the maximum
-               // InsetBibKey width could have changed
-               lv_.view()->redraw();
-               lv_.view()->fitCursor(lv_.view()->getLyXText());
-       }
+       // FIXME:
+       // confirm, is this only necessary for FormBibTeX ???
+       if (params().getContents() != inset()->params().getContents())
+               lv_.view()->ChangeCitationsIfUnique(inset()->params().getContents(),
+                                                   params().getContents());
+
+       inset()->setParams(params());
+       lv_.view()->updateInset(inset(), true);
+
+       // We need to do a redraw because the maximum
+       // InsetBibKey width could have changed
+       lv_.view()->redraw();
+       lv_.view()->fitCursor(lv_.view()->getLyXText());
 }
index 27263b24259a9ac8b3abc013575a76eeafcaa9ac..6a852cbe0927f561de4a39e1117614b60c72241a 100644 (file)
@@ -30,9 +30,13 @@ public:
        ///
        ControlBibitem(LyXView &, Dialogs &);
 
-protected:
-       /// Get changed parameters and Dispatch them to the kernel.
-       virtual void apply();
+private:
+       /// Dispatch the changed parameters to the kernel.
+       virtual void applyParamsToInset();
+       /// not needed.
+       virtual void applyParamsNoInset() {}
+       /// not needed.
+       virtual void clearDaughterParams() {}
 };
 
 #endif // CONTROLBIBITEM_H
index 0692d609829c89de5757243117ffcc1d510fca9a..560b20e32d998cd4ac670daf0b38706340eb5496 100644 (file)
@@ -23,7 +23,7 @@
 #include "ControlBibtex.h"
 #include "Dialogs.h"
 #include "LyXView.h"
-#include "BufferView.h"
+#include "buffer.h"
 
 using SigC::slot;
 
@@ -33,22 +33,21 @@ ControlBibtex::ControlBibtex(LyXView & lv, Dialogs & d)
        d_.showBibtex.connect(slot(this, &ControlBibtex::showInset));
 }
 
-void ControlBibtex::apply()
+void ControlBibtex::applyParamsToInset()
 {
-       view().apply();
-
-       if (inset_ && params() != inset_->params()) {
-               if (params().getContents() != inset_->params().getContents())
-                       lv_.view()->ChangeCitationsIfUnique(
-                               inset_->params().getContents(),
-                               params().getContents());
-
-               inset_->setParams(params());
-               lv_.view()->updateInset(inset_, true);
-
-               // We need to do a redraw because the maximum
-               // InsetBibKey width could have changed
-               lv_.view()->redraw();
-               lv_.view()->fitCursor(lv_.view()->getLyXText());
-       }
+       if (params().getContents() != inset()->params().getContents())
+               lv_.view()->ChangeCitationsIfUnique(inset()->params().getContents(),
+                                                   params().getContents());
+
+       inset()->setParams(params());
+       lv_.view()->updateInset(inset(), true);
+
+       // We need to do a redraw because the maximum
+       // InsetBibKey width could have changed
+       lv_.view()->redraw();
+       lv_.view()->fitCursor(lv_.view()->getLyXText());
 }
+
+
+void ControlBibtex::applyParamsNoInset()
+{}
index 2be3c6c241f4401ecea4798dfe5b3bd4f4ffb260..392540aaf023627171f48d9e62e4d10421e2ea08 100644 (file)
@@ -30,9 +30,13 @@ public:
        ///
        ControlBibtex(LyXView &, Dialogs &);
 
-protected:
-       /// Get changed parameters and Dispatch them to the kernel.
-       virtual void apply();
+private:
+       /// Dispatch the changed parameters to the kernel.
+       virtual void applyParamsToInset();
+       /// 
+       virtual void applyParamsNoInset();
+       /// not needed.
+       virtual void clearDaughterParams() {}
 };
 
 #endif // CONTROLBIBTEX_H
index 4eb44ca0b681d40d7aad34a71c204cbc526cb3d1..b593c83c52643b6445e3f7aff5d3afcebdccb357 100644 (file)
@@ -71,7 +71,7 @@ public:
        ///
        void setToggleAll(bool);
 
-protected:
+private:
        /// Get changed parameters and Dispatch them to the kernel.
        virtual void apply();
        /// set the params before show or update.
@@ -79,8 +79,9 @@ protected:
        /// clean-up on hide.
        virtual void clearParams();
 
-private:
+       ///
        LyXFont * font_;
+       ///
        bool toggleall_;
 };
 
index 7a882f7f1766febb9ed9b224c798eecff752c45c..57b1f2745c4e5186e3b0235c1b138d15ee5744f4 100644 (file)
@@ -45,7 +45,7 @@ ControlCitation::ControlCitation(LyXView & lv, Dialogs & d)
 }
 
 
-void ControlCitation::clearParams()
+void ControlCitation::clearDaughterParams()
 {
        bibkeysInfo_.clear();
 }
index 166264ec5ed297fefd4fe3d7fa0212ef6ed3b705..26ff36da4aaaa15c01ee69e458c5f7b63425d0f7 100644 (file)
@@ -55,8 +55,8 @@ public:
            Empty if no info exists. */
        string const getBibkeyInfo(string const &);
 private:
-       /// Clean up, then hide dialog.
-       virtual void clearParams();
+       /// clean-up any daughter class-particular data on hide.
+       virtual void clearDaughterParams();
        /// The info associated with each key
        InfoMap bibkeysInfo_;
 };
index 1ed0c12fa68ef2a1f86685f76b2909825664df7d..d95c53bf2e1166b5f7b3baa5dac018477cd14194 100644 (file)
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* This file is part of
  * ====================================================== 
  *
 #include <config.h>
 
 #include "ControlCommand.h"
-#include "BufferView.h"
+#include "buffer.h"
 #include "Dialogs.h"
 #include "lyxfunc.h"
 #include "LyXView.h"
-#include "support/LAssert.h"
 
 ControlCommand::ControlCommand(LyXView & lv, Dialogs & d, kb_action ac)
-       : ControlInset<InsetCommand>(lv, d),
-         params_(0), action_(ac)
+       : ControlInset<InsetCommand, InsetCommandParams>(lv, d),
+         action_(ac)
 {}
 
 
-void ControlCommand::showInset(InsetCommand * inset)
+InsetCommandParams const ControlCommand::getParams(string const & arg)
 {
-       if (inset == 0) return;  // maybe we should Assert this?
-
-       connectInset(inset);
-       show(inset->params());
-}
-
-
-void ControlCommand::createInset(string const & arg)
-{
-       connectInset();
-
-       if ( !arg.empty() )
-               bc().valid(); // so that the user can press Ok
-
        InsetCommandParams params;
        params.setFromString(arg);
-       show(params);
+       return params;
 }
 
-
-void ControlCommand::update()
+InsetCommandParams const ControlCommand::getParams(InsetCommand const & inset)
 {
-       if (params_) delete params_;
-
-       if (inset_)
-               params_ = new InsetCommandParams(inset_->params());
-       else
-               params_ = new InsetCommandParams;
-
-       bc().readOnly(isReadonly());
-       view().update();
+       return inset.params();
 }
 
-
-void ControlCommand::show(InsetCommandParams const & params)
+void ControlCommand::applyParamsToInset()
 {
-       if (params_) delete params_;
-       params_ = new InsetCommandParams(params);
-
-       bc().readOnly(isReadonly());
-       view().show();
+       inset()->setParams(params());
+       lv_.view()->updateInset(inset(), true);
 }
 
-
-void ControlCommand::hide()
+void ControlCommand::applyParamsNoInset()
 {
-       if (params_) {
-               delete params_;
-               params_ = 0;
-       }
-
-       clearParams();
-
-       disconnect();
-       view().hide();
-}
+       if (action_ == LFUN_NOACTION) return;
 
-InsetCommandParams & ControlCommand::params() const
-{
-       Assert(params_);
-       return *params_;
+       lv_.getLyXFunc()->Dispatch(action_, params().getAsString());
 }
 
-
-void ControlCommand::apply()
-{
-       view().apply();
-
-       if (inset_) {
-               // Only update if contents have changed
-               if (params() != inset_->params()) {
-                       inset_->setParams(params());
-                       lv_.view()->updateInset(inset_, true);
-               }
-       } else if (action_ != LFUN_NOACTION){
-               lv_.getLyXFunc()->Dispatch(action_, params().getAsString());
-       }
-}
index 996a84d3264ffbac59c0c807d4bba9f9e7bf92c5..cd7ea20783e7af20912f7e344f18a23aea5d9043 100644 (file)
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* This file is part of
  * ====================================================== 
  *
 #pragma interface
 #endif
 
-#include "ControlDialogs.h"
+#include "ControlInset.h"
 #include "insets/insetcommand.h"
 #include "commandtags.h" // kb_action
 
 /** The Inset dialog controller. Connects/disconnects signals, launches 
     GUI-dependent View and returns the output from this View to the kernel.
  */
-class ControlCommand : public ControlInset<InsetCommand>
+class ControlCommand : public ControlInset<InsetCommand, InsetCommandParams>
 {
 public:
        ///
        ControlCommand(LyXView &, Dialogs &, kb_action=LFUN_NOACTION);
 
-       /// Allow the View access to the local copy.
-       InsetCommandParams & params() const;
-
-protected:
-       /// Slots connected in the daughter classes c-tor.
-       /// Slot launching dialog to (possibly) create a new inset.
-       void createInset(string const &);
-       /// Slot launching dialog to an existing inset.
-       void showInset(InsetCommand *);
-
-       /// Connect signals and launch View.
-       void show(InsetCommandParams const &);
-
-       /// Instantiation of private ControlBase virtual methods.
-       /// Get changed parameters and Dispatch them to the kernel.
-       virtual void apply();
-       /// Disconnect signals and hide View.
-       virtual void hide();
-       /// Update dialog before showing it.
-       virtual void update();
-
-       /// clean-up on hide.
-       virtual void clearParams() {}
-       
-
 private:
-       /** A local copy of the inset's params.
-           Memory is allocated only whilst the dialog is visible.
-       */
-       InsetCommandParams * params_;
+       /// Dispatch the changed parameters to the kernel.
+       virtual void applyParamsToInset();
+       /// 
+       virtual void applyParamsNoInset();
+       /// get the parameters from the string passed to createInset.
+       virtual InsetCommandParams const getParams(string const &);
+       /// get the parameters from the inset passed to showInset.
+       virtual InsetCommandParams const getParams(InsetCommand const &);
+
        /// Controls what is done in LyXFunc::Dispatch()
        kb_action const action_;
 };
index 7a295c9610a1d7d64cfde7217f86db75a3c290af..ff8a805a09c1ac560570e62749e112e85daf1c67 100644 (file)
@@ -108,17 +108,17 @@ public:
 protected:
        ///
        virtual bool isBufferDependent() const { return true; }
-       /** Slot connected to update signal.
-           Bool indicates if a buffer switch took place.
-           Default behaviour is to ignore this and simply update().
-       */
-       virtual void updateSlot(bool) { update(); }
        /// Connect signals
        virtual void connect();
        /// Disconnect signals
        virtual void disconnect();
 
 private:
+       /** Slot connected to update signal.
+           Bool indicates if a buffer switch took place.
+           Default behaviour is to ignore this and simply update().
+       */
+       virtual void updateSlot(bool) { update(); }
        /// Update connection.
        SigC::Connection u_;
 };
index 4026d20daa4d6bc6a47f0d2361ab81fbf3a16f4a..0bfea6048babe9525a998ee093f2b486d4f01599 100644 (file)
  * \file ControlDialogs.h
  * \author Angus Leeming <a.leeming@ic.ac.uk>
  *
- * ControlDialogs.h contains the definition of two template controller classes,
- * ControlDialog and ControlInset, rather clumsy names for classes that
- * control the showing, updating and hiding of popups.
- *
- * ControlInset is to be used as a parent class for popups that display and
- * can perhaps modify the contents of an individual inset. An example being the
- * ubiquitous Citation popup.
- *
  * ControlDialog is to be used as a parent class for popups that are not
  * Inset-popups. (An ugly description I know, but I hope the meaning is clear!
  * Can anyone do any better?) Examples would be the Document and Paragraph
  * popups.
- *
- * At the moment, ControlDialog is reaching a state of maturity as several
- * controllers are now derived from it and its required functionality
- * becaomes clear.
- *
- * ControlInset is still in a state of flux as currently only InsetCommand-type
- * insets have a controller.
- *
  */
 
-#ifndef CONTROLCONNECTIONS2_H
-#define CONTROLCONNECTIONS2_H
+#ifndef CONTROLDIALOGS_H
+#define CONTROLDIALOGS_H
 
 #include "ControlConnections.h"
-#include "LyXView.h"
 
 /** Base class to control connection/disconnection of signals with the LyX
     kernel for dialogs NOT used with insets.
@@ -57,46 +40,14 @@ protected:
        /// Update the dialog.
        virtual void update();
 
-       /// set the params before show or update
-       virtual void setParams() {}
        /// clean-up on hide.
        virtual void clearParams() {}
+       /// set the params before show or update
+       virtual void setParams() {}
 };
 
 
-/** Base class to control connection/disconnection of signals with the LyX
-    kernel for Inset dialogs.
- */
-class Inset;
-
-template <class Inset>
-class ControlInset : public ControlConnectBD
-{
-public:
-       ///
-       ControlInset(LyXView &, Dialogs &);
-
-protected:
-       /// Slot connected to update signal.
-       virtual void updateSlot(bool);
-       /// Connect signals
-       void connectInset(Inset * = 0);
-       /// Disconnect signals
-       virtual void disconnect();
-       ///
-       void disconnectInset();
-
-protected:
-       /// pointer to the inset passed through connectInset
-       Inset * inset_;
-
-private:
-       /// inset::hide connection.
-       SigC::Connection ih_;
-};
-
-
-
+#include "LyXView.h"
 
 
 template <class Base>
@@ -138,56 +89,4 @@ void ControlDialog<Base>::hide()
        view().hide();
 }
 
-
-template <class Inset>
-ControlInset<Inset>::ControlInset(LyXView & lv, Dialogs & d)
-       : ControlConnectBD(lv, d),
-         inset_(0), ih_(0)
-{}
-
-
-template <class Inset>
-void ControlInset<Inset>::updateSlot(bool switched)
-{
-       if (switched)
-               hide();
-       else
-               update();
-}
-
-
-template <class Inset>
-void ControlInset<Inset>::disconnect()
-{
-       inset_ = 0;
-       ih_.disconnect();
-       ControlConnectBD::disconnect();
-}
-
-
-template <class Inset>
-void ControlInset<Inset>::connectInset(Inset * inset)
-{
-       // If connected to another inset, disconnect from it.
-       if (inset_) {
-               ih_.disconnect();
-               inset_ = 0;
-       }
-
-       if (inset) {
-               inset_ = inset;
-               ih_ = inset->hideDialog.connect(
-                       SigC::slot(this, &ControlInset::hide));
-       }
-       connect();
-}
-
-
-template <class Inset>
-void ControlInset<Inset>::disconnectInset()
-{
-       ih_.disconnect();
-}
-
-
-#endif // CONTROLCONNECTIONS2_H
+#endif // CONTROLDIALOGS_H
diff --git a/src/frontends/controllers/ControlError.C b/src/frontends/controllers/ControlError.C
new file mode 100644 (file)
index 0000000..4a17860
--- /dev/null
@@ -0,0 +1,38 @@
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlError.C
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+
+#include "ControlError.h"
+#include "Dialogs.h"
+#include "LyXView.h"
+#include "buffer.h"
+#include "insets/inseterror.h"
+
+using SigC::slot;
+
+ControlError::ControlError(LyXView & lv, Dialogs & d)
+       : ControlInset<InsetError, string>(lv, d)
+{
+       d_.showError.connect(slot(this, &ControlError::showInset));
+}
+
+string const ControlError::getParams(InsetError const & inset)
+{
+       return inset.getContents();
+}
+
diff --git a/src/frontends/controllers/ControlError.h b/src/frontends/controllers/ControlError.h
new file mode 100644 (file)
index 0000000..e296b54
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * \file ControlError.h
+ * This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2000-2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \author Angus Leeming, a.leeming@.ac.uk
+ */
+
+#ifndef CONTROLERROR_H
+#define CONTROLERROR_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlInset.h"
+
+class InsetError;
+
+/** A controller for LaTeX Error dialogs.
+ */
+class ControlError : public ControlInset<InsetError, string>
+{
+public:
+       ///
+       ControlError(LyXView &, Dialogs &);
+
+private:
+       /// not needed.
+       virtual void applyParamsToInset() {}
+       /// 
+       virtual void applyParamsNoInset() {}
+       /// 
+       virtual void clearDaughterParams() {}
+       /// get the parameters from the string passed to createInset.
+       virtual string const getParams(string const &) { return string(); }
+       /// get the parameters from the inset passed to showInset.
+       virtual string const getParams(InsetError const &);
+};
+
+#endif // CONTROLERROR_H
diff --git a/src/frontends/controllers/ControlInclude.C b/src/frontends/controllers/ControlInclude.C
new file mode 100644 (file)
index 0000000..04416f2
--- /dev/null
@@ -0,0 +1,40 @@
+/**
+ * \file ControlInclude.C
+ * Copyright 2001 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Alejandro Aguilar Sierra
+ * \author John Levon, moz@compsoc.man.ac.uk
+ * \author Angus Leeming, a.leeming@.ac.uk
+ */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+#include "ControlInclude.h"
+#include "buffer.h"
+#include "Dialogs.h"
+#include "lyxfunc.h"
+#include "LyXView.h"
+
+using SigC::slot;
+
+ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
+       : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
+{
+       d_.showInclude.connect(slot(this, &ControlInclude::showInset));
+}
+
+LyXView * ControlInclude::lv() const
+{
+       return &lv_;
+}
+
+
+void ControlInclude::applyParamsToInset()
+{
+       inset()->set(params());
+       lv_.view()->updateInset(inset(), true);
+}
diff --git a/src/frontends/controllers/ControlInclude.h b/src/frontends/controllers/ControlInclude.h
new file mode 100644 (file)
index 0000000..06bb86e
--- /dev/null
@@ -0,0 +1,47 @@
+/**
+ * \file ControlInclude.h
+ * Copyright 2001 the LyX Team
+ * See the file COPYING
+ *
+ * \author Alejandro Aguilar Sierra
+ * \author John Levon, moz@compsoc.man.ac.uk
+ * \author Angus Leeming, a.leeming@.ac.uk
+ */
+
+#ifndef CONTROLINCLUDE_H
+#define CONTROLINCLUDE_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlInset.h"
+#include "insets/insetinclude.h" // InsetIncludeParams
+
+/** A controller for the Include file dialog.
+ */
+class ControlInclude
+       : public ControlInset<InsetInclude, InsetInclude::Params>
+{
+public:
+       ///
+       ControlInclude(LyXView &, Dialogs &);
+
+       /// The file dialog popup requires a LyXView * ???
+       LyXView * lv() const;
+
+private:
+       /// Dispatch the changed parameters to the kernel.
+       virtual void applyParamsToInset();
+       /// Should be used but currently isn't
+       virtual void applyParamsNoInset() {}
+       /// not needed.
+       virtual void clearDaughterParams() {}
+       /// get the parameters from the string passed to createInset.
+       virtual InsetInclude::Params const getParams(string const &)
+               { return InsetInclude::Params(); }
+       /// get the parameters from the inset passed to showInset.
+       virtual InsetInclude::Params const getParams(InsetInclude const & inset)
+               { return inset.params(); }
+};
+#endif // CONTROLINCLUDE_H
diff --git a/src/frontends/controllers/ControlInset.h b/src/frontends/controllers/ControlInset.h
new file mode 100644 (file)
index 0000000..7ca3a90
--- /dev/null
@@ -0,0 +1,241 @@
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlInsets.h
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ *
+ * ControlInset is to be used as a parent class for popups that display and
+ * can perhaps modify the contents of an individual inset. An example being the
+ * ubiquitous Citation popup.
+ */
+
+#ifndef CONTROLINSET_H
+#define CONTROLINSET_H
+
+#include "ControlConnections.h"
+
+class Inset;
+
+template <class Inset, class Params>
+class ControlInset : public ControlConnectBD
+{
+public:
+       ///
+       ControlInset(LyXView &, Dialogs &);
+       /// Allow the View access to the local copy.
+       Params & params() const;
+
+protected:
+       /// Slots connected in the daughter classes c-tor.
+       /// Slot launching dialog to (possibly) create a new inset.
+       void createInset(string const &);
+       /// Slot launching dialog to an existing inset.
+       void showInset(Inset * inset);
+       /// Allow the daughter methods to access the inset.
+       Inset * inset() const;
+
+private:
+       /** These 5 methods are all that the individual daughter classes
+           should need to instantiate. */
+
+       /// if the inset exists then do this...
+       virtual void applyParamsToInset() = 0;
+       /// else this...
+       virtual void applyParamsNoInset() = 0;
+       /// clean-up any daughter class-particular data on hide.
+       virtual void clearDaughterParams() = 0;
+       /// get the parameters from the string passed to createInset.
+       virtual Params const getParams(string const &) = 0;
+       /// get the parameters from the inset passed to showInset.
+       virtual Params const getParams(Inset const &) = 0;
+
+       /// Instantiation of ControlBase virtual methods.
+
+       /// Get changed parameters and Dispatch them to the kernel.
+       virtual void apply();
+       /// Disconnect signals and hide View.
+       virtual void hide();
+       /// Update the dialog.
+       virtual void update();
+
+       /** Instantiation of ControlConnectBD private virtual method.
+           Slot connected to update signal. */
+       virtual void updateSlot(bool);
+
+       /// Show the dialog.
+       void show(Params const &);
+       /// Connect signals
+       void connectInset(Inset * = 0);
+       /// Disconnect signals
+       virtual void disconnect();
+       ///
+       void disconnectInset();
+
+       /// pointer to the inset passed through connectInset
+       Inset * inset_; 
+       /// inset::hide connection.
+       SigC::Connection ih_;
+       /** A local copy of the inset's params.
+           Memory is allocated only whilst the dialog is visible.
+       */
+       Params * params_;
+};
+
+
+#include "LyXView.h"
+#include "support/LAssert.h"
+
+
+
+template <class Inset, class Params>
+ControlInset<Inset, Params>::ControlInset(LyXView & lv, Dialogs & d)
+       : ControlConnectBD(lv, d),
+         inset_(0), ih_(0), params_(0)
+{}
+
+
+template <class Inset, class Params>
+void ControlInset<Inset, Params>::showInset(Inset * inset)
+{
+       if (inset == 0) return;  // maybe we should Assert this?
+
+       connectInset(inset);
+       show(getParams(*inset));
+}
+
+
+template <class Inset, class Params>
+void ControlInset<Inset, Params>::createInset(string const & arg)
+{
+       connectInset();
+
+       if ( !arg.empty() )
+               bc().valid(); // so that the user can press Ok
+
+       show(getParams(arg));
+}
+
+
+template <class Inset, class Params>
+void ControlInset<Inset, Params>::show(Params const & params)
+{
+       if (params_) delete params_;
+       params_ = new Params(params);
+
+       bc().readOnly(isReadonly());
+       view().show();
+}
+
+
+template <class Inset, class Params>
+void ControlInset<Inset, Params>::hide()
+{
+       if (params_) {
+               delete params_;
+               params_ = 0;
+       }
+
+       clearDaughterParams();
+
+       disconnect();
+       view().hide();
+}
+
+
+template <class Inset, class Params>
+void ControlInset<Inset, Params>::update()
+{
+       if (params_) delete params_;
+
+       if (inset_)
+               params_ = new Params(getParams(*inset_));
+       else
+               params_ = new Params();
+
+       bc().readOnly(isReadonly());
+       view().update();
+}
+
+
+template <class Inset, class Params>
+void ControlInset<Inset, Params>::apply()
+{
+       if (lv_.buffer()->isReadonly() || !inset_)
+               return;
+
+       view().apply();
+
+       if (inset_ && params() != getParams(*inset_))
+               applyParamsToInset();
+       else if (!inset_)
+               applyParamsNoInset();
+}
+
+
+template <class Inset, class Params>
+Params & ControlInset<Inset, Params>::params() const
+{
+       Assert(params_);
+       return *params_;
+}
+
+
+template <class Inset, class Params>
+Inset * ControlInset<Inset, Params>::inset() const
+{
+       Assert(inset_);
+       return inset_;
+}
+
+
+template <class Inset, class Params>
+void ControlInset<Inset, Params>::updateSlot(bool switched)
+{
+       if (switched)
+               hide();
+       else
+               update();
+}
+
+
+template <class Inset, class Params>
+void ControlInset<Inset, Params>::disconnect()
+{
+       inset_ = 0;
+       ih_.disconnect();
+       ControlConnectBD::disconnect();
+}
+
+
+template <class Inset, class Params>
+void ControlInset<Inset, Params>::connectInset(Inset * inset)
+{
+       // If connected to another inset, disconnect from it.
+       if (inset_) {
+               ih_.disconnect();
+               inset_ = 0;
+       }
+
+       if (inset) {
+               inset_ = inset;
+               ih_ = inset->hideDialog.connect(
+                       SigC::slot(this, &ControlInset::hide));
+       }
+       connect();
+}
+
+
+template <class Inset, class Params>
+void ControlInset<Inset, Params>::disconnectInset()
+{
+       ih_.disconnect();
+}
+
+
+#endif // CONTROLINSET_H
index 22f02707401935dec2c253523daee683fe393312..894671fd0427d1134821d4ac3a7e2412e17e329a 100644 (file)
@@ -36,7 +36,7 @@ public:
        std::pair<Buffer::LogType, string> const & logfile()
                { return logfile_; }
 
-protected:
+private:
        ///
        virtual void apply() {}
        /// set the params before show or update
@@ -44,7 +44,6 @@ protected:
        /// clean-up on hide.
        virtual void clearParams();
 
-private:
        std::pair<Buffer::LogType, string> logfile_;
 };
 
index 9644225dc5f0207b9be2be8f14ea73b074198aa3..790d4418a70a9b074392dc7d0557f37d282a0ac5 100644 (file)
@@ -34,7 +34,7 @@ public:
        ///
        string const & logfile() { return logfile_; }
 
-protected:
+private:
        ///
        virtual void apply() {}
        /// set the params before show or update
@@ -42,7 +42,6 @@ protected:
        /// clean-up on hide.
        virtual void clearParams();
 
-private:
        string logfile_;
 };
 
index 8d934df7c73531cbcbd0b7e2e4a8fffa798a13af..cfa4bc5c874ed4224ccc4d64bce5f3902ec51057 100644 (file)
@@ -109,6 +109,34 @@ public:
 };
 
 
+/** Specialization for Error dialog
+ */
+class ControlError;
+
+template <class GUIview, class GUIbc>
+class GUIError :
+       public GUI<ControlError, GUIview, OkCancelPolicy, GUIbc> {
+public:
+       ///
+       GUIError(LyXView & lv, Dialogs & d)
+               : GUI<ControlError, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
+};
+
+
+/** Specialization for Include dialog
+ */
+class ControlInclude;
+
+template <class GUIview, class GUIbc>
+class GUIInclude :
+       public GUI<ControlInclude, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
+public:
+       ///
+       GUIInclude(LyXView & lv, Dialogs & d)
+               : GUI<ControlInclude, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
+};
+
+
 /** Specialization for Log dialog
  */
 class ControlLog;
index 704b535f4a95007cb5d93f3b4cdfdefd9f704193..fb219a4424187c0f7de2f451ab25e16d9386a4d5 100644 (file)
@@ -29,9 +29,14 @@ libcontrollers_la_SOURCES=\
        ControlConnections.C \
        ControlConnections.h \
        ControlCopyright.C \
+       ControlCopyright.h \
        ControlCredits.h \
        ControlCredits.C \
-       ControlCopyright.h \
+       ControlError.h \
+       ControlError.C \
+       ControlInclude.C \
+       ControlInclude.h \
+       ControlInset.h \
        ControlLog.C \
        ControlLog.h \
        ControlVCLog.C \
index 8890cc9f7151b6cd120c3fc0e0e0be4dacfd73b9..095baae30754b03892bd033ebf7ee7fa33b8bce1 100644 (file)
@@ -1,3 +1,21 @@
+2001-03-23  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * FormError.[Ch]:
+       * form_error.fd:
+       * FormInclude.[Ch]:
+       * form_include.fd: implemented controller-view split.
+
+       * Dialogs.C: associated changes.
+
+       * FormBibitem.h:
+       * FormBibtex.h:
+       * FormCitation.h: moved methods from protected to private.
+
+2001-03-23  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * FormCredits.C (build): changes associated with
+       ControlCredits::getCredits returning a stringstream not a vector<string>
+
 2001-03-22  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * FormCopyright.[Ch]:
index a9461eb57311a9b04bcd3d78b87c52bf16d079be..c34f73c976f732d3c634897a133cbc28d83cec7a 100644 (file)
@@ -25,6 +25,8 @@
 #include "ControlCitation.h"
 #include "ControlCopyright.h"
 #include "ControlCredits.h"
+#include "ControlError.h"
+#include "ControlInclude.h"
 #include "ControlLog.h"
 #include "ControlVCLog.h"
 
@@ -38,6 +40,8 @@
 #include "form_citation.h"
 #include "form_copyright.h"
 #include "form_credits.h"
+#include "form_error.h"
+#include "form_include.h"
 
 #include "FormBibitem.h"
 #include "FormBibtex.h"
 #include "FormCitation.h"
 #include "FormCopyright.h"
 #include "FormCredits.h"
+#include "FormError.h"
+#include "FormInclude.h"
 #include "FormLog.h"
 #include "FormVCLog.h"
 
 #include "FormDocument.h"
-#include "FormError.h"
 #include "FormExternal.h" 
 #include "FormGraphics.h"
-#include "FormInclude.h"
 #include "FormIndex.h"
 #include "FormMathsPanel.h"
 #include "FormParagraph.h"
@@ -82,14 +86,14 @@ Dialogs::Dialogs(LyXView * lv)
        add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
        add(new GUICopyright<FormCopyright, xformsBC>(*lv, *this));
        add(new GUICredits<FormCredits, xformsBC>(*lv, *this));
+       add(new GUIError<FormError, xformsBC>(*lv, *this));
+       add(new GUIInclude<FormInclude, xformsBC>(*lv, *this));
        add(new GUILog<FormLog, xformsBC>(*lv, *this));
        add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
 
        add(new FormDocument(lv, this));
-       add(new FormError(lv, this));
        add(new FormExternal(lv, this));
        add(new FormGraphics(lv, this));
-       add(new FormInclude(lv, this));
        add(new FormIndex(lv, this));
        add(new FormMathsPanel(lv, this));
        add(new FormParagraph(lv, this));
index 3016ab6aaf2ea7d597ae73f8c179ed46ee62579d..82e1326d795cb7e7a6b48bc452f8fcedcc1528b8 100644 (file)
@@ -28,16 +28,13 @@ public:
        ///
        FormBibitem(ControlBibitem &);
 
-       // Functions accessible to the Controller.
-
+private:
        /// Set the Params variable for the Controller.
        virtual void apply();
        /// Build the dialog.
        virtual void build();
        /// Update dialog before/whilst showing it.
        virtual void update();
-
-private:
        /// Filter the inputs on callback from xforms
        virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
 
index 452cab7d594bcfb2eb6411641564fa1ffaa340a2..6b19448f10c72a9bdba292f44253f82ac92ae16f 100644 (file)
@@ -28,16 +28,13 @@ public:
        ///
        FormBibtex(ControlBibtex &);
 
-       // Functions accessible to the Controller.
-
+private:
        /// Set the Params variable for the Controller.
        virtual void apply();
        /// Build the dialog.
        virtual void build();
        /// Update dialog before/whilst showing it.
        virtual void update();
-       
-private:
        /// Filter the inputs on callback from xforms
        virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
        ///
index d35c256a15b75e4bdae3bf99e9147a41f808b306..541470f2d246092d3a41f79edc0bc71653fc9f69 100644 (file)
@@ -30,17 +30,6 @@ public:
        ///
        FormCitation(ControlCitation &);
 
-       // Functions accessible to the Controller.
-
-       /// Set the Params variable for the Controller.
-       virtual void apply();
-       /// Build the dialog.
-       virtual void build();
-       /// Hide the dialog.
-       virtual void hide();
-       /// Update dialog before/whilst showing it.
-       virtual void update();
-
 private:
        ///
        enum State {
@@ -50,6 +39,14 @@ private:
                OFF
        };
 
+       /// Set the Params variable for the Controller.
+       virtual void apply();
+       /// Build the dialog.
+       virtual void build();
+       /// Hide the dialog.
+       virtual void hide();
+       /// Update dialog before/whilst showing it.
+       virtual void update();
        /// Filter the inputs on callback from xforms
        virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
 
index 0a6b5b2d1a583f3e926ddb05de99f861742dd32a..a475649a00ab38c52326aed6736a7268579f18d6 100644 (file)
@@ -1,74 +1,34 @@
-// -*- C++ -*-
-/* This file is part of
+/*
+ * \file FormError.C
+ * This file is part of
  * ====================================================== 
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2000-2001 The LyX Team.
  *
  * ======================================================
+ *
+ * \author Angus Leeming, a.leeming@.ac.uk
  */
 
-#include <config.h>
-
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-#include "Dialogs.h"
+#include <config.h>
+
+#include "xformsBC.h"
+#include "ControlError.h"
 #include "FormError.h"
 #include "form_error.h"
-#include "insets/inseterror.h"
-#include "support/LAssert.h"
-
-using SigC::slot;
-
-FormError::FormError(LyXView * lv, Dialogs * d)
-       : FormInset( lv, d, _("LaTeX Error")),
-         inset_(0)
-{
-       Assert(lv && d);
-       // let the dialog be shown
-       // This is a permanent connection so we won't bother
-       // storing a copy because we won't be disconnecting.
-       d->showError.connect(slot(this, &FormError::showInset));
-}
-
-
-FL_FORM * FormError::form() const
-{
-       if (dialog_.get()) return dialog_->form;
-       return 0;
-}
+#include "xforms_helpers.h" // formatted
 
+typedef FormCB<ControlError, FormDB<FD_form_error> > base_class;
 
-void FormError::disconnect()
-{
-       inset_ = 0;
-       message_.erase();
-       FormInset::disconnect();
-}
-
-
-void FormError::showInset(InsetError * inset)
-{
-       if (inset == 0) return; // Is this _really_ allowed? (Lgb)
-
-       // If connected to another inset, disconnect from it.
-       if (inset_)
-               ih_.disconnect();
-
-       inset_ = inset;
-       message_ = inset->getContents();
-       ih_ = inset->hideDialog.connect(slot(this, &FormError::hide));
-       show();
-}
-
-
-void FormError::update()
-{
-       fl_set_object_label(dialog_->message, message_.c_str());
-}
+FormError::FormError(ControlError & c)
+       : base_class(c, _("LaTeX Error"))
+{}
 
 
 void FormError::build()
@@ -79,3 +39,11 @@ void FormError::build()
        bc().setCancel(dialog_->button_cancel);
        bc().refresh();
 }
+
+
+void FormError::update()
+{
+       string const txt = formatted(controller().params(),
+                                    dialog_->message->w-10);
+       fl_set_object_label(dialog_->message, txt.c_str());
+}
index 50331bb9411ae827fcbe1d38fa2c2efd34e7d39a..08342a8963abb95fb64ec1adbb1d9212582f694d 100644 (file)
@@ -1,65 +1,46 @@
-// -*- C++ -*-
-/* This file is part of
+/*
+ * \file FormError.h
+ * This file is part of
  * ====================================================== 
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2000-2001 The LyX Team.
  *
  * ======================================================
+ *
+ * \author Angus Leeming, a.leeming@.ac.uk
  */
 
 #ifndef FORMERROR_H
 #define FORMERROR_H
 
-#include <boost/smart_ptr.hpp>
-
 #ifdef __GNUG__
 #pragma interface
 #endif
 
-#include "FormInset.h"
+#include "FormBase.h"
 
-class InsetError;
+class ControlError;
 struct FD_form_error;
 
-/** This class provides an XForms implementation of the FormError Dialog.
+/** This class provides an XForms implementation of the Error Dialog.
  */
-class FormError : public FormInset {
+class FormError : public FormCB<ControlError, FormDB<FD_form_error> > {
 public:
        /// Constructor
-       FormError(LyXView *, Dialogs *);
-private:
-       /// Pointer to the actual instantiation of the ButtonController.
-       virtual xformsBC & bc();
-       /// Disconnect signals. Also perform any necessary housekeeping.
-       virtual void disconnect();
+       FormError(ControlError &);
 
-       /// Slot launching dialog to an existing inset
-       void showInset(InsetError *);
-       /// Update dialog before showing it
-       virtual void update();
+private:
+       /// not needed.
+       virtual void apply() {}
        /// Build the dialog
        virtual void build();
-       /// Pointer to the actual instantiation of the xforms form
-       virtual FL_FORM * form() const;
+       /// Update dialog before showing it
+       virtual void update();
+
        /// Fdesign generated method
        FD_form_error * build_error();
-
-       /// Real GUI implementation.
-       boost::scoped_ptr<FD_form_error> dialog_;
-       /// pointer to the inset passed through showInset
-       InsetError * inset_;
-       /// the error message
-       string message_;
-       /// The ButtonController
-       ButtonController<OkCancelPolicy, xformsBC> bc_;
 };
 
-
-inline
-xformsBC & FormError::bc()
-{
-       return bc_;
-}
-#endif
+#endif // FORMERROR_H
index 30bf53255f5a3bd5cf9b11a106710c9cb200accb..66efb6d0879a9aef9c7c67447056192673c9a41b 100644 (file)
@@ -4,9 +4,10 @@
  * Read the file COPYING
  *
  * \author Alejandro Aguilar Sierra
- * \author John Levon
+ * \author John Levon, moz@compsoc.man.ac.uk
+ * \author Angus Leeming, a.leeming@.ac.uk
  */
-#include <config.h>
+
 #include <algorithm>
 #include <utility>
 
 #pragma implementation
 #endif
 
-#include "Dialogs.h"
+#include <config.h>
+#include "xformsBC.h"
+#include "ControlInclude.h"
 #include "FormInclude.h"
+#include "form_include.h"
 #include "insets/insetinclude.h"
+
 #include "frontends/FileDialog.h"
-#include "support/filetools.h"
-#include "support/lstrings.h"
 #include "LyXView.h"
 #include "buffer.h"
-#include "lyxrc.h"
-#include "lyxfunc.h"
-#include "xforms_helpers.h"
 
-#include "form_include.h"
+#include "xforms_helpers.h" // setEnabled
+#include "support/filetools.h"
+#include "support/lstrings.h"
+#include "lyxrc.h"
 
 using std::make_pair;
 using std::pair;
-using SigC::slot;
-
-FormInclude::FormInclude(LyXView * lv, Dialogs * d)
-       : FormBaseBD(lv, d, _("Include file")),
-         ih_(0), inset_(0)
-{
-       d->showInclude.connect(slot(this, &FormInclude::showInclude));
-}
 
+typedef FormCB<ControlInclude, FormDB<FD_form_include> > base_class;
 
-FL_FORM * FormInclude::form() const
-{
-       if (dialog_.get()) 
-               return dialog_->form;
-       return 0;
-}
-
-
-void FormInclude::connect()
-{
-       u_ = d_->updateBufferDependent.
-                connect(slot(this, &FormInclude::updateSlot));
-       h_ = d_->hideBufferDependent.
-                connect(slot(this, &FormInclude::hide));
-       FormBaseDeprecated::connect();
-}
-
-
-void FormInclude::disconnect()
-{
-       ih_.disconnect();
-       FormBaseBD::disconnect();
-       inset_ = 0;
-}
-
-
-void FormInclude::updateSlot(bool switched)
-{
-       if (switched)
-               hide();
-       else
-               update();
-}
+FormInclude::FormInclude(ControlInclude & c)
+       : base_class(c, _("Include file"))
+{}
 
 
 void FormInclude::build()
@@ -80,36 +46,21 @@ void FormInclude::build()
        dialog_.reset(build_include());
 
        // Manage the ok and cancel buttons
-       bc_.setOK(dialog_->button_ok);
-       bc_.setCancel(dialog_->button_cancel);
-       bc_.refresh();
-
-       bc_.addReadOnly(dialog_->button_browse);
-       bc_.addReadOnly(dialog_->check_verbatim);
-       bc_.addReadOnly(dialog_->check_typeset);
-       bc_.addReadOnly(dialog_->check_useinput);
-       bc_.addReadOnly(dialog_->check_useinclude);
-}
-
-
-void FormInclude::showInclude(InsetInclude * inset)
-{
-       // If connected to another inset, disconnect from it.
-       if (inset_)
-               ih_.disconnect();
-
-       inset_    = inset;
-       params    = inset->params();
-       ih_ = inset->hideDialog.connect(slot(this, &FormInclude::hide));
-       show();
+       bc().setOK(dialog_->button_ok);
+       bc().setCancel(dialog_->button_cancel);
+       bc().refresh();
+
+       bc().addReadOnly(dialog_->button_browse);
+       bc().addReadOnly(dialog_->check_verbatim);
+       bc().addReadOnly(dialog_->check_typeset);
+       bc().addReadOnly(dialog_->check_useinput);
+       bc().addReadOnly(dialog_->check_useinclude);
 }
 
 
 void FormInclude::update()
 {
-       bc().readOnly(lv_->buffer()->isReadonly());
-
-       if (!inset_) {
+       if (controller().params().noload) {
                fl_set_input(dialog_->input_filename, "");
                fl_set_button(dialog_->check_typeset, 0);
                fl_set_button(dialog_->check_useinput, 0);
@@ -121,11 +72,13 @@ void FormInclude::update()
                return;
        }
 
-       fl_set_input(dialog_->input_filename, params.cparams.getContents().c_str());
+       fl_set_input(dialog_->input_filename,
+                    controller().params().cparams.getContents().c_str());
 
-       string const cmdname = params.cparams.getCmdName();
+       string const cmdname = controller().params().cparams.getCmdName();
 
-       fl_set_button(dialog_->check_typeset, int(params.noload));
+       fl_set_button(dialog_->check_typeset,
+                     int(controller().params().noload));
 
        fl_set_button(dialog_->check_useinput, cmdname == "input");
        fl_set_button(dialog_->check_useinclude, cmdname == "include");
@@ -145,86 +98,85 @@ void FormInclude::update()
 
 void FormInclude::apply()
 {
-       if (lv_->buffer()->isReadonly())
-               return;
+       controller().params().noload = fl_get_button(dialog_->check_typeset);
 
-       params.noload = fl_get_button(dialog_->check_typeset);
-
-       params.cparams.setContents(fl_get_input(dialog_->input_filename));
+       controller().params().cparams.
+               setContents(fl_get_input(dialog_->input_filename));
 
        if (fl_get_button(dialog_->check_useinput))
-               params.flag = InsetInclude::INPUT;
+               controller().params().flag = InsetInclude::INPUT;
        else if (fl_get_button(dialog_->check_useinclude))
-               params.flag = InsetInclude::INCLUDE;
+               controller().params().flag = InsetInclude::INCLUDE;
        else if (fl_get_button(dialog_->check_verbatim)) {
                if (fl_get_button(dialog_->check_visiblespace))
-                       params.flag = InsetInclude::VERBAST;
+                       controller().params().flag = InsetInclude::VERBAST;
                else
-                       params.flag = InsetInclude::VERB;
+                       controller().params().flag = InsetInclude::VERB;
        }
-       
-       inset_->setFromParams(params);
-       lv_->view()->updateInset(inset_, true);
 }
 
-#ifdef WITH_WARNINGS
-#warning convert this to use the buttoncontroller
-#endif
-bool FormInclude::input(FL_OBJECT *, long data)
+
+ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
 {
-       State state = static_cast<State>(data);
+       if (ob == dialog_->button_browse)
+               return inputBrowse();
+
+       if (ob == dialog_->button_load) {
+               if (compare(fl_get_input(dialog_->input_filename),"")) {
+                       ApplyButton();
+                       return ButtonPolicy::SMI_NOOP;
+               }
+       }
 
-       switch (state) {
-               case BROWSE: {
-                       // Should browsing too be disabled in RO-mode?
-                       FileDialog fileDlg(lv_, _("Select document to include"),
-                               LFUN_SELECT_FILE_SYNC,
-                               make_pair(string(_("Documents")), string(lyxrc.document_path)));
+       if (ob == dialog_->check_verbatim) {
+               setEnabled(dialog_->check_visiblespace, true);
 
-                       string ext;
-                  
-                       /* input TeX, verbatim, or LyX file ? */
-                       if (fl_get_button(dialog_->check_useinput))
-                               ext = _("*.tex| LaTeX Documents (*.tex)");
-                       else if (fl_get_button(dialog_->check_verbatim))
-                               ext = _("*| All files ");
-                       else
-                               ext = _("*.lyx| LyX Documents (*.lyx)");
+       } else if (ob == dialog_->check_useinclude ||
+                  ob == dialog_->check_useinput) {
+               fl_set_button(dialog_->check_visiblespace, 0);
+               setEnabled(dialog_->check_visiblespace, false);
+       }
        
-                       string mpath;
-
-                       mpath = OnlyPath(params.buffer->fileName());
-
-                       FileDialog::Result result = fileDlg.Select(mpath, ext, fl_get_input(dialog_->input_filename));
+       return ButtonPolicy::SMI_VALID;
+}
        
-                       // check selected filename
-                       if (result.second.empty())
-                               break;
+
+ButtonPolicy::SMInput FormInclude::inputBrowse()
+{
+       // Should browsing too be disabled in RO-mode?
+       FileDialog fileDlg(controller().lv(),
+                          _("Select document to include"),
+                          LFUN_SELECT_FILE_SYNC,
+                          make_pair(string(_("Documents")),
+                                    string(lyxrc.document_path)));
+
+       string ext;
+                  
+       // input TeX, verbatim, or LyX file ?
+       if (fl_get_button(dialog_->check_useinput))
+               ext = _("*.tex| LaTeX Documents (*.tex)");
+       else if (fl_get_button(dialog_->check_verbatim))
+               ext = _("*| All files ");
+       else
+               ext = _("*.lyx| LyX Documents (*.lyx)");
        
-                       string const filename2 = MakeRelPath(result.second, mpath);
+       string const mpath =
+               OnlyPath(controller().params().masterFilename_);
+
+       FileDialog::Result const result =
+               fileDlg.Select(mpath, ext,
+                              fl_get_input(dialog_->input_filename));
        
-                       if (prefixIs(filename2, ".."))
-                               fl_set_input(dialog_->input_filename, result.second.c_str());
-                       else
-                               fl_set_input(dialog_->input_filename, filename2.c_str());
-
-               }       break;
-
-               case LOAD:
-                       if (compare(fl_get_input(dialog_->input_filename),"")) {
-                               apply();
-                               lv_->getLyXFunc()->Dispatch(LFUN_CHILDOPEN, params.cparams.getContents());
-                       }
-                       break;
-
-               case VERBATIM:
-                       setEnabled(dialog_->check_visiblespace, true);
-                       break;
+       // check selected filename
+       if (result.second.empty())
+               return ButtonPolicy::SMI_NOOP;
        
-               case INPUTINCLUDE:
-                       fl_set_button(dialog_->check_visiblespace, 0);
-                       setEnabled(dialog_->check_visiblespace, false);
-                       break;
-       }
-       return true;
+       string const filename2 = MakeRelPath(result.second, mpath);
+
+       if (prefixIs(filename2, ".."))
+               fl_set_input(dialog_->input_filename, result.second.c_str());
+       else
+               fl_set_input(dialog_->input_filename, filename2.c_str());
+
+       return ButtonPolicy::SMI_VALID;
 }
index c97ef293de74be603dafd05e0b785fd87a849203..e2f9a7b457aa309fabfda8aa5e230400f5f145c0 100644 (file)
@@ -5,86 +5,42 @@
  * See the file COPYING
  *
  * \author Alejandro Aguilar Sierra
- * \author John Levon
+ * \author John Levon, moz@compsoc.man.ac.uk
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
  */
 #ifndef FORMINCLUDE_H
 #define FORMINCLUDE_H
 
-#include <boost/smart_ptr.hpp>
-
 #ifdef __GNUG__
 #pragma interface
 #endif
 
-#include "FormBaseDeprecated.h"
-#include "insets/insetinclude.h"
+#include "FormBase.h"
 
+class ControlInclude;
 struct FD_form_include;
 
-/** This class provides an XForms implementation of the FormInclude Dialog.
+/** This class provides an XForms implementation of the Include Dialog.
  */
-class FormInclude : public FormBaseBD {
+class FormInclude : public FormCB<ControlInclude, FormDB<FD_form_include> > {
 public:
        ///
-       FormInclude(LyXView *, Dialogs *);
-private:
-       ///
-       enum State {
-               /// the browse button
-               BROWSE = 0,
-               /// the load file button
-               LOAD = 5,
-               /// the verbatim radio choice
-               VERBATIM = 10,
-               /// the input and include radio choices
-               INPUTINCLUDE = 11
-       };
-       /// Pointer to the actual instantiation of the ButtonController.
-       virtual xformsBC & bc();
-       /// Slot launching dialog to an existing inset
-       void showInclude(InsetInclude *);
-
-       /// Connect signals. Also perform any necessary initialisation.
-       virtual void connect();
-       /// Disconnect signals. Also perform any necessary housekeeping.
-       virtual void disconnect();
+       FormInclude(ControlInclude &);
 
+private:
+       /// Set the Params variable for the Controller.
+       virtual void apply();
        /// Build the dialog
        virtual void build();
-       /// Filter the inputs
-       virtual bool input( FL_OBJECT *, long );
        /// Update dialog before showing it
        virtual void update();
-       /// Apply from dialog (modify or create inset)
-       virtual void apply();
-       /// Pointer to the actual instantiation of the xforms form
-       virtual FL_FORM * form() const;
-       /// bool indicates if a buffer switch took place
-       virtual void updateSlot(bool);
-
+       /// Filter the inputs on callback from xforms
+       virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
 
+       ///
+       ButtonPolicy::SMInput inputBrowse();
        /// Type definition from the fdesign produced header file.
        FD_form_include * build_include();
-
-       /// Real GUI implementation.
-       boost::scoped_ptr<FD_form_include> dialog_;
-       /// The ButtonController
-       ButtonController<OkCancelReadOnlyPolicy, xformsBC> bc_;
-
-       /// inset::hide connection.
-       SigC::Connection ih_;
-       /// pointer to the inset passed through showInset
-       InsetInclude * inset_;
-       /// the nitty-gritty. What is modified and passed back
-       InsetInclude::InsetIncludeParams params;
 };
 
-
-inline
-xformsBC & FormInclude::bc()
-{
-  return bc_;
-}
 #endif
index c29073aa34ea237cee6a1cbaed3c937d5cf23b68..591fa980fdc825bc5992b0cf0278a4625db4b7a1 100644 (file)
@@ -34,7 +34,7 @@ FD_form_error * FormError::build_error()
   }
     fl_set_object_gravity(obj, FL_South, FL_South);
     fl_set_object_resize(obj, FL_RESIZE_NONE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0);
+    fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
   fl_end_form();
 
   fdui->form->fdui = fdui;
index 63521193ef2772fcccb4c28ab2f2b5d4796da736..c87a7e2dd5db288eb9b7aed9013ab30f583cd71c 100644 (file)
@@ -5,7 +5,7 @@
 #define FD_form_error_h_
 
 /** Callbacks, globals and object handlers **/
-extern  "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
 
 
 /**** Forms and Objects ****/
index de4d092878e78b8b5a16757c7d787f352631e45a..8e602c31e6048807ccc191d608690cc3bc48c6ab 100644 (file)
@@ -32,7 +32,7 @@ FD_form_include * FormInclude::build_include()
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Don't typeset|#D");
     fdui->check_typeset = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 180, 70, 150, 30, idex(_(dummy)));
@@ -41,21 +41,21 @@ FD_form_include * FormInclude::build_include()
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
   fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 120, 170, 100, 30, _("OK"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedOKCB, 1);
+    fl_set_object_callback(obj, C_FormBaseOKCB, 0);
   {
     char const * const dummy = N_("Cancel|^[");
     fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 230, 170, 100, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 2);
+    fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
   {
     char const * const dummy = N_("Load|#L");
     fdui->button_load = obj = fl_add_button(FL_NORMAL_BUTTON, 230, 130, 100, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 5);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("File name:|#F");
     fdui->input_filename = obj = fl_add_input(FL_NORMAL_INPUT, 10, 30, 210, 30, idex(_(dummy)));
@@ -77,21 +77,21 @@ FD_form_include * FormInclude::build_include()
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 10);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Use input|#i");
     fdui->check_useinput = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 10, 100, 160, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 11);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Use include|#U");
     fdui->check_useinclude = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 10, 70, 160, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 11);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   fl_end_group();
 
   fl_end_form();
index f72e5b2fbe2ee425cc0e5d68ec86f40427a098ba..f7585b4adf42649180a372aa9ea5d291ab982220 100644 (file)
@@ -5,9 +5,9 @@
 #define FD_form_include_h_
 
 /** Callbacks, globals and object handlers **/
-extern  "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long);
-extern  "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT *, long);
-extern  "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseInputCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseOKCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
 
 
 /**** Forms and Objects ****/
index b0af973d9eadb82973c9e97188b17e080d9daadc..e60d43106e7354a531ddd55b269d52efe99b2d63 100644 (file)
@@ -63,7 +63,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_South FL_South
 name: button_cancel
-callback: C_FormBaseDeprecatedCancelCB
+callback: C_FormBaseCancelCB
 argument: 0
 
 ==============================
index 2d2f7ddff46bd88808104bd4c16ef265021dd5cb..8a69831e98ecd713f4190f0fa3118e64953029c4 100644 (file)
@@ -63,8 +63,8 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: button_browse
-callback: C_FormBaseDeprecatedInputCB
-argument: 0
+callback: C_FormBaseInputCB
+argument:
 
 --------------------
 class: FL_CHECKBUTTON
@@ -99,8 +99,8 @@ shortcut: ^M
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: button_ok
-callback: C_FormBaseDeprecatedOKCB
-argument: 1
+callback: C_FormBaseOKCB
+argument:
 
 --------------------
 class: FL_BUTTON
@@ -117,8 +117,8 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: button_cancel
-callback: C_FormBaseDeprecatedCancelCB
-argument: 2
+callback: C_FormBaseCancelCB
+argument:
 
 --------------------
 class: FL_BUTTON
@@ -135,8 +135,8 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: button_load
-callback: C_FormBaseDeprecatedInputCB
-argument: 5
+callback: C_FormBaseInputCB
+argument:
 
 --------------------
 class: FL_INPUT
@@ -207,8 +207,8 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: check_verbatim
-callback: C_FormBaseDeprecatedInputCB
-argument: 10
+callback: C_FormBaseInputCB
+argument:
 
 --------------------
 class: FL_CHECKBUTTON
@@ -225,8 +225,8 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: check_useinput
-callback: C_FormBaseDeprecatedInputCB
-argument: 11
+callback: C_FormBaseInputCB
+argument:
 
 --------------------
 class: FL_CHECKBUTTON
@@ -243,8 +243,8 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: check_useinclude
-callback: C_FormBaseDeprecatedInputCB
-argument: 11
+callback: C_FormBaseInputCB
+argument:
 
 --------------------
 class: FL_END_GROUP
index 4a01622a01e5caec5f0ac3ff59aea73e5e6bf749..0ef55349de32be50eb0ef784bf800b89998ad4e3 100644 (file)
@@ -1,3 +1,9 @@
+2001-03-23  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * insetinclude.[Ch]: rename InsetInclude::InsetIncludeParams as
+       InsetInclude::Params. Don't store a buffer * in Params. Store the
+       master file name instead.
+
 2001-03-23  Juergen Vigna  <jug@sad.it>
 
        * insetcollapsable.C (InsetMotionNotify):
index 42dfa7bd8def2a59d19db20f39640d0680b576b4..52fbee7f33023aeb574638bcfeff5fc60bc81561 100644 (file)
@@ -31,8 +31,8 @@ extern BufferList bufferlist;
 
 namespace {
 
-inline
-string const unique_id() {
+string const unique_id()
+{
        static unsigned int seed = 1000;
 
        std::ostringstream ost;
@@ -45,19 +45,16 @@ string const unique_id() {
 } // namespace anon
 
 
-InsetInclude::InsetInclude(InsetIncludeParams const & p)
-{
-       include_label = unique_id();
-       setFromParams(p);
-       params_.buffer = p.buffer;
-}
+InsetInclude::InsetInclude(Params const & p)
+       : params_(p), include_label(unique_id())
+{}
 
 
 InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer const & b)
 {
+       params_.cparams = p;
+       params_.masterFilename_ = b.fileName();
        include_label = unique_id();
-       params_.buffer = &b;
-       setFromParams(p);
 }
 
 
@@ -67,48 +64,60 @@ InsetInclude::~InsetInclude()
 }
 
 
-InsetInclude::InsetIncludeParams const & InsetInclude::params() const
+InsetInclude::Params const & InsetInclude::params() const
 {
        return params_;
 }
 
 
-void InsetInclude::setFromParams(InsetIncludeParams const & p)
+bool InsetInclude::Params::operator==(Params const & o) const
 {
-       params_.cparams.setContents(p.cparams.getContents());
-       params_.noload = p.noload;
-       if (params_.flag == p.flag)
-               return;
+       if (cparams == o.cparams && flag == o.flag &&
+           noload == o.noload && masterFilename_ == o.masterFilename_)
+               return true;
+       
+       return false;
+}
 
-       params_.flag = p.flag;
 
-       string command;
+bool InsetInclude::Params::operator!=(Params const & o) const
+{
+       return !(*this == o);
+}
+
 
+void InsetInclude::set(Params const & p)
+{
+       params_ = p;
+
+       // Just to be safe...
+       string command;
        switch (params_.flag) {
-               case INCLUDE:
-                       command="include";
-                       break;
-               case VERB:
-                       command="verbatiminput";
-                       break;
-               case INPUT:
-                       command="input";
-                       break;
-               case VERBAST:
-                       command="verbatiminput*";
-                       break;
+               case INCLUDE:
+                       command="include";
+                       break;
+               case VERB:
+                       command="verbatiminput";
+                       break;
+               case INPUT:
+                       command="input";
+                       break;
+               case VERBAST:
+                       command="verbatiminput*";
+                       break;
        }
-
        params_.cparams.setCmdName(command);
 }
 
 
 Inset * InsetInclude::Clone(Buffer const & buffer) const
 {
-       InsetIncludeParams p(params_);
-       p.buffer = &buffer;
+       Params p(params_);
+       p.masterFilename_ = buffer.fileName();
 
-       return new InsetInclude (p);
+       return new InsetInclude(p);
 }
 
 
@@ -184,7 +193,7 @@ string const InsetInclude::getFileName() const
 
 string const InsetInclude::getMasterFilename() const
 {
-       return params_.buffer->fileName();
+       return params_.masterFilename_;
 }
 
 
@@ -367,11 +376,11 @@ void InsetInclude::Validate(LaTeXFeatures & features) const
        string incfile(params_.cparams.getContents());
        string writefile;
 
-       Buffer const & b = *params_.buffer;
+       Buffer const * const b = bufferlist.getBuffer(getMasterFilename());
 
-       if (!b.tmppath.empty() && b.niceFile) {
+       if (b && !b->tmppath.empty() && b->niceFile) {
                incfile = subst(incfile, '/','@');
-               writefile = AddName(b.tmppath, incfile);
+               writefile = AddName(b->tmppath, incfile);
        } else
                writefile = getFileName();
 
@@ -388,8 +397,9 @@ void InsetInclude::Validate(LaTeXFeatures & features) const
        // to be loaded:
        if (loadIfNeeded()) {
                // a file got loaded
-               Buffer * tmp = bufferlist.getBuffer(getFileName());
-               tmp->validate(features);
+               Buffer const * const tmp = bufferlist.getBuffer(getFileName());
+               if (tmp)
+                       tmp->validate(features);
        }
 }
 
index f4a0ef2a39c1b557383e523c00b0cb2788bb9b00..e57afeb0c7e23bd0de8edbaaa4af5591701504eb 100644 (file)
@@ -27,9 +27,9 @@ struct LaTeXFeatures;
 class InsetInclude: public InsetButton, public boost::noncopyable {
 public:
         /// the type of inclusion
-        enum IncludeFlags {
+        enum Flags {
                ///
-               INCLUDE= 0,
+               INCLUDE = 0,
                ///
                VERB = 1,
                ///
@@ -38,30 +38,37 @@ public:
                VERBAST = 3
        };
 
-       struct InsetIncludeParams {
-               InsetIncludeParams(InsetCommandParams const & cp = InsetCommandParams(),
-                       IncludeFlags f = INCLUDE, bool nl = false, Buffer const * b = 0)
-                       : cparams(cp), flag(f), noload(nl), buffer(b) {}
+       struct Params {
+               Params(InsetCommandParams const & cp = InsetCommandParams(),
+                      Flags f = INCLUDE,
+                      bool nl = false,
+                      string const & name = string())
+                       : cparams(cp), flag(f), noload(nl),
+                         masterFilename_(name) {}
                InsetCommandParams cparams;
-               IncludeFlags flag;
+               Flags flag;
                bool noload;
-               Buffer const * buffer;
+               string masterFilename_;
+
+               ///
+               bool operator==(Params const &) const;
+               ///
+               bool operator!=(Params const &) const;
        };
 
        ///
-       InsetInclude(InsetIncludeParams const &);
+       InsetInclude(Params const &);
        ///
        InsetInclude(InsetCommandParams const &, Buffer const &);
        ///
        ~InsetInclude();
 
        /// get the parameters
-       InsetIncludeParams const & params(void) const;
-
+       Params const & params(void) const;
        /// set the parameters
-       void setFromParams(InsetIncludeParams const & params);
+       void set(Params const & params);
 
-        ///
+       ///
         Inset * Clone(Buffer const &) const;
        ///
        Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; }
@@ -118,7 +125,7 @@ private:
         string const getFileName() const;
 
        /// the parameters
-       InsetIncludeParams params_;
+       Params params_;
        ///
        string include_label;
 };