#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"
+using namespace lyx::support;
-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;
+ Assert(bv);
+ bv->owner()->getDialogs().show(name(), inset2string(*bv->buffer()),
+ &inset());
}
-} // namespace anon
-
-void MailInset::showDialog() const
+void MailInset::updateDialog(BufferView * bv) const
{
- BufferView * bv = cachedBufferView(inset(), "showDialog");
- if (!bv)
- return;
-
- bv->owner()->getDialogs().show(name(), inset2string(), &inset());
-}
-
-
-void MailInset::updateDialog() const
-{
- BufferView * bv = cachedBufferView(inset(), "updateDDialog");
- if (!bv)
- return;
-
- bv->owner()->getDialogs().update(name(), inset2string());
+ 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());
}