Mercurial > audlegacy
annotate audacious/general.c @ 2270:50dea14e2fa3 trunk
[svn] Serbian language upadated
author | kustodian |
---|---|
date | Thu, 04 Jan 2007 14:55:34 -0800 |
parents | f18a5b617c34 |
children |
rev | line source |
---|---|
0 | 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 | |
2105
f18a5b617c34
[svn] - move to GPLv2-only. Based on my interpretation of the license, we are
nenolod
parents:
1459
diff
changeset
|
9 * the Free Software Foundation; under version 2 of the License. |
0 | 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 | |
17 * along with this program; if not, write to the Free Software | |
1459 | 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
0 | 19 */ |
20 | |
21 #include <glib.h> | |
22 #include <string.h> | |
23 #include "plugin.h" | |
24 #include "general.h" | |
25 | |
26 GeneralPluginData gp_data = { | |
27 NULL, | |
28 NULL | |
29 }; | |
30 | |
31 GList * | |
32 get_general_list(void) | |
33 { | |
34 return gp_data.general_list; | |
35 } | |
36 | |
37 GList * | |
38 get_general_enabled_list(void) | |
39 { | |
40 return gp_data.enabled_list; | |
41 } | |
42 | |
43 static GeneralPlugin * | |
44 get_general_plugin(gint i) | |
45 { | |
46 GList *node = g_list_nth(get_general_list(), i); | |
47 | |
48 if (!node) | |
49 return NULL; | |
50 | |
51 return GENERAL_PLUGIN(node->data); | |
52 } | |
53 | |
54 | |
55 void | |
56 general_about(gint i) | |
57 { | |
58 GeneralPlugin *plugin = get_general_plugin(i); | |
59 | |
60 if (!plugin || !plugin->about) | |
61 return; | |
62 | |
63 plugin->about(); | |
64 } | |
65 | |
66 void | |
67 general_configure(gint i) | |
68 { | |
69 GeneralPlugin *plugin = get_general_plugin(i); | |
70 | |
71 if (!plugin || !plugin->configure) | |
72 return; | |
73 | |
74 plugin->configure(); | |
75 } | |
76 | |
77 static gboolean | |
78 general_plugin_is_enabled(GeneralPlugin * plugin) | |
79 { | |
80 return (g_list_find(get_general_enabled_list(), plugin) != NULL); | |
81 } | |
82 | |
83 void | |
84 enable_general_plugin(gint i, gboolean enable) | |
85 { | |
86 GeneralPlugin *plugin = get_general_plugin(i); | |
87 | |
88 if (!plugin) | |
89 return; | |
90 | |
91 if (enable && !general_plugin_is_enabled(plugin)) { | |
92 gp_data.enabled_list = g_list_append(gp_data.enabled_list, plugin); | |
93 if (plugin->init) | |
94 plugin->init(); | |
95 } | |
96 else if (!enable && general_plugin_is_enabled(plugin)) { | |
97 gp_data.enabled_list = g_list_remove(gp_data.enabled_list, plugin); | |
98 if (plugin->cleanup) | |
99 plugin->cleanup(); | |
100 } | |
101 } | |
102 | |
103 gboolean | |
104 general_enabled(gint i) | |
105 { | |
106 return (g_list_find(gp_data.enabled_list, | |
107 get_general_plugin(i)) != NULL); | |
108 } | |
109 | |
110 gchar * | |
111 general_stringify_enabled_list(void) | |
112 { | |
113 GString *enable_str; | |
114 gchar *name; | |
115 GList *node = get_general_enabled_list(); | |
116 | |
117 if (!node) | |
118 return NULL; | |
119 | |
120 name = g_path_get_basename(GENERAL_PLUGIN(node->data)->filename); | |
121 enable_str = g_string_new(name); | |
122 g_free(name); | |
123 | |
124 for (node = g_list_next(node); node; node = g_list_next(node)) { | |
125 name = g_path_get_basename(GENERAL_PLUGIN(node->data)->filename); | |
126 g_string_append_c(enable_str, ','); | |
127 g_string_append(enable_str, name); | |
128 g_free(name); | |
129 } | |
130 | |
131 return g_string_free(enable_str, FALSE); | |
132 } | |
133 | |
134 void | |
135 general_enable_from_stringified_list(const gchar * list_str) | |
136 { | |
137 gchar **list, **str; | |
138 GeneralPlugin *plugin; | |
139 | |
140 if (!list_str || !strcmp(list_str, "")) | |
141 return; | |
142 | |
143 list = g_strsplit(list_str, ",", 0); | |
144 | |
145 for (str = list; *str; str++) { | |
146 GList *node; | |
147 | |
148 for (node = get_general_list(); node; node = g_list_next(node)) { | |
149 gchar *base; | |
150 | |
151 base = g_path_get_basename(GENERAL_PLUGIN(node->data)->filename); | |
152 | |
153 if (!strcmp(*str, base)) { | |
154 plugin = GENERAL_PLUGIN(node->data); | |
155 gp_data.enabled_list = g_list_append(gp_data.enabled_list, | |
156 plugin); | |
157 if (plugin->init) | |
158 plugin->init(); | |
159 } | |
160 | |
161 g_free(base); | |
162 } | |
163 } | |
164 | |
165 g_strfreev(list); | |
166 } |