Mercurial > audlegacy
annotate Plugins/Visualization/libvisual-proxy/lv_bmp_config.c @ 395:0923a41170bb trunk
[svn] Add S3M support back after receiving a convincing testcase.
author | chainsaw |
---|---|
date | Sat, 07 Jan 2006 06:18:13 -0800 |
parents | 244cc47a7ae3 |
children |
rev | line source |
---|---|
61 | 1 #include <stdlib.h> |
2 #include <string.h> | |
3 #include <gtk/gtk.h> | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
4 #include <libaudacious/configdb.h> |
314
31725d73a697
[svn] Squash the implicit declaration warnings by including the correct util.h
chainsaw
parents:
313
diff
changeset
|
5 #include <libaudacious/util.h> |
61 | 6 #include <libvisual/libvisual.h> |
7 #include <glib/gi18n.h> | |
8 | |
9 #include "config.h" | |
10 | |
11 #include "lv_bmp_config.h" | |
12 #include "config_gui.h" | |
13 | |
14 #define CONFIG_DEFAULT_ACTOR_PLUGIN "infinite" | |
321
bd81a73eadff
[svn] Okay, braindead configuration handling. Disabling config button for now.
chainsaw
parents:
318
diff
changeset
|
15 #define CONFIG_DEFAULT_INPUT_PLUGIN "alsa" |
61 | 16 #define CONFIG_DEFAULT_MORPH_PLUGIN "alphablend" |
17 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
18 static Options default_options = { NULL, NULL, NULL, 320, 200, 30, 24, FALSE, FALSE, FALSE, TRUE, FALSE }; |
61 | 19 static Options options = { NULL, NULL, NULL, -1, -1, -1, -1, FALSE, FALSE, FALSE, TRUE, FALSE }; |
20 static ConfigWin *config_win = NULL; | |
21 | |
22 static gboolean options_loaded = FALSE; | |
23 static gboolean fullscreen; | |
24 static gboolean gl_plugins_only; | |
25 static gboolean non_gl_plugins_only; | |
26 static gboolean all_plugins_enabled; | |
27 static gboolean random_morph; | |
28 static int fps; | |
29 | |
30 static gchar *actor_plugin_buffer = NULL; | |
31 | |
32 /* Table of GtkListItem's */ | |
33 static GHashTable *actor_plugin_table = NULL; | |
34 | |
35 /* List of gboolean's */ | |
36 static GHashTable *actor_plugin_enable_table = NULL; | |
37 | |
38 /* Lists of VisPluginRef's */ | |
39 static GSList *actor_plugins_gl = NULL; | |
40 static GSList *actor_plugins_nongl = NULL; | |
41 | |
42 static VisPluginRef *current_actor = NULL; | |
43 | |
44 static char *morph_plugin = NULL; | |
45 static char *morph_plugin_buffer = NULL; | |
46 static GSList *morph_plugins_list = NULL; | |
47 | |
48 static void sync_options (void); | |
49 | |
50 static void config_win_load_actor_plugin_gl_list (void); | |
51 static void config_win_load_actor_plugin_nongl_list (void); | |
52 | |
53 static int config_win_load_morph_plugin_list (void); | |
54 | |
55 static int load_actor_plugin_list (void); | |
56 static int load_morph_plugin_list (void); | |
57 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
58 static void load_actor_plugin_enable_table (ConfigDb *db); |
61 | 59 |
60 static void remove_boolean (gpointer key, gpointer value, gpointer data); | |
61 | |
62 static void config_win_set_defaults (void); | |
63 static void config_win_connect_callbacks (void); | |
64 static void config_visual_initialize (void); | |
65 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
66 static gboolean read_config_db (ConfigDb *db); |
61 | 67 |
68 static void dummy (GtkWidget *widget, gpointer data); | |
69 | |
70 Options *lv_bmp_config_open () | |
71 { | |
72 actor_plugin_buffer = g_malloc0 (OPTIONS_MAX_NAME_LEN); | |
73 options.last_plugin = actor_plugin_buffer; | |
74 morph_plugin_buffer = g_malloc0 (OPTIONS_MAX_NAME_LEN); | |
75 | |
76 config_visual_initialize (); | |
77 | |
78 srand (time(NULL)); | |
79 | |
80 load_actor_plugin_list (); | |
81 | |
82 load_morph_plugin_list (); | |
83 | |
84 return &options; | |
85 } | |
86 | |
87 int lv_bmp_config_close () | |
88 { | |
89 if (actor_plugin_buffer != NULL) | |
90 g_free (actor_plugin_buffer); | |
91 if (morph_plugin_buffer != NULL) | |
92 g_free (morph_plugin_buffer); | |
93 | |
94 if (actor_plugin_table) { | |
95 g_hash_table_destroy (actor_plugin_table); | |
96 actor_plugin_table = NULL; | |
97 } | |
98 if (actor_plugin_enable_table) { | |
99 g_hash_table_foreach (actor_plugin_enable_table, remove_boolean, NULL); | |
100 g_hash_table_destroy (actor_plugin_enable_table); | |
101 actor_plugin_enable_table = NULL; | |
102 } | |
103 | |
104 if (actor_plugins_gl) { | |
105 g_slist_free (actor_plugins_gl); | |
106 actor_plugins_gl = NULL; | |
107 } | |
108 if (actor_plugins_nongl) { | |
109 g_slist_free (actor_plugins_nongl); | |
110 actor_plugins_nongl = NULL; | |
111 } | |
112 if (morph_plugins_list) { | |
113 g_slist_free (morph_plugins_list); | |
114 morph_plugins_list = NULL; | |
115 } | |
116 | |
117 options_loaded = FALSE; | |
118 | |
119 return 0; | |
120 } | |
121 | |
122 int lv_bmp_config_load_prefs () | |
123 { | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
124 ConfigDb *db; |
61 | 125 gboolean errors; |
126 GtkWidget *msg; | |
127 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
128 db = bmp_cfg_db_open(); |
61 | 129 |
130 errors = FALSE; | |
321
bd81a73eadff
[svn] Okay, braindead configuration handling. Disabling config button for now.
chainsaw
parents:
318
diff
changeset
|
131 errors = read_config_db (db); |
bd81a73eadff
[svn] Okay, braindead configuration handling. Disabling config button for now.
chainsaw
parents:
318
diff
changeset
|
132 if (errors) |
bd81a73eadff
[svn] Okay, braindead configuration handling. Disabling config button for now.
chainsaw
parents:
318
diff
changeset
|
133 printf("Error reported in config read\n"); |
61 | 134 |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
135 load_actor_plugin_enable_table (db); |
61 | 136 |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
137 bmp_cfg_db_close(db); |
61 | 138 |
139 /* | |
140 * Set our local copies | |
141 */ | |
142 if (!visual_morph_valid_by_name (morph_plugin_buffer)) { | |
143 msg = xmms_show_message (PACKAGE_NAME, | |
144 _("The morph plugin specified on the config\n" | |
145 "file is not a valid morph plugin.\n" | |
146 "We will use "CONFIG_DEFAULT_MORPH_PLUGIN | |
147 " morph plugin instead.\n" | |
148 "If you want another one, please choose it\n" | |
149 "on the configure dialog."), | |
314
31725d73a697
[svn] Squash the implicit declaration warnings by including the correct util.h
chainsaw
parents:
313
diff
changeset
|
150 _("Accept"), TRUE, GTK_SIGNAL_FUNC(dummy), NULL); |
61 | 151 gtk_widget_show (msg); |
152 strcpy (morph_plugin_buffer, CONFIG_DEFAULT_MORPH_PLUGIN); | |
153 } | |
154 options.morph_plugin = morph_plugin_buffer; | |
155 morph_plugin = morph_plugin_buffer; | |
156 random_morph = options.random_morph; | |
157 | |
158 fullscreen = options.fullscreen; | |
159 fps = options.fps; | |
160 gl_plugins_only = options.gl_plugins_only; | |
161 non_gl_plugins_only = options.non_gl_plugins_only; | |
162 all_plugins_enabled = options.all_plugins_enabled; | |
163 | |
164 if (gl_plugins_only) | |
165 visual_log (VISUAL_LOG_INFO, _("GL plugins only")); | |
166 else if (non_gl_plugins_only) | |
167 visual_log (VISUAL_LOG_INFO, _("non GL plugins only")); | |
168 else if (all_plugins_enabled) | |
169 visual_log (VISUAL_LOG_INFO, _("All plugins enabled")); | |
170 else | |
171 visual_log (VISUAL_LOG_WARNING, "Cannot determine which kind of plugin to show"); | |
172 | |
173 if (errors) { | |
321
bd81a73eadff
[svn] Okay, braindead configuration handling. Disabling config button for now.
chainsaw
parents:
318
diff
changeset
|
174 visual_log (VISUAL_LOG_INFO, _("LibVisual: configuration is missing or corrupt, saving defaults")); |
61 | 175 lv_bmp_config_save_prefs (); |
176 } | |
177 | |
178 options_loaded = TRUE; | |
179 | |
180 return 0; | |
181 } | |
182 | |
183 static void save_actor_enable_state (gpointer data, gpointer user_data) | |
184 { | |
185 VisPluginRef *actor; | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
186 ConfigDb *db; |
61 | 187 gboolean *enable; |
188 | |
189 actor = data; | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
190 db = user_data; |
61 | 191 |
192 visual_log_return_if_fail (actor != NULL); | |
193 visual_log_return_if_fail (actor->info != NULL); | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
194 visual_log_return_if_fail (db != NULL); |
61 | 195 |
196 enable = g_hash_table_lookup (actor_plugin_enable_table, actor->info->plugname); | |
197 if (!enable) { | |
198 visual_log (VISUAL_LOG_DEBUG, "enable == NULL for %s", actor->info->plugname); | |
199 return; | |
200 } | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
201 bmp_cfg_db_set_bool (db, "libvisual", actor->info->plugname, *enable); |
61 | 202 } |
203 | |
204 int lv_bmp_config_save_prefs () | |
205 { | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
206 ConfigDb *db; |
61 | 207 |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
208 db = bmp_cfg_db_open(); |
61 | 209 |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
210 bmp_cfg_db_set_string (db, "libvisual", "version", VERSION); |
61 | 211 |
212 if (options.last_plugin != NULL && (strlen(options.last_plugin) > 0)) | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
213 bmp_cfg_db_set_string (db, "libvisual", "last_plugin", options.last_plugin); |
61 | 214 else |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
215 bmp_cfg_db_set_string (db, "libvisual", "last_plugin", CONFIG_DEFAULT_ACTOR_PLUGIN); |
61 | 216 |
217 if (options.morph_plugin != NULL && (strlen(options.morph_plugin) > 0)) | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
218 bmp_cfg_db_set_string (db, "libvisual", "morph_plugin", options.morph_plugin); |
61 | 219 else |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
220 bmp_cfg_db_set_string (db, "libvisual", "morph_plugin", CONFIG_DEFAULT_MORPH_PLUGIN); |
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
221 bmp_cfg_db_set_bool (db, "libvisual", "random_morph", options.random_morph); |
61 | 222 |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
223 bmp_cfg_db_set_int (db, "libvisual", "width", options.width); |
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
224 bmp_cfg_db_set_int (db, "libvisual", "height", options.height); |
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
225 bmp_cfg_db_set_int (db, "libvisual", "color_depth", options.depth); |
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
226 bmp_cfg_db_set_int (db, "libvisual", "fps", options.fps); |
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
227 bmp_cfg_db_set_bool (db, "libvisual", "fullscreen", options.fullscreen); |
61 | 228 if (options.gl_plugins_only) |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
229 bmp_cfg_db_set_string (db, "libvisual", "enabled_plugins", "gl_only"); |
61 | 230 else if (options.non_gl_plugins_only) |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
231 bmp_cfg_db_set_string (db, "libvisual", "enabled_plugins", "non_gl_only"); |
61 | 232 else if (options.all_plugins_enabled) |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
233 bmp_cfg_db_set_string (db, "libvisual", "enabled_plugins", "all"); |
61 | 234 else |
235 g_warning ("Inconsistency on config module"); | |
236 | |
237 visual_log_return_val_if_fail (actor_plugins_gl != NULL, -1); | |
238 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
239 g_slist_foreach (actor_plugins_gl, save_actor_enable_state, db); |
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
240 g_slist_foreach (actor_plugins_nongl, save_actor_enable_state, db); |
61 | 241 |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
242 bmp_cfg_db_close(db); |
61 | 243 |
244 return 0; | |
245 } | |
246 | |
247 void lv_bmp_config_toggle_fullscreen (void) | |
248 { | |
249 fullscreen = !fullscreen; | |
250 options.fullscreen = !options.fullscreen; | |
251 if (config_win != NULL) | |
252 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->checkbutton_fullscreen), | |
253 fullscreen); | |
254 } | |
255 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
256 char *lv_bmp_config_get_prev_actor (void) |
61 | 257 { |
258 const gchar *prev_plugin; | |
259 gboolean *plugin_enabled; | |
260 int round; | |
261 | |
262 round = 0; | |
263 prev_plugin = options.last_plugin; | |
264 do { | |
265 prev_plugin = visual_actor_get_prev_by_name (prev_plugin); | |
266 if (!prev_plugin) { | |
267 round++; | |
268 continue; | |
269 } | |
270 plugin_enabled = g_hash_table_lookup (actor_plugin_enable_table, prev_plugin); | |
271 if (!plugin_enabled) | |
272 continue; | |
273 if (*plugin_enabled) | |
274 return prev_plugin; | |
275 } while (round < 2); | |
276 | |
277 return NULL; | |
278 } | |
279 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
280 char *lv_bmp_config_get_next_actor (void) |
61 | 281 { |
282 const gchar *next_plugin; | |
283 gboolean *plugin_enabled; | |
284 int round; | |
285 | |
286 round = 0; | |
287 next_plugin = options.last_plugin; | |
288 do { | |
289 next_plugin = visual_actor_get_next_by_name (next_plugin); | |
290 if (!next_plugin) { | |
291 round++; | |
292 continue; | |
293 } | |
294 plugin_enabled = g_hash_table_lookup (actor_plugin_enable_table, next_plugin); | |
295 if (!plugin_enabled) | |
296 continue; | |
297 if (*plugin_enabled) | |
298 return next_plugin; | |
299 } while (round < 2); | |
300 | |
301 return NULL; | |
302 } | |
303 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
304 void lv_bmp_config_set_current_actor (char *name) |
61 | 305 { |
306 visual_log_return_if_fail (name != NULL); | |
307 | |
308 options.last_plugin = name; | |
309 } | |
310 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
311 char *lv_bmp_config_morph_plugin (void) |
61 | 312 { |
313 GSList *l; | |
314 int i, pos; | |
315 | |
316 visual_log_return_val_if_fail (g_slist_length (morph_plugins_list) > 0, NULL); | |
317 | |
318 if (random_morph) { | |
319 pos = (rand () % (g_slist_length (morph_plugins_list))); | |
320 l = morph_plugins_list; | |
321 for (i = 0; i < pos; i++) | |
322 l = g_slist_next(l); | |
323 return ((char*)l->data); | |
324 } else { | |
325 return options.morph_plugin; | |
326 } | |
327 } | |
328 | |
329 void lv_bmp_config_window () | |
330 { | |
331 if (config_win != NULL) { | |
332 gtk_widget_grab_default (config_win->button_cancel); | |
333 gtk_widget_show (config_win->window_main); | |
334 return; | |
335 } | |
336 | |
337 config_visual_initialize (); | |
338 | |
339 if (!options_loaded) { | |
340 lv_bmp_config_open (); | |
341 lv_bmp_config_load_prefs (); | |
342 } | |
343 | |
344 config_win = lv_bmp_config_gui_new (); | |
345 | |
346 if (options_loaded) { | |
347 gtk_spin_button_set_value (GTK_SPIN_BUTTON(config_win->spinbutton_fps), options.fps); | |
348 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->checkbutton_fullscreen), | |
349 options.fullscreen); | |
350 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->radiobutton_onlygl), | |
351 options.gl_plugins_only); | |
352 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->radiobutton_onlynongl), | |
353 options.non_gl_plugins_only); | |
354 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->radiobutton_all_plugins), | |
355 options.all_plugins_enabled); | |
356 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->checkbutton_morph_random), | |
357 options.random_morph); | |
358 | |
359 } else { | |
360 config_win_set_defaults (); | |
361 } | |
362 | |
363 config_win_connect_callbacks (); | |
364 | |
365 gtk_widget_grab_default (config_win->button_cancel); | |
366 | |
367 if (options.all_plugins_enabled || options.non_gl_plugins_only) | |
368 config_win_load_actor_plugin_nongl_list (); | |
369 if (options.all_plugins_enabled || options.gl_plugins_only) | |
370 config_win_load_actor_plugin_gl_list (); | |
371 | |
372 config_win_load_morph_plugin_list (); | |
373 | |
374 gtk_widget_show (config_win->window_main); | |
375 } | |
376 | |
377 static void on_checkbutton_fullscreen_toggled (GtkToggleButton *togglebutton, gpointer user_data) | |
378 { | |
379 fullscreen = !fullscreen; | |
380 } | |
381 | |
382 static void on_radiobutton_opengl_toggled (GtkToggleButton *togglebutton, gpointer user_data) | |
383 { | |
384 gl_plugins_only = !gl_plugins_only; | |
385 | |
386 gtk_list_clear_items (GTK_LIST(config_win->list_vis_plugins), 0, -1); | |
387 config_win_load_actor_plugin_gl_list (); | |
388 } | |
389 | |
390 static void on_radiobutton_non_opengl_toggled (GtkToggleButton *togglebutton, gpointer user_data) | |
391 { | |
392 non_gl_plugins_only = !non_gl_plugins_only; | |
393 | |
394 gtk_list_clear_items (GTK_LIST(config_win->list_vis_plugins), 0, -1); | |
395 config_win_load_actor_plugin_nongl_list (); | |
396 } | |
397 | |
398 static void on_radiobutton_all_plugins_toggled (GtkToggleButton *togglebutton, gpointer user_data) | |
399 { | |
400 all_plugins_enabled = !all_plugins_enabled; | |
401 | |
402 gtk_list_clear_items (GTK_LIST(config_win->list_vis_plugins), 0, -1); | |
403 config_win_load_actor_plugin_gl_list (); | |
404 config_win_load_actor_plugin_nongl_list (); | |
405 } | |
406 | |
407 static void on_spinbutton_fps_changed (GtkEditable *editable, gpointer user_data) | |
408 { | |
409 gchar *buffer; | |
410 | |
411 buffer = gtk_editable_get_chars (editable, (gint) 0, (gint) -1); | |
412 fps = atoi (buffer); | |
413 g_free (buffer); | |
414 } | |
415 | |
416 static void on_button_ok_clicked (GtkButton *button, gpointer user_data) | |
417 { | |
418 sync_options (); | |
419 lv_bmp_config_save_prefs (); | |
420 gtk_widget_hide (gtk_widget_get_toplevel (GTK_WIDGET(button))); | |
421 } | |
422 | |
423 static void on_button_apply_clicked (GtkButton *button, gpointer user_data) | |
424 { | |
425 sync_options (); | |
426 lv_bmp_config_save_prefs (); | |
427 } | |
428 | |
429 | |
430 static void on_button_cancel_clicked (GtkButton *button, gpointer user_data) | |
431 { | |
432 /* | |
433 * Restore original values | |
434 */ | |
435 if (options_loaded) { | |
436 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->checkbutton_fullscreen), | |
437 options.fullscreen); | |
438 gtk_spin_button_set_value (GTK_SPIN_BUTTON(config_win->spinbutton_fps), options.fps); | |
439 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->radiobutton_onlygl), | |
440 options.gl_plugins_only); | |
441 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->radiobutton_onlynongl), | |
442 options.non_gl_plugins_only); | |
443 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->radiobutton_all_plugins), | |
444 options.all_plugins_enabled); | |
445 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->checkbutton_morph_random), | |
446 options.random_morph); | |
447 | |
448 } else { | |
449 config_win_set_defaults (); | |
450 } | |
451 | |
452 gtk_widget_hide (gtk_widget_get_toplevel (GTK_WIDGET(button))); | |
453 } | |
454 | |
455 static void sync_options () | |
456 { | |
457 options.fullscreen = fullscreen; | |
458 options.fps = fps; | |
459 options.gl_plugins_only = gl_plugins_only; | |
460 options.non_gl_plugins_only = non_gl_plugins_only; | |
461 options.all_plugins_enabled = all_plugins_enabled; | |
462 options.morph_plugin = morph_plugin; | |
463 options.random_morph = random_morph; | |
464 } | |
465 | |
466 static void on_checkbutton_vis_plugin_toggled (GtkToggleButton *togglebutton, gpointer user_data); | |
467 | |
468 static void on_actor_plugin_selected (GtkListItem *item, VisPluginRef *actor) | |
469 { | |
470 gboolean *enabled; | |
471 | |
472 visual_log_return_if_fail (actor != NULL); | |
473 visual_log_return_if_fail (actor->info != NULL); | |
474 | |
475 current_actor = actor; | |
476 enabled = g_hash_table_lookup (actor_plugin_enable_table, actor->info->plugname); | |
477 visual_log_return_if_fail (enabled != NULL); | |
478 | |
479 gtk_signal_disconnect_by_func (GTK_OBJECT (config_win->checkbutton_vis_plugin), | |
314
31725d73a697
[svn] Squash the implicit declaration warnings by including the correct util.h
chainsaw
parents:
313
diff
changeset
|
480 GTK_SIGNAL_FUNC(on_checkbutton_vis_plugin_toggled), NULL); |
61 | 481 |
482 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->checkbutton_vis_plugin), *enabled); | |
483 | |
484 gtk_signal_connect (GTK_OBJECT (config_win->checkbutton_vis_plugin), "toggled", | |
485 GTK_SIGNAL_FUNC (on_checkbutton_vis_plugin_toggled), | |
486 NULL); | |
487 } | |
488 | |
489 static void on_checkbutton_vis_plugin_toggled (GtkToggleButton *togglebutton, gpointer user_data) | |
490 { | |
491 GtkWidget *item; | |
492 GList *items = NULL; | |
493 gint pos; | |
494 gchar *name; | |
495 gchar *plugname; | |
496 gboolean *enable; | |
497 | |
498 if (!current_actor) | |
499 return; | |
500 | |
501 plugname = current_actor->info->plugname; | |
502 if (gtk_toggle_button_get_active (togglebutton)) { | |
503 /* We are enabling the selected actor */ | |
504 item = g_hash_table_lookup (actor_plugin_table, plugname); | |
505 g_hash_table_remove (actor_plugin_table, plugname); | |
506 | |
507 /* Drop the item from the list, after save his position */ | |
508 pos = gtk_list_child_position (GTK_LIST(config_win->list_vis_plugins), item); | |
509 items = g_list_append (items, item); | |
510 gtk_list_remove_items (GTK_LIST(config_win->list_vis_plugins), items); | |
511 g_list_free (items); | |
512 | |
513 /* Create a new item marked as enabled */ | |
375
244cc47a7ae3
[svn] We have no choice but to continue as planned. Deploy the sentinels!
chainsaw
parents:
321
diff
changeset
|
514 name = g_strconcat (current_actor->info->name, _(" (enabled)"), NULL); |
61 | 515 item = gtk_list_item_new_with_label (name); |
516 g_free (name); | |
517 /*gtk_list_select_item (GTK_LIST(config_win->list_vis_plugins), pos);*/ | |
518 gtk_widget_show (item); | |
519 gtk_signal_connect (GTK_OBJECT(item), "select", | |
520 GTK_SIGNAL_FUNC(on_actor_plugin_selected), | |
521 (gpointer) current_actor); | |
522 | |
523 /* Insert the new item */ | |
524 items = NULL; | |
525 items = g_list_append (items, item); | |
526 gtk_list_insert_items (GTK_LIST(config_win->list_vis_plugins), items, pos); | |
527 | |
528 g_hash_table_insert (actor_plugin_table, plugname, item); | |
529 | |
530 /* Mark it as enabled */ | |
531 enable = g_hash_table_lookup (actor_plugin_enable_table, plugname); | |
532 visual_log_return_if_fail (enable != NULL); | |
533 *enable = TRUE; | |
534 } else { | |
535 item = g_hash_table_lookup (actor_plugin_table, plugname); | |
536 g_hash_table_remove (actor_plugin_table, plugname); | |
537 | |
538 /* Drop the item from the list, after save his position */ | |
539 pos = gtk_list_child_position (GTK_LIST(config_win->list_vis_plugins), item); | |
540 items = g_list_append (items, item); | |
541 gtk_list_remove_items (GTK_LIST(config_win->list_vis_plugins), items); | |
542 g_list_free (items); | |
543 | |
544 /* Create a new item marked as enabled */ | |
545 item = gtk_list_item_new_with_label (current_actor->info->name); | |
546 /*gtk_list_select_item (GTK_LIST(config_win->list_vis_plugins), pos);*/ | |
547 gtk_widget_show (item); | |
548 gtk_signal_connect (GTK_OBJECT(item), "select", | |
549 GTK_SIGNAL_FUNC(on_actor_plugin_selected), | |
550 (gpointer) current_actor); | |
551 | |
552 /* Insert the new item */ | |
553 items = NULL; | |
554 items = g_list_append (items, item); | |
555 gtk_list_insert_items (GTK_LIST(config_win->list_vis_plugins), items, pos); | |
556 | |
557 g_hash_table_insert (actor_plugin_table, plugname, item); | |
558 | |
559 /* Mark it as disabled */ | |
560 enable = g_hash_table_lookup (actor_plugin_enable_table, plugname); | |
561 visual_log_return_if_fail (enable != NULL); | |
562 *enable = FALSE; | |
563 } | |
564 } | |
565 | |
566 static void on_button_vis_plugin_about_clicked (GtkButton *button, gpointer data) | |
567 { | |
568 GtkWidget *msgwin; | |
569 gchar *msg; | |
570 | |
571 if (!current_actor) | |
572 return; | |
573 | |
574 visual_log_return_if_fail (current_actor->info != NULL); | |
575 | |
576 msg = g_strconcat (current_actor->info->name, "\n", | |
577 _("Version: "), current_actor->info->version, "\n", | |
578 current_actor->info->about, "\n", | |
579 _("Author: "), current_actor->info->author, "\n\n", | |
375
244cc47a7ae3
[svn] We have no choice but to continue as planned. Deploy the sentinels!
chainsaw
parents:
321
diff
changeset
|
580 current_actor->info->help, NULL); |
314
31725d73a697
[svn] Squash the implicit declaration warnings by including the correct util.h
chainsaw
parents:
313
diff
changeset
|
581 msgwin = xmms_show_message (PACKAGE_NAME, msg, _("Accept"), TRUE, GTK_SIGNAL_FUNC(dummy), NULL); |
61 | 582 gtk_widget_show (msgwin); |
583 g_free (msg); | |
584 } | |
585 | |
586 /* FIXME Libvisual API must have something for doing this! */ | |
587 static int is_gl_actor (VisPluginRef *actor) | |
588 { | |
589 VisPluginData *plugin; | |
590 VisActorPlugin *actplugin; | |
591 | |
592 visual_log_return_val_if_fail (actor != NULL, -1); | |
593 visual_log_return_val_if_fail (actor->info->plugin != NULL, -1); | |
594 | |
595 plugin = visual_plugin_load (actor); | |
596 actplugin = plugin->info->plugin; | |
597 if (actplugin->depth & VISUAL_VIDEO_DEPTH_GL) { | |
598 visual_plugin_unload (plugin); | |
599 return TRUE; | |
600 } else { | |
601 visual_plugin_unload (plugin); | |
602 return FALSE; | |
603 } | |
604 } | |
605 | |
606 static void actor_plugin_add (VisPluginRef *actor) | |
607 { | |
608 visual_log_return_if_fail (actor != NULL); | |
609 | |
610 if (is_gl_actor (actor)) | |
611 actor_plugins_gl = g_slist_append (actor_plugins_gl, actor); | |
612 else | |
613 actor_plugins_nongl = g_slist_append (actor_plugins_nongl, actor); | |
614 } | |
615 | |
616 /* | |
617 * This function initializes the actor_plugin_(gl/nongl)_items lists. | |
618 */ | |
619 static int load_actor_plugin_list () | |
620 { | |
621 VisList *list; | |
622 VisListEntry *item; | |
623 VisPluginRef *actor; | |
624 GtkWidget *msg; | |
625 | |
626 /* We want to load the lists just once */ | |
627 visual_log_return_val_if_fail (actor_plugins_gl == NULL, -1); | |
628 visual_log_return_val_if_fail (actor_plugins_nongl == NULL, -1); | |
629 | |
630 list = visual_actor_get_list (); | |
631 if (!list) { | |
632 visual_log (VISUAL_LOG_WARNING, _("The list of actor plugins is empty.")); | |
633 return -1; | |
634 } | |
635 | |
636 item = NULL; | |
637 /* FIXME update to visual_list_is_empty() when ready */ | |
638 if (!(actor = (VisPluginRef*) visual_list_next (list, &item))) { | |
639 msg = xmms_show_message (_(PACKAGE_NAME " error"), | |
640 _("There are no actor plugins installed.\n" | |
641 PACKAGE_NAME " cannot be initialized.\n" | |
642 "Please visit http://libvisual.sf.net to\n" | |
643 "to get some nice plugins."), | |
314
31725d73a697
[svn] Squash the implicit declaration warnings by including the correct util.h
chainsaw
parents:
313
diff
changeset
|
644 _("Accept"), TRUE, GTK_SIGNAL_FUNC(dummy), NULL); |
61 | 645 return -1; |
646 } | |
647 | |
648 item = NULL; | |
649 while ((actor = (VisPluginRef*) visual_list_next (list, &item))) | |
650 actor_plugin_add (actor); | |
651 | |
652 return 0; | |
653 } | |
654 | |
655 static guint hash_function (gconstpointer key) | |
656 { | |
657 const char *skey; | |
658 guint hash_value = 0; | |
659 int i; | |
660 | |
661 if (!key) | |
662 return 0; | |
663 | |
664 skey = key; | |
665 for (i = 0; i < strlen (skey); i++) | |
666 hash_value = (hash_value << 4) + (hash_value ^ (guint) skey[i]); | |
667 | |
668 return hash_value; | |
669 } | |
670 | |
671 static gint hash_compare (gconstpointer s1, gconstpointer s2) | |
672 { | |
673 return (!strcmp ((char*) s1, (char*) s2)); | |
674 } | |
675 | |
676 static void load_actor_enable_state (gpointer data, gpointer user_data) | |
677 { | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
678 ConfigDb *db; |
61 | 679 VisPluginRef *actor; |
680 gboolean enabled, *b; | |
681 | |
682 actor = data; | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
683 db = user_data; |
61 | 684 |
685 visual_log_return_if_fail (actor != NULL); | |
686 visual_log_return_if_fail (actor->info != NULL); | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
687 visual_log_return_if_fail (db != NULL); |
61 | 688 |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
689 if (!bmp_cfg_db_get_bool (db, "libvisual", actor->info->plugname, &enabled)) |
61 | 690 enabled = TRUE; |
691 | |
692 b = g_malloc (sizeof(gboolean)); | |
693 *b = enabled; | |
694 g_hash_table_insert (actor_plugin_enable_table, actor->info->plugname, b); | |
695 } | |
696 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
697 static void load_actor_plugin_enable_table (ConfigDb *db) |
61 | 698 { |
699 visual_log_return_if_fail (actor_plugins_nongl != NULL); | |
700 visual_log_return_if_fail (actor_plugins_gl != NULL); | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
701 visual_log_return_if_fail (db != NULL); |
61 | 702 |
703 if (!actor_plugin_enable_table) | |
704 actor_plugin_enable_table = g_hash_table_new (hash_function, hash_compare); | |
705 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
706 g_slist_foreach (actor_plugins_nongl, load_actor_enable_state, db); |
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
707 g_slist_foreach (actor_plugins_gl, load_actor_enable_state, db); |
61 | 708 } |
709 | |
710 static void remove_boolean (gpointer key, gpointer value, gpointer data) | |
711 { | |
712 g_free (value); | |
713 } | |
714 | |
715 static void new_actor_item (gpointer data, gpointer user_data) | |
716 { | |
717 GList *items; | |
718 GtkWidget *item/*, *olditem*/; | |
719 VisPluginRef *actor; | |
720 gchar *name; | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
721 gchar *plugname; |
61 | 722 gboolean *enabled; |
723 | |
724 actor = data; | |
725 items = *(GList**)user_data; | |
726 | |
727 visual_log_return_if_fail (actor != NULL); | |
728 visual_log_return_if_fail (actor->info != NULL); | |
729 | |
730 plugname = actor->info->plugname; | |
731 enabled = g_hash_table_lookup (actor_plugin_enable_table, plugname); | |
732 visual_log_return_if_fail (enabled != NULL); | |
733 | |
734 /* Create the new item */ | |
735 if (*enabled) { | |
375
244cc47a7ae3
[svn] We have no choice but to continue as planned. Deploy the sentinels!
chainsaw
parents:
321
diff
changeset
|
736 name = g_strconcat (actor->info->name, _(" (enabled)"), NULL); |
61 | 737 item = gtk_list_item_new_with_label (name); |
738 g_free (name); | |
739 } else { | |
740 item = gtk_list_item_new_with_label (actor->info->name); | |
741 } | |
742 | |
743 gtk_widget_show (item); | |
744 gtk_signal_connect (GTK_OBJECT(item), "select", | |
745 GTK_SIGNAL_FUNC(on_actor_plugin_selected), | |
746 (gpointer) actor); | |
747 items = g_list_append (items, item); | |
748 | |
749 /*olditem = g_hash_table_lookup (actor_plugin_table, plugname); | |
750 if (olditem) | |
751 gtk_widget_destroy (olditem);*/ | |
752 | |
753 g_hash_table_remove (actor_plugin_table, plugname); | |
754 g_hash_table_insert (actor_plugin_table, plugname, item); | |
755 | |
756 *(GList**)user_data = items; | |
757 } | |
758 | |
759 static void config_win_load_actor_plugin_gl_list () | |
760 { | |
761 GList *items; | |
762 | |
763 if (!actor_plugin_table) | |
764 actor_plugin_table = g_hash_table_new (hash_function, hash_compare); | |
765 | |
766 items = NULL; | |
767 g_slist_foreach (actor_plugins_gl, new_actor_item, &items); | |
768 gtk_list_append_items (GTK_LIST(config_win->list_vis_plugins), items); | |
769 } | |
770 | |
771 static void config_win_load_actor_plugin_nongl_list () | |
772 { | |
773 GList *items; | |
774 | |
775 if (!actor_plugin_table) | |
776 actor_plugin_table = g_hash_table_new (hash_function, hash_compare); | |
777 | |
778 items = NULL; | |
779 g_slist_foreach (actor_plugins_nongl, new_actor_item, &items); | |
780 gtk_list_append_items (GTK_LIST(config_win->list_vis_plugins), items); | |
781 } | |
782 | |
783 static void on_morph_plugin_activate (GtkMenuItem *menuitem, char *name) | |
784 { | |
785 visual_log_return_if_fail (name != NULL); | |
786 | |
787 morph_plugin = name; | |
788 } | |
789 | |
790 static int config_win_load_morph_plugin_list () | |
791 { | |
792 VisList *list; | |
793 VisListEntry *item; | |
794 VisPluginRef *morph; | |
795 GtkWidget *msg; | |
796 GtkWidget *menu; | |
797 GtkWidget *menuitem; | |
798 GSList *group; | |
799 gint index; | |
800 | |
801 /* FIXME use load_morph_plugin_list() */ | |
802 list = visual_morph_get_list (); | |
803 if (!list) { | |
804 visual_log (VISUAL_LOG_WARNING, _("The list of morph plugins is empty.")); | |
805 return -1; | |
806 } | |
807 | |
808 item = NULL; | |
809 /* FIXME update to visual_list_is_empty() when ready */ | |
810 if (!(morph = (VisPluginRef*) visual_list_next (list, &item))) { | |
811 msg = xmms_show_message (PACKAGE_NAME, | |
812 _("There are no morph plugins, so switching\n" | |
813 "between visualization plugins will be do it\n" | |
814 "without any morphing."), | |
314
31725d73a697
[svn] Squash the implicit declaration warnings by including the correct util.h
chainsaw
parents:
313
diff
changeset
|
815 _("Accept"), TRUE, GTK_SIGNAL_FUNC(dummy), NULL); |
61 | 816 return -1; |
817 } | |
818 index = 0; | |
819 item = NULL; | |
820 while ((morph = (VisPluginRef*) visual_list_next (list, &item))) { | |
821 if (!(morph->info)) { | |
822 visual_log (VISUAL_LOG_WARNING, _("There is no info for this plugin")); | |
823 continue; | |
824 } | |
825 group = config_win->optionmenu_morph_plugin_group; | |
826 menu = gtk_option_menu_get_menu (GTK_OPTION_MENU(config_win->optionmenu_morph_plugin)); | |
827 menuitem = gtk_radio_menu_item_new_with_label (group, morph->info->plugname); | |
828 group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM(menuitem)); | |
829 gtk_menu_append (GTK_MENU(menu), menuitem); | |
830 config_win->optionmenu_morph_plugin_group = group; | |
831 | |
832 gtk_signal_connect (GTK_OBJECT(menuitem), "activate", | |
833 GTK_SIGNAL_FUNC(on_morph_plugin_activate), | |
834 (gpointer) morph->info->plugname); | |
835 | |
836 gtk_widget_show (menuitem); | |
837 | |
838 if (!strcmp (morph->info->plugname, options.morph_plugin)) { | |
839 gtk_menu_item_activate (GTK_MENU_ITEM(menuitem)); | |
840 gtk_menu_set_active (GTK_MENU(menu), index); | |
841 gtk_option_menu_set_history (GTK_OPTION_MENU(config_win->optionmenu_morph_plugin), index); | |
842 } | |
843 index++; | |
844 } | |
845 | |
846 return 0; | |
847 } | |
848 | |
849 static int load_morph_plugin_list () | |
850 { | |
851 VisList *list; | |
852 VisListEntry *item; | |
853 VisPluginRef *morph; | |
854 GtkWidget *msg; | |
855 | |
856 list = visual_morph_get_list (); | |
857 if (!list) { | |
858 visual_log (VISUAL_LOG_WARNING, _("The list of morph plugins is empty.")); | |
859 return -1; | |
860 } | |
861 | |
862 item = NULL; | |
863 /* FIXME update to visual_list_is_empty() when ready */ | |
864 if (!(morph = (VisPluginRef*) visual_list_next (list, &item))) { | |
865 msg = xmms_show_message (PACKAGE_NAME, | |
866 _("There are no morph plugins, so switching\n" | |
867 "between visualization plugins will be do it\n" | |
868 "without any morphing."), | |
314
31725d73a697
[svn] Squash the implicit declaration warnings by including the correct util.h
chainsaw
parents:
313
diff
changeset
|
869 _("Accept"), TRUE, GTK_SIGNAL_FUNC(dummy), NULL); |
61 | 870 return -1; |
871 } | |
872 item = NULL; | |
873 while ((morph = (VisPluginRef*) visual_list_next (list, &item))) { | |
874 if (!(morph->info)) { | |
875 visual_log (VISUAL_LOG_WARNING, _("There is no info for this plugin")); | |
876 continue; | |
877 } | |
878 morph_plugins_list = g_slist_append (morph_plugins_list, morph->info->plugname); | |
879 } | |
880 | |
881 return 0; | |
882 } | |
883 | |
884 static void on_button_morph_plugin_about_clicked (GtkButton *button, gpointer data) | |
885 { | |
886 VisList *list; | |
887 VisListEntry *item; | |
888 VisPluginRef *morph; | |
889 gchar *msg; | |
890 GtkWidget *msgwin; | |
891 | |
892 list = visual_morph_get_list (); | |
893 if (!list) { | |
894 visual_log (VISUAL_LOG_WARNING, _("The list of input plugins is empty.")); | |
895 return; | |
896 } | |
897 | |
898 item = NULL; | |
899 while ((morph = (VisPluginRef*) visual_list_next (list, &item))) { | |
900 if (!(morph->info)) { | |
901 visual_log (VISUAL_LOG_WARNING, _("There is no info for this plugin")); | |
902 continue; | |
903 } | |
904 if (strcmp (morph->info->plugname, options.morph_plugin) == 0) { | |
905 msg = g_strconcat (morph->info->name, "\n", | |
906 _("Version: "), morph->info->version, "\n", | |
907 morph->info->about, "\n", | |
908 _("Author: "), morph->info->author, "\n\n", | |
375
244cc47a7ae3
[svn] We have no choice but to continue as planned. Deploy the sentinels!
chainsaw
parents:
321
diff
changeset
|
909 morph->info->help, NULL); |
61 | 910 msgwin = xmms_show_message (PACKAGE_NAME, msg, |
314
31725d73a697
[svn] Squash the implicit declaration warnings by including the correct util.h
chainsaw
parents:
313
diff
changeset
|
911 _("Accept"), TRUE, GTK_SIGNAL_FUNC(dummy), NULL); |
61 | 912 gtk_widget_show (msgwin); |
913 g_free (msg); | |
914 break; | |
915 } | |
916 } | |
917 } | |
918 | |
919 static void on_checkbutton_morph_random_toggled (GtkToggleButton *togglebutton, gpointer user_data) | |
920 { | |
921 random_morph = !random_morph; | |
922 } | |
923 | |
924 /* | |
925 * This function set the default values on configure dialog for all options, | |
926 * except the selected vis and morph plugins. | |
927 */ | |
928 static void config_win_set_defaults (void) | |
929 { | |
930 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->checkbutton_fullscreen), | |
931 default_options.fullscreen); | |
932 gtk_spin_button_set_value (GTK_SPIN_BUTTON(config_win->spinbutton_fps), default_options.fps); | |
933 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->radiobutton_onlygl), | |
934 default_options.gl_plugins_only); | |
935 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->radiobutton_onlynongl), | |
936 default_options.non_gl_plugins_only); | |
937 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->radiobutton_all_plugins), | |
938 default_options.all_plugins_enabled); | |
939 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (config_win->checkbutton_morph_random), | |
940 default_options.random_morph); | |
941 } | |
942 | |
943 static void config_win_connect_callbacks (void) | |
944 { | |
945 gtk_signal_connect (GTK_OBJECT (config_win->checkbutton_vis_plugin), "toggled", | |
946 GTK_SIGNAL_FUNC (on_checkbutton_vis_plugin_toggled), | |
947 NULL); | |
948 gtk_signal_connect (GTK_OBJECT (config_win->checkbutton_fullscreen), "toggled", | |
949 GTK_SIGNAL_FUNC (on_checkbutton_fullscreen_toggled), | |
950 NULL); | |
951 gtk_signal_connect (GTK_OBJECT (config_win->radiobutton_onlygl), "toggled", | |
952 GTK_SIGNAL_FUNC (on_radiobutton_opengl_toggled), | |
953 NULL); | |
954 gtk_signal_connect (GTK_OBJECT (config_win->radiobutton_onlynongl), "toggled", | |
955 GTK_SIGNAL_FUNC (on_radiobutton_non_opengl_toggled), | |
956 NULL); | |
957 gtk_signal_connect (GTK_OBJECT (config_win->radiobutton_all_plugins), "toggled", | |
958 GTK_SIGNAL_FUNC (on_radiobutton_all_plugins_toggled), | |
959 NULL); | |
960 gtk_signal_connect (GTK_OBJECT (config_win->spinbutton_fps), "changed", | |
961 GTK_SIGNAL_FUNC (on_spinbutton_fps_changed), | |
962 NULL); | |
963 gtk_signal_connect (GTK_OBJECT (config_win->button_ok), "clicked", | |
964 GTK_SIGNAL_FUNC (on_button_ok_clicked), | |
965 NULL); | |
966 gtk_signal_connect (GTK_OBJECT (config_win->button_apply), "clicked", | |
967 GTK_SIGNAL_FUNC (on_button_apply_clicked), | |
968 NULL); | |
969 gtk_signal_connect (GTK_OBJECT (config_win->button_cancel), "clicked", | |
970 GTK_SIGNAL_FUNC (on_button_cancel_clicked), | |
971 NULL); | |
972 gtk_signal_connect (GTK_OBJECT (config_win->button_vis_plugin_about), "clicked", | |
973 GTK_SIGNAL_FUNC (on_button_vis_plugin_about_clicked), | |
974 NULL); | |
975 gtk_signal_connect (GTK_OBJECT (config_win->button_morph_plugin_about), "clicked", | |
976 GTK_SIGNAL_FUNC (on_button_morph_plugin_about_clicked), | |
977 NULL); | |
978 gtk_signal_connect (GTK_OBJECT (config_win->checkbutton_morph_random), "toggled", | |
979 GTK_SIGNAL_FUNC (on_checkbutton_morph_random_toggled), | |
980 NULL); | |
981 } | |
982 | |
983 static void config_visual_initialize () | |
984 { | |
985 int argc; | |
986 char **argv; | |
987 GtkWidget *msg; | |
988 | |
989 if (!visual_is_initialized ()) { | |
990 argv = g_malloc (sizeof(char*)); | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
991 argv[0] = g_strdup ("Libvisual"); |
61 | 992 argc = 1; |
993 if (visual_init (&argc, &argv) < 0) { | |
994 msg = xmms_show_message (PACKAGE_NAME, | |
995 _("We cannot initialize Libvisual library.\n" | |
996 "Libvisual is necessary for this plugin to work."), | |
314
31725d73a697
[svn] Squash the implicit declaration warnings by including the correct util.h
chainsaw
parents:
313
diff
changeset
|
997 _("Accept"), TRUE, GTK_SIGNAL_FUNC(dummy), NULL); |
61 | 998 gtk_widget_show (msg); |
999 g_free (argv[0]); | |
1000 g_free (argv); | |
1001 return; | |
1002 } | |
1003 g_free (argv[0]); | |
1004 g_free (argv); | |
1005 } | |
1006 } | |
1007 | |
1008 static void dummy (GtkWidget *widget, gpointer data) | |
1009 { | |
1010 } | |
1011 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
1012 static gboolean read_config_db (ConfigDb *db) |
61 | 1013 { |
1014 gchar *enabled_plugins; | |
1015 gboolean errors = FALSE; | |
1016 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
1017 if (!bmp_cfg_db_get_string (db, "libvisual", "last_plugin", &actor_plugin_buffer) |
61 | 1018 || (strlen (actor_plugin_buffer) <= 0)) { |
1019 visual_log (VISUAL_LOG_DEBUG, "Error on last_plugin option"); | |
1020 strcpy (actor_plugin_buffer, CONFIG_DEFAULT_ACTOR_PLUGIN); | |
1021 errors = TRUE; | |
1022 } | |
1023 options.last_plugin = actor_plugin_buffer; | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
1024 if (!bmp_cfg_db_get_string (db, "libvisual", "morph_plugin", &morph_plugin_buffer) |
61 | 1025 || (strlen (morph_plugin_buffer) <= 0)) { |
1026 visual_log (VISUAL_LOG_DEBUG, "Error on morph_plugin option"); | |
1027 strcpy (morph_plugin_buffer, CONFIG_DEFAULT_MORPH_PLUGIN); | |
1028 errors = TRUE; | |
1029 } | |
1030 morph_plugin = morph_plugin_buffer; | |
1031 options.morph_plugin = morph_plugin; | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
1032 if (!bmp_cfg_db_get_bool (db, "libvisual", "random_morph", &options.random_morph)) { |
61 | 1033 visual_log (VISUAL_LOG_DEBUG, "Error on random_morph option"); |
1034 options.random_morph = default_options.random_morph; | |
1035 errors = TRUE; | |
1036 } | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
1037 if (!bmp_cfg_db_get_int (db, "libvisual", "width", &options.width) || options.width <= 0) { |
61 | 1038 visual_log (VISUAL_LOG_DEBUG, "Error on width option"); |
1039 options.width = default_options.width; | |
1040 errors = TRUE; | |
1041 } | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
1042 if (!bmp_cfg_db_get_int (db, "libvisual", "height", &options.height) || options.height <= 0) { |
61 | 1043 visual_log (VISUAL_LOG_DEBUG, "Error on height option"); |
1044 options.height = default_options.height; | |
1045 errors = TRUE; | |
1046 } | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
1047 if (!bmp_cfg_db_get_int (db, "libvisual", "fps", &options.fps) || options.fps <= 0) { |
61 | 1048 visual_log (VISUAL_LOG_DEBUG, "Error on fps option"); |
1049 options.fps = default_options.fps; | |
1050 errors = TRUE; | |
1051 } | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
1052 if (!bmp_cfg_db_get_int (db, "libvisual", "color_depth", &options.depth) || options.depth <= 0) { |
61 | 1053 visual_log (VISUAL_LOG_DEBUG, "Error on color_depth option"); |
1054 options.depth = default_options.depth; | |
1055 errors = TRUE; | |
1056 } | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
1057 if (!bmp_cfg_db_get_bool (db, "libvisual", "fullscreen", &options.fullscreen)) { |
61 | 1058 visual_log (VISUAL_LOG_DEBUG, "Error on fullscreen option"); |
1059 options.fullscreen = default_options.fullscreen; | |
1060 errors = TRUE; | |
1061 } | |
1062 enabled_plugins = g_malloc0 (OPTIONS_MAX_NAME_LEN); | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
1063 if (!bmp_cfg_db_get_string (db, "libvisual", "enabled_plugins", &enabled_plugins) |
61 | 1064 || (strlen (enabled_plugins) <= 0)) { |
1065 visual_log (VISUAL_LOG_DEBUG, "Error on enabled_plugins option: %s", enabled_plugins); | |
1066 options.gl_plugins_only = default_options.gl_plugins_only; | |
1067 options.non_gl_plugins_only = default_options.non_gl_plugins_only; | |
1068 options.all_plugins_enabled = default_options.all_plugins_enabled; | |
1069 errors = TRUE; | |
1070 } else { | |
1071 options.gl_plugins_only = FALSE; | |
1072 options.non_gl_plugins_only = FALSE; | |
1073 options.all_plugins_enabled = FALSE; | |
1074 if (strcmp (enabled_plugins, "gl_only") == 0) | |
1075 options.gl_plugins_only = TRUE; | |
1076 else if (strcmp (enabled_plugins, "non_gl_only") == 0) | |
1077 options.non_gl_plugins_only = TRUE; | |
1078 else if (strcmp (enabled_plugins, "all") == 0) | |
1079 options.all_plugins_enabled = TRUE; | |
1080 else { | |
1081 visual_log (VISUAL_LOG_WARNING, _("Invalid value for 'enabled_plugins' option")); | |
1082 options.gl_plugins_only = default_options.gl_plugins_only; | |
1083 options.non_gl_plugins_only = default_options.non_gl_plugins_only; | |
1084 options.all_plugins_enabled = default_options.all_plugins_enabled; | |
1085 errors = TRUE; | |
1086 } | |
1087 } | |
1088 g_free (enabled_plugins); | |
1089 | |
1090 return errors; | |
1091 } |