diff --git a/lib/ChangeLog b/lib/ChangeLog index 0b946df697..487fa0907d 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2003-03-05 Angus Leeming + + * ui/default.ui: use 'dialog-show-new-inset "external"' instead + of 'external-insert'. + 2003-03-03 Jean-Marc Lasgouttes * doc/LaTeXConfig.lyx.in: really get rid of iletter description diff --git a/lib/ui/default.ui b/lib/ui/default.ui index 979eb0ef0b..943924df83 100644 --- a/lib/ui/default.ui +++ b/lib/ui/default.ui @@ -215,7 +215,7 @@ Menuset Separator Item "Include File...|d" "buffer-child-insert" Submenu "Insert File|e" "insert_file" - Item "External Material...|x" "external-insert" + Item "External Material...|x" "dialog-show-new-inset external" End Menu "insert_special" diff --git a/src/ChangeLog b/src/ChangeLog index d7fb16c609..9bd261a94c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2003-03-05 Angus Leeming + + * commandtags.h: + * LyXAction.C (init): + * src/factory.C (createInset): + * lyxfunc.C (getStatus): + * text3.C (dispatch): + remove LFUN_INSET_EXTERNAL and LFUN_INSERT_URL + + * factory.C (createInset): add "external" to LFUN_INSET_APPLY. + 2003-03-05 Lars Gullik Bjønnes * ParagraphList.C (insert): handle insert right before end() diff --git a/src/LyXAction.C b/src/LyXAction.C index acafbe2bfd..db96a61f2a 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -175,8 +175,6 @@ void LyXAction::init() N_("Remove all error boxes"), ReadOnly }, { LFUN_INSET_ERT, "ert-insert", N_("Insert a new ERT Inset"), Noop }, - { LFUN_INSET_EXTERNAL, "external-insert", - N_("Insert a new external inset"), Noop }, { LFUN_INSET_GRAPHICS, "graphics-insert", N_("Insert Graphics"), Noop }, { LFUN_FILE_INSERT, "file-insert", "", Noop }, @@ -368,7 +366,6 @@ void LyXAction::init() { LFUN_UP, "up", "", ReadOnly }, { LFUN_UPSEL, "up-select", "", ReadOnly }, { LFUN_URL, "url-insert", "", Noop }, - { LFUN_INSERT_URL, "", "internal only", Noop }, { LFUN_VC_CHECKIN, "vc-check-in", "", ReadOnly }, { LFUN_VC_CHECKOUT, "vc-check-out", "", ReadOnly }, { LFUN_VC_HISTORY, "vc-history", "", ReadOnly }, diff --git a/src/commandtags.h b/src/commandtags.h index 085ae4f7a2..676af0c27c 100644 --- a/src/commandtags.h +++ b/src/commandtags.h @@ -243,7 +243,6 @@ enum kb_action { LFUN_LOTVIEW, // Dekel 20000519 LFUN_LOAVIEW, // Dekel 20000519 LFUN_SET_COLOR, // SLior 20000611 - LFUN_INSET_EXTERNAL, // Alstrup 20000609 LFUN_INSET_MARGINAL, // Lgb 20000626 LFUN_INSET_MINIPAGE, // Lgb 20000627 LFUN_INSET_FLOAT, // Lgb 20000627 @@ -255,7 +254,6 @@ enum kb_action { #endif LFUN_INSET_CAPTION, // Lgb 20000718 LFUN_SWITCHBUFFER, // and where is this coming from? - LFUN_INSERT_URL, // Angus 20000726 LFUN_TABULAR_FEATURE, // Jug 20000728 LFUN_LAYOUT_TABULAR, // Jug 20000731 LFUN_SCROLL_INSET, // Jug 20000801 diff --git a/src/factory.C b/src/factory.C index 31ccbb68b3..e863e929bd 100644 --- a/src/factory.C +++ b/src/factory.C @@ -62,9 +62,6 @@ Inset * createInset(FuncRequest const & cmd) case LFUN_INSET_ERT: return new InsetERT(params); - case LFUN_INSET_EXTERNAL: - return new InsetExternal; - case LFUN_INSET_FOOTNOTE: return new InsetFoot(params); @@ -152,13 +149,6 @@ Inset * createInset(FuncRequest const & cmd) return new InsetParent( InsetCommandParams("lyxparent", cmd.argument), *bv->buffer()); - case LFUN_INSERT_URL: - { - InsetCommandParams p; - p.setFromString(cmd.argument); - return new InsetUrl(p); - } - #if 0 case LFUN_INSET_LIST: return new InsetList; @@ -194,6 +184,13 @@ Inset * createInset(FuncRequest const & cmd) inset->status(bv, s); return inset; + } else if (name == "external") { + InsetExternal::Params iep; + InsetExternalMailer::string2params(cmd.argument, iep); + InsetExternal * inset = new InsetExternal; + inset->setFromParams(iep); + return inset; + } else if (name == "index") { InsetCommandParams icp; InsetCommandMailer::string2params(cmd.argument, icp); diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 6ab9d73573..20b441b99d 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,8 @@ +2003-03-05 Angus Leeming + + * Dialogs.h: remove showExternal. + * guiapi.[Ch]: remove gui_ShowExternal. + 2003-02-27 Angus Leeming * screen.C (redraw, greyOut): ensure that the painter is started diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index 2e31183cc3..c5f0b26f55 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -23,9 +23,6 @@ class Dialog; class InsetBase; class LyXView; -class InsetCommand; -class InsetError; -class InsetExternal; class InsetFloat; class InsetWrap; class InsetGraphics; @@ -89,8 +86,6 @@ public: void setUserFreeFont(); /// void showDocument(); - /// show the external inset dialog - void showExternal(InsetExternal *); /// show the contents of a file. void showFile(string const &); /// diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 0cab2480ea..ab53904fac 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,9 @@ +2003-03-05 Angus Leeming + + * ControlExternal.[Ch]: rewrite to use the Dialog-based scheme. + + * Dialog.h: make view() public. Add dialog() methods. + 2003-02-28 Alfredo Braunstein * ControlGraphics.C: removed #include "converter.h" diff --git a/src/frontends/controllers/ControlExternal.C b/src/frontends/controllers/ControlExternal.C index 3572b00320..7c5ee9fd48 100644 --- a/src/frontends/controllers/ControlExternal.C +++ b/src/frontends/controllers/ControlExternal.C @@ -12,82 +12,70 @@ #include - #include "ControlExternal.h" #include "buffer.h" -#include "BufferView.h" +#include "funcrequest.h" #include "gettext.h" #include "helper_funcs.h" #include "lyxrc.h" -#include "support/filetools.h" - #include using std::vector; -ControlExternal::ControlExternal(LyXView & lv, Dialogs & d) - : ControlInset(lv, d) +ControlExternal::ControlExternal(Dialog & parent) + : Dialog::Controller(parent) {} -InsetExternal::Params const ControlExternal::getParams(string const &) +void ControlExternal::initialiseParams(string const & data) { - return InsetExternal::Params(); + inset_.reset(new InsetExternal); + InsetExternal::Params params; + InsetExternalMailer::string2params(data, params); + inset_->setFromParams(params); + inset_->setView(kernel().bufferview()); } -InsetExternal::Params const -ControlExternal::getParams(InsetExternal const & inset) +void ControlExternal::clearParams() { - return inset.params(); + inset_.reset(); } -void ControlExternal::applyParamsToInset() +void ControlExternal::dispatchParams() { - inset()->setFromParams(params()); - bufferview()->updateInset(inset(), true); + InsetExternal::Params p = params(); + string const lfun = InsetExternalMailer::params2string("external", p); + kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun)); +} + + +void ControlExternal::setParams(InsetExternal::Params const & p) +{ + inset_->setFromParams(p); } void ControlExternal::editExternal() { - // fill the local, controller's copy of the Params struct with - // the contents of the dialog's fields. - view().apply(); - - // Create a local copy of the inset and initialise it with this - // params struct. - boost::scoped_ptr ie; - ie.reset(static_cast(inset()->clone(*buffer()))); - ie->setFromParams(params()); - - ie->editExternal(); + dialog().view().apply(); + inset_->editExternal(); } void ControlExternal::viewExternal() { - view().apply(); - - boost::scoped_ptr ie; - ie.reset(static_cast(inset()->clone(*buffer()))); - ie->setFromParams(params()); - - ie->viewExternal(); + dialog().view().apply(); + inset_->viewExternal(); } void ControlExternal::updateExternal() { - view().apply(); - - boost::scoped_ptr ie; - ie.reset(static_cast(inset()->clone(*buffer()))); - ie->setFromParams(params()); - - ie->updateExternal(); + dialog().view().apply(); + inset_->updateExternal(); } @@ -137,7 +125,7 @@ string const ControlExternal::Browse(string const & input) const { string const title = _("Select external file"); - string const bufpath = buffer()->filePath(); + string const bufpath = kernel().buffer()->filePath(); /// Determine the template file extension ExternalTemplate const & et = params().templ; diff --git a/src/frontends/controllers/ControlExternal.h b/src/frontends/controllers/ControlExternal.h index 5fb97ef693..ff4d189c9d 100644 --- a/src/frontends/controllers/ControlExternal.h +++ b/src/frontends/controllers/ControlExternal.h @@ -15,17 +15,29 @@ #define CONTROLEXTERNAL_H -#include "ControlInset.h" +#include "Dialog.h" #include "insets/insetexternal.h" +#include -/** A controller for External dialogs. - */ -class ControlExternal - : public ControlInset -{ + +class ControlExternal : public Dialog::Controller { public: /// - ControlExternal(LyXView &, Dialogs &); + ControlExternal(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; } + + /// + InsetExternal::Params const & params() const + { return inset_->params(); } + /// + void setParams(InsetExternal::Params const &); /// void editExternal(); @@ -43,13 +55,7 @@ public: string const Browse(string const &) const; private: /// - virtual void applyParamsToInset(); - /// not needed. - virtual void applyParamsNoInset() {} - /// get the parameters from the string passed to createInset. - virtual InsetExternal::Params const getParams(string const &); - /// get the parameters from the inset passed to showInset. - virtual InsetExternal::Params const getParams(InsetExternal const &); + boost::scoped_ptr inset_; }; #endif // CONTROLEXTERNAL_H diff --git a/src/frontends/controllers/Dialog.h b/src/frontends/controllers/Dialog.h index b61ef4533e..ef83ec5c14 100644 --- a/src/frontends/controllers/Dialog.h +++ b/src/frontends/controllers/Dialog.h @@ -101,11 +101,11 @@ public: Controller & controller() const; /// ButtonControllerBase & bc() const; -private: /// View & view() const; //@} +private: /// void apply(); @@ -141,6 +141,10 @@ public: /// virtual bool disconnectOnApply() const { return false; } /// + Dialog & dialog() { return parent_; } + /// + Dialog const & dialog() const { return parent_; } + /// Kernel & kernel() { return parent_.kernel(); } /// Kernel const & kernel() const { return parent_.kernel(); } diff --git a/src/frontends/guiapi.C b/src/frontends/guiapi.C index 876e532308..2224339997 100644 --- a/src/frontends/guiapi.C +++ b/src/frontends/guiapi.C @@ -45,12 +45,6 @@ void gui_ShowDocument(Dialogs & d) } -void gui_ShowExternal(InsetExternal * ie, Dialogs & d) -{ - d.showExternal(ie); -} - - void gui_ShowFile(string const & f, Dialogs & d) { d.showFile(f); diff --git a/src/frontends/guiapi.h b/src/frontends/guiapi.h index 7763e6a726..a07d4d944e 100644 --- a/src/frontends/guiapi.h +++ b/src/frontends/guiapi.h @@ -16,7 +16,6 @@ #include "LString.h" class Dialogs; -class InsetExternal; class InsetFloat; class InsetWrap; class InsetGraphics; @@ -32,7 +31,6 @@ void gui_ShowAboutlyx(Dialogs &); void gui_ShowCharacter(Dialogs &); void gui_SetUserFreeFont(Dialogs &); void gui_ShowDocument(Dialogs &); -void gui_ShowExternal(InsetExternal *, Dialogs &); void gui_ShowFile(string const &, Dialogs &); void gui_ShowFloat(InsetFloat *, Dialogs &); void gui_ShowForks(Dialogs &); diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index d8dedda87f..11f6d9c006 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,13 @@ +2003-03-05 Angus Leeming + + * QExternal.[Ch]: changes to use the new Dialog-based scheme. + + * Dialogs.C: + * Dialogs2.C: + * Dialogs_impl.h: remove external dialog. + + * Dialogs3.C: add external dialog. + 2003-03-05 Angus Leeming * QIndex.[Ch]: minimal changes needed to use this dialog diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index 68d0669bd9..ca1cb58bbe 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -30,7 +30,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) changes(lv, d), character(lv, d), document(lv, d), - external(lv, d), file(lv, d), floats(lv, d), graphics(lv, d), diff --git a/src/frontends/qt2/Dialogs2.C b/src/frontends/qt2/Dialogs2.C index abff472248..b489b386d8 100644 --- a/src/frontends/qt2/Dialogs2.C +++ b/src/frontends/qt2/Dialogs2.C @@ -46,12 +46,6 @@ void Dialogs::showDocument() } -void Dialogs::showExternal(InsetExternal * ie) -{ - pimpl_->external.controller().showInset(ie); -} - - void Dialogs::showFile(string const & f) { pimpl_->file.controller().showFile(f); diff --git a/src/frontends/qt2/Dialogs3.C b/src/frontends/qt2/Dialogs3.C index 83b7e97d38..9c8bdeee27 100644 --- a/src/frontends/qt2/Dialogs3.C +++ b/src/frontends/qt2/Dialogs3.C @@ -18,6 +18,7 @@ #include "ControlCitation.h" #include "ControlError.h" #include "ControlERT.h" +#include "ControlExternal.h" #include "ControlIndex.h" #include "ControlLabel.h" #include "ControlRef.h" @@ -34,6 +35,8 @@ #include "QErrorDialog.h" #include "QERT.h" #include "QERTDialog.h" +#include "QExternal.h" +#include "QExternalDialog.h" // Here would be an appropriate point to lecture on the evils // of the Qt headers, those most fucked up of disgusting ratholes. // But I won't. @@ -58,6 +61,9 @@ typedef ButtonController typedef ButtonController OkCancelReadOnlyBC; +typedef ButtonController + OkApplyCancelReadOnlyBC; + typedef ButtonController NoRepeatedApplyReadOnlyBC; @@ -65,8 +71,8 @@ typedef ButtonController namespace { char const * const dialognames[] = { "bibitem", "bibtex", "citation", - "error", "ert", "index", "label", "ref", - "toc", "url" }; + "error", "ert", "external", "index", + "label", "ref", "toc", "url" }; char const * const * const end_dialognames = dialognames + (sizeof(dialognames) / sizeof(char *)); @@ -118,6 +124,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlERT(*dialog)); dialog->setView(new QERT(*dialog)); dialog->setButtonController(new NoRepeatedApplyReadOnlyBC); + } else if (name == "external") { + dialog->setController(new ControlExternal(*dialog)); + dialog->setView(new QExternal(*dialog)); + dialog->setButtonController(new OkApplyCancelReadOnlyBC); } else if (name == "index") { dialog->setController(new ControlIndex(*dialog)); dialog->setView(new QIndex(*dialog, diff --git a/src/frontends/qt2/Dialogs_impl.h b/src/frontends/qt2/Dialogs_impl.h index 98e4e41229..9918ace7f5 100644 --- a/src/frontends/qt2/Dialogs_impl.h +++ b/src/frontends/qt2/Dialogs_impl.h @@ -19,7 +19,6 @@ #include "ControlChanges.h" #include "ControlCharacter.h" #include "ControlDocument.h" -#include "ControlExternal.h" #include "ControlFloat.h" #include "ControlForks.h" #include "ControlGraphics.h" @@ -48,8 +47,6 @@ #include "QCharacterDialog.h" #include "QDocument.h" #include "QDocumentDialog.h" -#include "QExternal.h" -#include "QExternalDialog.h" #include "QFloat.h" #include "QFloatDialog.h" //#include "QForks.h" @@ -113,9 +110,6 @@ CharacterDialog; typedef GUI DocumentDialog; -typedef GUI -ExternalDialog; - typedef GUI FileDialog; @@ -180,7 +174,6 @@ struct Dialogs::Impl { ChangesDialog changes; CharacterDialog character; DocumentDialog document; - ExternalDialog external; FileDialog file; FloatDialog floats; GraphicsDialog graphics; diff --git a/src/frontends/qt2/QExternal.C b/src/frontends/qt2/QExternal.C index c686b18683..fe43270ddc 100644 --- a/src/frontends/qt2/QExternal.C +++ b/src/frontends/qt2/QExternal.C @@ -25,11 +25,11 @@ #include -typedef Qt2CB > base_class; +typedef QController > base_class; -QExternal::QExternal() - : base_class(qt_("LyX: Insert External Material")) +QExternal::QExternal(Dialog & parent) + : base_class(parent, qt_("LyX: Insert External Material")) { } @@ -67,21 +67,22 @@ void QExternal::update_contents() } -string const & QExternal::helpText() +string const QExternal::helpText() const { - InsetExternal::Params & params = controller().params(); - - params.templ = controller().getTemplate(dialog_->externalCO->currentItem()); - return params.templ.helpText; + ExternalTemplate templ = + controller().getTemplate(dialog_->externalCO->currentItem()); + return templ.helpText; } void QExternal::apply() { - InsetExternal::Params & params = controller().params(); + InsetExternal::Params params = controller().params(); params.filename = fromqstr(dialog_->fileED->text()); params.parameters = fromqstr(dialog_->paramsED->text()); params.templ = controller().getTemplate(dialog_->externalCO->currentItem()); + + controller().setParams(params); } diff --git a/src/frontends/qt2/QExternal.h b/src/frontends/qt2/QExternal.h index ee12e83ebf..b698cfe65f 100644 --- a/src/frontends/qt2/QExternal.h +++ b/src/frontends/qt2/QExternal.h @@ -13,18 +13,20 @@ #define QEXTERNAL_H -#include "Qt2Base.h" +#include "QDialogView.h" + class ControlExternal; class QExternalDialog; + class QExternal - : public Qt2CB > + : public QController > { public: friend class QExternalDialog; - QExternal(); + QExternal(Dialog &); private: /// Apply changes @@ -35,7 +37,7 @@ private: virtual void build_dialog(); /// get the right helptext - string const & helpText(); + string const helpText() const; }; #endif // QEXTERNAL_H diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 52bf4b9c10..4316e65b6b 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,14 @@ +2003-03-05 Angus Leeming + + * FormExternal.[Ch]: + * forms/form_external.fd: changes to use the new Dialog-based scheme. + + * Dialogs.C: + * Dialogs2.C: + * Dialogs_impl.h: remove external dialog. + + * Dialogs3.C: add external dialog. + 2003-03-04 Angus Leeming * FormText.[Ch]: the label of the input widget is passed to the diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index 231f3aa2e9..082c909f9d 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -30,7 +30,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) changes(lv, d), character(lv, d), document(lv, d), - external(lv, d), file(lv, d), floats(lv, d), forks(lv, d), diff --git a/src/frontends/xforms/Dialogs2.C b/src/frontends/xforms/Dialogs2.C index 39cfbeba6a..1b49484186 100644 --- a/src/frontends/xforms/Dialogs2.C +++ b/src/frontends/xforms/Dialogs2.C @@ -46,12 +46,6 @@ void Dialogs::showDocument() } -void Dialogs::showExternal(InsetExternal * ie) -{ - pimpl_->external.controller().showInset(ie); -} - - void Dialogs::showFile(string const & f) { pimpl_->file.controller().showFile(f); diff --git a/src/frontends/xforms/Dialogs3.C b/src/frontends/xforms/Dialogs3.C index 2482052a84..8146d51ec6 100644 --- a/src/frontends/xforms/Dialogs3.C +++ b/src/frontends/xforms/Dialogs3.C @@ -35,6 +35,10 @@ #include "FormERT.h" #include "forms/form_ert.h" +#include "ControlExternal.h" +#include "FormExternal.h" +#include "forms/form_external.h" + #include "ControlIndex.h" #include "ControlLabel.h" @@ -63,10 +67,12 @@ typedef ButtonController typedef ButtonController OkCancelReadOnlyBC; +typedef ButtonController + OkApplyCancelReadOnlyBC; + typedef ButtonController NoRepeatedApplyReadOnlyBC; - namespace { // char const * const dialognames[] = { "bibitem", "bibtex", "citation", @@ -75,8 +81,8 @@ namespace { // "minipage", "ref", "tabular", "toc", // "url", "wrap" }; char const * const dialognames[] = { "bibitem", "bibtex", "citation", - "error", "ert", "index", "label", "ref", - "toc", "url" }; + "error", "ert", "external", "index", + "label", "ref", "toc", "url" }; char const * const * const end_dialognames = dialognames + (sizeof(dialognames) / sizeof(char *)); @@ -128,6 +134,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlERT(*dialog)); dialog->setView(new FormERT(*dialog)); dialog->setButtonController(new NoRepeatedApplyReadOnlyBC); + } else if (name == "external") { + dialog->setController(new ControlExternal(*dialog)); + dialog->setView(new FormExternal(*dialog)); + dialog->setButtonController(new OkApplyCancelReadOnlyBC); } else if (name == "index") { dialog->setController(new ControlIndex(*dialog)); dialog->setView(new FormText(*dialog, diff --git a/src/frontends/xforms/Dialogs_impl.h b/src/frontends/xforms/Dialogs_impl.h index 5233665b2b..2675704317 100644 --- a/src/frontends/xforms/Dialogs_impl.h +++ b/src/frontends/xforms/Dialogs_impl.h @@ -38,10 +38,6 @@ #include "FormDocument.h" #include "forms/form_document.h" -#include "ControlExternal.h" -#include "FormExternal.h" -#include "forms/form_external.h" - #include "ControlFloat.h" #include "FormFloat.h" #include "forms/form_float.h" @@ -138,9 +134,6 @@ CharacterDialog; typedef GUI DocumentDialog; -typedef GUI -ExternalDialog; - typedef GUI FileDialog; @@ -213,7 +206,6 @@ struct Dialogs::Impl { ChangesDialog changes; CharacterDialog character; DocumentDialog document; - ExternalDialog external; FileDialog file; FloatDialog floats; ForksDialog forks; diff --git a/src/frontends/xforms/FormExternal.C b/src/frontends/xforms/FormExternal.C index ae63875668..0b8d63735f 100644 --- a/src/frontends/xforms/FormExternal.C +++ b/src/frontends/xforms/FormExternal.C @@ -24,22 +24,24 @@ #include "support/lstrings.h" #include FORMS_H_LOCATION -typedef FormCB > base_class; +typedef FormController > base_class; -FormExternal::FormExternal() - : base_class(_("Edit external file")) +FormExternal::FormExternal(Dialog & parent) + : base_class(parent, _("Edit external file")) {} void FormExternal::apply() { - controller().params().filename = - fl_get_input(dialog_->input_filename); - controller().params().parameters = - fl_get_input(dialog_->input_parameters); + InsetExternal::Params params = controller().params(); + + params.filename = fl_get_input(dialog_->input_filename); + params.parameters = fl_get_input(dialog_->input_parameters); int const choice = fl_get_choice(dialog_->choice_template) - 1; - controller().params().templ = controller().getTemplate(choice); + params.templ = controller().getTemplate(choice); + + controller().setParams(params); } @@ -91,7 +93,9 @@ ButtonPolicy::SMInput FormExternal::input(FL_OBJECT * ob, long) // set to the chosen template int const choice = fl_get_choice(dialog_->choice_template) - 1; - controller().params().templ = controller().getTemplate(choice); + InsetExternal::Params params = controller().params(); + params.templ = controller().getTemplate(choice); + controller().setParams(params); updateComboChange(); diff --git a/src/frontends/xforms/FormExternal.h b/src/frontends/xforms/FormExternal.h index 08265fad81..a6fce676eb 100644 --- a/src/frontends/xforms/FormExternal.h +++ b/src/frontends/xforms/FormExternal.h @@ -15,17 +15,18 @@ #define FORMEXTERNAL_H -#include "FormBase.h" -#include "insets/insetexternal.h" +#include "FormDialogView.h" + class ControlExternal; struct FD_external; /// The class for editing External insets via a dialog -class FormExternal : public FormCB > { +class FormExternal + : public FormController > { public: /// - FormExternal(); + FormExternal(Dialog &); private: /// apply changes virtual void apply(); diff --git a/src/frontends/xforms/forms/form_external.fd b/src/frontends/xforms/forms/form_external.fd index f7e7b3750b..a601a0712e 100644 --- a/src/frontends/xforms/forms/form_external.fd +++ b/src/frontends/xforms/forms/form_external.fd @@ -46,7 +46,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NorthWest FL_NorthEast name: choice_template -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -82,7 +82,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_SouthWest FL_SouthEast name: input_filename -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -100,7 +100,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_SouthEast FL_SouthEast name: button_filenamebrowse -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -118,7 +118,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_SouthWest FL_SouthEast name: input_parameters -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -136,7 +136,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_edit -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -154,7 +154,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_view -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -172,7 +172,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_update -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -190,7 +190,7 @@ shortcut: ^M resize: FL_RESIZE_ALL gravity: FL_SouthEast FL_SouthEast name: button_ok -callback: C_FormBaseOKCB +callback: C_FormDialogView_OKCB argument: 0 -------------------- @@ -208,7 +208,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_SouthEast FL_SouthEast name: button_apply -callback: C_FormBaseApplyCB +callback: C_FormDialogView_ApplyCB argument: 0 -------------------- @@ -226,7 +226,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_SouthEast FL_SouthEast name: button_close -callback: C_FormBaseCancelCB +callback: C_FormDialogView_CancelCB argument: 0 ============================== diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 849c49cf09..e47b49fc34 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2003-03-05 Angus Leeming + + * insetexternal.[Ch]: define a new class InsetExternalMailer and use + it to communicate with the frontend dialogs. + 2003-03-04 Lars Gullik Bjønnes * insettext.C (collapseParagraphs): adjust diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index ecbbbf4fa5..a58941e7b3 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -15,13 +15,14 @@ #include "ExternalTemplate.h" #include "BufferView.h" #include "buffer.h" -#include "frontends/LyXView.h" +#include "funcrequest.h" #include "lyx_main.h" #include "LaTeXFeatures.h" #include "gettext.h" #include "debug.h" #include "lyxlex.h" +#include "frontends/LyXView.h" #include "frontends/Dialogs.h" #include "support/filetools.h" @@ -50,16 +51,33 @@ InsetExternal::InsetExternal() InsetExternal::~InsetExternal() { lyx::unlink(tempname_); - hideDialog(); + InsetExternalMailer mailer(*this); + mailer.hideDialog(); } -InsetExternal::Params InsetExternal::params() const +InsetExternal::Params const & InsetExternal::params() const { return params_; } +dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd) +{ + if (cmd.action != LFUN_INSET_MODIFY) + return UNDISPATCHED; + + InsetExternal::Params p; + InsetExternalMailer::string2params(cmd.argument, p); + if (p.filename.empty()) + return UNDISPATCHED; + + setFromParams(p); + cmd.view()->updateInset(this, true); + return DISPATCHED; +} + + void InsetExternal::setFromParams(Params const & p) { params_.filename = p.filename; @@ -74,11 +92,10 @@ string const InsetExternal::editMessage() const } -void InsetExternal::edit(BufferView * bv, - int /*x*/, int /*y*/, mouse_button::state) +void InsetExternal::edit(BufferView *, int, int, mouse_button::state) { - view_ = bv; - view_->owner()->getDialogs().showExternal(this); + InsetExternalMailer mailer(*this); + mailer.showDialog(); } @@ -341,3 +358,57 @@ bool operator!=(InsetExternal::Params const & left, { return !(left == right); } + + +InsetExternalMailer::InsetExternalMailer(InsetExternal & inset) + : name_("external"), inset_(inset) +{} + + +string const InsetExternalMailer::inset2string() const +{ + + return params2string(name(), inset_.params()); +} + + +void InsetExternalMailer::string2params(string const & in, + InsetExternal::Params & params) +{ + params = InsetExternal::Params(); + + string name; + string body = split(in, name, ' '); + + if (name != "external" || body.empty()) + return; + + // This is part of the inset proper that is usually swallowed + // by Buffer::readInset + body = split(body, name, ' '); + if (name != "External") + return; + + istringstream data(body); + LyXLex lex(0,0); + lex.setStream(data); + + InsetExternal inset; + inset.read(0, lex); + params = inset.params(); +} + + +string const +InsetExternalMailer::params2string(string const & name, + InsetExternal::Params const & params) +{ + InsetExternal inset; + inset.setFromParams(params); + ostringstream data; + data << name << ' '; + inset.write(0, data); + data << "\\end_inset\n"; + + return data.str(); +} diff --git a/src/lyxfunc.C b/src/lyxfunc.C index ee199e8291..8821b45569 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -519,9 +519,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const case LFUN_TABULAR_INSERT: code = Inset::TABULAR_CODE; break; - case LFUN_INSET_EXTERNAL: - code = Inset::EXTERNAL_CODE; - break; case LFUN_INSET_MARGINAL: code = Inset::MARGIN_CODE; break; @@ -578,7 +575,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const break; case LFUN_HTMLURL: case LFUN_URL: - case LFUN_INSERT_URL: code = Inset::URL_CODE; break; case LFUN_QUOTE: diff --git a/src/text3.C b/src/text3.C index d7d5883117..68b22a6f2b 100644 --- a/src/text3.C +++ b/src/text3.C @@ -1626,8 +1626,6 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) doInsertInset(this, cmd, true, true); break; - case LFUN_INSERT_URL: - case LFUN_INSET_EXTERNAL: case LFUN_INDEX_INSERT: // Just open the inset doInsertInset(this, cmd, true, false);