]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xformsTimeout.C
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / xforms / xformsTimeout.C
1 /**
2  * \file xformsTimeout.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author John Levon
8  * \author Angus Leeming
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "xformsTimeout.h"
16 #include "debug.h"
17
18 #include "lyx_forms.h"
19
20 Timeout::Timeout(unsigned int msec, Type t)
21         : pimpl_(new lyx::frontend::xformsTimeout(*this)),
22           type(t), timeout_ms(msec)
23 {}
24
25
26 namespace lyx {
27 namespace frontend {
28
29 namespace {
30
31 extern "C"
32 void C_TimeoutCB(int, void * data)
33 {
34         xformsTimeout * to = static_cast<xformsTimeout *>(data);
35         to->emitCB();
36 }
37
38 } // namespace anon
39
40
41 xformsTimeout::xformsTimeout(Timeout & owner)
42         : Timeout::Impl(owner), timeout_id(-1)
43 {}
44
45
46 void xformsTimeout::emitCB()
47 {
48         emit();
49 }
50
51
52 bool xformsTimeout::running() const
53 {
54         return timeout_id != -1;
55 }
56
57
58 void xformsTimeout::start()
59 {
60         if (running()) {
61                 lyxerr << "Timeout::start: already running!" << std::endl;
62
63         } else {
64                 timeout_id = fl_add_timeout(timeout_ms(),
65                                             C_TimeoutCB, this);
66         }
67 }
68
69
70 void xformsTimeout::stop()
71 {
72         if (running()) {
73                 fl_remove_timeout(timeout_id);
74                 timeout_id = -1;
75         }
76 }
77
78
79 void xformsTimeout::reset()
80 {
81         timeout_id = -1;
82 }
83
84 } // namespace frontend
85 } // namespace lyx