+2003-03-10 Angus Leeming <leeming@lyx.org>
+
+ * Dialogs.h (hide): make it a static method that returns a
+ boost::signal2<> & (takes 'name' and 'inset' args).
+
2003-03-09 Angus Leeming <leeming@lyx.org>
* Dialogs.h: remove showMergeChanges.
}
+boost::signal2<void, string const &, InsetBase*> & Dialogs::hide()
+{
+ static BugfixSignal<boost::signal2<void, string const &, InsetBase*> >
+ 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();
}
-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;
#include <boost/scoped_ptr.hpp>
#include <boost/signals/signal0.hpp>
#include <boost/signals/signal1.hpp>
+#include <boost/signals/signal2.hpp>
class Dialog;
class InsetBase;
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<void, string const &, InsetBase*> & hide();
///
void disconnect(string const & name);
///
InsetBase * getOpenInset(string const & name) const;
private:
+ ///
+ void hideSlot(string const & name, InsetBase * inset);
///
void redraw() const;
///
#include <config.h>
#include "ControlChanges.h"
-#include "frontends/Dialogs.h"
-#include "frontends/LyXView.h"
#include "buffer.h"
#include "BufferView.h"
#include "funcrequest.h"
+2003-03-10 Angus Leeming <leeming@lyx.org>
+
+ * 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 <dekelts@tau.ac.il>
* insetfloat.h: Set default placement to an empty string.
}
-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);
}
}
-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);
}
setLoadingBuffer(bv->buffer(), false);
InsetCommandMailer mailer("citation", *this);
- mailer.showDialog();
+ mailer.showDialog(bv);
}
case LFUN_INSET_DIALOG_UPDATE: {
InsetCommandMailer mailer(cmd.argument, *this);
- mailer.updateDialog();
+ mailer.updateDialog(cmd.view());
}
break;
InsetError::~InsetError()
{
- if (view())
- view()->owner()->getDialogs().hide("error");
+ Dialogs::hide()("error", this);
}
}
-bool InsetERT::showInsetDialog(BufferView *) const
+bool InsetERT::showInsetDialog(BufferView * bv) const
{
InsetERTMailer mailer(const_cast<InsetERT &>(*this));
- mailer.showDialog();
+ mailer.showDialog(bv);
return true;
}
case LFUN_INSET_DIALOG_UPDATE: {
InsetExternalMailer mailer(*this);
- mailer.updateDialog();
+ mailer.updateDialog(cmd.view());
}
break;
}
-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);
}
case LFUN_INSET_DIALOG_UPDATE: {
InsetFloatMailer mailer(*this);
- mailer.updateDialog();
+ mailer.updateDialog(cmd.view());
}
break;
if (!inset.showInsetDialog(bv)) {
InsetFloat * tmp = const_cast<InsetFloat *>(this);
InsetFloatMailer mailer(*tmp);
- mailer.showDialog();
+ mailer.showDialog(bv);
}
return true;
}
}
-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);
}
case LFUN_INSET_DIALOG_UPDATE: {
InsetGraphicsMailer mailer(*this);
- mailer.updateDialog();
+ mailer.updateDialog(cmd.view());
}
break;
}
-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);
}
case LFUN_INSET_DIALOG_UPDATE: {
InsetIncludeMailer mailer(*this);
- mailer.updateDialog();
+ mailer.updateDialog(cmd.view());
}
break;
}
-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);
}
}
-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);
}
}
-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);
}
case LFUN_INSET_DIALOG_UPDATE: {
InsetMinipageMailer mailer(*this);
- mailer.updateDialog();
+ mailer.updateDialog(cmd.view());
}
break;
if (!inset.showInsetDialog(bv)) {
InsetMinipage * tmp = const_cast<InsetMinipage *>(this);
InsetMinipageMailer mailer(*tmp);
- mailer.showDialog();
+ mailer.showDialog(bv);
}
return true;
bv->owner()->dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
else if (button == mouse_button::button1) {
InsetCommandMailer mailer("ref", *this);
- mailer.showDialog();
+ mailer.showDialog(bv);
}
}
if (inset->lyxCode() == TABULAR_CODE &&
!the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE)) {
InsetTabularMailer mailer(*this);
- mailer.updateDialog();
+ mailer.updateDialog(bv);
oldcell = actcell;
}
return true;
}
if (cmd.button() == mouse_button::button3 && !ret) {
InsetTabularMailer mailer(*this);
- mailer.showDialog();
+ mailer.showDialog(cmd.view());
return true;
}
return ret;
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:
actcell != oldcell) {
InsetTabular * inset = const_cast<InsetTabular *>(this);
InsetTabularMailer mailer(*inset);
- mailer.updateDialog();
+ mailer.updateDialog(bv);
oldcell = actcell;
}
in_reset_pos = 0;
if (!the_locking_inset || !the_locking_inset->showInsetDialog(bv)) {
InsetTabular * tmp = const_cast<InsetTabular *>(this);
InsetTabularMailer mailer(*tmp);
- mailer.showDialog();
+ mailer.showDialog(bv);
}
return true;
}
}
InsetTabular * tmp = const_cast<InsetTabular *>(this);
InsetTabularMailer mailer(*tmp);
- mailer.showDialog();
+ mailer.showDialog(bv);
}
}
-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);
}
}
-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);
}
case LFUN_INSET_DIALOG_UPDATE: {
InsetWrapMailer mailer(*this);
- mailer.updateDialog();
+ mailer.updateDialog(cmd.view());
}
break;
if (!inset.showInsetDialog(bv)) {
InsetWrap * tmp = const_cast<InsetWrap *>(this);
InsetWrapMailer mailer(*tmp);
- mailer.showDialog();
+ mailer.showDialog(bv);
}
return true;
}
#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());
}
class InsetBase;
+class BufferView;
class MailInset {
///
virtual ~MailInset() {};
///
- void showDialog() const;
+ void showDialog(BufferView *) const;
///
- void updateDialog() const;
+ void updateDialog(BufferView *) const;
///
void hideDialog() const;
///
break;
case LFUN_DIALOG_HIDE:
- owner ->getDialogs().hide(argument);
+ Dialogs::hide()(argument, 0);
break;
case LFUN_DIALOG_DISCONNECT_INSET: