]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GTimeout.C
Wrap most of the frontend code up inside namespace lyx::frontend.
[lyx.git] / src / frontends / gtk / GTimeout.C
1 /**
2  * \file gtk/GTimeout.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Baruch Even
7  * \author Michael Koziarski
8  * \author Huang Ying
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14 #include <gtkmm.h>
15
16 #include "GTimeout.h"
17 #include "debug.h"
18
19
20 Timeout::Timeout(unsigned int msec, Type t)
21         : pimpl_(new lyx::frontend::GTimeout(*this)),
22           type(t), timeout_ms(msec)
23 {}
24
25 namespace lyx {
26 namespace frontend {
27
28 GTimeout::GTimeout(Timeout & owner)
29         : Timeout::Impl(owner)
30 {
31 }
32
33
34 void GTimeout::reset()
35 {
36         stop();
37 }
38
39
40 bool GTimeout::running() const
41 {
42         return running_;
43 }
44
45
46 void GTimeout::start()
47 {
48         if (conn_.connected()) {
49                 lyxerr << "Timeout::start: already running!" << std::endl;
50                 stop();
51         }
52
53         conn_ = Glib::signal_timeout().connect(
54                          SigC::slot(*this, &GTimeout::timeoutEvent),
55                          timeout_ms()
56                         );
57         running_ = true;
58 }
59
60
61 void GTimeout::stop()
62 {
63         conn_.disconnect();
64         running_ = false;
65 }
66
67
68 bool GTimeout::timeoutEvent()
69 {
70         emit();
71         return false; // discontinue emitting timeouts.
72 }
73
74 } // namespace frontend
75 } // namespace lyx