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