Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdio.h>
00022
00023 #include "eventqueue.h"
00024
00025 static gboolean eventqueue_handle(gpointer udata)
00026 {
00027 HookCallQueue *hq = (HookCallQueue *) udata;
00028
00029 hook_call(hq->name, hq->user_data);
00030
00031 g_free(hq->name);
00032 if (hq->free_data && hq->user_data)
00033 g_free(hq->user_data);
00034
00035 g_slice_free(HookCallQueue, hq);
00036
00037 return FALSE;
00038 }
00039
00040 void event_queue(const gchar *name, gpointer user_data)
00041 {
00042 HookCallQueue *hq;
00043
00044 hq = g_slice_new0(HookCallQueue);
00045 hq->name = g_strdup(name);
00046 hq->user_data = user_data;
00047 hq->free_data = FALSE;
00048
00049 g_idle_add_full(G_PRIORITY_HIGH_IDLE, eventqueue_handle, hq, NULL);
00050 }
00051
00052 void event_queue_timed(gint time, const gchar *name, gpointer user_data)
00053 {
00054 HookCallQueue *hq;
00055
00056
00057
00058
00059 if (user_data)
00060 {
00061 g_warning("Unsafe event_queue of \"%s\" with "
00062 "pointer. (Use event_queue_with_data_free instead.)\n", name);
00063 return;
00064 }
00065
00066 hq = g_slice_new0(HookCallQueue);
00067 hq->name = g_strdup(name);
00068 hq->user_data = user_data;
00069 hq->free_data = FALSE;
00070
00071 g_timeout_add(time, eventqueue_handle, hq);
00072 }
00073
00074 void event_queue_with_data_free(const gchar *name, gpointer user_data)
00075 {
00076 HookCallQueue *hq;
00077
00078 g_return_if_fail(name != NULL);
00079 g_return_if_fail(user_data != NULL);
00080
00081 hq = g_slice_new0(HookCallQueue);
00082 hq->name = g_strdup(name);
00083 hq->user_data = user_data;
00084 hq->free_data = TRUE;
00085
00086 g_idle_add_full(G_PRIORITY_HIGH_IDLE, eventqueue_handle, hq, NULL);
00087 }