From d577d991b97ae2b5ee1af23641bcffc3f83af5b2 Mon Sep 17 00:00:00 2001 From: Pixel Date: Wed, 4 Nov 2009 11:56:41 -0800 Subject: Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux. --- iup/src/gtk/iupgtk_timer.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 iup/src/gtk/iupgtk_timer.c (limited to 'iup/src/gtk/iupgtk_timer.c') diff --git a/iup/src/gtk/iupgtk_timer.c b/iup/src/gtk/iupgtk_timer.c new file mode 100755 index 0000000..ecbefa3 --- /dev/null +++ b/iup/src/gtk/iupgtk_timer.c @@ -0,0 +1,61 @@ +/** \file + * \brief Timer for the GTK Driver. + * + * See Copyright Notice in "iup.h" + */ + + +#include +#include + +#include + +#include "iup.h" + +#include "iup_object.h" +#include "iup_attrib.h" +#include "iup_str.h" +#include "iup_assert.h" +#include "iup_timer.h" + + +static gboolean gtkTimerProc(gpointer data) +{ + Ihandle *ih = (Ihandle*)data; + Icallback cb; + + if (!iupObjectCheck(ih)) /* control could be destroyed before timer callback */ + return FALSE; + + cb = IupGetCallback(ih, "ACTION_CB"); + if (cb && cb(ih)==IUP_CLOSE) + IupExitLoop(); + + return TRUE; +} + +void iupdrvTimerRun(Ihandle *ih) +{ + unsigned int time_ms; + + if (ih->serial > 0) /* timer already started */ + return; + + time_ms = iupAttribGetInt(ih, "TIME"); + if (time_ms > 0) + ih->serial = g_timeout_add(time_ms, gtkTimerProc, (gpointer)ih); +} + +void iupdrvTimerStop(Ihandle* ih) +{ + if (ih->serial > 0) + { + g_source_remove(ih->serial); + ih->serial = -1; + } +} + +void iupdrvTimerInitClass(Iclass* ic) +{ + (void)ic; +} -- cgit v1.2.3