diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index db99b80f6b..bb832714c3 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,8 @@ +2003-03-10 Angus Leeming + + * Dialogs.h (hide): make it a static method that returns a + boost::signal2<> & (takes 'name' and 'inset' args). + 2003-03-09 Angus Leeming * Dialogs.h: remove showMergeChanges. diff --git a/src/frontends/Dialogs.C b/src/frontends/Dialogs.C index 23907a8709..bfbfd10e20 100644 --- a/src/frontends/Dialogs.C +++ b/src/frontends/Dialogs.C @@ -43,11 +43,20 @@ boost::signal0 & Dialogs::redrawGUI() } +boost::signal2 & Dialogs::hide() +{ + static BugfixSignal > + thesignal; + return thesignal(); +} + + Dialogs::Dialogs(LyXView & lyxview) : lyxview_(lyxview) { // Connect signals redrawGUI().connect(boost::bind(&Dialogs::redraw, this)); + hide().connect(boost::bind(&Dialogs::hideSlot, this, _1, _2)); // All this is slated to go init_pimpl(); @@ -106,12 +115,15 @@ void Dialogs::update(string const & name, string const & data) } -void Dialogs::hide(string const & name) +void Dialogs::hideSlot(string const & name, InsetBase * inset) { Dialog * dialog = find(name); if (!dialog) return; + if (inset && inset != getOpenInset(name)) + return; + if (dialog->isVisible()) dialog->hide(); open_insets_[name] = 0; diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index b6f9f4b8da..c528fc3c1c 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -18,6 +18,7 @@ #include #include #include +#include class Dialog; class InsetBase; @@ -123,13 +124,17 @@ public: Update the contents of the dialog. */ void update(string const & name, string const & data); - /// - void hide(string const & name); + /** All Dialogs of the given 'name' will be closed if they are + connected to the given 'inset'. + */ + static boost::signal2 & hide(); /// void disconnect(string const & name); /// InsetBase * getOpenInset(string const & name) const; private: + /// + void hideSlot(string const & name, InsetBase * inset); /// void redraw() const; /// diff --git a/src/frontends/controllers/ControlChanges.C b/src/frontends/controllers/ControlChanges.C index 96f744c9ad..b3b6f8feb6 100644 --- a/src/frontends/controllers/ControlChanges.C +++ b/src/frontends/controllers/ControlChanges.C @@ -11,8 +11,6 @@ #include #include "ControlChanges.h" -#include "frontends/Dialogs.h" -#include "frontends/LyXView.h" #include "buffer.h" #include "BufferView.h" #include "funcrequest.h" diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 36c5f9092e..594ca54c96 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,31 @@ +2003-03-10 Angus Leeming + + * mailinset.[Ch] (showDialog, updateDialog): now take a mandatory + BufferView * arg. + (hideDialog): calls the new static Dialogs::hide() method. + + * insetbibitem.C (edit): + * insetbibtex.C (edit): + * insetcite.C (edit): + * insetcommand.C (localDispatch): + * inseterror.C (d-tor): + * insetert.C (showInsetDialog): + * insetexternal.C (localDispatch, edit): + * insetfloat.C (localDispatch, showInsetDialog): + * insetfloatlist.C (edit): + * insetgraphics.C (localDispatch, edit): + * insetinclude.C (localDispatch, edit): + * insetindex.C (edit): + * insetlabel.C (edit): + * insetminipage.C (localDispatch, showInsetDialog): + * insetref.C (edit): + * insettabular.C (unlockInsetInInset, lfunMouseRelease, localDispatch, + resetPos, showInsetDialog, openLayoutDialog): + * insettoc.C (edit): + * inseturl.C (edit): + * insetwrap.C (localDispatch, showInsetDialog): + changes due to the changed MailInset interface. + 2003-03-10 Dekel Tsur * insetfloat.h: Set default placement to an empty string. diff --git a/src/insets/insetbibitem.C b/src/insets/insetbibitem.C index 50abe3fe5b..670c4d200e 100644 --- a/src/insets/insetbibitem.C +++ b/src/insets/insetbibitem.C @@ -126,10 +126,10 @@ string const InsetBibitem::getScreenLabel(Buffer const *) const } -void InsetBibitem::edit(BufferView *, int, int, mouse_button::state) +void InsetBibitem::edit(BufferView * bv, int, int, mouse_button::state) { InsetCommandMailer mailer("bibitem", *this); - mailer.showDialog(); + mailer.showDialog(bv); } diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index 370faeaf2b..6796f5db48 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -218,10 +218,10 @@ void InsetBibtex::fillWithBibKeys } -void InsetBibtex::edit(BufferView *, int, int, mouse_button::state) +void InsetBibtex::edit(BufferView * bv, int, int, mouse_button::state) { InsetCommandMailer mailer("bibtex", *this); - mailer.showDialog(); + mailer.showDialog(bv); } diff --git a/src/insets/insetcite.C b/src/insets/insetcite.C index 9d9db5b0df..8bd95bfdbe 100644 --- a/src/insets/insetcite.C +++ b/src/insets/insetcite.C @@ -324,7 +324,7 @@ void InsetCitation::edit(BufferView * bv, int, int, mouse_button::state) setLoadingBuffer(bv->buffer(), false); InsetCommandMailer mailer("citation", *this); - mailer.showDialog(); + mailer.showDialog(bv); } diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index 70676127b9..95ecbce1a6 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -84,7 +84,7 @@ dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd) case LFUN_INSET_DIALOG_UPDATE: { InsetCommandMailer mailer(cmd.argument, *this); - mailer.updateDialog(); + mailer.updateDialog(cmd.view()); } break; diff --git a/src/insets/inseterror.C b/src/insets/inseterror.C index 084a777bb5..858fcf6f15 100644 --- a/src/insets/inseterror.C +++ b/src/insets/inseterror.C @@ -35,8 +35,7 @@ InsetError::InsetError(string const & str, bool) InsetError::~InsetError() { - if (view()) - view()->owner()->getDialogs().hide("error"); + Dialogs::hide()("error", this); } diff --git a/src/insets/insetert.C b/src/insets/insetert.C index a4807b046f..78783ecde0 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -670,10 +670,10 @@ void InsetERT::status(BufferView * bv, ERTStatus const st) const } -bool InsetERT::showInsetDialog(BufferView *) const +bool InsetERT::showInsetDialog(BufferView * bv) const { InsetERTMailer mailer(const_cast(*this)); - mailer.showDialog(); + mailer.showDialog(bv); return true; } diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 9b8ffe451c..81980a9860 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -81,7 +81,7 @@ dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd) case LFUN_INSET_DIALOG_UPDATE: { InsetExternalMailer mailer(*this); - mailer.updateDialog(); + mailer.updateDialog(cmd.view()); } break; @@ -111,10 +111,10 @@ string const InsetExternal::editMessage() const } -void InsetExternal::edit(BufferView *, int, int, mouse_button::state) +void InsetExternal::edit(BufferView * bv, int, int, mouse_button::state) { InsetExternalMailer mailer(*this); - mailer.showDialog(); + mailer.showDialog(bv); } diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index 27ae97c90c..4a261a507a 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -172,7 +172,7 @@ dispatch_result InsetFloat::localDispatch(FuncRequest const & cmd) case LFUN_INSET_DIALOG_UPDATE: { InsetFloatMailer mailer(*this); - mailer.updateDialog(); + mailer.updateDialog(cmd.view()); } break; @@ -335,7 +335,7 @@ bool InsetFloat::showInsetDialog(BufferView * bv) const if (!inset.showInsetDialog(bv)) { InsetFloat * tmp = const_cast(this); InsetFloatMailer mailer(*tmp); - mailer.showDialog(); + mailer.showDialog(bv); } return true; } diff --git a/src/insets/insetfloatlist.C b/src/insets/insetfloatlist.C index f6b49cef57..eea56091cc 100644 --- a/src/insets/insetfloatlist.C +++ b/src/insets/insetfloatlist.C @@ -96,10 +96,10 @@ void InsetFloatList::read(Buffer const * buf, LyXLex & lex) } -void InsetFloatList::edit(BufferView *, int, int, mouse_button::state) +void InsetFloatList::edit(BufferView * bv, int, int, mouse_button::state) { InsetCommandMailer mailer("toc", *this); - mailer.showDialog(); + mailer.showDialog(bv); } diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index c03c06a6ac..ec49afb8c0 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -237,7 +237,7 @@ dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd) case LFUN_INSET_DIALOG_UPDATE: { InsetGraphicsMailer mailer(*this); - mailer.updateDialog(); + mailer.updateDialog(cmd.view()); } break; @@ -436,10 +436,10 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font, } -void InsetGraphics::edit(BufferView *, int, int, mouse_button::state) +void InsetGraphics::edit(BufferView * bv, int, int, mouse_button::state) { InsetGraphicsMailer mailer(*this); - mailer.showDialog(); + mailer.showDialog(bv); } diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index b03f939202..ec0fb8f226 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -134,7 +134,7 @@ dispatch_result InsetInclude::localDispatch(FuncRequest const & cmd) case LFUN_INSET_DIALOG_UPDATE: { InsetIncludeMailer mailer(*this); - mailer.updateDialog(); + mailer.updateDialog(cmd.view()); } break; @@ -212,10 +212,10 @@ Inset * InsetInclude::clone(Buffer const & buffer, bool) const } -void InsetInclude::edit(BufferView *, int, int, mouse_button::state) +void InsetInclude::edit(BufferView * bv, int, int, mouse_button::state) { InsetIncludeMailer mailer(*this); - mailer.showDialog(); + mailer.showDialog(bv); } diff --git a/src/insets/insetindex.C b/src/insets/insetindex.C index 29d2aa4b80..c7f4b935eb 100644 --- a/src/insets/insetindex.C +++ b/src/insets/insetindex.C @@ -38,10 +38,10 @@ string const InsetIndex::getScreenLabel(Buffer const *) const } -void InsetIndex::edit(BufferView *, int, int, mouse_button::state) +void InsetIndex::edit(BufferView * bv, int, int, mouse_button::state) { InsetCommandMailer mailer("index", *this); - mailer.showDialog(); + mailer.showDialog(bv); } diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index efb874673d..30010afad8 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -45,10 +45,10 @@ vector const InsetLabel::getLabelList() const } -void InsetLabel::edit(BufferView *, int, int, mouse_button::state) +void InsetLabel::edit(BufferView * bv, int, int, mouse_button::state) { InsetCommandMailer mailer("label", *this); - mailer.showDialog(); + mailer.showDialog(bv); } diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index 7586407a7d..02d8a8f8ac 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -124,7 +124,7 @@ dispatch_result InsetMinipage::localDispatch(FuncRequest const & cmd) case LFUN_INSET_DIALOG_UPDATE: { InsetMinipageMailer mailer(*this); - mailer.updateDialog(); + mailer.updateDialog(cmd.view()); } break; @@ -367,7 +367,7 @@ bool InsetMinipage::showInsetDialog(BufferView * bv) const if (!inset.showInsetDialog(bv)) { InsetMinipage * tmp = const_cast(this); InsetMinipageMailer mailer(*tmp); - mailer.showDialog(); + mailer.showDialog(bv); } return true; diff --git a/src/insets/insetref.C b/src/insets/insetref.C index 7f0e3f1b8f..022bebd23e 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -42,7 +42,7 @@ void InsetRef::edit(BufferView * bv, int, int, mouse_button::state button) bv->owner()->dispatch(FuncRequest(LFUN_REF_GOTO, getContents())); else if (button == mouse_button::button1) { InsetCommandMailer mailer("ref", *this); - mailer.showDialog(); + mailer.showDialog(bv); } } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index e43c89c79b..72037697f9 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -736,7 +736,7 @@ bool InsetTabular::unlockInsetInInset(BufferView * bv, UpdatableInset * inset, if (inset->lyxCode() == TABULAR_CODE && !the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE)) { InsetTabularMailer mailer(*this); - mailer.updateDialog(); + mailer.updateDialog(bv); oldcell = actcell; } return true; @@ -884,7 +884,7 @@ bool InsetTabular::lfunMouseRelease(FuncRequest const & cmd) } if (cmd.button() == mouse_button::button3 && !ret) { InsetTabularMailer mailer(*this); - mailer.showDialog(); + mailer.showDialog(cmd.view()); return true; } return ret; @@ -1170,12 +1170,12 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd) break; case LFUN_LAYOUT_TABULAR: { InsetTabularMailer mailer(*this); - mailer.showDialog(); + mailer.showDialog(bv); break; } case LFUN_INSET_DIALOG_UPDATE: { InsetTabularMailer mailer(*this); - mailer.updateDialog(); + mailer.updateDialog(bv); break; } case LFUN_TABULAR_FEATURE: @@ -1667,7 +1667,7 @@ void InsetTabular::resetPos(BufferView * bv) const actcell != oldcell) { InsetTabular * inset = const_cast(this); InsetTabularMailer mailer(*inset); - mailer.updateDialog(); + mailer.updateDialog(bv); oldcell = actcell; } in_reset_pos = 0; @@ -2354,7 +2354,7 @@ bool InsetTabular::showInsetDialog(BufferView * bv) const if (!the_locking_inset || !the_locking_inset->showInsetDialog(bv)) { InsetTabular * tmp = const_cast(this); InsetTabularMailer mailer(*tmp); - mailer.showDialog(); + mailer.showDialog(bv); } return true; } @@ -2372,7 +2372,7 @@ void InsetTabular::openLayoutDialog(BufferView * bv) const } InsetTabular * tmp = const_cast(this); InsetTabularMailer mailer(*tmp); - mailer.showDialog(); + mailer.showDialog(bv); } diff --git a/src/insets/insettoc.C b/src/insets/insettoc.C index 0c64eb5013..8b7816766f 100644 --- a/src/insets/insettoc.C +++ b/src/insets/insettoc.C @@ -53,10 +53,10 @@ Inset::Code InsetTOC::lyxCode() const } -void InsetTOC::edit(BufferView *, int, int, mouse_button::state) +void InsetTOC::edit(BufferView * bv, int, int, mouse_button::state) { InsetCommandMailer mailer("toc", *this); - mailer.showDialog(); + mailer.showDialog(bv); } diff --git a/src/insets/inseturl.C b/src/insets/inseturl.C index 60c2ab2a12..0c1c1f17aa 100644 --- a/src/insets/inseturl.C +++ b/src/insets/inseturl.C @@ -34,10 +34,10 @@ InsetUrl::~InsetUrl() } -void InsetUrl::edit(BufferView *, int, int, mouse_button::state) +void InsetUrl::edit(BufferView * bv, int, int, mouse_button::state) { InsetCommandMailer mailer("url", *this); - mailer.showDialog(); + mailer.showDialog(bv); } diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index 3851bfcc32..92cdeaa4aa 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -102,7 +102,7 @@ dispatch_result InsetWrap::localDispatch(FuncRequest const & cmd) case LFUN_INSET_DIALOG_UPDATE: { InsetWrapMailer mailer(*this); - mailer.updateDialog(); + mailer.updateDialog(cmd.view()); } break; @@ -291,7 +291,7 @@ bool InsetWrap::showInsetDialog(BufferView * bv) const if (!inset.showInsetDialog(bv)) { InsetWrap * tmp = const_cast(this); InsetWrapMailer mailer(*tmp); - mailer.showDialog(); + mailer.showDialog(bv); } return true; } diff --git a/src/insets/mailinset.C b/src/insets/mailinset.C index 69e8e8682d..8cf6e8606f 100644 --- a/src/insets/mailinset.C +++ b/src/insets/mailinset.C @@ -14,55 +14,27 @@ #include "mailinset.h" #include "inset.h" #include "BufferView.h" -#include "debug.h" #include "frontends/LyXView.h" #include "frontends/Dialogs.h" +#include "support/LAssert.h" #include "Lsstream.h" -namespace { - -BufferView * cachedBufferView(InsetBase & inset, string const & title) +void MailInset::showDialog(BufferView * bv) const { - BufferView * const bv = inset.view(); - if (!bv) { - lyxerr << "MailInset::" << title << ":\n" - << "The BufferView has not been cached!" - << std::endl; - } - return bv; -} - -} // namespace anon - - -void MailInset::showDialog() const -{ - BufferView * bv = cachedBufferView(inset(), "showDialog"); - if (!bv) - return; - + lyx::Assert(bv); bv->owner()->getDialogs().show(name(), inset2string(), &inset()); } -void MailInset::updateDialog() const +void MailInset::updateDialog(BufferView * bv) const { - BufferView * bv = cachedBufferView(inset(), "updateDDialog"); - if (!bv) - return; - + lyx::Assert(bv); bv->owner()->getDialogs().update(name(), inset2string()); } void MailInset::hideDialog() const { - BufferView * bv = cachedBufferView(inset(), "hideDialog"); - if (!bv) - return; - - InsetBase * cmp = bv->owner()->getDialogs().getOpenInset(name()); - if (cmp == &inset()) - bv->owner()->getDialogs().hide(name()); + Dialogs::hide()(name(), &inset()); } diff --git a/src/insets/mailinset.h b/src/insets/mailinset.h index e4d1fe3048..b5a365e4cb 100644 --- a/src/insets/mailinset.h +++ b/src/insets/mailinset.h @@ -17,6 +17,7 @@ class InsetBase; +class BufferView; class MailInset { @@ -24,9 +25,9 @@ public: /// virtual ~MailInset() {}; /// - void showDialog() const; + void showDialog(BufferView *) const; /// - void updateDialog() const; + void updateDialog(BufferView *) const; /// void hideDialog() const; /// diff --git a/src/lyxfunc.C b/src/lyxfunc.C index f762f743ce..7638abb4b4 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1409,7 +1409,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) break; case LFUN_DIALOG_HIDE: - owner ->getDialogs().hide(argument); + Dialogs::hide()(argument, 0); break; case LFUN_DIALOG_DISCONNECT_INSET: