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/gmain.c | |
| parent | 72c746b089906cafd0c10880aca3fbe78198054b (diff) | |
Get rid of g_timeout_remove and g_io_remove_watch in favor for g_source_remove
Diffstat (limited to 'eglib/gmain.c')
| -rw-r--r-- | eglib/gmain.c | 114 | 
1 files changed, 59 insertions, 55 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 */  | 
