annotate src/audacious/eventqueue.c @ 4787:f04094af8d57

remove XMMS-style fileopener
author mf0102 <0102@gmx.at>
date Tue, 30 Sep 2008 17:58:41 +0200
parents c43530370508
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3149
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
1 /*
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
2 * Audacious
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
3 * Copyright (c) 2006-2007 Audacious development team.
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
4 *
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
7 * the Free Software Foundation; under version 3 of the License.
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
8 *
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
12 * GNU General Public License for more details.
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
13 *
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses>.
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
16 *
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
17 * The Audacious team does not consider modular code linking to
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
18 * Audacious or using our public API to be a derived work.
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
19 */
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
20
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
21 #include "eventqueue.h"
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
22
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
23 static gboolean eventqueue_handle(gpointer udata)
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
24 {
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
25 HookCallQueue *hq = (HookCallQueue *) udata;
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
26
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
27 hook_call(hq->name, hq->user_data);
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
28
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
29 g_free(hq->name);
4581
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
30 if (hq->free_data && hq->user_data)
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
31 g_free(hq->user_data);
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
32
3514
331bfc72ef66 Convert some things to use GSlice.
William Pitcock <nenolod@atheme.org>
parents: 3149
diff changeset
33 g_slice_free(HookCallQueue, hq);
3149
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
34
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
35 return FALSE;
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
36 }
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
37
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
38 void event_queue(const gchar *name, gpointer user_data)
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
39 {
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
40 HookCallQueue *hq;
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
41
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
42 g_return_if_fail(name != NULL);
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
43
3514
331bfc72ef66 Convert some things to use GSlice.
William Pitcock <nenolod@atheme.org>
parents: 3149
diff changeset
44 hq = g_slice_new0(HookCallQueue);
3149
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
45 hq->name = g_strdup(name);
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
46 hq->user_data = user_data;
4581
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
47 hq->free_data = FALSE;
3149
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
48
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
49 g_idle_add_full(G_PRIORITY_HIGH_IDLE, eventqueue_handle, hq, NULL);
84c44d369969 Add eventqueue interface.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
50 }
3720
6f6982108001 Add a function to eventqueue API, event_queue_timed() which calls a hook at a postponed time.
William Pitcock <nenolod@atheme.org>
parents: 3514
diff changeset
51
3721
e71fe9091fc9 oops wrong version
William Pitcock <nenolod@atheme.org>
parents: 3720
diff changeset
52 void event_queue_timed(gint time, const gchar *name, gpointer user_data)
3720
6f6982108001 Add a function to eventqueue API, event_queue_timed() which calls a hook at a postponed time.
William Pitcock <nenolod@atheme.org>
parents: 3514
diff changeset
53 {
6f6982108001 Add a function to eventqueue API, event_queue_timed() which calls a hook at a postponed time.
William Pitcock <nenolod@atheme.org>
parents: 3514
diff changeset
54 HookCallQueue *hq;
6f6982108001 Add a function to eventqueue API, event_queue_timed() which calls a hook at a postponed time.
William Pitcock <nenolod@atheme.org>
parents: 3514
diff changeset
55
6f6982108001 Add a function to eventqueue API, event_queue_timed() which calls a hook at a postponed time.
William Pitcock <nenolod@atheme.org>
parents: 3514
diff changeset
56 g_return_if_fail(name != NULL);
6f6982108001 Add a function to eventqueue API, event_queue_timed() which calls a hook at a postponed time.
William Pitcock <nenolod@atheme.org>
parents: 3514
diff changeset
57
6f6982108001 Add a function to eventqueue API, event_queue_timed() which calls a hook at a postponed time.
William Pitcock <nenolod@atheme.org>
parents: 3514
diff changeset
58 hq = g_slice_new0(HookCallQueue);
6f6982108001 Add a function to eventqueue API, event_queue_timed() which calls a hook at a postponed time.
William Pitcock <nenolod@atheme.org>
parents: 3514
diff changeset
59 hq->name = g_strdup(name);
6f6982108001 Add a function to eventqueue API, event_queue_timed() which calls a hook at a postponed time.
William Pitcock <nenolod@atheme.org>
parents: 3514
diff changeset
60 hq->user_data = user_data;
4581
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
61 hq->free_data = FALSE;
3720
6f6982108001 Add a function to eventqueue API, event_queue_timed() which calls a hook at a postponed time.
William Pitcock <nenolod@atheme.org>
parents: 3514
diff changeset
62
6f6982108001 Add a function to eventqueue API, event_queue_timed() which calls a hook at a postponed time.
William Pitcock <nenolod@atheme.org>
parents: 3514
diff changeset
63 g_timeout_add(time, eventqueue_handle, hq);
6f6982108001 Add a function to eventqueue API, event_queue_timed() which calls a hook at a postponed time.
William Pitcock <nenolod@atheme.org>
parents: 3514
diff changeset
64 }
4581
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
65
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
66 void event_queue_with_data_free(const gchar *name, gpointer user_data)
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
67 {
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
68 HookCallQueue *hq;
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
69
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
70 g_return_if_fail(name != NULL);
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
71 g_return_if_fail(user_data != NULL);
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
72
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
73 hq = g_slice_new0(HookCallQueue);
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
74 hq->name = g_strdup(name);
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
75 hq->user_data = user_data;
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
76 hq->free_data = TRUE;
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
77
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 3721
diff changeset
78 g_idle_add_full(G_PRIORITY_HIGH_IDLE, eventqueue_handle, hq, NULL);
4588
d9b2fe7a2d04 Added a newline at end of file.
Matti Hamalainen <ccr@tnsp.org>
parents: 4581
diff changeset
79 }