]> git.lyx.org Git - lyx.git/commitdiff
Move the include dialog to the new scheme
authorAngus Leeming <leeming@lyx.org>
Wed, 5 Mar 2003 14:59:37 +0000 (14:59 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 5 Mar 2003 14:59:37 +0000 (14:59 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6353 a592a061-630c-0410-9148-cb99ea01b6c8

36 files changed:
lib/ChangeLog
lib/ui/default.ui
src/BufferView_pimpl.C
src/ChangeLog
src/LyXAction.C
src/commandtags.h
src/factory.C
src/frontends/ChangeLog
src/frontends/Dialogs.h
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlInclude.C
src/frontends/controllers/ControlInclude.h
src/frontends/guiapi.C
src/frontends/guiapi.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/Dialogs.C
src/frontends/qt2/Dialogs2.C
src/frontends/qt2/Dialogs3.C
src/frontends/qt2/Dialogs_impl.h
src/frontends/qt2/QInclude.C
src/frontends/qt2/QInclude.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/Dialogs.C
src/frontends/xforms/Dialogs2.C
src/frontends/xforms/Dialogs3.C
src/frontends/xforms/Dialogs_impl.h
src/frontends/xforms/FormInclude.C
src/frontends/xforms/FormInclude.h
src/frontends/xforms/forms/form_include.fd
src/insets/ChangeLog
src/insets/insetcommandparams.C
src/insets/insetcommandparams.h
src/insets/insetert.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/lyxfunc.C

index 487fa0907d1365c0ac3f9f54b49dd42667b55923..6eac0d4f94f0e03ccdc79f4e34527b6f47ce47cd 100644 (file)
@@ -2,6 +2,7 @@
 
        * ui/default.ui: use 'dialog-show-new-inset "external"' instead
        of 'external-insert'.
+       use "dialog-show-new-inset include" instead of "buffer-child-insert".
 
 2003-03-03  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
index 943924df8348db7bc1ae69b95acef933b52b035b..c3ee7193c71656607eaec4865c2cd16622658e58 100644 (file)
@@ -213,7 +213,7 @@ Menuset
        Item "Tabular Material...|b" "tabular-insert"
        Submenu "Floats|a" "insert_floats"
        Separator
-       Item "Include File...|d" "buffer-child-insert"
+       Item "Include File...|d" "dialog-show-new-inset include"
        Submenu "Insert File|e" "insert_file"
        Item "External Material...|x" "dialog-show-new-inset external"
     End
index cac2fb0e59a4a7cb11d29fc71c422818989e4fbb..c34467edaefdef328265ccda61abfdb5d720f68c 100644 (file)
@@ -1204,23 +1204,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
        }
        break;
 
-       case LFUN_CHILD_INSERT:
-       {
-               InsetInclude::Params p;
-               if (!ev.argument.empty())
-                       p.cparams.setFromString(ev.argument);
-               p.masterFilename_ = buffer_->fileName();
-
-               InsetInclude * inset = new InsetInclude(p);
-               if (!insertInset(inset))
-                       delete inset;
-               else {
-                       updateInset(inset, true);
-                       bv_->owner()->getDialogs().showInclude(inset);
-               }
-       }
-       break;
-
        case LFUN_FLOAT_LIST:
                if (tclass.floats().typeExist(ev.argument)) {
                        Inset * inset = new InsetFloatList(ev.argument);
index 9bd261a94c4998ad526f9ddc056c91390703e338..daee8907ebad4900bf4a3c8317cbd34ad41f27b4 100644 (file)
@@ -1,3 +1,13 @@
+2003-03-05  Angus Leeming  <leeming@lyx.org>
+
+       * commandtags.h:
+       * LyXAction.C (init):
+       * BufferView_pimpl.C (dispatch):
+       * lyxfunc.C (getStatus):
+       remove LFUN_CHILD_INSERT.
+
+       * factory.C (createInset): add "include" to LFUN_INSET_APPLY.
+
 2003-03-05  Angus Leeming  <leeming@lyx.org>
 
        * commandtags.h:
index db96a61f2aca246685c48d345c564f857d9cdcd0..243ee5528c60163fdd0bd786a9ba2f1cc0bd93a1 100644 (file)
@@ -114,7 +114,6 @@ void LyXAction::init()
                  N_("Go to beginning of document"), ReadOnly },
                { LFUN_BEGINNINGBUFSEL, "buffer-begin-select",
                  N_("Select to beginning of document"), ReadOnly },
-               { LFUN_CHILD_INSERT, "buffer-child-insert", "", Noop },
                { LFUN_CHILDOPEN, "buffer-child-open", "", ReadOnly },
                { LFUN_RUNCHKTEX, "buffer-chktex", N_("Check TeX"), ReadOnly },
                { LFUN_CLOSEBUFFER, "buffer-close", N_("Close"), ReadOnly },
index 676af0c27cfdb5a6fca07b803f2bc76d8d1002f9..d17808acbe38a4bc3d251738b3bdb8c40f6513c2 100644 (file)
@@ -196,7 +196,6 @@ enum kb_action {
        LFUN_LAYOUT_COPY,               // Asger 1997-05-04
        LFUN_LAYOUT_PASTE,              // Asger 1997-05-04
        LFUN_TABINSERT, // 180          // Ale 970515
-       LFUN_CHILD_INSERT,              // Ale 970521
        LFUN_CHILDOPEN,                 // Ale 970528
        LFUN_TOC_INSERT,                // Lgb 97-05-27
        LFUN_FLOAT_LIST,                // Lgb 20010503
index e863e929bdf70b17424f5f1681ca01d3a3af9e74..57e30700933bb317ae84e5ea665cdd1ee4270719 100644 (file)
@@ -26,6 +26,7 @@
 #include "insets/insetexternal.h"
 #include "insets/insetfloat.h"
 #include "insets/insetfoot.h"
+#include "insets/insetinclude.h"
 #include "insets/insetindex.h"
 #include "insets/insetlabel.h"
 #include "insets/insetmarginal.h"
@@ -191,6 +192,11 @@ Inset * createInset(FuncRequest const & cmd)
                        inset->setFromParams(iep);
                        return inset;
 
+               } else if (name == "include") {
+                       InsetInclude::Params iip;
+                       InsetIncludeMailer::string2params(cmd.argument, iip);
+                       return new InsetInclude(iip);
+
                } else if (name == "index") {
                        InsetCommandParams icp;
                        InsetCommandMailer::string2params(cmd.argument, icp);
index 20b441b99d80e6f2e4006ca62823814788370a9a..7785c5e7d5d8ed8c02de33584db75824649192d6 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-05  Angus Leeming  <leeming@lyx.org>
+
+       * Dialogs.h: remove showInclude.
+       * guiapi.[Ch]: remove gui_ShowInclude.
+
 2003-03-05  Angus Leeming  <leeming@lyx.org>
 
        * Dialogs.h: remove showExternal.
index c5f0b26f551eeab8c47236b1e2793aae5cf849ce..03a8b060cc4d933d6879d8b805ed4b8d90f23ba6 100644 (file)
@@ -26,7 +26,6 @@ class LyXView;
 class InsetFloat;
 class InsetWrap;
 class InsetGraphics;
-class InsetInclude;
 class InsetInfo;
 class InsetMinipage;
 class Paragraph;
@@ -96,8 +95,6 @@ public:
        void showForks();
        ///
        void showGraphics(InsetGraphics *);
-       /// show the details of a LyX file include inset
-       void showInclude(InsetInclude *);
        /// show the LaTeX log or build file
        void showLogFile();
        /// display the top-level maths panel
index ab53904fac49cc45458a964b68b7f80856e92543..4c263b33fe2f65a28edb7628af6182d28fbf6c83 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-05  Angus Leeming  <leeming@lyx.org>
+
+       * ControlInclude.[Ch]: rewrite to use the Dialog-based scheme.
+
 2003-03-05  Angus Leeming  <leeming@lyx.org>
 
        * ControlExternal.[Ch]: rewrite to use the Dialog-based scheme.
index 4e6282c677ef642f19e88ee604471fc3ef28c135..5d8639ce902c3aaed5fa98bec171d08b7a57ab87 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <config.h>
 
-
 #include "ControlInclude.h"
 
 #include "helper_funcs.h"
 using std::pair;
 
 
-ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
-       : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
+ControlInclude::ControlInclude(Dialog & parent)
+       : Dialog::Controller(parent)
 {}
 
 
-void ControlInclude::applyParamsToInset()
+void ControlInclude::initialiseParams(string const & data)
+{
+       InsetInclude::Params params;
+       InsetIncludeMailer::string2params(data, params);
+       inset_.reset(new InsetInclude(params));
+}
+
+
+void ControlInclude::clearParams()
+{
+       inset_.reset();
+}
+
+
+void ControlInclude::dispatchParams()
 {
-       inset()->set(params());
-       bufferview()->updateInset(inset(), true);
+       InsetInclude::Params p = params();
+       string const lfun = InsetIncludeMailer::params2string("include", p);
+       kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
 }
 
 
+void ControlInclude::setParams(InsetInclude::Params const & params)
+{
+       inset_->set(params);
+}
+
 string const ControlInclude::Browse(string const & in_name, Type in_type)
 {
        string const title = _("Select document to include");
@@ -75,7 +94,7 @@ string const ControlInclude::Browse(string const & in_name, Type in_type)
 
 void ControlInclude::load(string const & file)
 {
-       lyxfunc().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
+       kernel().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
 }
 
 
index af0ffd700b9696cc1b50c5d2ac9ebf995e3f7eff..06f7056006bdc3c35637ec5faed16605613ee3a5 100644 (file)
 #define CONTROLINCLUDE_H
 
 
-#include "ControlInset.h"
+#include "Dialog.h"
 #include "insets/insetinclude.h" // InsetIncludeParams
 
+
 /** A controller for the Include file dialog.
  */
-class ControlInclude
-       : public ControlInset<InsetInclude, InsetInclude::Params>
-{
+class ControlInclude : public Dialog::Controller {
 public:
        ///
        enum Type {
@@ -34,7 +33,22 @@ public:
                INCLUDE
        };
        ///
-       ControlInclude(LyXView &, Dialogs &);
+       ControlInclude(Dialog &);
+
+       ///
+       virtual void initialiseParams(string const & data);
+       /// clean-up on hide.
+       virtual void clearParams();
+       /// clean-up on hide.
+       virtual void dispatchParams();
+       ///
+       virtual bool isBufferDependent() const { return true; }
+
+       ///
+       InsetInclude::Params const & params() const 
+               { return inset_->params(); }
+       ///
+       void setParams(InsetInclude::Params const &);
 
        /// Browse for a file
        string const Browse(string const &, Type);
@@ -45,17 +59,8 @@ public:
        /// test if file exist
        bool fileExists(string const & file);
 private:
-       /// Dispatch the changed parameters to the kernel.
-       virtual void applyParamsToInset();
-       /// Should be used but currently isn't
-       virtual void applyParamsNoInset() {}
-       /// 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();
-       }
+       ///
+       boost::scoped_ptr<InsetInclude> inset_;
 };
+
 #endif // CONTROLINCLUDE_H
index 2224339997149d67dc0a81ab3436a758d9a58150..bb28ee521154c5c03ff4a7dc240d85bd5f9f83fe 100644 (file)
@@ -74,12 +74,6 @@ void gui_ShowGraphics(InsetGraphics * ig, Dialogs & d)
 }
 
 
-void gui_ShowInclude(InsetInclude * ii, Dialogs & d)
-{
-       d.showInclude(ii);
-}
-
-
 void gui_ShowLogFile(Dialogs & d)
 {
        d.showLogFile();
index a07d4d944e728db68b386e4e0b5e4ba1d6637c95..b5d9e35a5354c450cc889af0e44d5086ce8a9c1a 100644 (file)
@@ -19,7 +19,6 @@ class Dialogs;
 class InsetFloat;
 class InsetWrap;
 class InsetGraphics;
-class InsetInclude;
 class InsetMinipage;
 class InsetTabular;
 
@@ -35,7 +34,6 @@ void gui_ShowFile(string const &, Dialogs &);
 void gui_ShowFloat(InsetFloat *, Dialogs &);
 void gui_ShowForks(Dialogs &);
 void gui_ShowGraphics(InsetGraphics *, Dialogs &);
-void gui_ShowInclude(InsetInclude *, Dialogs &);
 void gui_ShowLogFile(Dialogs &);
 void gui_ShowMathPanel(Dialogs &);
 void gui_ShowMinipage(InsetMinipage *, Dialogs &);
index 11f6d9c0069448f26506e498bda01ffb605478b2..af19308ef41d77b262d1e0a760cb7beff81fb0f6 100644 (file)
@@ -1,3 +1,13 @@
+2003-03-05  Angus Leeming  <leeming@lyx.org>
+
+       * QInclude.[Ch]: changes to use the new Dialog-based scheme.
+
+       * Dialogs.C:
+       * Dialogs2.C:
+       * Dialogs_impl.h: remove include dialog.
+
+       * Dialogs3.C: add include dialog.
+
 2003-03-05  Angus Leeming  <leeming@lyx.org>
 
        * QExternal.[Ch]: changes to use the new Dialog-based scheme.
index ca1cb58bbedd50d2700dd51b605d6331e2f86fdc..0b6074f98529285a6fff3a67cf470b036f84c3a6 100644 (file)
@@ -33,7 +33,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
          file(lv, d),
          floats(lv, d),
          graphics(lv, d),
-         include(lv, d),
          logfile(lv, d),
          minipage(lv, d),
          paragraph(lv, d),
index b489b386d878228fe7b081b531c8169a182ff910..d8a702bd28ac60ab613a4f9cd5e95e7d712ab53b 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <config.h>
 
-
 #include "Dialogs_impl.h"
 
 
@@ -68,12 +67,6 @@ void Dialogs::showGraphics(InsetGraphics * ig)
 }
 
 
-void Dialogs::showInclude(InsetInclude * ii)
-{
-       pimpl_->include.controller().showInset(ii);
-}
-
-
 void Dialogs::showLogFile()
 {
        pimpl_->logfile.controller().show();
index 9c8bdeee279e284ff5311a50baf45c66148077a2..26883fbb593b655295d0bfac6e02ed9fab812e69 100644 (file)
@@ -19,6 +19,7 @@
 #include "ControlError.h"
 #include "ControlERT.h"
 #include "ControlExternal.h"
+#include "ControlInclude.h"
 #include "ControlIndex.h"
 #include "ControlLabel.h"
 #include "ControlRef.h"
@@ -41,6 +42,8 @@
 // of the Qt headers, those most fucked up of disgusting ratholes.
 // But I won't.
 #undef signals
+#include "QInclude.h"
+#include "QIncludeDialog.h"
 #include "QIndex.h"
 #include "QIndexDialog.h"
 #include "QRef.h"
@@ -67,12 +70,11 @@ typedef ButtonController<OkApplyCancelReadOnlyPolicy, Qt2BC>
 typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, Qt2BC>
        NoRepeatedApplyReadOnlyBC;
 
-
 namespace {
 
 char const * const dialognames[] = { "bibitem", "bibtex", "citation",
-                                    "error", "ert", "external", "index",
-                                    "label", "ref", "toc", "url" };
+                                    "error", "ert", "external", "include",
+                                    "index", "label", "ref", "toc", "url" };
 
 char const * const * const end_dialognames =
        dialognames + (sizeof(dialognames) / sizeof(char *));
@@ -128,6 +130,10 @@ Dialog * Dialogs::build(string const & name)
                dialog->setController(new ControlExternal(*dialog));
                dialog->setView(new QExternal(*dialog));
                dialog->setButtonController(new OkApplyCancelReadOnlyBC);
+       } else if (name == "include") {
+               dialog->setController(new ControlInclude(*dialog));
+               dialog->setView(new QInclude(*dialog));
+               dialog->setButtonController(new OkApplyCancelReadOnlyBC);
        } else if (name == "index") {
                dialog->setController(new ControlIndex(*dialog));
                dialog->setView(new QIndex(*dialog,
index 9918ace7f5928ad84dcddf1fa469bab5e9610985..9c2f9ea964afef62c04f835bb68216b762db71fe 100644 (file)
@@ -11,7 +11,6 @@
 #ifndef DIALOGS_IMPL_H
 #define DIALOGS_IMP_H
 
-
 #include "Dialogs.h"
 #include "controllers/GUI.h"
 
@@ -23,7 +22,6 @@
 #include "ControlForks.h"
 #include "ControlGraphics.h"
 #include "insets/insetgraphicsParams.h"
-#include "ControlInclude.h"
 #include "ControlLog.h"
 #include "ControlMinipage.h"
 #include "ControlParagraph.h"
@@ -56,8 +54,6 @@
 #undef signals
 #include "QGraphics.h"
 #include "QGraphicsDialog.h"
-#include "QInclude.h"
-#include "QIncludeDialog.h"
 #include "QLog.h"
 #include "QLogDialog.h"
 #include "QMinipage.h"
@@ -119,9 +115,6 @@ FloatDialog;
 typedef GUI<ControlGraphics, QGraphics, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
 GraphicsDialog;
 
-typedef GUI<ControlInclude, QInclude, OkCancelReadOnlyPolicy, Qt2BC>
-IncludeDialog;
-
 typedef GUI<ControlLog, QLog, OkCancelPolicy, Qt2BC>
 LogFileDialog;
 
@@ -177,7 +170,6 @@ struct Dialogs::Impl {
        FileDialog          file;
        FloatDialog         floats;
        GraphicsDialog      graphics;
-       IncludeDialog       include;
        LogFileDialog       logfile;
        MinipageDialog      minipage;
        ParagraphDialog     paragraph;
index c9f9266c5eb6fa0fdca3e3d87e22677b9132b15e..352866a2e39610f026db74328fcacbc464874191 100644 (file)
 #include <qcombobox.h>
 
 
-typedef Qt2CB<ControlInclude, Qt2DB<QIncludeDialog> > base_class;
+typedef QController<ControlInclude, QView<QIncludeDialog> > base_class;
 
 
-QInclude::QInclude()
-       : base_class(qt_("LyX: Include File"))
-{
-}
+QInclude::QInclude(Dialog & parent)
+       : base_class(parent, qt_("LyX: Include File"))
+{}
 
 
 void QInclude::build_dialog()
@@ -82,7 +81,7 @@ void QInclude::update_contents()
 
 void QInclude::apply()
 {
-       InsetInclude::Params params = controller().params();
+       InsetInclude::Params params = controller().params();
 
        params.cparams.setContents(fromqstr(dialog_->filenameED->text()));
        params.cparams.preview(dialog_->previewCB->isChecked());
@@ -98,6 +97,7 @@ void QInclude::apply()
                else
                        params.flag = InsetInclude::VERB;
        }
+       controller().setParams(params);
 }
 
 
index 766e76c0484cfdefea1f21bb7ff8ca9027163851..0c77bc81fd8f93ab5362fd37d63cc778c0d0b186 100644 (file)
 #define QINCLUDE_H
 
 
-#include "Qt2Base.h"
+#include "QDialogView.h"
+
 
 class ControlInclude;
 class QIncludeDialog;
 
 ///
-class QInclude
-       : public Qt2CB<ControlInclude, Qt2DB<QIncludeDialog> >
+class QInclude : public QController<ControlInclude, QView<QIncludeDialog> >
 {
 public:
        ///
        friend class QIncludeDialog;
        ///
-       QInclude();
+       QInclude(Dialog &);
 protected:
        virtual bool isValid();
 private:
index 4316e65b6b8899de1c6ed16790714798a74f3d09..a45bafa0a9ccd0d465fe0ebafe6e622c50feb5c7 100644 (file)
@@ -1,3 +1,14 @@
+2003-03-05  Angus Leeming  <leeming@lyx.org>
+
+       * FormInclude.[Ch]:
+       * forms/form_include.fd: changes to use the new Dialog-based scheme.
+
+       * Dialogs.C:
+       * Dialogs2.C:
+       * Dialogs_impl.h: remove include dialog.
+
+       * Dialogs3.C: add include dialog.
+
 2003-03-05  Angus Leeming  <leeming@lyx.org>
 
        * FormExternal.[Ch]:
index 082c909f9d21e23023de5bde5753d41a1b1fd3b1..94fbd92e1ca461456200b9321b625a5d4018b8b0 100644 (file)
@@ -34,7 +34,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
          floats(lv, d),
          forks(lv, d),
          graphics(lv, d),
-         include(lv, d),
          logfile(lv, d),
          mathpanel(lv, d),
          minipage(lv, d),
index 1b4948418674135a79fcf572d921a5c0f0d91693..44fd17852430fc51708dc95ca041783433cb49bd 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <config.h>
 
-
 #include "Dialogs_impl.h"
 
 
@@ -70,12 +69,6 @@ void Dialogs::showGraphics(InsetGraphics * ig)
 }
 
 
-void Dialogs::showInclude(InsetInclude * ii)
-{
-       pimpl_->include.controller().showInset(ii);
-}
-
-
 void Dialogs::showLogFile()
 {
        pimpl_->logfile.controller().show();
index 8146d51ec67814b1537f5394ad43d3fb77594692..68cfcb9299ca5527a3b7e2122150ea96c8771fcb 100644 (file)
 #include "FormExternal.h"
 #include "forms/form_external.h"
 
+#include "ControlInclude.h"
+#include "FormInclude.h"
+#include "forms/form_include.h"
+
 #include "ControlIndex.h"
 #include "ControlLabel.h"
 
@@ -73,6 +77,7 @@ typedef ButtonController<OkApplyCancelReadOnlyPolicy, xformsBC>
 typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC>
        NoRepeatedApplyReadOnlyBC;
 
+
 namespace {
 
 // char const * const dialognames[] = { "bibitem", "bibtex", "citation",
@@ -81,8 +86,8 @@ namespace {
 //                                  "minipage", "ref", "tabular", "toc",
 //                                  "url", "wrap" };
 char const * const dialognames[] = { "bibitem", "bibtex", "citation",
-                                    "error", "ert", "external", "index",
-                                    "label", "ref", "toc", "url" };
+                                    "error", "ert", "external", "include",
+                                    "index", "label", "ref", "toc", "url" };
 
 char const * const * const end_dialognames =
        dialognames + (sizeof(dialognames) / sizeof(char *));
@@ -138,6 +143,10 @@ Dialog * Dialogs::build(string const & name)
                dialog->setController(new ControlExternal(*dialog));
                dialog->setView(new FormExternal(*dialog));
                dialog->setButtonController(new OkApplyCancelReadOnlyBC);
+       } else if (name == "include") {
+               dialog->setController(new ControlInclude(*dialog));
+               dialog->setView(new FormInclude(*dialog));
+               dialog->setButtonController(new OkApplyCancelReadOnlyBC);
        } else if (name == "index") {
                dialog->setController(new ControlIndex(*dialog));
                dialog->setView(new FormText(*dialog,
index 2675704317d7b6d71065f1e6d38970f51f279b84..3d29405c15a40101ae16adb357db9f3fc5e595f9 100644 (file)
@@ -11,7 +11,6 @@
 #ifndef DIALOGS_IMPL_H
 #define DIALOGS_IMP_H
 
-
 #include "Dialogs.h"
 #include "controllers/GUI.h"
 
 #include "FormGraphics.h"
 #include "forms/form_graphics.h"
 
-#include "ControlInclude.h"
-#include "FormInclude.h"
-#include "forms/form_include.h"
-
 #include "ControlLog.h"
 #include "FormLog.h"
 
@@ -146,9 +141,6 @@ ForksDialog;
 typedef GUI<ControlGraphics, FormGraphics, NoRepeatedApplyReadOnlyPolicy, xformsBC>
 GraphicsDialog;
 
-typedef GUI<ControlInclude, FormInclude, OkCancelReadOnlyPolicy, xformsBC>
-IncludeDialog;
-
 typedef GUI<ControlLog, FormLog, OkCancelPolicy, xformsBC>
 LogFileDialog;
 
@@ -210,7 +202,6 @@ struct Dialogs::Impl {
        FloatDialog         floats;
        ForksDialog         forks;
        GraphicsDialog      graphics;
-       IncludeDialog       include;
        LogFileDialog       logfile;
        MathPanelDialog     mathpanel;
        MinipageDialog      minipage;
index 7cab61e6a0ffae5dfb6827100c2c9fb6afb7ea76..0ff8250415d4eaea911da98444bcce4126e3fb74 100644 (file)
 #include "support/lstrings.h" // strip
 #include FORMS_H_LOCATION
 
-typedef FormCB<ControlInclude, FormDB<FD_include> > base_class;
+typedef FormController<ControlInclude, FormView<FD_include> > base_class;
 
-FormInclude::FormInclude()
-       : base_class(_("Include file"))
+FormInclude::FormInclude(Dialog & parent)
+       : base_class(parent, _("Include file"))
 {}
 
 
@@ -113,26 +113,29 @@ void FormInclude::update()
 
 void FormInclude::apply()
 {
-       controller().params().cparams
-               .preview(fl_get_button(dialog_->check_preview));
+       InsetInclude::Params params = controller().params();
+
+       params.cparams.preview(fl_get_button(dialog_->check_preview));
 
        string const file = fl_get_input(dialog_->input_filename);
        if (controller().fileExists(file))
-               controller().params().cparams.setContents(file);
+               params.cparams.setContents(file);
        else
-               controller().params().cparams.setContents("");
+               params.cparams.setContents("");
 
        ControlInclude::Type const type = ControlInclude::Type(type_.get());
        if (type == ControlInclude::INPUT)
-               controller().params().flag = InsetInclude::INPUT;
+               params.flag = InsetInclude::INPUT;
        else if (type == ControlInclude::INCLUDE)
-               controller().params().flag = InsetInclude::INCLUDE;
+               params.flag = InsetInclude::INCLUDE;
        else if (type == ControlInclude::VERBATIM) {
                if (fl_get_button(dialog_->check_visiblespace))
-                       controller().params().flag = InsetInclude::VERBAST;
+                       params.flag = InsetInclude::VERBAST;
                else
-                       controller().params().flag = InsetInclude::VERB;
+                       params.flag = InsetInclude::VERB;
        }
+
+       controller().setParams(params);
 }
 
 
@@ -151,7 +154,7 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
        } else if (ob == dialog_->button_load) {
                string const in_name = fl_get_input(dialog_->input_filename);
                if (!rtrim(in_name).empty() && controller().fileExists(in_name)) {
-                       controller().OKButton();
+                       dialog().OKButton();
                        controller().load(rtrim(in_name));
                        action = ButtonPolicy::SMI_NOOP;
                }
index 1041b02b3feb67a56514e613575494defa9b1002..cfa8504035bf687d617d4c8de291aca9d24c3f5c 100644 (file)
 #define FORMINCLUDE_H
 
 
-#include "FormBase.h"
+#include "FormDialogView.h"
 #include "RadioButtonGroup.h"
 
+
 class ControlInclude;
 struct FD_include;
 
 /** This class provides an XForms implementation of the Include Dialog.
  */
-class FormInclude : public FormCB<ControlInclude, FormDB<FD_include> > {
+class FormInclude
+       : public FormController<ControlInclude, FormView<FD_include> > {
 public:
        ///
-       FormInclude();
+       FormInclude(Dialog &);
 private:
        /// Set the Params variable for the Controller.
        virtual void apply();
index c414020d605e30f4fe67ec124643877826880449..f4f833022a6709228dece98d010e407d5269d231 100644 (file)
@@ -64,7 +64,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_NorthEast FL_NorthEast
 name: button_browse
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -82,7 +82,7 @@ shortcut: ^M
 resize: FL_RESIZE_NONE
 gravity: FL_SouthEast FL_SouthEast
 name: button_ok
-callback: C_FormBaseOKCB
+callback: C_FormDialogView_OKCB
 argument: 0
 
 --------------------
@@ -100,7 +100,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_SouthEast FL_SouthEast
 name: button_close
-callback: C_FormBaseCancelCB
+callback: C_FormDialogView_CancelCB
 argument: 0
 
 --------------------
@@ -118,7 +118,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_NorthWest FL_North
 name: button_load
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -136,7 +136,7 @@ shortcut:
 resize: FL_RESIZE_X
 gravity: FL_NorthWest FL_NorthEast
 name: input_filename
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -154,7 +154,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_NorthWest FL_North
 name: check_visiblespace
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -190,7 +190,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_NorthWest FL_NorthWest
 name: radio_verbatim
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -208,7 +208,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_NorthWest FL_NorthWest
 name: radio_useinput
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
        value: 1
 
@@ -227,7 +227,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_NorthWest FL_NorthWest
 name: radio_useinclude
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
@@ -263,7 +263,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_NorthWest FL_North
 name: check_preview
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
 argument: 0
 
 ==============================
index e47b49fc345d3d948eb493c0f726ea4f09a10e1e..fc5ef6e282e39f1d1ed5cd72996deea5ebeb93d0 100644 (file)
@@ -1,3 +1,10 @@
+2003-03-05  Angus Leeming  <leeming@lyx.org>
+
+       * insetcommandparams.[Ch] (getAsString, setFromString): remove.
+
+       * insetinclude.[Ch]: define a new class InsetIncludeMailer and use
+       it to communicate with the frontend dialogs.
+
 2003-03-05  Angus Leeming  <leeming@lyx.org>
 
        * insetexternal.[Ch]: define a new class InsetExternalMailer and use
index 5d1976f58d85db4bdd932937b999adecad396b1b..82a4056cbee398a65c25c7ba5a328873b6429133 100644 (file)
@@ -32,36 +32,6 @@ InsetCommandParams::InsetCommandParams(string const & n,
 {}
 
 
-string const InsetCommandParams::getAsString() const
-{
-       return cmdname + "|++|" + contents + "|++|" + options;
-}
-
-
-void InsetCommandParams::setFromString(string const & b)
-{
-       string::size_type idx = b.find("|++|");
-       if (idx == string::npos) {
-               cmdname = b;
-               contents = "";
-               options = "";
-               return;
-       }
-
-       cmdname = b.substr(0, idx);
-       string tmp = b.substr(idx+4);
-
-       idx = tmp.find("|++|");
-       if (idx == string::npos) {
-               contents = tmp;
-               options = "";
-       } else {
-               contents  = tmp.substr(0, idx);
-               options = tmp.substr(idx+4);
-       }
-}
-
-
 void InsetCommandParams::scanCommand(string const & cmd)
 {
        string tcmdname, toptions, tcontents;
index 671cc97fa629fc2325e40a7f81f18240dd4c42d6..ac10b0e97ecf76e805ab769403948745d2f27465 100644 (file)
@@ -51,10 +51,6 @@ public:
        ///
        void setContents(string const & c) { contents = c; }
        ///
-       string const getAsString() const;
-       ///
-       void setFromString(string const &);
-       ///
        bool preview() const { return preview_; }
        ///
        void preview(bool p) { preview_ = p; }
index 4f909b71b5b67bbd83f8ee9a76bef3ebdc4cf488..4d874eaf7b28b4473b8e40c67d784c948f69def4 100644 (file)
@@ -176,5 +176,4 @@ private:
        InsetERT & inset_;
 };
 
-
 #endif
index ae777b330a2765f1906348cc125c8081edd52eef..1df52b8b554304933cf9d6510f98ab3b74aef072 100644 (file)
 #include "bufferlist.h"
 #include "BufferView.h"
 #include "debug.h"
-#include "lyxrc.h"
-#include "LaTeXFeatures.h"
+#include "funcrequest.h"
 #include "gettext.h"
+#include "LaTeXFeatures.h"
+#include "lyxlex.h"
+#include "lyxrc.h"
 
 #include "frontends/Dialogs.h"
 #include "frontends/LyXView.h"
@@ -106,7 +108,26 @@ InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer const & b)
 
 InsetInclude::~InsetInclude()
 {
-       hideDialog();
+       InsetIncludeMailer mailer(*this);
+       mailer.hideDialog();
+}
+
+
+dispatch_result InsetInclude::localDispatch(FuncRequest const & cmd)
+{
+       if (cmd.action != LFUN_INSET_MODIFY)
+               return UNDISPATCHED;
+
+       InsetInclude::Params p;
+       InsetIncludeMailer::string2params(cmd.argument, p);
+       if (p.cparams.getCmdName().empty())
+               return UNDISPATCHED;
+
+       set(p);
+       params_.masterFilename_ = cmd.view()->buffer()->fileName();
+
+       cmd.view()->updateInset(this, true);
+       return DISPATCHED;
 }
 
 
@@ -172,9 +193,10 @@ Inset * InsetInclude::clone(Buffer const & buffer, bool) const
 }
 
 
-void InsetInclude::edit(BufferView * bv, int, int, mouse_button::state)
+void InsetInclude::edit(BufferView *, int, int, mouse_button::state)
 {
-       bv->owner()->getDialogs().showInclude(this);
+       InsetIncludeMailer mailer(*this);
+       mailer.showDialog();
 }
 
 
@@ -586,3 +608,57 @@ void InsetInclude::PreviewImpl::restartLoading()
                view()->updateInset(&parent(), false);
        generatePreview();
 }
+
+
+InsetIncludeMailer::InsetIncludeMailer(InsetInclude & inset)
+       : name_("include"), inset_(inset)
+{}
+
+
+string const InsetIncludeMailer::inset2string() const
+{
+       return params2string(name(), inset_.params());
+}
+
+
+void InsetIncludeMailer::string2params(string const & in,
+                                      InsetInclude::Params & params)
+{
+       params = InsetInclude::Params();
+
+       string name;
+       string body = split(in, name, ' ');
+
+       if (name != "include" || body.empty())
+               return;
+
+       // This is part of the inset proper that is usually swallowed
+       // by Buffer::readInset
+       body = split(body, name, ' ');
+       if (name != "Include")
+               return;
+
+       istringstream data(body);
+       LyXLex lex(0,0);
+       lex.setStream(data);
+
+       InsetInclude inset(params);     
+       inset.read(0, lex);
+       params = inset.params();
+}
+
+
+string const
+InsetIncludeMailer::params2string(string const & name,
+                                 InsetInclude::Params const & params)
+{
+       InsetInclude inset(params);
+       inset.set(params);
+       ostringstream data;
+       data << name << ' ';
+       inset.write(0, data);
+       data << "\\end_inset\n";
+
+       return data.str();
+}
+
index 291f3c8dd918a0b636ca1fc9073564431ffb1526..4c26ce769367a65898a97f9487aad013042d955b 100644 (file)
@@ -15,7 +15,6 @@
 
 #include "insetcommand.h"
 
-#include <boost/signals/signal0.hpp>
 #include <boost/scoped_ptr.hpp>
 
 class Buffer;
@@ -58,6 +57,9 @@ public:
 
        ~InsetInclude();
 
+       ///
+       virtual dispatch_result localDispatch(FuncRequest const & cmd); 
+
        /// Override these InsetButton methods if Previewing
        int ascent(BufferView *, LyXFont const &) const;
        ///
@@ -119,8 +121,6 @@ public:
        ///
        void addPreview(grfx::PreviewLoader &) const;
 
-       /// hide a dialog if about
-       boost::signal0<void> hideDialog;
 private:
        /// get the text displayed on the button
        string const getScreenLabel(Buffer const *) const;
@@ -149,4 +149,28 @@ inline bool InsetInclude::isVerbatim() const
        return params_.flag == VERB || params_.flag == VERBAST;
 }
 
+#include "mailinset.h"
+
+class InsetIncludeMailer : public MailInset {
+public:
+       ///
+       InsetIncludeMailer(InsetInclude & inset);
+       ///
+       virtual Inset & inset() const { return inset_; }
+       ///
+       virtual string const & name() const { return name_; }
+       ///
+       virtual string const inset2string() const;
+       ///
+       static void string2params(string const &, InsetInclude::Params &);
+       ///
+       static string const params2string(string const & name,
+                                         InsetInclude::Params const &);
+private:
+       ///
+       string const name_;
+       ///
+       InsetInclude & inset_;
+};
+
 #endif // INSETINCLUDE_H
index 8821b45569a775d4cb2a96ce2a9bcf24529b8458..b6e957f01ab69f3cdec7f7ec6bc0394631cf495e 100644 (file)
@@ -564,9 +564,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        case LFUN_INDEX_PRINT:
                code = Inset::INDEX_PRINT_CODE;
                break;
-       case LFUN_CHILD_INSERT:
-               code = Inset::INCLUDE_CODE;
-               break;
        case LFUN_TOC_INSERT:
                code = Inset::TOC_CODE;
                break;