]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/timer.cpp
No real changes, just get rid of _wxMenuAt() in wxOSX menu code.
[wxWidgets.git] / src / gtk1 / timer.cpp
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 #include "wx/wxprec.h"
11
12 #if wxUSE_TIMER
13
14 #include "wx/gtk1/private/timer.h"
15
16 #include "gtk/gtk.h"
17
18 // ----------------------------------------------------------------------------
19 // wxTimer
20 // ----------------------------------------------------------------------------
21
22 extern "C" {
23 static gint timeout_callback(void *data)
24 {
25 wxTimerImpl * const timer = (wxTimerImpl *)data;
26
27 const bool keepGoing = !timer->IsOneShot();
28 if ( !keepGoing )
29 timer->Stop();
30
31 // When getting called from GDK's timer handler we
32 // are no longer within GDK's grab on the GUI
33 // thread so we must lock it here ourselves.
34 gdk_threads_enter();
35
36 timer->Notify();
37
38 // Release lock again.
39 gdk_threads_leave();
40
41 return keepGoing;
42 }
43 }
44
45 bool wxGTKTimerImpl::Start(int millisecs, bool oneShot)
46 {
47 if ( !wxTimerImpl::Start(millisecs, oneShot) )
48 return false;
49
50 wxASSERT_MSG( m_tag == -1, wxT("shouldn't be still running") );
51
52 m_tag = gtk_timeout_add( m_milli, timeout_callback, this );
53
54 return true;
55 }
56
57 void wxGTKTimerImpl::Stop()
58 {
59 wxASSERT_MSG( m_tag != -1, wxT("should be running") );
60
61 gtk_timeout_remove( m_tag );
62 m_tag = -1;
63 }
64
65 #endif // wxUSE_TIMER
66