annotate src/audacious/interface.c @ 4675:48cdebc174ef

enabled interface destruction
author mf0102 <0102@gmx.at>
date Sun, 29 Jun 2008 18:04:43 +0200
parents 742abc97b3ab
children 07b4e2a5eedb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4666
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
1 /*
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
2 * Audacious2
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
3 * Copyright (c) 2008 William Pitcock <nenolod@dereferenced.org>
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
4 *
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
7 * the Free Software Foundation; under version 3 of the License.
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
8 *
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
12 * GNU General Public License for more details.
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
13 *
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses>.
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
16 *
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
17 * The Audacious team does not consider modular code linking to
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
18 * Audacious or using our public API to be a derived work.
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
19 */
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
20
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
21 #include <glib.h>
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
22 #include <mowgli.h>
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
23
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
24 #include "interface.h"
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
25
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
26 static mowgli_dictionary_t *interface_dict_ = NULL;
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
27
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
28 void
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
29 interface_register(Interface *i)
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
30 {
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
31 if (interface_dict_ == NULL)
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
32 interface_dict_ = mowgli_dictionary_create(g_ascii_strcasecmp);
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
33
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
34 mowgli_dictionary_add(interface_dict_, i->id, i);
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
35 }
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
36
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
37 void
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
38 interface_deregister(Interface *i)
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
39 {
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
40 g_return_if_fail(interface_dict_ != NULL);
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
41
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
42 mowgli_dictionary_delete(interface_dict_, i->id);
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
43 }
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
44
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
45 /*
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
46 * TODO:
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
47 * - set up InterfaceOps struct for the Interface to use
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
48 */
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
49 void
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
50 interface_run(Interface *i)
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
51 {
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
52 i->init();
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
53 }
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
54
4675
48cdebc174ef enabled interface destruction
mf0102 <0102@gmx.at>
parents: 4666
diff changeset
55 void
48cdebc174ef enabled interface destruction
mf0102 <0102@gmx.at>
parents: 4666
diff changeset
56 interface_destroy(Interface *i)
48cdebc174ef enabled interface destruction
mf0102 <0102@gmx.at>
parents: 4666
diff changeset
57 {
48cdebc174ef enabled interface destruction
mf0102 <0102@gmx.at>
parents: 4666
diff changeset
58 if (i->fini != NULL)
48cdebc174ef enabled interface destruction
mf0102 <0102@gmx.at>
parents: 4666
diff changeset
59 i->fini();
48cdebc174ef enabled interface destruction
mf0102 <0102@gmx.at>
parents: 4666
diff changeset
60 }
48cdebc174ef enabled interface destruction
mf0102 <0102@gmx.at>
parents: 4666
diff changeset
61
4666
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
62 Interface *
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
63 interface_get(gchar *id)
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
64 {
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
65 if (interface_dict_ == NULL)
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
66 return NULL;
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
67
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
68 return mowgli_dictionary_retrieve(interface_dict_, id);
742abc97b3ab Add preliminary Interface API.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
69 }