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>
* doc/LaTeXConfig.lyx.in: really get rid of iletter description

View File

@ -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"

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>
* ParagraphList.C (insert): handle insert right before end()

View File

@ -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 },

View File

@ -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

View File

@ -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);

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>
* screen.C (redraw, greyOut): ensure that the painter is started

View File

@ -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 &);
///

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>
* ControlGraphics.C: removed #include "converter.h"

View File

@ -12,82 +12,70 @@
#include <config.h>
#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 <vector>
using std::vector;
ControlExternal::ControlExternal(LyXView & lv, Dialogs & d)
: ControlInset<InsetExternal, InsetExternal::Params>(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<InsetExternal> ie;
ie.reset(static_cast<InsetExternal *>(inset()->clone(*buffer())));
ie->setFromParams(params());
ie->editExternal();
dialog().view().apply();
inset_->editExternal();
}
void ControlExternal::viewExternal()
{
view().apply();
boost::scoped_ptr<InsetExternal> ie;
ie.reset(static_cast<InsetExternal *>(inset()->clone(*buffer())));
ie->setFromParams(params());
ie->viewExternal();
dialog().view().apply();
inset_->viewExternal();
}
void ControlExternal::updateExternal()
{
view().apply();
boost::scoped_ptr<InsetExternal> ie;
ie.reset(static_cast<InsetExternal *>(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;

View File

@ -15,17 +15,29 @@
#define CONTROLEXTERNAL_H
#include "ControlInset.h"
#include "Dialog.h"
#include "insets/insetexternal.h"
#include <boost/scoped_ptr.hpp>
/** A controller for External dialogs.
*/
class ControlExternal
: public ControlInset<InsetExternal, InsetExternal::Params>
{
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<InsetExternal> inset_;
};
#endif // CONTROLEXTERNAL_H

View File

@ -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(); }

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)
{
d.showFile(f);

View File

@ -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 &);

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>
* 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),
character(lv, d),
document(lv, d),
external(lv, d),
file(lv, d),
floats(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)
{
pimpl_->file.controller().showFile(f);

View File

@ -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<OkCancelPolicy, Qt2BC>
typedef ButtonController<OkCancelReadOnlyPolicy, Qt2BC>
OkCancelReadOnlyBC;
typedef ButtonController<OkApplyCancelReadOnlyPolicy, Qt2BC>
OkApplyCancelReadOnlyBC;
typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, Qt2BC>
NoRepeatedApplyReadOnlyBC;
@ -65,8 +71,8 @@ typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, Qt2BC>
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,

View File

@ -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<ControlDocument, QDocument, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
DocumentDialog;
typedef GUI<ControlExternal, QExternal, OkApplyCancelReadOnlyPolicy, Qt2BC>
ExternalDialog;
typedef GUI<ControlShowFile, QShowFile, OkCancelPolicy, Qt2BC>
FileDialog;
@ -180,7 +174,6 @@ struct Dialogs::Impl {
ChangesDialog changes;
CharacterDialog character;
DocumentDialog document;
ExternalDialog external;
FileDialog file;
FloatDialog floats;
GraphicsDialog graphics;

View File

@ -25,11 +25,11 @@
#include <vector>
typedef Qt2CB<ControlExternal, Qt2DB<QExternalDialog> > base_class;
typedef QController<ControlExternal, QView<QExternalDialog> > 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);
}

View File

@ -13,18 +13,20 @@
#define QEXTERNAL_H
#include "Qt2Base.h"
#include "QDialogView.h"
class ControlExternal;
class QExternalDialog;
class QExternal
: public Qt2CB<ControlExternal, Qt2DB<QExternalDialog> >
: public QController<ControlExternal, QView<QExternalDialog> >
{
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

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>
* 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),
character(lv, d),
document(lv, d),
external(lv, d),
file(lv, d),
floats(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)
{
pimpl_->file.controller().showFile(f);

View File

@ -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<OkCancelPolicy, xformsBC>
typedef ButtonController<OkCancelReadOnlyPolicy, xformsBC>
OkCancelReadOnlyBC;
typedef ButtonController<OkApplyCancelReadOnlyPolicy, xformsBC>
OkApplyCancelReadOnlyBC;
typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC>
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,

View File

@ -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<ControlDocument, FormDocument, NoRepeatedApplyReadOnlyPolicy, xformsBC>
DocumentDialog;
typedef GUI<ControlExternal, FormExternal, OkApplyCancelReadOnlyPolicy, xformsBC>
ExternalDialog;
typedef GUI<ControlShowFile, FormShowFile, OkCancelPolicy, xformsBC>
FileDialog;
@ -213,7 +206,6 @@ struct Dialogs::Impl {
ChangesDialog changes;
CharacterDialog character;
DocumentDialog document;
ExternalDialog external;
FileDialog file;
FloatDialog floats;
ForksDialog forks;

View File

@ -24,22 +24,24 @@
#include "support/lstrings.h"
#include FORMS_H_LOCATION
typedef FormCB<ControlExternal, FormDB<FD_external> > base_class;
typedef FormController<ControlExternal, FormView<FD_external> > 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();

View File

@ -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<ControlExternal, FormDB<FD_external> > {
class FormExternal
: public FormController<ControlExternal, FormView<FD_external> > {
public:
///
FormExternal();
FormExternal(Dialog &);
private:
/// apply changes
virtual void apply();

View File

@ -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
==============================

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>
* insettext.C (collapseParagraphs): adjust

View File

@ -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();
}

View File

@ -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:

View File

@ -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);