]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/timer.cpp
added wxTo/FromString() overloads for wxFont (1st part of patch 1760073)
[wxWidgets.git] / src / gtk / timer.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: gtk/timer.cpp
3// Purpose: wxTimer implementation
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#if wxUSE_TIMER
14
15#include "wx/gtk/private/timer.h"
16
17#include <gtk/gtk.h>
18
19// ----------------------------------------------------------------------------
20// wxTimerImpl
21// ----------------------------------------------------------------------------
22
23extern "C" {
24
25static gboolean timeout_callback(gpointer data)
26{
27 wxGTKTimerImpl *timer = (wxGTKTimerImpl*)data;
28
29 const bool keepGoing = !timer->IsOneShot();
30 if ( !keepGoing )
31 timer->Stop();
32
33 // When getting called from GDK's timer handler we
34 // are no longer within GDK's grab on the GUI
35 // thread so we must lock it here ourselves.
36 gdk_threads_enter();
37
38 timer->Notify();
39
40 // Release lock again.
41 gdk_threads_leave();
42
43 return keepGoing;
44}
45
46} // extern "C"
47
48bool wxGTKTimerImpl::Start(int millisecs, bool oneShot)
49{
50 if ( !wxTimerImpl::Start(millisecs, oneShot) )
51 return false;
52
53 wxASSERT_MSG( !m_sourceId, _T("shouldn't be still running") );
54
55 m_sourceId = g_timeout_add(m_milli, timeout_callback, this);
56
57 return true;
58}
59
60void wxGTKTimerImpl::Stop()
61{
62 wxASSERT_MSG( m_sourceId, _T("should be running") );
63
64 g_source_remove(m_sourceId);
65 m_sourceId = 0;
66}
67
68#endif // wxUSE_TIMER
69