-// -*- C++ -*-
/**
* \file mailinset.C
* This file is part of LyX, the document processor.
*
* \author Angus Leeming
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "mailinset.h"
-#include "inset.h"
-#include "BufferView.h"
-#include "debug.h"
-#include "frontends/LyXView.h"
-#include "frontends/Dialogs.h"
-#include "Lsstream.h"
-
-namespace {
-
-BufferView * cachedBufferView(InsetBase & inset, string const & title)
-{
- BufferView * const bv = inset.view();
- if (!bv) {
- lyxerr << "MailInset::" << title << ":\n"
- << "The BufferView has not been cached!"
- << std::endl;
- }
- return bv;
-}
+#include "BufferView.h"
-} // namespace anon
+#include "frontends/Dialogs.h"
+#include "frontends/LyXView.h"
-void MailInset::showDialog() const
+void MailInset::showDialog(BufferView * bv) const
{
- BufferView * bv = cachedBufferView(inset(), "showDialog");
- if (!bv)
- return;
-
- bv->owner()->getDialogs().show(name(), inset2string(), &inset());
+ BOOST_ASSERT(bv);
+ bv->owner()->getDialogs().show(name(), inset2string(*bv->buffer()),
+ &inset());
}
-void MailInset::updateDialog() const
+void MailInset::updateDialog(BufferView * bv) const
{
- BufferView * bv = cachedBufferView(inset(), "updateDDialog");
- if (!bv)
- return;
-
- bv->owner()->getDialogs().update(name(), inset2string());
+ BOOST_ASSERT(bv);
+ if(bv->owner()->getDialogs().visible(name()))
+ bv->owner()->getDialogs().update(name(),
+ inset2string(*bv->buffer()));
}
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());
}