]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/timer.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTimer implementation
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
15 #include "wx/gtk/private/timer.h"
20 // ----------------------------------------------------------------------------
22 // ----------------------------------------------------------------------------
26 static gboolean
timeout_callback(gpointer data
)
28 wxGTKTimerImpl
*timer
= (wxGTKTimerImpl
*)data
;
30 const bool keepGoing
= !timer
->IsOneShot();
34 // When getting called from GDK's timer handler we
35 // are no longer within GDK's grab on the GUI
36 // thread so we must lock it here ourselves.
41 // Release lock again.
44 wxApp
* app
= wxTheApp
;
53 bool wxGTKTimerImpl::Start(int millisecs
, bool oneShot
)
55 if ( !wxTimerImpl::Start(millisecs
, oneShot
) )
58 wxASSERT_MSG( !m_sourceId
, _T("shouldn't be still running") );
60 m_sourceId
= g_timeout_add(m_milli
, timeout_callback
, this);
65 void wxGTKTimerImpl::Stop()
67 wxASSERT_MSG( m_sourceId
, _T("should be running") );
69 g_source_remove(m_sourceId
);