]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/Timeout_pimpl.C
e68528f60cbb158316e26f8bceae8b50073594ba
[lyx.git] / src / frontends / gnome / Timeout_pimpl.C
1 /**
2  * \file gnome/Timeout_pimpl.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  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #include <config.h>
13
14 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include <gtkmm/main.h>
19 #include "Timeout_pimpl.h"
20 #include "debug.h"
21
22
23 Timeout::Pimpl::Pimpl(Timeout * owner)
24         : owner_(owner)
25 {
26 }
27
28
29 void Timeout::Pimpl::reset()
30 {
31         stop();
32 }
33
34 bool Timeout::Pimpl::running() const
35 {
36         return running_;
37 }
38
39 void Timeout::Pimpl::start()
40 {
41         if (conn_.connected()) {
42                 lyxerr << "Timeout::start: already running!" << std::endl;
43                 stop();
44         }
45
46         conn_ = Gtk::Main::signal_timeout().connect(
47                          SigC::slot(*this, &Timeout::Pimpl::timeoutEvent),
48                          owner_->timeout_ms
49                         );
50         running_ = true;
51 }
52
53
54 void Timeout::Pimpl::stop()
55 {
56         conn_.disconnect();
57         running_ = false;
58 }
59
60
61 bool Timeout::Pimpl::timeoutEvent()
62 {
63         owner_->emit();
64         return false; // discontinue emitting timeouts.
65 }