From 87f6314dabdc2067a19e01f8b29f9ecc38ed825b Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 8 Mar 2014 14:13:27 +0000 Subject: move scheduleing into browser operation table --- monkey/main.c | 18 ++++++++++-------- monkey/schedule.c | 23 +++++++++++++++-------- monkey/schedule.h | 3 ++- 3 files changed, 27 insertions(+), 17 deletions(-) (limited to 'monkey') diff --git a/monkey/main.c b/monkey/main.c index 07ce7eeeb..96476d26a 100644 --- a/monkey/main.c +++ b/monkey/main.c @@ -21,14 +21,6 @@ #include #include "utils/nsoption.h" -#include "monkey/poll.h" -#include "monkey/dispatch.h" -#include "monkey/browser.h" -#include "monkey/cert.h" -#include "monkey/401login.h" -#include "monkey/filetype.h" -#include "monkey/fetch.h" - #include "content/urldb.h" #include "content/fetchers/resource.h" #include "desktop/gui.h" @@ -37,6 +29,15 @@ #include "utils/filepath.h" #include "utils/url.h" +#include "monkey/poll.h" +#include "monkey/dispatch.h" +#include "monkey/browser.h" +#include "monkey/cert.h" +#include "monkey/401login.h" +#include "monkey/filetype.h" +#include "monkey/fetch.h" +#include "monkey/schedule.h" + char **respaths; /** resource search path vector */ /* Stolen from gtk/gui.c */ @@ -103,6 +104,7 @@ static bool nslog_stream_configure(FILE *fptr) static struct gui_browser_table monkey_browser_table = { .poll = monkey_poll, + .schedule = monkey_schedule, .quit = monkey_quit, .launch_url = gui_launch_url, diff --git a/monkey/schedule.c b/monkey/schedule.c index c4b138533..e8ec1c6fa 100644 --- a/monkey/schedule.c +++ b/monkey/schedule.c @@ -20,7 +20,7 @@ #include #include -#include "utils/schedule.h" +#include "utils/errors.h" #include "monkey/schedule.h" @@ -75,7 +75,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 = { @@ -91,20 +91,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) +nserror monkey_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. */ - LOG(("queued a callback to %p(%p) for %d msecs time", callback, p, msec_timeout)); + LOG(("queued a callback to %p(%p) for %d msecs time", callback, p, t)); 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 diff --git a/monkey/schedule.h b/monkey/schedule.h index c63215e88..44ef9bf3b 100644 --- a/monkey/schedule.h +++ b/monkey/schedule.h @@ -19,7 +19,8 @@ #ifndef NETSURF_GTK_CALLBACK_H #define NETSURF_GTK_CALLBACK_H 1 -typedef void (*gtk_callback)(void *p); +nserror monkey_schedule(int t, void (*callback)(void *p), void *p); + bool schedule_run(void); #endif /* NETSURF_GTK_CALLBACK_H */ -- cgit v1.2.3