]>
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"
19 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
25 static gboolean
timeout_callback(gpointer data
)
27 wxGTKTimerImpl
*timer
= (wxGTKTimerImpl
*)data
;
29 const bool keepGoing
= !timer
->IsOneShot();
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.
40 // Release lock again.
48 bool wxGTKTimerImpl::Start(int millisecs
, bool oneShot
)
50 if ( !wxTimerImpl::Start(millisecs
, oneShot
) )
53 wxASSERT_MSG( !m_sourceId
, _T("shouldn't be still running") );
55 m_sourceId
= g_timeout_add(m_milli
, timeout_callback
, this);
60 void wxGTKTimerImpl::Stop()
62 wxASSERT_MSG( m_sourceId
, _T("should be running") );
64 g_source_remove(m_sourceId
);