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