annotate audacious/general.c @ 2015:200970e7a3b1 trunk

[svn] - run chardet against even valid UTF-8 strings, as they may be non-UTF-8 sequences encoded as UTF-8.
author nenolod
date Mon, 27 Nov 2006 15:38:11 -0800
parents 705d4c089fce
children f18a5b617c34
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 * Based on XMMS:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 * (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
1459
705d4c089fce [svn] Fix postal code.
chainsaw
parents: 1458
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 #include <glib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23 #include <string.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 #include "plugin.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 #include "general.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27 GeneralPluginData gp_data = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 NULL
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 get_general_list(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 return gp_data.general_list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38 GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 get_general_enabled_list(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 return gp_data.enabled_list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 static GeneralPlugin *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 get_general_plugin(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 GList *node = g_list_nth(get_general_list(), i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 if (!node)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 return GENERAL_PLUGIN(node->data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 general_about(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 GeneralPlugin *plugin = get_general_plugin(i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 if (!plugin || !plugin->about)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 plugin->about();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 general_configure(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 GeneralPlugin *plugin = get_general_plugin(i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 if (!plugin || !plugin->configure)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 plugin->configure();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 general_plugin_is_enabled(GeneralPlugin * plugin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 return (g_list_find(get_general_enabled_list(), plugin) != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 enable_general_plugin(gint i, gboolean enable)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 GeneralPlugin *plugin = get_general_plugin(i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 if (!plugin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 if (enable && !general_plugin_is_enabled(plugin)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 gp_data.enabled_list = g_list_append(gp_data.enabled_list, plugin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 if (plugin->init)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 plugin->init();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 else if (!enable && general_plugin_is_enabled(plugin)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 gp_data.enabled_list = g_list_remove(gp_data.enabled_list, plugin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 if (plugin->cleanup)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 plugin->cleanup();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 general_enabled(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 return (g_list_find(gp_data.enabled_list,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 get_general_plugin(i)) != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 general_stringify_enabled_list(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114 GString *enable_str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 gchar *name;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 GList *node = get_general_enabled_list();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 if (!node)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 name = g_path_get_basename(GENERAL_PLUGIN(node->data)->filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 enable_str = g_string_new(name);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 g_free(name);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 for (node = g_list_next(node); node; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126 name = g_path_get_basename(GENERAL_PLUGIN(node->data)->filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 g_string_append_c(enable_str, ',');
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 g_string_append(enable_str, name);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 g_free(name);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 return g_string_free(enable_str, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 general_enable_from_stringified_list(const gchar * list_str)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 gchar **list, **str;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 GeneralPlugin *plugin;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 if (!list_str || !strcmp(list_str, ""))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 list = g_strsplit(list_str, ",", 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 for (str = list; *str; str++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 GList *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 for (node = get_general_list(); node; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 gchar *base;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 base = g_path_get_basename(GENERAL_PLUGIN(node->data)->filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 if (!strcmp(*str, base)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 plugin = GENERAL_PLUGIN(node->data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 gp_data.enabled_list = g_list_append(gp_data.enabled_list,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 plugin);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 if (plugin->init)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 plugin->init();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 g_free(base);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 g_strfreev(list);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167 }