]> git.lyx.org Git - lyx.git/blobdiff - src/insets/mailinset.C
Enable convertDefault.sh to run even if its executable bit is not set.
[lyx.git] / src / insets / mailinset.C
index 69e8e8682dd629e2da4f40bad5160d40a6b50c12..eb396823e77e768efcb72a4b25ec1eeb8ac212c1 100644 (file)
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /**
  * \file mailinset.C
  * This file is part of LyX, the document processor.
@@ -6,7 +5,7 @@
  *
  * \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 "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());
 }