Mercurial > audlegacy
annotate src/audacious/general.c @ 4236:1ab015fe2ade
RG icon added. some changes
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Thu, 31 Jan 2008 21:43:51 +0300 |
parents | f6b25d4d2245 |
children | 2b7a74fce100 |
rev | line source |
---|---|
2313 | 1 /* BMP - Cross-platform multimedia player |
2 * Copyright (C) 2003-2004 BMP development team. | |
3 * | |
4 * Based on XMMS: | |
5 * Copyright (C) 1998-2003 XMMS development team. | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2313
diff
changeset
|
9 * the Free Software Foundation; under version 3 of the License. |
2313 | 10 * |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2313
diff
changeset
|
17 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
18 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
19 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
20 * Audacious or using our public API to be a derived work. |
2313 | 21 */ |
22 | |
23 #include <glib.h> | |
24 #include <string.h> | |
25 #include "plugin.h" | |
26 #include "general.h" | |
27 | |
28 GeneralPluginData gp_data = { | |
29 NULL, | |
30 NULL | |
31 }; | |
32 | |
33 GList * | |
34 get_general_list(void) | |
35 { | |
36 return gp_data.general_list; | |
37 } | |
38 | |
39 GList * | |
40 get_general_enabled_list(void) | |
41 { | |
42 return gp_data.enabled_list; | |
43 } | |
44 | |
45 static GeneralPlugin * | |
46 get_general_plugin(gint i) | |
47 { | |
48 GList *node = g_list_nth(get_general_list(), i); | |
49 | |
50 if (!node) | |
51 return NULL; | |
52 | |
53 return GENERAL_PLUGIN(node->data); | |
54 } | |
55 | |
56 void | |
57 enable_general_plugin(gint i, gboolean enable) | |
58 { | |
59 GeneralPlugin *plugin = get_general_plugin(i); | |
60 | |
61 if (!plugin) | |
62 return; | |
63 | |
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
64 if (enable && !plugin->enabled) { |
2313 | 65 gp_data.enabled_list = g_list_append(gp_data.enabled_list, plugin); |
66 if (plugin->init) | |
67 plugin->init(); | |
68 } | |
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
69 else if (!enable && plugin->enabled) { |
2313 | 70 gp_data.enabled_list = g_list_remove(gp_data.enabled_list, plugin); |
71 if (plugin->cleanup) | |
72 plugin->cleanup(); | |
73 } | |
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
74 |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
75 plugin->enabled = enable; |
2313 | 76 } |
77 | |
78 gchar * | |
79 general_stringify_enabled_list(void) | |
80 { | |
81 GString *enable_str; | |
82 gchar *name; | |
83 GList *node = get_general_enabled_list(); | |
84 | |
85 if (!node) | |
86 return NULL; | |
87 | |
88 name = g_path_get_basename(GENERAL_PLUGIN(node->data)->filename); | |
89 enable_str = g_string_new(name); | |
90 g_free(name); | |
91 | |
92 for (node = g_list_next(node); node; node = g_list_next(node)) { | |
93 name = g_path_get_basename(GENERAL_PLUGIN(node->data)->filename); | |
94 g_string_append_c(enable_str, ','); | |
95 g_string_append(enable_str, name); | |
96 g_free(name); | |
97 } | |
98 | |
99 return g_string_free(enable_str, FALSE); | |
100 } | |
101 | |
102 void | |
103 general_enable_from_stringified_list(const gchar * list_str) | |
104 { | |
105 gchar **list, **str; | |
106 GeneralPlugin *plugin; | |
107 | |
108 if (!list_str || !strcmp(list_str, "")) | |
109 return; | |
110 | |
111 list = g_strsplit(list_str, ",", 0); | |
112 | |
113 for (str = list; *str; str++) { | |
114 GList *node; | |
115 | |
116 for (node = get_general_list(); node; node = g_list_next(node)) { | |
117 gchar *base; | |
118 | |
119 base = g_path_get_basename(GENERAL_PLUGIN(node->data)->filename); | |
120 | |
121 if (!strcmp(*str, base)) { | |
122 plugin = GENERAL_PLUGIN(node->data); | |
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
123 plugin->enabled = TRUE; |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3123
diff
changeset
|
124 |
2313 | 125 gp_data.enabled_list = g_list_append(gp_data.enabled_list, |
126 plugin); | |
127 if (plugin->init) | |
128 plugin->init(); | |
129 } | |
130 | |
131 g_free(base); | |
132 } | |
133 } | |
134 | |
135 g_strfreev(list); | |
136 } |