diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-12-13 22:09:39 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-12-13 22:09:39 +0000 |
commit | 56fc47822c355ed966638aa2649f667d03c8cadb (patch) | |
tree | daf907e6e76a3d195e47b1dc4846bfc09fd6b8d6 | |
parent | e2c096a5884b1cad0c38d1076b79ff276e9ad9d5 (diff) | |
download | navit-56fc47822c355ed966638aa2649f667d03c8cadb.tar.gz |
Add:Core:Improved and implemented idle callback
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1789 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r-- | navit/callback.h | 10 | ||||
-rw-r--r-- | navit/event.c | 4 | ||||
-rw-r--r-- | navit/event_glib.c | 23 |
3 files changed, 33 insertions, 4 deletions
diff --git a/navit/callback.h b/navit/callback.h index 3954b361d..3d437e2e9 100644 --- a/navit/callback.h +++ b/navit/callback.h @@ -94,6 +94,16 @@ static inline struct callback *callback_new_3(void (*func)(void), void *p1, void return callback_new(func, 3, p); } +static inline struct callback *callback_new_4(void (*func)(void), void *p1, void *p2, void *p3, void *p4) +{ + void *p[4]; + p[0]=p1; + p[1]=p2; + p[2]=p3; + p[3]=p4; + return callback_new(func, 4, p); +} + static inline void callback_call_0(struct callback *cb) { callback_call(cb, 0, NULL); diff --git a/navit/event.c b/navit/event.c index f75c3f327..96fdde176 100644 --- a/navit/event.c +++ b/navit/event.c @@ -67,9 +67,9 @@ event_remove_timeout(struct event_timeout *ev) } struct event_idle * -event_add_idle(struct callback *cb) +event_add_idle(int priority, struct callback *cb) { - return event_methods.add_idle(cb); + return event_methods.add_idle(priority,cb); } void diff --git a/navit/event_glib.c b/navit/event_glib.c index 7a4a1ebbb..7a3c6f5f6 100644 --- a/navit/event_glib.c +++ b/navit/event_glib.c @@ -125,15 +125,34 @@ event_glib_remove_timeout(struct event_timeout *ev) g_free(ev); } +struct event_idle { + guint source; + struct callback *cb; +}; + +static gboolean +event_glib_call_idle(struct event_idle *ev) +{ + callback_call_0(ev->cb); + return TRUE; +} + static struct event_idle * -event_glib_add_idle(struct callback *cb) +event_glib_add_idle(int priority, struct callback *cb) { - return NULL; + struct event_idle *ret=g_new0(struct event_idle, 1); + ret->cb=cb; + ret->source = g_idle_add_full(priority+100, (GSourceFunc)event_glib_call_idle, (gpointer)ret, NULL); + return ret; } static void event_glib_remove_idle(struct event_idle *ev) { + if (! ev) + return; + g_source_remove(ev->source); + g_free(ev); } static void |