]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/timer.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/timer.cpp
3 // Purpose: wxTimer implementation
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
14 #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.
43 wxApp
* app
= wxTheApp
;
52 bool wxGTKTimerImpl::Start(int millisecs
, bool oneShot
)
54 if ( !wxTimerImpl::Start(millisecs
, oneShot
) )
57 wxASSERT_MSG( !m_sourceId
, wxT("shouldn't be still running") );
59 m_sourceId
= g_timeout_add(m_milli
, timeout_callback
, this);
64 void wxGTKTimerImpl::Stop()
66 wxASSERT_MSG( m_sourceId
, wxT("should be running") );
68 g_source_remove(m_sourceId
);