]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GTimeout.C
Add ShowFile dialog
[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
15 #include "GTimeout.h"
16 #include "debug.h"
17
18 #include <gtkmm.h>
19
20
21 Timeout::Timeout(unsigned int msec, Type t)
22         : pimpl_(new lyx::frontend::GTimeout(*this)),
23           type(t), timeout_ms(msec)
24 {}
25
26 namespace lyx {
27 namespace frontend {
28
29 GTimeout::GTimeout(Timeout & owner)
30         : Timeout::Impl(owner)
31 {
32 }
33
34
35 void GTimeout::reset()
36 {
37         stop();
38 }
39
40
41 bool GTimeout::running() const
42 {
43         return running_;
44 }
45
46
47 void GTimeout::start()
48 {
49         if (conn_.connected()) {
50                 lyxerr << "Timeout::start: already running!" << std::endl;
51                 stop();
52         }
53
54         conn_ = Glib::signal_timeout().connect(
55                          sigc::mem_fun(*this, &GTimeout::timeoutEvent),
56                          timeout_ms()
57                         );
58         running_ = true;
59 }
60
61
62 void GTimeout::stop()
63 {
64         conn_.disconnect();
65         running_ = false;
66 }
67
68
69 bool GTimeout::timeoutEvent()
70 {
71         emit();
72         return false; // discontinue emitting timeouts.
73 }
74
75 } // namespace frontend
76 } // namespace lyx