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