summaryrefslogtreecommitdiff
path: root/monkey
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 /monkey
parentfb9b171e325488dc9792ee0f3062f15d8ec597ee (diff)
downloadnetsurf-87f6314dabdc2067a19e01f8b29f9ecc38ed825b.tar.gz
netsurf-87f6314dabdc2067a19e01f8b29f9ecc38ed825b.tar.bz2
move scheduleing into browser operation table
Diffstat (limited to 'monkey')
-rw-r--r--monkey/main.c18
-rw-r--r--monkey/schedule.c23
-rw-r--r--monkey/schedule.h3
3 files changed, 27 insertions, 17 deletions
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 <stdlib.h>
#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 <stdlib.h>
#include <stdbool.h>
-#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 */