]> git.lyx.org Git - lyx.git/blob - src/insets/mailinset.C
Get it right...
[lyx.git] / src / insets / mailinset.C
1 // -*- C++ -*-
2 /**
3  * \file mailinset.C
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #include <config.h>
13
14 #include "mailinset.h"
15 #include "inset.h"
16 #include "BufferView.h"
17 #include "debug.h"
18 #include "frontends/LyXView.h"
19 #include "frontends/Dialogs.h"
20 #include "Lsstream.h"
21
22
23 namespace {
24
25 BufferView * cachedBufferView(InsetBase & inset, string const & title)
26 {
27         BufferView * const bv = inset.view();
28         if (!bv) {
29                 lyxerr << "MailInset::" << title << ":\n"
30                        << "The BufferView has not been cached!"
31                        << std::endl;
32         }
33         return bv;
34 }
35
36 } // namespace anon
37
38
39 void MailInset::showDialog() const
40 {
41         BufferView * bv = cachedBufferView(inset(), "showDialog");
42         if (!bv)
43                 return;
44
45         bv->owner()->getDialogs().show(name(), inset2string(), &inset());
46 }
47
48
49 void MailInset::updateDialog() const
50 {
51         BufferView * bv = cachedBufferView(inset(), "updateDDialog");
52         if (!bv)
53                 return;
54
55         bv->owner()->getDialogs().update(name(), inset2string());
56 }
57
58
59 void MailInset::hideDialog() const
60 {
61         BufferView * bv = cachedBufferView(inset(), "hideDialog");
62         if (!bv)
63                 return;
64
65         InsetBase * cmp = bv->owner()->getDialogs().getOpenInset(name());
66         if (cmp == &inset())
67                 bv->owner()->getDialogs().hide(name());
68 }