From: <kr_...@us...> - 2003-03-26 12:56:34
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1:/tmp/cvs-serv29420/port/src/cbits/GTK Modified Files: Timer.c Log Message: bugfixes Index: Timer.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/Timer.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Timer.c 26 Mar 2003 02:19:57 -0000 1.4 --- Timer.c 26 Mar 2003 12:56:30 -0000 1.5 *************** *** 1,71 **** ! #include "Timer.h" ! #include "Handlers_stub.h" ! #include "Internals.h" ! ! static gboolean osTimerProc(gpointer data) ! { ! handleTimer((TimerHandle) data); ! return TRUE; ! } ! ! TimerHandle osCreateTimer(int msecs) ! { ! TimerHandle timer = rmalloc(sizeof(*timer)); ! timer->interval = msecs; ! timer->enabled = TRUE; ! timer->id = (msecs > 0) ? gtk_timeout_add(msecs, osTimerProc, timer) : 0; ! ! gActiveObjects++; ! return timer; ! } ! ! void osDestroyTimer(TimerHandle timer) ! { ! if (timer!=NULL) ! { ! if (timer->id > 0) ! gtk_timeout_remove(timer->id); ! rfree(timer); ! gActiveObjects--; ! } ! } ! ! void osSetTimerInterval(TimerHandle timer, int msecs) ! { ! if (timer->interval != msecs) ! { ! timer->interval = msecs; ! if (timer->enabled) ! { ! if (timer->id > 0) ! gtk_timeout_remove(timer->id); ! timer->id = (msecs > 0) gtk_timeout_add(msecs, osTimerProc, timer) : 0; ! } ! } ! }; ! ! int osGetTimerInterval(TimerHandle timer) ! { ! return timer->interval; ! }; ! ! void osEnableTimer(TimerHandle timer, BOOL enabled) ! { ! timer->enabled = enabled; ! if (timer->enabled) ! { ! if (timer->id <= 0 && timer->interval > 0) ! timer->id = gtk_timeout_add(msecs, osTimerProc, timer); ! } ! else ! { ! if (timer->id > 0) ! gtk_timeout_remove(timer->id); ! timer->id = 0; ! } ! }; ! ! BOOL osIsTimerEnabled(TimerHandle timer) ! { ! return timer->enabled; ! }; --- 1,71 ---- ! #include "Timer.h" ! #include "Handlers_stub.h" ! #include "Internals.h" ! ! static gboolean osTimerProc(gpointer data) ! { ! handleTimer((TimerHandle) data); ! return TRUE; ! } ! ! TimerHandle osCreateTimer(int msecs) ! { ! TimerHandle timer = rmalloc(sizeof(*timer)); ! timer->interval = msecs; ! timer->enabled = TRUE; ! timer->id = (msecs > 0) ? gtk_timeout_add(msecs, osTimerProc, timer) : 0; ! ! gActiveObjects++; ! return timer; ! } ! ! void osDestroyTimer(TimerHandle timer) ! { ! if (timer!=NULL) ! { ! if (timer->id > 0) ! gtk_timeout_remove(timer->id); ! rfree(timer); ! gActiveObjects--; ! } ! } ! ! void osSetTimerInterval(TimerHandle timer, int msecs) ! { ! if (timer->interval != msecs) ! { ! timer->interval = msecs; ! if (timer->enabled) ! { ! if (timer->id > 0) ! gtk_timeout_remove(timer->id); ! timer->id = (msecs > 0) ? gtk_timeout_add(msecs, osTimerProc, timer) : 0; ! } ! } ! }; ! ! int osGetTimerInterval(TimerHandle timer) ! { ! return timer->interval; ! }; ! ! void osEnableTimer(TimerHandle timer, BOOL enabled) ! { ! timer->enabled = enabled; ! if (timer->enabled) ! { ! if (timer->id <= 0 && timer->interval > 0) ! timer->id = gtk_timeout_add(timer->interval, osTimerProc, timer); ! } ! else ! { ! if (timer->id > 0) ! gtk_timeout_remove(timer->id); ! timer->id = 0; ! } ! }; ! ! BOOL osIsTimerEnabled(TimerHandle timer) ! { ! return timer->enabled; ! }; |