2001-03-28 11:14:05 +00:00
|
|
|
/**
|
2003-02-22 18:01:16 +00:00
|
|
|
* \file gnomeTimeout.C
|
2002-09-25 14:26:13 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-28 11:14:05 +00:00
|
|
|
*
|
|
|
|
* \author Baruch Even
|
2002-03-14 14:03:54 +00:00
|
|
|
* \author Michael Koziarski
|
2002-09-25 14:26:13 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-03-28 11:14:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2003-02-08 00:25:34 +00:00
|
|
|
#include <glibmm/main.h>
|
2003-02-22 18:01:16 +00:00
|
|
|
#include "gnomeTimeout.h"
|
2001-03-28 11:14:05 +00:00
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
|
2003-02-22 18:01:16 +00:00
|
|
|
Timeout::Timeout(unsigned int msec, Type t)
|
|
|
|
: pimpl_(new gnomeTimeout(*this)), type(t), timeout_ms(msec)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
gnomeTimeout::(gnomeTimeoutTimeout * owner)
|
|
|
|
: Timeout::Impl(owner), timeout_id(-1)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void gnomeTimeout::reset()
|
2001-03-28 11:14:05 +00:00
|
|
|
{
|
|
|
|
stop();
|
|
|
|
}
|
|
|
|
|
2003-02-22 18:01:16 +00:00
|
|
|
|
|
|
|
bool gnomeTimeout::running() const
|
2002-03-14 14:03:54 +00:00
|
|
|
{
|
2002-03-21 21:21:28 +00:00
|
|
|
return running_;
|
2002-03-14 14:03:54 +00:00
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2003-02-22 18:01:16 +00:00
|
|
|
|
|
|
|
void gnomeTimeout::start()
|
2001-03-28 11:14:05 +00:00
|
|
|
{
|
|
|
|
if (conn_.connected()) {
|
|
|
|
lyxerr << "Timeout::start: already running!" << std::endl;
|
|
|
|
stop();
|
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2003-02-08 00:25:34 +00:00
|
|
|
conn_ = Glib::signal_timeout().connect(
|
2002-06-02 04:15:33 +00:00
|
|
|
SigC::slot(*this, &Timeout::Pimpl::timeoutEvent),
|
2003-02-22 18:01:16 +00:00
|
|
|
timeout_ms()
|
2001-03-28 11:14:05 +00:00
|
|
|
);
|
2002-03-14 14:03:54 +00:00
|
|
|
running_ = true;
|
2001-03-28 11:14:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-22 18:01:16 +00:00
|
|
|
void gnomeTimeout::stop()
|
2001-03-28 11:14:05 +00:00
|
|
|
{
|
|
|
|
conn_.disconnect();
|
2002-03-14 14:03:54 +00:00
|
|
|
running_ = false;
|
2001-03-28 11:14:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-22 18:01:16 +00:00
|
|
|
bool gnomeTimeout::timeoutEvent()
|
2001-03-28 11:14:05 +00:00
|
|
|
{
|
2003-02-22 18:01:16 +00:00
|
|
|
emit();
|
2002-06-02 04:15:33 +00:00
|
|
|
return false; // discontinue emitting timeouts.
|
2001-03-28 11:14:05 +00:00
|
|
|
}
|