Move the external dialog to the new scheme.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6351 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-03-05 11:30:35 +00:00
parent ca067e952a
commit b7c9ae4931
33 changed files with 261 additions and 167 deletions

View File

@ -1,3 +1,8 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* ui/default.ui: use 'dialog-show-new-inset "external"' instead
of 'external-insert'.
2003-03-03 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr> 2003-03-03 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* doc/LaTeXConfig.lyx.in: really get rid of iletter description * doc/LaTeXConfig.lyx.in: really get rid of iletter description

View File

@ -215,7 +215,7 @@ Menuset
Separator Separator
Item "Include File...|d" "buffer-child-insert" Item "Include File...|d" "buffer-child-insert"
Submenu "Insert File|e" "insert_file" Submenu "Insert File|e" "insert_file"
Item "External Material...|x" "external-insert" Item "External Material...|x" "dialog-show-new-inset external"
End End
Menu "insert_special" Menu "insert_special"

View File

@ -1,3 +1,14 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* 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 <larsbj@gullik.net> 2003-03-05 Lars Gullik Bjønnes <larsbj@gullik.net>
* ParagraphList.C (insert): handle insert right before end() * ParagraphList.C (insert): handle insert right before end()

View File

@ -175,8 +175,6 @@ void LyXAction::init()
N_("Remove all error boxes"), ReadOnly }, N_("Remove all error boxes"), ReadOnly },
{ LFUN_INSET_ERT, "ert-insert", { LFUN_INSET_ERT, "ert-insert",
N_("Insert a new ERT Inset"), Noop }, N_("Insert a new ERT Inset"), Noop },
{ LFUN_INSET_EXTERNAL, "external-insert",
N_("Insert a new external inset"), Noop },
{ LFUN_INSET_GRAPHICS, "graphics-insert", { LFUN_INSET_GRAPHICS, "graphics-insert",
N_("Insert Graphics"), Noop }, N_("Insert Graphics"), Noop },
{ LFUN_FILE_INSERT, "file-insert", "", Noop }, { LFUN_FILE_INSERT, "file-insert", "", Noop },
@ -368,7 +366,6 @@ void LyXAction::init()
{ LFUN_UP, "up", "", ReadOnly }, { LFUN_UP, "up", "", ReadOnly },
{ LFUN_UPSEL, "up-select", "", ReadOnly }, { LFUN_UPSEL, "up-select", "", ReadOnly },
{ LFUN_URL, "url-insert", "", Noop }, { LFUN_URL, "url-insert", "", Noop },
{ LFUN_INSERT_URL, "", "internal only", Noop },
{ LFUN_VC_CHECKIN, "vc-check-in", "", ReadOnly }, { LFUN_VC_CHECKIN, "vc-check-in", "", ReadOnly },
{ LFUN_VC_CHECKOUT, "vc-check-out", "", ReadOnly }, { LFUN_VC_CHECKOUT, "vc-check-out", "", ReadOnly },
{ LFUN_VC_HISTORY, "vc-history", "", ReadOnly }, { LFUN_VC_HISTORY, "vc-history", "", ReadOnly },

View File

