summaryrefslogtreecommitdiff
path: root/gtk/schedule.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-03-08 14:13:27 +0000
committerVincent Sanders <vince@kyllikki.org>2014-03-09 15:37:40 +0000
commit87f6314dabdc2067a19e01f8b29f9ecc38ed825b (patch)
tree78f8f8395e3bf3b7ee2c18a7b5a5e6d2d5ca9ddc /gtk/schedule.c
parentfb9b171e325488dc9792ee0f3062f15d8ec597ee (diff)
downloadnetsurf-87f6314dabdc2067a19e01f8b29f9ecc38ed825b.tar.gz
netsurf-87f6314dabdc2067a19e01f8b29f9ecc38ed825b.tar.bz2
move scheduleing into browser operation table
Diffstat (limited to 'gtk/schedule.c')
-rw-r--r--gtk/schedule.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/gtk/schedule.c b/gtk/schedule.c
index 5b168b689..e28675a0b 100644
--- a/gtk/schedule.c
+++ b/gtk/schedule.c
@@ -20,7 +20,8 @@
#include <stdlib.h>
#include <stdbool.h>
-#include "utils/schedule.h"
+#include "utils/errors.h"
+
#include "gtk/schedule.h"
#ifdef DEBUG_GTK_SCHEDULE
@@ -71,7 +72,7 @@ nsgtk_schedule_kill_callback(void *_target, void *_match)
}
}
-void
+static void
schedule_remove(void (*callback)(void *p), void *p)
{
_nsgtk_callback_t cb_match = {
@@ -87,19 +88,27 @@ schedule_remove(void (*callback)(void *p), void *p)
nsgtk_schedule_kill_callback, &cb_match);
}
-void
-schedule(int t, void (*callback)(void *p), void *p)
+/* exported interface documented in gtk/schedule.h */
+nserror nsgtk_schedule(int t, void (*callback)(void *p), void *p)
{
- const int msec_timeout = t * 10;
- _nsgtk_callback_t *cb = malloc(sizeof(_nsgtk_callback_t));
+ _nsgtk_callback_t *cb;
+
/* Kill any pending schedule of this kind. */
schedule_remove(callback, p);
+
+ if (t < 0) {
+ return NSERROR_OK;
+ }
+
+ cb = malloc(sizeof(_nsgtk_callback_t));
cb->callback = callback;
cb->context = p;
cb->callback_killed = false;
/* Prepend is faster right now. */
queued_callbacks = g_list_prepend(queued_callbacks, cb);
- g_timeout_add(msec_timeout, nsgtk_schedule_generic_callback, cb);
+ g_timeout_add(t, nsgtk_schedule_generic_callback, cb);
+
+ return NSERROR_OK;
}
bool