diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2007-01-20 14:43:59 +0000 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2007-01-20 14:43:59 +0000 |
commit | f2fdd9fee9109cb0fa7f37a26acd0b1eaf2f40f2 (patch) | |
tree | 1140b225e33ef166d7a256e7ad0efd3195161f57 /eglib | |
parent | 72c746b089906cafd0c10880aca3fbe78198054b (diff) |
Get rid of g_timeout_remove and g_io_remove_watch in favor for g_source_remove
Diffstat (limited to 'eglib')
-rw-r--r-- | eglib/gmain.c | 114 | ||||
-rw-r--r-- | eglib/gmain.h | 2 |
2 files changed, 59 insertions, 57 deletions
diff --git a/eglib/gmain.c b/eglib/gmain.c index 8566265c..ea3adebd 100644 --- a/eglib/gmain.c +++ b/eglib/gmain.c @@ -174,21 +174,11 @@ static GMainContext *g_main_context_default() return default_context; } -gboolean g_source_remove(guint tag) +static gboolean g_io_remove_watch(GMainContext *context, guint id) { - /* Not implemented yet */ - return FALSE; -} - -void g_io_remove_watch(guint id) -{ - GMainContext *context = g_main_context_default(); GSList *l; struct watch *w; - if (!context) - return; - for (l = context->watches; l != NULL; l = l->next) { w = l->data; @@ -198,7 +188,7 @@ void g_io_remove_watch(guint id) context->watches = g_slist_remove(context->watches, w); watch_free(w); - return; + return TRUE; } for (l = context->proc_watches; l != NULL; l = l->next) { @@ -210,8 +200,64 @@ void g_io_remove_watch(guint id) context->proc_watches = g_slist_remove(context->proc_watches, w); watch_free(w); - return; + return TRUE; + } + + return FALSE; +} + +static gboolean g_timeout_remove(GMainContext *context, const guint id) +{ + GSList *l; + struct timeout *t; + + l = context->timeouts; + + while (l) { + t = l->data; + l = l->next; + + if (t->id != id) + continue; + + context->timeouts = g_slist_remove(context->timeouts, t); + free(t); + + return TRUE; } + + l = context->proc_timeouts; + + while (l) { + t = l->data; + l = l->next; + + if (t->id != id) + continue; + + context->proc_timeouts = g_slist_remove(context->proc_timeouts, t); + free(t); + + return TRUE; + } + + return FALSE; +} + +gboolean g_source_remove(guint tag) +{ + GMainContext *context = g_main_context_default(); + + if (!context) + return FALSE; + + if (g_io_remove_watch(context, tag)) + return TRUE; + + if (g_timeout_remove(context, tag)) + return TRUE; + + return FALSE; } int watch_prio_cmp(struct watch *w1, struct watch *w2) @@ -498,48 +544,6 @@ guint g_timeout_add(guint interval, GSourceFunc function, gpointer data) return t->id; } -gint g_timeout_remove(const guint id) -{ - GMainContext *context = g_main_context_default(); - GSList *l; - struct timeout *t; - - if (!context) - return -1; - - l = context->timeouts; - - while (l) { - t = l->data; - l = l->next; - - if (t->id != id) - continue; - - context->timeouts = g_slist_remove(context->timeouts, t); - free(t); - - return 0; - } - - l = context->proc_timeouts; - - while (l) { - t = l->data; - l = l->next; - - if (t->id != id) - continue; - - context->proc_timeouts = g_slist_remove(context->proc_timeouts, t); - free(t); - - return 0; - } - - return -1; -} - guint g_idle_add(GSourceFunc func, gpointer user_data) { /* Not implemented */ diff --git a/eglib/gmain.h b/eglib/gmain.h index 9c50b050..7080c687 100644 --- a/eglib/gmain.h +++ b/eglib/gmain.h @@ -100,14 +100,12 @@ guint g_io_add_watch(GIOChannel *channel, GIOCondition condition, guint g_io_add_watch_full(GIOChannel *channel, gint priority, GIOCondition condition, GIOFunc func, gpointer user_data, GDestroyNotify notify); -void g_io_remove_watch(guint id); GMainLoop *g_main_loop_new(GMainContext *context, gboolean is_running); void g_main_loop_run(GMainLoop *loop); void g_main_loop_quit(GMainLoop *loop); void g_main_loop_unref(GMainLoop *loop); guint g_timeout_add(guint interval, GSourceFunc function, gpointer data); -gint g_timeout_remove(const guint id); gboolean g_source_remove(guint tag); guint g_idle_add(GSourceFunc func, gpointer user_data); |