@ -243,7 +243,6 @@ enum kb_action {
LFUN_LOTVIEW, // Dekel 20000519 LFUN_LOTVIEW, // Dekel 20000519
LFUN_LOAVIEW, // Dekel 20000519 LFUN_LOAVIEW, // Dekel 20000519
LFUN_SET_COLOR, // SLior 20000611 LFUN_SET_COLOR, // SLior 20000611
LFUN_INSET_EXTERNAL, // Alstrup 20000609
LFUN_INSET_MARGINAL, // Lgb 20000626 LFUN_INSET_MARGINAL, // Lgb 20000626
LFUN_INSET_MINIPAGE, // Lgb 20000627 LFUN_INSET_MINIPAGE, // Lgb 20000627
LFUN_INSET_FLOAT, // Lgb 20000627 LFUN_INSET_FLOAT, // Lgb 20000627
@ -255,7 +254,6 @@ enum kb_action {
#endif #endif
LFUN_INSET_CAPTION, // Lgb 20000718 LFUN_INSET_CAPTION, // Lgb 20000718
LFUN_SWITCHBUFFER, // and where is this coming from? LFUN_SWITCHBUFFER, // and where is this coming from?
LFUN_INSERT_URL, // Angus 20000726
LFUN_TABULAR_FEATURE, // Jug 20000728 LFUN_TABULAR_FEATURE, // Jug 20000728
LFUN_LAYOUT_TABULAR, // Jug 20000731 LFUN_LAYOUT_TABULAR, // Jug 20000731
LFUN_SCROLL_INSET, // Jug 20000801 LFUN_SCROLL_INSET, // Jug 20000801

View File

@ -62,9 +62,6 @@ Inset * createInset(FuncRequest const & cmd)
case LFUN_INSET_ERT: case LFUN_INSET_ERT:
return new InsetERT(params); return new InsetERT(params);
case LFUN_INSET_EXTERNAL:
return new InsetExternal;
case LFUN_INSET_FOOTNOTE: case LFUN_INSET_FOOTNOTE:
return new InsetFoot(params); return new InsetFoot(params);
@ -152,13 +149,6 @@ Inset * createInset(FuncRequest const & cmd)
return new InsetParent( return new InsetParent(
InsetCommandParams("lyxparent", cmd.argument), *bv->buffer()); InsetCommandParams("lyxparent", cmd.argument), *bv->buffer());
case LFUN_INSERT_URL:
{
InsetCommandParams p;
p.setFromString(cmd.argument);
return new InsetUrl(p);
}
#if 0 #if 0
case LFUN_INSET_LIST: case LFUN_INSET_LIST:
return new InsetList; return new InsetList;
@ -194,6 +184,13 @@ Inset * createInset(FuncRequest const & cmd)
inset->status(bv, s); inset->status(bv, s);
return inset; 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") { } else if (name == "index") {
InsetCommandParams icp; InsetCommandParams icp;
InsetCommandMailer::string2params(cmd.argument, icp); InsetCommandMailer::string2params(cmd.argument, icp);

View File

@ -1,3 +1,8 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* Dialogs.h: remove showExternal.
* guiapi.[Ch]: remove gui_ShowExternal.
2003-02-27 Angus Leeming <leeming@lyx.org> 2003-02-27 Angus Leeming <leeming@lyx.org>
* screen.C (redraw, greyOut): ensure that the painter is started * screen.C (redraw, greyOut): ensure that the painter is started

View File

@ -23,9 +23,6 @@ class Dialog;
class InsetBase; class InsetBase;
class LyXView; class LyXView;
class InsetCommand;
class InsetError;
class InsetExternal;
class InsetFloat; class InsetFloat;
class InsetWrap; class InsetWrap;
class InsetGraphics; class InsetGraphics;
@ -89,8 +86,6 @@ public:
void setUserFreeFont(); void setUserFreeFont();
/// ///
void showDocument(); void showDocument();
/// show the external inset dialog
void showExternal(InsetExternal *);
/// show the contents of a file. /// show the contents of a file.
void showFile(string const &); void showFile(string const &);
/// ///

View File

@ -1,3 +1,9 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* ControlExternal.[Ch]: rewrite to use the Dialog-based scheme.
* Dialog.h: make view() public. Add dialog() methods.
2003-02-28 Alfredo Braunstein <abraunst@libero.it> 2003-02-28 Alfredo Braunstein <abraunst@libero.it>
* ControlGraphics.C: removed #include "converter.h" * ControlGraphics.C: removed #include "converter.h"

View File

@ -12,82 +12,70 @@
#include <config.h> #include <config.h>
#include "ControlExternal.h" #include "ControlExternal.h"
#include "buffer.h" #include "buffer.h"
#include "BufferView.h" #include "funcrequest.h"
#include "gettext.h" #include "gettext.h"
#include "helper_funcs.h" #include "helper_funcs.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "support/filetools.h"
#include <vector> #include <vector>
using std::vector; using std::vector;
ControlExternal::ControlExternal(LyXView & lv, Dialogs & d) ControlExternal::ControlExternal(Dialog & parent)
: ControlInset<InsetExternal, InsetExternal::Params>(lv, d) : 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 void ControlExternal::clearParams()
ControlExternal::getParams(InsetExternal const & inset)
{ {
return inset.params(); inset_.reset();
} }
void ControlExternal::applyParamsToInset() void ControlExternal::dispatchParams()
{ {
inset()->setFromParams(params()); InsetExternal::Params p = params();
bufferview()->updateInset(inset(), true); 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() void ControlExternal::editExternal()
{ {
// fill the local, controller's copy of the Params struct with dialog().view().apply();
// the contents of the dialog's fields. inset_->editExternal();
view().apply();
// Create a local copy of the inset and initialise it with this
// params struct.
boost::scoped_ptr<InsetExternal> ie;
ie.reset(static_cast<InsetExternal *>(inset()->clone(*buffer())));
ie->setFromParams(params());
ie->editExternal();
} }
void ControlExternal::viewExternal() void ControlExternal::viewExternal()
{ {
view().apply(); dialog().view().apply();
inset_->viewExternal();
boost::scoped_ptr<InsetExternal> ie;
ie.reset(static_cast<InsetExternal *>(inset()->clone(*buffer())));
ie->setFromParams(params());
ie->viewExternal();
} }
void ControlExternal::updateExternal() void ControlExternal::updateExternal()
{ {
view().apply(); dialog().view().apply();
inset_->updateExternal();
boost::scoped_ptr<InsetExternal> ie;
ie.reset(static_cast<InsetExternal *>(inset()->clone(*buffer())));
ie->setFromParams(params());
ie->updateExternal();
} }
@ -137,7 +125,7 @@ string const ControlExternal::Browse(string const & input) const
{ {
string const title = _("Select external file"); string const title = _("Select external file");
string const bufpath = buffer()->filePath(); string const bufpath = kernel().buffer()->filePath();
/// Determine the template file extension /// Determine the template file extension
ExternalTemplate const & et = params().templ; ExternalTemplate const & et = params().templ;

View File

@ -15,17 +15,29 @@
#define CONTROLEXTERNAL_H #define CONTROLEXTERNAL_H
#include "ControlInset.h" #include "Dialog.h"
#include "insets/insetexternal.h" #include "insets/insetexternal.h"
#include <boost/scoped_ptr.hpp>
/** A controller for External dialogs.
*/ class ControlExternal : public Dialog::Controller {
class ControlExternal
: public ControlInset<InsetExternal, InsetExternal::Params>
{
public: 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(); void editExternal();
@ -43,13 +55,7 @@ public:
string const Browse(string const &) const; string const Browse(string const &) const;
private: private:
/// ///
virtual void applyParamsToInset(); boost::scoped_ptr<InsetExternal> inset_;
/// 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 &);
}; };
#endif // CONTROLEXTERNAL_H #endif // CONTROLEXTERNAL_H

View File

@ -101,11 +101,11 @@ public:
Controller & controller() const; Controller & controller() const;
/// ///
ButtonControllerBase & bc() const; ButtonControllerBase & bc() const;
private:
/// ///
View & view() const; View & view() const;
//@} //@}
private:
/// ///
void apply(); void apply();
@ -141,6 +141,10 @@ public:
/// ///
virtual bool disconnectOnApply() const { return false; } virtual bool disconnectOnApply() const { return false; }
/// ///
Dialog & dialog() { return parent_; }
///
Dialog const & dialog() const { return parent_; }
///
Kernel & kernel() { return parent_.kernel(); } Kernel & kernel() { return parent_.kernel(); }
/// ///
Kernel const & kernel() const { return parent_.kernel(); } Kernel const & kernel() const { return parent_.kernel(); }

View File

@ -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) void gui_ShowFile(string const & f, Dialogs & d)
{ {
d.showFile(f); d.showFile(f);

View File

@ -16,7 +16,6 @@
#include "LString.h" #include "LString.h"
class Dialogs; class Dialogs;
class InsetExternal;
class InsetFloat; class InsetFloat;
class InsetWrap; class InsetWrap;
class InsetGraphics; class InsetGraphics;
@ -32,7 +31,6 @@ void gui_ShowAboutlyx(Dialogs &);
void gui_ShowCharacter(Dialogs &); void gui_ShowCharacter(Dialogs &);
void gui_SetUserFreeFont(Dialogs &); void gui_SetUserFreeFont(Dialogs &);
void gui_ShowDocument(Dialogs &); void gui_ShowDocument(Dialogs &);
void gui_ShowExternal(InsetExternal *, Dialogs &);
void gui_ShowFile(string const &, Dialogs &); void gui_ShowFile(string const &, Dialogs &);
void gui_ShowFloat(InsetFloat *, Dialogs &); void gui_ShowFloat(InsetFloat *, Dialogs &);
void gui_ShowForks(Dialogs &); void gui_ShowForks(Dialogs &);

View File

@ -1,3 +1,13 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* 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 <leeming@lyx.org> 2003-03-05 Angus Leeming <leeming@lyx.org>
* QIndex.[Ch]: minimal changes needed to use this dialog * QIndex.[Ch]: minimal changes needed to use this dialog

View File

@ -30,7 +30,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
changes(lv, d), changes(lv, d),
character(lv, d), character(lv, d),
document(lv, d), document(lv, d),
external(lv, d),
file(lv, d), file(lv, d),
floats(lv, d), floats(lv, d),
graphics(lv, d), graphics(lv, d),

View File

@ -46,12 +46,6 @@ void Dialogs::showDocument()
} }
void Dialogs::showExternal(InsetExternal * ie)
{
pimpl_->external.controller().showInset(ie);
}
void Dialogs::showFile(string const & f) void Dialogs::showFile(string const & f)
{ {
pimpl_->file.controller().showFile(f); pimpl_->file.controller().showFile(f);

View File

@ -18,6 +18,7 @@
#include "ControlCitation.h" #include "ControlCitation.h"
#include "ControlError.h" #include "ControlError.h"
#include "ControlERT.h" #include "ControlERT.h"
#include "ControlExternal.h"
#include "ControlIndex.h" #include "ControlIndex.h"
#include "ControlLabel.h" #include "ControlLabel.h"
#include "ControlRef.h" #include "ControlRef.h"
@ -34,6 +35,8 @@
#include "QErrorDialog.h" #include "QErrorDialog.h"
#include "QERT.h" #include "QERT.h"
#include "QERTDialog.h" #include "QERTDialog.h"
#include "QExternal.h"
#include "QExternalDialog.h"
// Here would be an appropriate point to lecture on the evils // Here would be an appropriate point to lecture on the evils
// of the Qt headers, those most fucked up of disgusting ratholes. // of the Qt headers, those most fucked up of disgusting ratholes.
// But I won't. // But I won't.
@ -58,6 +61,9 @@ typedef ButtonController<OkCancelPolicy, Qt2BC>
typedef ButtonController<OkCancelReadOnlyPolicy, Qt2BC> typedef ButtonController<OkCancelReadOnlyPolicy, Qt2BC>
OkCancelReadOnlyBC; OkCancelReadOnlyBC;
typedef ButtonController<OkApplyCancelReadOnlyPolicy, Qt2BC>
OkApplyCancelReadOnlyBC;
typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, Qt2BC> typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, Qt2BC>
NoRepeatedApplyReadOnlyBC; NoRepeatedApplyReadOnlyBC;
@ -65,8 +71,8 @@ typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, Qt2BC>
namespace { namespace {
char const * const dialognames[] = { "bibitem", "bibtex", "citation", char const * const dialognames[] = { "bibitem", "bibtex", "citation",
"error", "ert", "index", "label", "ref", "error", "ert", "external", "index",
"toc", "url" }; "label", "ref", "toc", "url" };
char const * const * const end_dialognames = char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *)); dialognames + (sizeof(dialognames) / sizeof(char *));
@ -118,6 +124,10 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlERT(*dialog)); dialog->setController(new ControlERT(*dialog));
dialog->setView(new QERT(*dialog)); dialog->setView(new QERT(*dialog));
dialog->setButtonController(new NoRepeatedApplyReadOnlyBC); 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") { } else if (name == "index") {
dialog->setController(new ControlIndex(*dialog)); dialog->setController(new ControlIndex(*dialog));
dialog->setView(new QIndex(*dialog, dialog->setView(new QIndex(*dialog,

View File

@ -19,7 +19,6 @@
#include "ControlChanges.h" #include "ControlChanges.h"
#include "ControlCharacter.h" #include "ControlCharacter.h"
#include "ControlDocument.h" #include "ControlDocument.h"
#include "ControlExternal.h"
#include "ControlFloat.h" #include "ControlFloat.h"
#include "ControlForks.h" #include "ControlForks.h"
#include "ControlGraphics.h" #include "ControlGraphics.h"
@ -48,8 +47,6 @@
#include "QCharacterDialog.h" #include "QCharacterDialog.h"
#include "QDocument.h" #include "QDocument.h"
#include "QDocumentDialog.h" #include "QDocumentDialog.h"
#include "QExternal.h"
#include "QExternalDialog.h"
#include "QFloat.h" #include "QFloat.h"
#include "QFloatDialog.h" #include "QFloatDialog.h"
//#include "QForks.h" //#include "QForks.h"
@ -113,9 +110,6 @@ CharacterDialog;
typedef GUI<ControlDocument, QDocument, NoRepeatedApplyReadOnlyPolicy, Qt2BC> typedef GUI<ControlDocument, QDocument, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
DocumentDialog; DocumentDialog;
typedef GUI<ControlExternal, QExternal, OkApplyCancelReadOnlyPolicy, Qt2BC>
ExternalDialog;
typedef GUI<ControlShowFile, QShowFile, OkCancelPolicy, Qt2BC> typedef GUI<ControlShowFile, QShowFile, OkCancelPolicy, Qt2BC>
FileDialog; FileDialog;
@ -180,7 +174,6 @@ struct Dialogs::Impl {
ChangesDialog changes; ChangesDialog changes;
CharacterDialog character; CharacterDialog character;
DocumentDialog document; DocumentDialog document;
ExternalDialog external;
FileDialog file; FileDialog file;
FloatDialog floats; FloatDialog floats;
GraphicsDialog graphics; GraphicsDialog graphics;

View File

@ -25,11 +25,11 @@
#include <vector> #include <vector>
typedef Qt2CB<ControlExternal, Qt2DB<QExternalDialog> > base_class; typedef QController<ControlExternal, QView<QExternalDialog> > base_class;
QExternal::QExternal() QExternal::QExternal(Dialog & parent)
: base_class(qt_("LyX: Insert External Material")) : 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(); ExternalTemplate templ =
controller().getTemplate(dialog_->externalCO->currentItem());
params.templ = controller().getTemplate(dialog_->externalCO->currentItem()); return templ.helpText;
return params.templ.helpText;
} }
void QExternal::apply() void QExternal::apply()
{ {
InsetExternal::Params & params = controller().params(); InsetExternal::Params params = controller().params();
params.filename = fromqstr(dialog_->fileED->text()); params.filename = fromqstr(dialog_->fileED->text());
params.parameters = fromqstr(dialog_->paramsED->text()); params.parameters = fromqstr(dialog_->paramsED->text());
params.templ = controller().getTemplate(dialog_->externalCO->currentItem()); params.templ = controller().getTemplate(dialog_->externalCO->currentItem());
controller().setParams(params);
} }

View File

@ -13,18 +13,20 @@
#define QEXTERNAL_H #define QEXTERNAL_H
#include "Qt2Base.h" #include "QDialogView.h"
class ControlExternal; class ControlExternal;
class QExternalDialog; class QExternalDialog;
class QExternal class QExternal
: public Qt2CB<ControlExternal, Qt2DB<QExternalDialog> > : public QController<ControlExternal, QView<QExternalDialog> >
{ {
public: public:
friend class QExternalDialog; friend class QExternalDialog;
QExternal(); QExternal(Dialog &);
private: private:
/// Apply changes /// Apply changes
@ -35,7 +37,7 @@ private:
virtual void build_dialog(); virtual void build_dialog();
/// get the right helptext /// get the right helptext
string const & helpText(); string const helpText() const;
}; };
#endif // QEXTERNAL_H #endif // QEXTERNAL_H

View File

@ -1,3 +1,14 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* 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 <leeming@lyx.org> 2003-03-04 Angus Leeming <leeming@lyx.org>
* FormText.[Ch]: the label of the input widget is passed to the * FormText.[Ch]: the label of the input widget is passed to the

View File

@ -30,7 +30,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
changes(lv, d), changes(lv, d),
character(lv, d), character(lv, d),
document(lv, d), document(lv, d),
external(lv, d),
file(lv, d), file(lv, d),
floats(lv, d), floats(lv, d),
forks(lv, d), forks(lv, d),

View File

@ -46,12 +46,6 @@ void Dialogs::showDocument()
} }
void Dialogs::showExternal(InsetExternal * ie)
{
pimpl_->external.controller().showInset(ie);
}
void Dialogs::showFile(string const & f) void Dialogs::showFile(string const & f)
{ {
pimpl_->file.controller().showFile(f); pimpl_->file.controller().showFile(f);

View File

@ -35,6 +35,10 @@
#include "FormERT.h" #include "FormERT.h"
#include "forms/form_ert.h" #include "forms/form_ert.h"
#include "ControlExternal.h"
#include "FormExternal.h"
#include "forms/form_external.h"
#include "ControlIndex.h" #include "ControlIndex.h"
#include "ControlLabel.h" #include "ControlLabel.h"
@ -63,10 +67,12 @@ typedef ButtonController<OkCancelPolicy, xformsBC>
typedef ButtonController<OkCancelReadOnlyPolicy, xformsBC> typedef ButtonController<OkCancelReadOnlyPolicy, xformsBC>
OkCancelReadOnlyBC; OkCancelReadOnlyBC;
typedef ButtonController<OkApplyCancelReadOnlyPolicy, xformsBC>
OkApplyCancelReadOnlyBC;
typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC>
NoRepeatedApplyReadOnlyBC; NoRepeatedApplyReadOnlyBC;
namespace { namespace {
// char const * const dialognames[] = { "bibitem", "bibtex", "citation", // char const * const dialognames[] = { "bibitem", "bibtex", "citation",
@ -75,8 +81,8 @@ namespace {
// "minipage", "ref", "tabular", "toc", // "minipage", "ref", "tabular", "toc",
// "url", "wrap" }; // "url", "wrap" };
char const * const dialognames[] = { "bibitem", "bibtex", "citation", char const * const dialognames[] = { "bibitem", "bibtex", "citation",
"error", "ert", "index", "label", "ref", "error", "ert", "external", "index",
"toc", "url" }; "label", "ref", "toc", "url" };
char const * const * const end_dialognames = char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *)); dialognames + (sizeof(dialognames) / sizeof(char *));
@ -128,6 +134,10 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlERT(*dialog)); dialog->setController(new ControlERT(*dialog));
dialog->setView(new FormERT(*dialog)); dialog->setView(new FormERT(*dialog));
dialog->setButtonController(new NoRepeatedApplyReadOnlyBC); 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") { } else if (name == "index") {
dialog->setController(new ControlIndex(*dialog)); dialog->setController(new ControlIndex(*dialog));
dialog->setView(new FormText(*dialog, dialog->setView(new FormText(*dialog,

View File

@ -38,10 +38,6 @@
#include "FormDocument.h" #include "FormDocument.h"
#include "forms/form_document.h" #include "forms/form_document.h"
#include "ControlExternal.h"
#include "FormExternal.h"
#include "forms/form_external.h"
#include "ControlFloat.h" #include "ControlFloat.h"
#include "FormFloat.h" #include "FormFloat.h"
#include "forms/form_float.h" #include "forms/form_float.h"
@ -138,9 +134,6 @@ CharacterDialog;
typedef GUI<ControlDocument, FormDocument, NoRepeatedApplyReadOnlyPolicy, xformsBC> typedef GUI<ControlDocument, FormDocument, NoRepeatedApplyReadOnlyPolicy, xformsBC>
DocumentDialog; DocumentDialog;
typedef GUI<ControlExternal, FormExternal, OkApplyCancelReadOnlyPolicy, xformsBC>
ExternalDialog;
typedef GUI<ControlShowFile, FormShowFile, OkCancelPolicy, xformsBC> typedef GUI<ControlShowFile, FormShowFile, OkCancelPolicy, xformsBC>
FileDialog; FileDialog;
@ -213,7 +206,6 @@ struct Dialogs::Impl {
ChangesDialog changes; ChangesDialog changes;
CharacterDialog character; CharacterDialog character;
DocumentDialog document; DocumentDialog document;
ExternalDialog external;
FileDialog file; FileDialog file;
FloatDialog floats; FloatDialog floats;
ForksDialog forks; ForksDialog forks;

View File

@ -24,22 +24,24 @@
#include "support/lstrings.h" #include "support/lstrings.h"
#include FORMS_H_LOCATION #include FORMS_H_LOCATION
typedef FormCB<ControlExternal, FormDB<FD_external> > base_class; typedef FormController<ControlExternal, FormView<FD_external> > base_class;
FormExternal::FormExternal() FormExternal::FormExternal(Dialog & parent)
: base_class(_("Edit external file")) : base_class(parent, _("Edit external file"))
{} {}
void FormExternal::apply() void FormExternal::apply()
{ {
controller().params().filename = InsetExternal::Params params = controller().params();
fl_get_input(dialog_->input_filename);
controller().params().parameters = params.filename = fl_get_input(dialog_->input_filename);
fl_get_input(dialog_->input_parameters); params.parameters = fl_get_input(dialog_->input_parameters);
int const choice = fl_get_choice(dialog_->choice_template) - 1; 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 // set to the chosen template
int const choice = fl_get_choice(dialog_->choice_template) - 1; 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(); updateComboChange();

View File

@ -15,17 +15,18 @@
#define FORMEXTERNAL_H #define FORMEXTERNAL_H
#include "FormBase.h" #include "FormDialogView.h"
#include "insets/insetexternal.h"
class ControlExternal; class ControlExternal;
struct FD_external; struct FD_external;
/// The class for editing External insets via a dialog /// The class for editing External insets via a dialog
class FormExternal : public FormCB<ControlExternal, FormDB<FD_external> > { class FormExternal
: public FormController<ControlExternal, FormView<FD_external> > {
public: public:
/// ///
FormExternal(); FormExternal(Dialog &);
private: private:
/// apply changes /// apply changes
virtual void apply(); virtual void apply();

View File

@ -46,7 +46,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_NorthWest FL_NorthEast gravity: FL_NorthWest FL_NorthEast
name: choice_template name: choice_template
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -82,7 +82,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_SouthWest FL_SouthEast gravity: FL_SouthWest FL_SouthEast
name: input_filename name: input_filename
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -100,7 +100,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_filenamebrowse name: button_filenamebrowse
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -118,7 +118,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_SouthWest FL_SouthEast gravity: FL_SouthWest FL_SouthEast
name: input_parameters name: input_parameters
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -136,7 +136,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_edit name: button_edit
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -154,7 +154,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_view name: button_view
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -172,7 +172,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_update name: button_update
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -190,7 +190,7 @@ shortcut: ^M
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_ok name: button_ok
callback: C_FormBaseOKCB callback: C_FormDialogView_OKCB
argument: 0 argument: 0
-------------------- --------------------
@ -208,7 +208,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_apply name: button_apply
callback: C_FormBaseApplyCB callback: C_FormDialogView_ApplyCB
argument: 0 argument: 0
-------------------- --------------------
@ -226,7 +226,7 @@ shortcut:
resize: FL_RESIZE_ALL resize: FL_RESIZE_ALL
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_close name: button_close
callback: C_FormBaseCancelCB callback: C_FormDialogView_CancelCB
argument: 0 argument: 0
============================== ==============================

View File

@ -1,3 +1,8 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* insetexternal.[Ch]: define a new class InsetExternalMailer and use
it to communicate with the frontend dialogs.
2003-03-04 Lars Gullik Bjønnes <larsbj@gullik.net> 2003-03-04 Lars Gullik Bjønnes <larsbj@gullik.net>
* insettext.C (collapseParagraphs): adjust * insettext.C (collapseParagraphs): adjust

View File

@ -15,13 +15,14 @@
#include "ExternalTemplate.h" #include "ExternalTemplate.h"
#include "BufferView.h" #include "BufferView.h"
#include "buffer.h" #include "buffer.h"
#include "frontends/LyXView.h" #include "funcrequest.h"
#include "lyx_main.h" #include "lyx_main.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "gettext.h" #include "gettext.h"
#include "debug.h" #include "debug.h"
#include "lyxlex.h" #include "lyxlex.h"
#include "frontends/LyXView.h"
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
#include "support/filetools.h" #include "support/filetools.h"
@ -50,16 +51,33 @@ InsetExternal::InsetExternal()
InsetExternal::~InsetExternal() InsetExternal::~InsetExternal()
{ {
lyx::unlink(tempname_); lyx::unlink(tempname_);
hideDialog(); InsetExternalMailer mailer(*this);
mailer.hideDialog();
} }
InsetExternal::Params InsetExternal::params() const InsetExternal::Params const & InsetExternal::params() const
{ {
return params_; 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) void InsetExternal::setFromParams(Params const & p)
{ {
params_.filename = p.filename; params_.filename = p.filename;
@ -74,11 +92,10 @@ string const InsetExternal::editMessage() const
} }
void InsetExternal::edit(BufferView * bv, void InsetExternal::edit(BufferView *, int, int, mouse_button::state)
int /*x*/, int /*y*/, mouse_button::state)
{ {
view_ = bv; InsetExternalMailer mailer(*this);
view_->owner()->getDialogs().showExternal(this); mailer.showDialog();
} }
@ -341,3 +358,57 @@ bool operator!=(InsetExternal::Params const & left,
{ {
return !(left == right); 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();
}

View File

@ -519,9 +519,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
case LFUN_TABULAR_INSERT: case LFUN_TABULAR_INSERT:
code = Inset::TABULAR_CODE; code = Inset::TABULAR_CODE;
break; break;
case LFUN_INSET_EXTERNAL:
code = Inset::EXTERNAL_CODE;
break;
case LFUN_INSET_MARGINAL: case LFUN_INSET_MARGINAL:
code = Inset::MARGIN_CODE; code = Inset::MARGIN_CODE;
break; break;
@ -578,7 +575,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
break; break;
case LFUN_HTMLURL: case LFUN_HTMLURL:
case LFUN_URL: case LFUN_URL:
case LFUN_INSERT_URL:
code = Inset::URL_CODE; code = Inset::URL_CODE;
break; break;
case LFUN_QUOTE: case LFUN_QUOTE:

View File

@ -1626,8 +1626,6 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
doInsertInset(this, cmd, true, true); doInsertInset(this, cmd, true, true);
break; break;
case LFUN_INSERT_URL:
case LFUN_INSET_EXTERNAL:
case LFUN_INDEX_INSERT: case LFUN_INDEX_INSERT:
// Just open the inset // Just open the inset
doInsertInset(this, cmd, true, false); doInsertInset(this, cmd, true, false);