]> icculus.org git repositories - mikachu/openbox.git/blob - otk_c/timer.h
otk using ustring for shit that draws. expended its inferface yet some more.
[mikachu/openbox.git] / otk_c / timer.h
1 // -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __timer_h
3 #define __timer_h
4
5 #include <X11/Xlib.h>
6 #include <Python.h>
7
8 #ifdef    TIME_WITH_SYS_TIME
9 #  include <sys/time.h>
10 #  include <time.h>
11 #else // !TIME_WITH_SYS_TIME
12 #  ifdef    HAVE_SYS_TIME_H
13 #    include <sys/time.h>
14 #  else // !HAVE_SYS_TIME_H
15 #    include <time.h>
16 #  endif // HAVE_SYS_TIME_H
17 #endif // TIME_WITH_SYS_TIME
18
19 extern PyTypeObject OtkTimer_Type;
20
21 //! The data passed to the OtkTimeoutHandler function.
22 /*!
23   Note: this is a very useful place to put an object instance, and set the
24   event handler to a static function in the same class.
25 */
26 typedef void *OtkTimeoutData;
27 //! The type of function which can be set as the callback for an OtkTimer
28 //! firing
29 typedef void (*OtkTimeoutHandler)(OtkTimeoutData);
30
31 typedef struct OtkTimer {
32   PyObject_HEAD
33   OtkTimeoutHandler handler;
34   OtkTimeoutData data;
35   Bool recur;
36   long timeout;
37
38   // don't edit these
39   Bool timing;
40   struct timeval start;
41   struct timeval end;
42 } OtkTimer;
43
44 PyObject *OtkTimer_New(OtkTimeoutHandler handler, OtkTimeoutData data);
45
46 //! Causes the timer to begin
47 void OtkTimer_Start(OtkTimer *self);
48
49 //! Causes the timer to stop
50 void OtkTimer_Stop(OtkTimer *self);
51
52 #endif // __timer_h