116
|
1 /* Iris - visualization plugin for XMMS
|
|
2 * Copyright (C) 2000-2002 Cédric DELFOSSE (cdelfosse@free.fr)
|
|
3 *
|
|
4 * This program is free software; you can redistribute it and/or modify
|
|
5 * it under the terms of the GNU General Public License as published by
|
|
6 * the Free Software Foundation; either version 2 of the License, or
|
|
7 * (at your option) any later version.
|
|
8 *
|
|
9 * This program is distributed in the hope that it will be useful,
|
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 * GNU General Public License for more details.
|
|
13 *
|
|
14 * You should have received a copy of the GNU General Public License
|
|
15 * along with this program; if not, write to the Free Software
|
|
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
17 */
|
|
18
|
|
19 #include <stdio.h>
|
|
20 #include <stdlib.h>
|
|
21 #include <gtk/gtk.h>
|
|
22 #include <audacious/configdb.h>
|
|
23 #include <GL/gl.h>
|
|
24 #include "iris.h"
|
|
25 #include "config.h"
|
|
26
|
|
27 iris_config config;
|
|
28 iris_config newconfig;
|
|
29 GLWindow GLWin;
|
|
30
|
|
31 static char section_name[] = "iris";
|
|
32
|
|
33 GtkWidget *config_window;
|
|
34
|
|
35 GtkWidget *preview_color_one_color;
|
|
36 GtkWidget *preview_color_two_colors_1;
|
|
37 GtkWidget *preview_color_two_colors_2;
|
|
38 GtkWidget *preview_background;
|
|
39 GtkWidget *preview_flash;
|
|
40
|
|
41 static GtkWidget *config_ctree;
|
|
42 static GtkWidget *config_notebook;
|
|
43 static gint config_page;
|
|
44
|
|
45 static gboolean
|
|
46 check_cfg_version (ConfigDb * db)
|
|
47 {
|
|
48 char *vstr;
|
|
49
|
|
50 if (bmp_cfg_db_get_string (db, "iris", "version", &vstr))
|
|
51 if (!strcmp (vstr, VERSION))
|
|
52 return FALSE;
|
|
53 return TRUE;
|
|
54 }
|
|
55
|
|
56
|
|
57 void
|
|
58 iris_set_default_prefs (void)
|
|
59 {
|
|
60 int i;
|
|
61
|
|
62 for (i = 0; i < THEME_NUMBER; i++)
|
|
63 {
|
|
64 theme_config_global_default (i);
|
|
65 if (theme[i].config_default != NULL)
|
|
66 theme[i].config_default ();
|
|
67 }
|
|
68
|
|
69 config.bgc_red = 0.0;
|
|
70 config.bgc_green = 0.0;
|
|
71 config.bgc_blue = 0.0;
|
|
72
|
|
73 config.bgc_random = FALSE;
|
|
74
|
|
75 config.color_red = 0.0;
|
|
76 config.color_green = 0.0;
|
|
77 config.color_blue = 1.0;
|
|
78
|
|
79 config.color_random = TRUE;
|
|
80
|
|
81 config.color1_red = 1.0;
|
|
82 config.color1_green = 0.0;
|
|
83 config.color1_blue = 0.0;
|
|
84
|
|
85 config.color2_red = 0.0;
|
|
86 config.color2_green = 1.0;
|
|
87 config.color2_blue = 0.0;
|
|
88
|
|
89 config.color12_random = TRUE;
|
|
90
|
|
91 config.color_flash_red = 1.0;
|
|
92 config.color_flash_green = 1.0;
|
|
93 config.color_flash_blue = 1.0;
|
|
94
|
|
95 config.color_mode = 1;
|
|
96
|
|
97 config.color_beat = TRUE;
|
|
98
|
|
99 config.flash_speed = 5;
|
|
100
|
|
101 config.fps = 50;
|
|
102
|
|
103 config.change_theme_on_beat = FALSE;
|
|
104
|
|
105 config.fs_width = 640;
|
|
106 config.fs_height = 480;
|
|
107
|
|
108 config.window_width = 640;
|
|
109 config.window_height = 480;
|
|
110
|
|
111 config.fullscreen = FALSE;
|
|
112
|
|
113 config.transition = TRUE;
|
|
114 config.trans_duration = 10.0;
|
|
115 }
|
|
116
|
|
117
|
|
118 void
|
|
119 iris_config_read (void)
|
|
120 {
|
|
121 ConfigDb *db;
|
|
122
|
|
123 db = bmp_cfg_db_open();
|
|
124
|
|
125 /* Check the config version string. If the string is too old, default values
|
|
126 * are installed. If the string returns NULL, iris has not been run before,
|
|
127 * and default values are installed. */
|
|
128 if (check_cfg_version (db))
|
|
129 {
|
|
130 printf("Bad iris plugin version detected in config, using default configuration\n");
|
|
131 iris_set_default_prefs ();
|
|
132 }
|
|
133 else
|
|
134 {
|
|
135 int i;
|
|
136
|
|
137 /* load config of all the theme */
|
|
138 for (i = 0; i < THEME_NUMBER; i++)
|
|
139 {
|
|
140 theme_config_global_read (db, section_name, i);
|
|
141 if (theme[i].config_read != NULL)
|
|
142 theme[i].config_read (db, section_name);
|
|
143 }
|
|
144
|
|
145 bmp_cfg_db_get_float (db, section_name, "bgc_red", &config.bgc_red);
|
|
146 bmp_cfg_db_get_float (db, section_name, "bgc_green", &config.bgc_green);
|
|
147 bmp_cfg_db_get_float (db, section_name, "bgc_blue", &config.bgc_blue);
|
|
148 bmp_cfg_db_get_bool (db, section_name, "bgc_random", &config.bgc_random);
|
|
149 bmp_cfg_db_get_float (db, section_name, "color_red", &config.color_red);
|
|
150 bmp_cfg_db_get_float (db, section_name, "color_green", &config.color_green);
|
|
151 bmp_cfg_db_get_float (db, section_name, "color_blue", &config.color_blue);
|
|
152 bmp_cfg_db_get_bool (db, section_name, "color_random", &config.color_random);
|
|
153 bmp_cfg_db_get_float (db, section_name, "color1_red", &config.color1_red);
|
|
154 bmp_cfg_db_get_float (db, section_name, "color1_green", &config.color1_green);
|
|
155 bmp_cfg_db_get_float (db, section_name, "color1_blue", &config.color1_blue);
|
|
156 bmp_cfg_db_get_float (db, section_name, "color2_red", &config.color2_red);
|
|
157 bmp_cfg_db_get_float (db, section_name, "color2_green", &config.color2_green);
|
|
158 bmp_cfg_db_get_float (db, section_name, "color2_blue", &config.color2_blue);
|
|
159 bmp_cfg_db_get_bool (db, section_name, "color12_random", &config.color12_random);
|
|
160 bmp_cfg_db_get_float (db, section_name, "color_flash_red", &config.color_flash_red);
|
|
161 bmp_cfg_db_get_float (db, section_name, "color_flash_green", &config.color_flash_green);
|
|
162 bmp_cfg_db_get_float (db, section_name, "color_flash_blue", &config.color_flash_blue);
|
|
163 bmp_cfg_db_get_int (db, section_name, "color_mode", &config.color_mode);
|
|
164 bmp_cfg_db_get_bool (db, section_name, "color_beat", &config.color_beat);
|
|
165 bmp_cfg_db_get_int (db, section_name, "flash_speed", &config.flash_speed);
|
|
166 bmp_cfg_db_get_int (db, section_name, "fps", &config.fps);
|
|
167 bmp_cfg_db_get_bool (db, section_name, "change_theme_on_beat", &config.change_theme_on_beat);
|
|
168 bmp_cfg_db_get_int (db, section_name, "fs_width", &config.fs_width);
|
|
169 bmp_cfg_db_get_int (db, section_name, "fs_height", &config.fs_height);
|
|
170 bmp_cfg_db_get_int (db, section_name, "window_width", &config.window_width);
|
|
171 bmp_cfg_db_get_int (db, section_name, "window_height", &config.window_height);
|
|
172 bmp_cfg_db_get_bool (db, section_name, "fullscreen", &config.fullscreen);
|
|
173 bmp_cfg_db_get_bool (db, section_name, "transition", &config.transition);
|
|
174 bmp_cfg_db_get_float (db, section_name, "trans_duration", &config.trans_duration);
|
|
175 }
|
|
176 bmp_cfg_db_close(db);
|
|
177 }
|
|
178
|
|
179
|
|
180 void
|
|
181 iris_config_write (iris_config * config)
|
|
182 {
|
|
183 ConfigDb *db;
|
|
184 int i;
|
|
185
|
|
186 db = bmp_cfg_db_open();
|
|
187
|
|
188 /* save config of all the theme */
|
|
189 for (i = 0; i < THEME_NUMBER; i++)
|
|
190 {
|
|
191 theme_config_global_write (db, section_name, i);
|
|
192 if (theme[i].config_write != NULL)
|
|
193 theme[i].config_write (db, section_name);
|
|
194 }
|
|
195
|
|
196 /* Save the current configuration in the "iris" section */
|
|
197 bmp_cfg_db_set_string (db, section_name, "version", VERSION);
|
|
198 bmp_cfg_db_set_float (db, section_name, "bgc_red", config->bgc_red);
|
|
199 bmp_cfg_db_set_float (db, section_name, "bgc_green", config->bgc_green);
|
|
200 bmp_cfg_db_set_float (db, section_name, "bgc_blue", config->bgc_blue);
|
|
201 bmp_cfg_db_set_bool (db, section_name, "bgc_random", config->bgc_random);
|
|
202 bmp_cfg_db_set_float (db, section_name, "color_red", config->color_red);
|
|
203 bmp_cfg_db_set_float (db, section_name, "color_green", config->color_green);
|
|
204 bmp_cfg_db_set_float (db, section_name, "color_blue", config->color_blue);
|
|
205 bmp_cfg_db_set_bool (db, section_name, "color_random", config->color_random);
|
|
206 bmp_cfg_db_set_float (db, section_name, "color1_red", config->color1_red);
|
|
207 bmp_cfg_db_set_float (db, section_name, "color1_green", config->color1_green);
|
|
208 bmp_cfg_db_set_float (db, section_name, "color1_blue", config->color1_blue);
|
|
209 bmp_cfg_db_set_float (db, section_name, "color2_red", config->color2_red);
|
|
210 bmp_cfg_db_set_float (db, section_name, "color2_green", config->color2_green);
|
|
211 bmp_cfg_db_set_float (db, section_name, "color2_blue", config->color2_blue);
|
|
212 bmp_cfg_db_set_bool (db, section_name, "color12_random", config->color12_random);
|
|
213 bmp_cfg_db_set_float (db, section_name, "color_flash_red", config->color_flash_red);
|
|
214 bmp_cfg_db_set_float (db, section_name, "color_flash_green", config->color_flash_green);
|
|
215 bmp_cfg_db_set_float (db, section_name, "color_flash_blue", config->color_flash_blue);
|
|
216 bmp_cfg_db_set_int (db, section_name, "color_mode", config->color_mode);
|
|
217 bmp_cfg_db_set_bool (db, section_name, "color_beat", config->color_beat);
|
|
218 bmp_cfg_db_set_int (db, section_name, "flash_speed", config->flash_speed);
|
|
219 bmp_cfg_db_set_int (db, section_name, "fps", config->fps);
|
|
220 bmp_cfg_db_set_bool (db, section_name, "change_theme_on_beat", config->change_theme_on_beat);
|
|
221 bmp_cfg_db_set_int (db, section_name, "fs_width", config->fs_width);
|
|
222 bmp_cfg_db_set_int (db, section_name, "fs_height", config->fs_height);
|
|
223 bmp_cfg_db_set_int (db, section_name, "window_width", config->window_width);
|
|
224 bmp_cfg_db_set_int (db, section_name, "window_height", config->window_height);
|
|
225 bmp_cfg_db_set_bool (db, section_name, "fullscreen", config->fullscreen);
|
|
226 bmp_cfg_db_set_bool (db, section_name, "transition", config->transition);
|
|
227 bmp_cfg_db_set_float (db, section_name, "trans_duration", config->trans_duration);
|
|
228
|
|
229 /* write out the XMMS config file */
|
|
230 bmp_cfg_db_close(db);
|
|
231 }
|
|
232
|
|
233
|
|
234 static void
|
|
235 set_color_preview (GLfloat red, GLfloat green, GLfloat blue,
|
|
236 GtkWidget * preview)
|
|
237 {
|
|
238 unsigned int a;
|
|
239 guchar buf[3 * 32];
|
|
240 char r, g, b;
|
|
241 char s[3];
|
|
242
|
|
243 // how to convert a float into a char ?
|
|
244 sprintf (s, "%.0f", red * 255);
|
|
245 r = (unsigned char) atoi (s);
|
|
246 sprintf (s, "%.0f", green * 255);
|
|
247 g = (unsigned char) atoi (s);
|
|
248 sprintf (s, "%.0f", blue * 255);
|
|
249 b = (unsigned char) atoi (s);
|
|
250
|
|
251 for (a = 0; a < 32; a++)
|
|
252 {
|
|
253 buf[3 * a] = (char) r;
|
|
254 buf[3 * a + 1] = (char) g;
|
|
255 buf[3 * a + 2] = (char) b;
|
|
256 }
|
|
257
|
|
258 for (a = 0; a < 16; a++)
|
|
259 gtk_preview_draw_row (GTK_PREVIEW (preview), buf, 0, a, 32);
|
|
260
|
|
261 gtk_widget_draw (preview, NULL);
|
|
262 }
|
|
263
|
|
264
|
|
265 static void
|
|
266 csel_ok (GtkWidget * w, GtkWidget * csel)
|
|
267 {
|
|
268 gdouble a[3];
|
|
269
|
|
270 gtk_color_selection_get_color (GTK_COLOR_SELECTION
|
|
271 (GTK_COLOR_SELECTION_DIALOG (csel)->
|
|
272 colorsel), &a[0]);
|
|
273
|
|
274 gtk_widget_destroy (csel);
|
|
275 }
|
|
276
|
|
277
|
|
278 static void
|
|
279 csel_ok2 (GtkWidget * csel, gpointer data)
|
|
280 {
|
|
281 gdouble a[3];
|
|
282
|
|
283 gtk_color_selection_get_color (GTK_COLOR_SELECTION
|
|
284 (GTK_COLOR_SELECTION_DIALOG (csel)->
|
|
285 colorsel), &a[0]);
|
|
286
|
|
287 switch ((int) data)
|
|
288 {
|
|
289 case 0:
|
|
290 {
|
|
291 newconfig.color_red = (GLfloat) a[0];
|
|
292 newconfig.color_green = (GLfloat) a[1];
|
|
293 newconfig.color_blue = (GLfloat) a[2];
|
|
294 set_color_preview (newconfig.color_red, newconfig.color_green,
|
|
295 newconfig.color_blue, preview_color_one_color);
|
|
296 break;
|
|
297 }
|
|
298 case 1:
|
|
299 {
|
|
300 newconfig.color1_red = (GLfloat) a[0];
|
|
301 newconfig.color1_green = (GLfloat) a[1];
|
|
302 newconfig.color1_blue = (GLfloat) a[2];
|
|
303 set_color_preview (newconfig.color1_red, newconfig.color1_green,
|
|
304 newconfig.color1_blue, preview_color_two_colors_1);
|
|
305 break;
|
|
306 }
|
|
307 case 2:
|
|
308 {
|
|
309 newconfig.color2_red = (GLfloat) a[0];
|
|
310 newconfig.color2_green = (GLfloat) a[1];
|
|
311 newconfig.color2_blue = (GLfloat) a[2];
|
|
312 set_color_preview (newconfig.color2_red, newconfig.color2_green,
|
|
313 newconfig.color2_blue, preview_color_two_colors_2);
|
|
314 break;
|
|
315 }
|
|
316 case 3:
|
|
317 {
|
|
318 newconfig.bgc_red = (GLfloat) a[0];
|
|
319 newconfig.bgc_green = (GLfloat) a[1];
|
|
320 newconfig.bgc_blue = (GLfloat) a[2];
|
|
321 set_color_preview (newconfig.bgc_red, newconfig.bgc_green,
|
|
322 newconfig.bgc_blue, preview_background);
|
|
323 break;
|
|
324 }
|
|
325 case 4:
|
|
326 {
|
|
327 newconfig.color_flash_red = (GLfloat) a[0];
|
|
328 newconfig.color_flash_green = (GLfloat) a[1];
|
|
329 newconfig.color_flash_blue = (GLfloat) a[2];
|
|
330 set_color_preview (newconfig.color_flash_red,
|
|
331 newconfig.color_flash_green,
|
|
332 newconfig.color_flash_blue, preview_flash);
|
|
333 break;
|
|
334 }
|
|
335 }
|
|
336
|
|
337 gtk_widget_destroy (csel);
|
|
338 }
|
|
339
|
|
340
|
|
341 static void
|
|
342 apply_clicked (void)
|
|
343 {
|
|
344 gint i;
|
|
345
|
|
346 memcpy (&config, &newconfig, sizeof (iris_config));
|
|
347 for (i = 0; i < THEME_NUMBER; i++)
|
|
348 {
|
|
349 memcpy (theme[i].config->global, theme[i].config_new->global,
|
|
350 sizeof (config_global));
|
|
351 theme_config_apply (i);
|
|
352 }
|
|
353 }
|
|
354
|
|
355
|
|
356 static void
|
|
357 cancel_clicked (GtkWidget * w, GtkWidget * window)
|
|
358 {
|
|
359 gtk_widget_destroy (window);
|
|
360 config_window = NULL;
|
|
361 }
|
|
362
|
|
363
|
|
364 static void
|
|
365 csel_deleteevent (GtkWidget * w, GtkWidget * csel)
|
|
366 {
|
|
367 gtk_widget_destroy (csel);
|
|
368 }
|
|
369
|
|
370
|
|
371 static void
|
|
372 ok_clicked (GtkWidget * w, GtkWidget * window)
|
|
373 {
|
|
374 apply_clicked ();
|
|
375 iris_config_write (&newconfig);
|
|
376 cancel_clicked (w, window);
|
|
377 }
|
|
378
|
|
379
|
|
380 static void
|
|
381 color_clicked (GtkWidget * w, gpointer data)
|
|
382 {
|
|
383 GtkWidget *csel;
|
|
384 gdouble a[3];
|
|
385
|
|
386 switch ((int) data)
|
|
387 {
|
|
388 case 0:
|
|
389 {
|
|
390 a[0] = (gdouble) newconfig.color_red;
|
|
391 a[1] = (gdouble) newconfig.color_green;
|
|
392 a[2] = (gdouble) newconfig.color_blue;
|
|
393 break;
|
|
394 }
|
|
395 case 1:
|
|
396 {
|
|
397 a[0] = (gdouble) newconfig.color1_red;
|
|
398 a[1] = (gdouble) newconfig.color1_green;
|
|
399 a[2] = (gdouble) newconfig.color1_blue;
|
|
400 break;
|
|
401 }
|
|
402 case 2:
|
|
403 {
|
|
404 a[0] = (gdouble) newconfig.color2_red;
|
|
405 a[1] = (gdouble) newconfig.color2_green;
|
|
406 a[2] = (gdouble) newconfig.color2_blue;
|
|
407 break;
|
|
408 }
|
|
409 case 3:
|
|
410 {
|
|
411 a[0] = (gdouble) newconfig.bgc_red;
|
|
412 a[1] = (gdouble) newconfig.bgc_green;
|
|
413 a[2] = (gdouble) newconfig.bgc_blue;
|
|
414 break;
|
|
415 }
|
|
416 case 4:
|
|
417 {
|
|
418 a[0] = (gdouble) newconfig.color_flash_red;
|
|
419 a[1] = (gdouble) newconfig.color_flash_green;
|
|
420 a[2] = (gdouble) newconfig.color_flash_blue;
|
|
421 break;
|
|
422 }
|
|
423 }
|
|
424
|
|
425 csel = gtk_color_selection_dialog_new ("Please choose a color");
|
|
426 /*gtk_window_set_modal (GTK_WINDOW
|
|
427 (&(GTK_COLOR_SELECTION_DIALOG (csel)->window)), TRUE);
|
|
428 gtk_window_set_transient_for (GTK_WINDOW
|
|
429 (&
|
|
430 (GTK_COLOR_SELECTION_DIALOG (csel)->window)),
|
|
431 GTK_WINDOW (config_window)); */
|
|
432 gtk_widget_hide (GTK_COLOR_SELECTION_DIALOG (csel)->help_button);
|
|
433 gtk_widget_hide (GTK_COLOR_SELECTION_DIALOG (csel)->cancel_button);
|
|
434 gtk_color_selection_set_color (GTK_COLOR_SELECTION
|
|
435 (GTK_COLOR_SELECTION_DIALOG (csel)->
|
|
436 colorsel), &a[0]);
|
|
437 gtk_widget_show (csel);
|
|
438
|
|
439 gtk_signal_connect (GTK_OBJECT
|
|
440 (GTK_COLOR_SELECTION_DIALOG (csel)->ok_button),
|
|
441 "clicked", GTK_SIGNAL_FUNC (csel_ok), csel);
|
|
442 gtk_signal_connect (GTK_OBJECT (csel), "delete_event",
|
|
443 GTK_SIGNAL_FUNC (csel_deleteevent), csel);
|
|
444 gtk_signal_connect (GTK_OBJECT (csel), "destroy",
|
|
445 GTK_SIGNAL_FUNC (csel_ok2), data);
|
|
446 }
|
|
447
|
|
448
|
|
449 void
|
|
450 colormode_toggled (GtkWidget * widget, gpointer data)
|
|
451 {
|
|
452 newconfig.color_mode = (unsigned int) data;
|
|
453 }
|
|
454
|
|
455
|
|
456 void
|
|
457 colorbeat_toggled (GtkWidget * widget, gpointer data)
|
|
458 {
|
|
459 newconfig.color_beat = !newconfig.color_beat;
|
|
460 }
|
|
461
|
|
462
|
|
463 void
|
|
464 theme_beat_toggled (GtkWidget * widget, gpointer data)
|
|
465 {
|
|
466 newconfig.change_theme_on_beat = !newconfig.change_theme_on_beat;
|
|
467 }
|
|
468
|
|
469
|
|
470 void
|
|
471 color_random_toggled (GtkWidget * widget, gpointer data)
|
|
472 {
|
|
473 newconfig.color_random = !newconfig.color_random;
|
|
474 }
|
|
475
|
|
476
|
|
477 void
|
|
478 color12_random_toggled (GtkWidget * widget, gpointer data)
|
|
479 {
|
|
480 newconfig.color12_random = !newconfig.color12_random;
|
|
481 }
|
|
482
|
|
483
|
|
484 void
|
|
485 bgc_random_toggled (GtkWidget * widget, gpointer data)
|
|
486 {
|
|
487 newconfig.bgc_random = !newconfig.bgc_random;
|
|
488 }
|
|
489
|
|
490
|
|
491 void
|
|
492 wireframe_toggled (GtkWidget * widget, gpointer * data)
|
|
493 {
|
|
494 newconfig.wireframe = !newconfig.wireframe;
|
|
495 }
|
|
496
|
|
497
|
|
498 void
|
|
499 fullscreen_toggled (GtkWidget * widget, gpointer data)
|
|
500 {
|
|
501 newconfig.fullscreen = !newconfig.fullscreen;
|
|
502 }
|
|
503
|
|
504 void
|
|
505 transition_toggled (GtkWidget * widget, gpointer data)
|
|
506 {
|
|
507 newconfig.transition = !newconfig.transition;
|
|
508 }
|
|
509
|
|
510 static void
|
|
511 combo_fs_activated (GtkWidget * widget, gpointer data)
|
|
512 {
|
|
513 sscanf (gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (data)->entry)), "%dx%d",
|
|
514 &newconfig.fs_width, &newconfig.fs_height);
|
|
515 }
|
|
516
|
|
517
|
|
518 static void
|
|
519 value_flash_speed (GtkAdjustment * adj)
|
|
520 {
|
|
521 newconfig.flash_speed = (int) adj->value;
|
|
522 }
|
|
523
|
|
524 static void
|
|
525 value_trans_duration (GtkAdjustment * adj)
|
|
526 {
|
|
527 newconfig.trans_duration = (int) adj->value;
|
|
528 }
|
|
529
|
|
530 static void
|
|
531 conf_closed (GtkWidget * w, GdkEvent * e, GtkWidget ** window)
|
|
532 {
|
|
533 gtk_widget_destroy (*window);
|
|
534 *window = NULL;
|
|
535 }
|
|
536
|
|
537
|
|
538 static void
|
|
539 priority_value_changed (GtkAdjustment * adj, gint i)
|
|
540 {
|
|
541 theme[i].config_new->global->priority = adj->value / 100.0;
|
|
542 }
|
|
543
|
|
544
|
|
545 static void
|
|
546 create_config_color (GtkWidget * vbox_container)
|
|
547 {
|
|
548 GtkWidget *frame;
|
|
549 GtkWidget *vbox;
|
|
550 GtkWidget *hbox;
|
|
551 GSList *group;
|
|
552
|
|
553 GtkWidget *radio_button_one_color;
|
|
554 GtkWidget *button_color_one_color;
|
|
555 // GtkWidget *preview_color_one_color; must be static
|
|
556
|
|
557 GtkWidget *radio_button_two_colors;
|
|
558 GtkWidget *button_color_two_colors_1;
|
|
559 GtkWidget *button_color_two_colors_2;
|
|
560 // GtkWidget *preview_color_two_colors_1; must be static
|
|
561 // GtkWidget *preview_color_two_colors_2; must be static
|
|
562
|
|
563 GtkWidget *check_button;
|
|
564
|
|
565 GtkWidget *hseparator;
|
|
566
|
|
567 GtkWidget *label;
|
|
568 GtkWidget *button_background;
|
|
569 // GtkWidget *preview_background; static
|
|
570
|
|
571 frame = gtk_frame_new ("color");
|
|
572 gtk_box_pack_start (GTK_BOX (vbox_container), frame, TRUE, TRUE, 0);
|
|
573 vbox = gtk_vbox_new (TRUE, 2);
|
|
574 gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
575
|
|
576 /* the first hbox: a radio button and a color selection/preview button */
|
|
577
|
|
578 hbox = gtk_hbox_new (FALSE, 2);
|
|
579 gtk_widget_show (hbox);
|
|
580 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 8);
|
|
581
|
|
582 radio_button_one_color =
|
|
583 gtk_radio_button_new_with_label (NULL, "one color");
|
|
584 gtk_box_pack_start (GTK_BOX (hbox), radio_button_one_color, FALSE, FALSE,
|
|
585 4);
|
|
586 gtk_widget_set_usize (radio_button_one_color, 100, 20);
|
|
587 gtk_widget_show (radio_button_one_color);
|
|
588
|
|
589 button_color_one_color = gtk_button_new ();
|
|
590 gtk_box_pack_start (GTK_BOX (hbox), button_color_one_color, FALSE, FALSE,
|
|
591 4);
|
|
592 gtk_widget_show (button_color_one_color);
|
|
593 preview_color_one_color = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
594 gtk_preview_size (GTK_PREVIEW (preview_color_one_color), 32, 16);
|
|
595 gtk_widget_show (preview_color_one_color);
|
|
596 gtk_container_add (GTK_CONTAINER (button_color_one_color),
|
|
597 preview_color_one_color);
|
|
598 set_color_preview (newconfig.color_red, newconfig.color_green,
|
|
599 newconfig.color_blue, preview_color_one_color);
|
|
600 gtk_widget_set_usize (button_color_one_color, 50, 20);
|
|
601 gtk_signal_connect (GTK_OBJECT (button_color_one_color), "clicked",
|
|
602 GTK_SIGNAL_FUNC (color_clicked), (gpointer) 0);
|
|
603
|
|
604 /* the second hbox: a radio button and two color selection/preview buttons */
|
|
605
|
|
606 hbox = gtk_hbox_new (FALSE, 3);
|
|
607 gtk_widget_show (hbox);
|
|
608 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 8);
|
|
609
|
|
610 group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button_one_color));
|
|
611 radio_button_two_colors =
|
|
612 gtk_radio_button_new_with_label (group, "two colors");
|
|
613 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_button_two_colors),
|
|
614 TRUE);
|
|
615 gtk_box_pack_start (GTK_BOX (hbox), radio_button_two_colors, FALSE, FALSE,
|
|
616 4);
|
|
617 gtk_widget_set_usize (radio_button_two_colors, 100, 20);
|
|
618 gtk_widget_show (radio_button_two_colors);
|
|
619
|
|
620 button_color_two_colors_1 = gtk_button_new ();
|
|
621 gtk_box_pack_start (GTK_BOX (hbox), button_color_two_colors_1, FALSE, FALSE,
|
|
622 4);
|
|
623 gtk_widget_show (button_color_two_colors_1);
|
|
624 preview_color_two_colors_1 = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
625 gtk_preview_size (GTK_PREVIEW (preview_color_two_colors_1), 32, 16);
|
|
626 gtk_widget_show (preview_color_two_colors_1);
|
|
627 gtk_container_add (GTK_CONTAINER (button_color_two_colors_1),
|
|
628 preview_color_two_colors_1);
|
|
629 set_color_preview (newconfig.color1_red, newconfig.color1_green,
|
|
630 newconfig.color1_blue, preview_color_two_colors_1);
|
|
631 gtk_widget_set_usize (button_color_two_colors_1, 50, 20);
|
|
632
|
|
633 gtk_signal_connect (GTK_OBJECT (button_color_two_colors_1), "clicked",
|
|
634 GTK_SIGNAL_FUNC (color_clicked), (gpointer) 1);
|
|
635
|
|
636 button_color_two_colors_2 = gtk_button_new ();
|
|
637 gtk_box_pack_start (GTK_BOX (hbox), button_color_two_colors_2, FALSE, FALSE,
|
|
638 4);
|
|
639 gtk_widget_show (button_color_two_colors_2);
|
|
640 preview_color_two_colors_2 = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
641 gtk_preview_size (GTK_PREVIEW (preview_color_two_colors_2), 32, 16);
|
|
642 gtk_widget_show (preview_color_two_colors_2);
|
|
643 gtk_container_add (GTK_CONTAINER (button_color_two_colors_2),
|
|
644 preview_color_two_colors_2);
|
|
645 set_color_preview (newconfig.color2_red, newconfig.color2_green,
|
|
646 newconfig.color2_blue, preview_color_two_colors_2);
|
|
647 gtk_widget_set_usize (button_color_two_colors_2, 50, 20);
|
|
648
|
|
649 gtk_signal_connect (GTK_OBJECT (button_color_two_colors_2), "clicked",
|
|
650 GTK_SIGNAL_FUNC (color_clicked), (gpointer) 2);
|
|
651
|
|
652 switch (newconfig.color_mode)
|
|
653 {
|
|
654 case 0:
|
|
655 {
|
|
656 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
|
657 (radio_button_one_color), TRUE);
|
|
658 break;
|
|
659 }
|
|
660 case 1:
|
|
661 {
|
|
662 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
|
663 (radio_button_two_colors), TRUE);
|
|
664 }
|
|
665 }
|
|
666
|
|
667 gtk_signal_connect (GTK_OBJECT (radio_button_one_color), "toggled",
|
|
668 GTK_SIGNAL_FUNC (colormode_toggled), (gpointer) 0);
|
|
669 gtk_signal_connect (GTK_OBJECT (radio_button_two_colors), "toggled",
|
|
670 GTK_SIGNAL_FUNC (colormode_toggled), (gpointer) 1);
|
|
671
|
|
672 check_button = gtk_check_button_new_with_label ("Random on beat");
|
|
673 gtk_widget_show (check_button);
|
|
674 gtk_box_pack_start (GTK_BOX (vbox), check_button, FALSE, FALSE, 4);
|
|
675 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
|
|
676 newconfig.color12_random);
|
|
677 gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
|
|
678 GTK_SIGNAL_FUNC (color12_random_toggled), NULL);
|
|
679
|
|
680 hseparator = gtk_hseparator_new ();
|
|
681 gtk_widget_show (hseparator);
|
|
682 gtk_box_pack_start (GTK_BOX (vbox), hseparator, FALSE, FALSE, 4);
|
|
683
|
|
684 /* the third hbox: a color selection/preview button */
|
|
685
|
|
686 hbox = gtk_hbox_new (FALSE, 2);
|
|
687 gtk_widget_show (hbox);
|
|
688 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
|
|
689
|
|
690 label = gtk_label_new ("Background color");
|
|
691 gtk_widget_show (label);
|
|
692 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
|
|
693
|
|
694 button_background = gtk_button_new ();
|
|
695 gtk_box_pack_start (GTK_BOX (hbox), button_background, FALSE, FALSE, 4);
|
|
696 gtk_widget_show (button_background);
|
|
697 preview_background = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
698 gtk_preview_size (GTK_PREVIEW (preview_background), 32, 16);
|
|
699 gtk_widget_show (preview_background);
|
|
700 gtk_container_add (GTK_CONTAINER (button_background), preview_background);
|
|
701 set_color_preview (newconfig.bgc_red, newconfig.bgc_green,
|
|
702 newconfig.bgc_blue, preview_background);
|
|
703 gtk_widget_set_usize (button_background, 50, 20);
|
|
704
|
|
705 gtk_signal_connect (GTK_OBJECT (button_background), "clicked",
|
|
706 GTK_SIGNAL_FUNC (color_clicked), (gpointer) 3);
|
|
707
|
|
708 check_button = gtk_check_button_new_with_label ("Random on beat");
|
|
709 gtk_widget_show (check_button);
|
|
710 gtk_box_pack_start (GTK_BOX (vbox), check_button, FALSE, FALSE, 4);
|
|
711 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
|
|
712 newconfig.bgc_random);
|
|
713 gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
|
|
714 GTK_SIGNAL_FUNC (bgc_random_toggled), NULL);
|
|
715 /*
|
|
716 check_button = gtk_check_button_new_with_label ("Wireframe");
|
|
717 gtk_widget_show (check_button);
|
|
718 gtk_box_pack_start (GTK_BOX (vbox), check_button, FALSE, FALSE, 4);
|
|
719 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
|
|
720 newconfig.wireframe);
|
|
721 gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
|
|
722 GTK_SIGNAL_FUNC (wireframe_toggled), NULL);
|
|
723 */
|
|
724 /* end */
|
|
725
|
|
726 }
|
|
727
|
|
728
|
|
729 static void
|
|
730 create_config_beat (GtkWidget * vbox_container)
|
|
731 {
|
|
732 GtkWidget *frame;
|
|
733 GtkWidget *vbox;
|
|
734 GtkWidget *hbox;
|
|
735
|
|
736 GtkWidget *button_beat;
|
|
737 GtkWidget *button_theme_beat;
|
|
738
|
|
739 GtkWidget *label;
|
|
740 GtkWidget *button_flash;
|
|
741 GtkWidget *preview_flash;
|
|
742
|
|
743 GtkObject *adjustment;
|
|
744 GtkWidget *hscale;
|
|
745
|
|
746 frame = gtk_frame_new ("beat");
|
|
747 gtk_box_pack_start (GTK_BOX (vbox_container), frame, TRUE, TRUE, 0);
|
|
748 vbox = gtk_vbox_new (FALSE, 2);
|
|
749 gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
750
|
|
751 /* the first hbox: two buttons */
|
|
752
|
|
753 hbox = gtk_hbox_new (FALSE, 2);
|
|
754 gtk_widget_show (hbox);
|
|
755 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
|
|
756
|
|
757 button_beat = gtk_check_button_new_with_label ("Flash on beat");
|
|
758 gtk_widget_show (button_beat);
|
|
759 gtk_box_pack_start (GTK_BOX (hbox), button_beat, FALSE, FALSE, 4);
|
|
760 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_beat),
|
|
761 newconfig.color_beat);
|
|
762 gtk_signal_connect (GTK_OBJECT (button_beat), "toggled",
|
|
763 GTK_SIGNAL_FUNC (colorbeat_toggled), NULL);
|
|
764
|
|
765 button_theme_beat =
|
|
766 gtk_check_button_new_with_label ("Change theme on beat");
|
|
767 gtk_widget_show (button_theme_beat);
|
|
768 gtk_box_pack_start (GTK_BOX (hbox), button_theme_beat, FALSE, FALSE, 4);
|
|
769 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_theme_beat),
|
|
770 newconfig.change_theme_on_beat);
|
|
771 gtk_signal_connect (GTK_OBJECT (button_theme_beat), "toggled",
|
|
772 GTK_SIGNAL_FUNC (theme_beat_toggled), NULL);
|
|
773
|
|
774 /* the second hbox: a label and a color selection/preview button */
|
|
775
|
|
776 hbox = gtk_hbox_new (FALSE, 2);
|
|
777 gtk_widget_show (hbox);
|
|
778 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
|
|
779
|
|
780 label = gtk_label_new ("Flash color");
|
|
781 gtk_widget_show (label);
|
|
782 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
|
|
783
|
|
784 button_flash = gtk_button_new ();
|
|
785 gtk_box_pack_start (GTK_BOX (hbox), button_flash, FALSE, FALSE, 4);
|
|
786 gtk_widget_show (button_flash);
|
|
787 preview_flash = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
788 gtk_preview_size (GTK_PREVIEW (preview_flash), 32, 16);
|
|
789 gtk_widget_show (preview_flash);
|
|
790 gtk_container_add (GTK_CONTAINER (button_flash), preview_flash);
|
|
791 set_color_preview (newconfig.color_flash_red, newconfig.color_flash_green,
|
|
792 newconfig.color_flash_blue, preview_flash);
|
|
793 gtk_widget_set_usize (button_flash, 50, 20);
|
|
794 gtk_signal_connect (GTK_OBJECT (button_flash), "clicked",
|
|
795 GTK_SIGNAL_FUNC (color_clicked), (gpointer) 4);
|
|
796
|
|
797 /* the third hbox: a label and a horizontal scale */
|
|
798
|
|
799 hbox = gtk_hbox_new (FALSE, 2);
|
|
800 gtk_widget_show (hbox);
|
|
801 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
|
|
802
|
|
803 label = gtk_label_new ("Flash duration (in frames)");
|
|
804 gtk_widget_show (label);
|
|
805 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
|
|
806
|
|
807 adjustment = gtk_adjustment_new (newconfig.flash_speed, 1, 50, 1, 5, 0);
|
|
808 hscale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
|
|
809 gtk_scale_set_value_pos (GTK_SCALE (hscale), GTK_POS_LEFT);
|
|
810 gtk_scale_set_digits (GTK_SCALE (hscale), 0);
|
|
811 gtk_widget_set_usize (GTK_WIDGET (hscale), 200, 25);
|
|
812 gtk_box_pack_start (GTK_BOX (hbox), hscale, FALSE, FALSE, 4);
|
|
813 gtk_widget_show (hscale);
|
|
814 gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
|
|
815 GTK_SIGNAL_FUNC (value_flash_speed), NULL);
|
|
816
|
|
817 label =
|
|
818 gtk_label_new
|
|
819 ("Image are drawn at a rate of 50 frames per second.\n So a flash of 50 frames lasts 1 second.");
|
|
820 gtk_widget_show (label);
|
|
821 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
|
|
822 }
|
|
823
|
|
824
|
|
825 static void
|
|
826 create_config_fs (GtkWidget * vbox_container)
|
|
827 {
|
|
828 GtkWidget *frame;
|
|
829 GtkWidget *vbox;
|
|
830 GtkWidget *hbox;
|
|
831
|
|
832 GtkWidget *button_fs;
|
|
833 GtkWidget *combobox_fs;
|
|
834
|
|
835 GtkWidget *label;
|
|
836
|
|
837 char str[10];
|
|
838
|
|
839 frame = gtk_frame_new ("fullscreen");
|
|
840 gtk_box_pack_start (GTK_BOX (vbox_container), frame, TRUE, TRUE, 0);
|
|
841 vbox = gtk_vbox_new (FALSE, 2);
|
|
842 gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
843
|
|
844 /* the first hbox: a button */
|
|
845
|
|
846 hbox = gtk_hbox_new (FALSE, 2);
|
|
847 gtk_widget_show (hbox);
|
|
848 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
|
|
849
|
|
850 button_fs = gtk_check_button_new_with_label ("Start in fullscreen mode");
|
|
851 gtk_widget_show (button_fs);
|
|
852 gtk_box_pack_start (GTK_BOX (hbox), button_fs, FALSE, FALSE, 4);
|
|
853 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_fs),
|
|
854 newconfig.fullscreen);
|
|
855 gtk_signal_connect (GTK_OBJECT (button_fs), "toggled",
|
|
856 GTK_SIGNAL_FUNC (fullscreen_toggled), NULL);
|
|
857
|
|
858 /* the second hbox: a label combobox */
|
|
859
|
|
860 hbox = gtk_hbox_new (FALSE, 2);
|
|
861 gtk_widget_show (hbox);
|
|
862 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
|
|
863
|
|
864 label = gtk_label_new ("Fullscreen resolution");
|
|
865 gtk_widget_show (label);
|
|
866 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
|
|
867
|
|
868 combobox_fs = gtk_combo_new ();
|
|
869
|
|
870 gtk_combo_set_popdown_strings (GTK_COMBO (combobox_fs), GLWin.glist);
|
|
871
|
|
872 gtk_box_pack_start (GTK_BOX (hbox), combobox_fs, FALSE, FALSE, 4);
|
|
873 gtk_widget_show (combobox_fs);
|
|
874
|
|
875 gtk_signal_connect (GTK_OBJECT (GTK_COMBO (combobox_fs)->entry), "changed",
|
|
876 GTK_SIGNAL_FUNC (combo_fs_activated), combobox_fs);
|
|
877 gtk_entry_set_editable (GTK_ENTRY (GTK_COMBO (combobox_fs)->entry), FALSE);
|
|
878 sprintf (str, "%dx%d", newconfig.fs_width, newconfig.fs_height);
|
|
879 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (combobox_fs)->entry), str);
|
|
880
|
|
881 label = gtk_label_new
|
|
882 ("Use the f key in the GL window\nto switch to fullscreen and back.\n\
|
|
883 Use the esc key to quit the plugin.\n\
|
|
884 \n\
|
|
885 If you use the sawfish window manager,\n\
|
|
886 you may have problem going fullscreen.\n\
|
|
887 In this case, switch to a console and\n\
|
|
888 type \'killall xmms\'.");
|
|
889 gtk_widget_show (label);
|
|
890 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
|
|
891 }
|
|
892
|
|
893 static void
|
|
894 create_config_transition (GtkWidget * vbox_container)
|
|
895 {
|
|
896 GtkWidget *frame;
|
|
897 GtkWidget *vbox;
|
|
898 GtkWidget *hbox;
|
|
899
|
|
900 GtkWidget *button_ts;
|
|
901 GtkWidget *label;
|
|
902
|
|
903 GtkObject *adjustment;
|
|
904 GtkWidget *hscale;
|
|
905
|
|
906 frame = gtk_frame_new ("transition");
|
|
907 gtk_box_pack_start (GTK_BOX (vbox_container), frame, TRUE, TRUE, 0);
|
|
908 vbox = gtk_vbox_new (FALSE, 2);
|
|
909 gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
910
|
|
911 /* the first hbox: a button */
|
|
912
|
|
913 hbox = gtk_hbox_new (FALSE, 2);
|
|
914 gtk_widget_show (hbox);
|
|
915 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
|
|
916
|
|
917 button_ts =
|
|
918 gtk_check_button_new_with_label ("Use transitions on theme change");
|
|
919 gtk_widget_show (button_ts);
|
|
920 gtk_box_pack_start (GTK_BOX (hbox), button_ts, FALSE, FALSE, 4);
|
|
921 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_ts),
|
|
922 newconfig.transition);
|
|
923 gtk_signal_connect (GTK_OBJECT (button_ts), "toggled",
|
|
924 GTK_SIGNAL_FUNC (transition_toggled), NULL);
|
|
925
|
|
926 label = gtk_label_new ("Chooses a random transition for now");
|
|
927 gtk_widget_show (label);
|
|
928 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
|
|
929
|
|
930 /* the second hbox: a label and a horizontal scale */
|
|
931
|
|
932 hbox = gtk_hbox_new (FALSE, 2);
|
|
933 gtk_widget_show (hbox);
|
|
934 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
|
|
935
|
|
936 label = gtk_label_new ("Transition duration (in miliseconds)");
|
|
937 gtk_widget_show (label);
|
|
938 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
|
|
939
|
|
940 adjustment =
|
|
941 gtk_adjustment_new (newconfig.trans_duration, 1.0, 50.0, 1.0, 1.0, 1.0);
|
|
942 hscale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
|
|
943 gtk_scale_set_value_pos (GTK_SCALE (hscale), GTK_POS_LEFT);
|
|
944 gtk_scale_set_digits (GTK_SCALE (hscale), 0);
|
|
945 gtk_widget_set_usize (GTK_WIDGET (hscale), 200, 25);
|
|
946 gtk_box_pack_start (GTK_BOX (hbox), hscale, FALSE, FALSE, 4);
|
|
947 gtk_widget_show (hscale);
|
|
948 gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
|
|
949 GTK_SIGNAL_FUNC (value_trans_duration), NULL);
|
|
950 }
|
|
951
|
|
952 static void
|
|
953 create_config_glx_info (GtkWidget * vbox_container)
|
|
954 {
|
|
955 GtkWidget *frame;
|
|
956 GtkWidget *vbox;
|
|
957 GtkWidget *hbox;
|
|
958
|
|
959 GtkWidget *label;
|
|
960
|
|
961 frame = gtk_frame_new ("GLX informations");
|
|
962 gtk_box_pack_start (GTK_BOX (vbox_container), frame, TRUE, TRUE, 0);
|
|
963 vbox = gtk_vbox_new (FALSE, 2);
|
|
964 gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
965
|
|
966 hbox = gtk_hbox_new (FALSE, 2);
|
|
967 gtk_widget_show (hbox);
|
|
968 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
|
|
969
|
|
970 if (GLWin.ctx == NULL)
|
|
971 {
|
|
972 label = gtk_label_new ("Launch the plugin and reopen the configure window to see\n\
|
|
973 informations about your GL setup.");
|
|
974 gtk_widget_show (label);
|
|
975 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
|
|
976 }
|
|
977 else
|
|
978 {
|
|
979 char *string;
|
|
980 string = g_strconcat ("GLX version: ", g_strdup_printf ("%d.%d", GLWin.glxMajorVersion, GLWin.glxMinorVersion), NULL);
|
|
981 label = gtk_label_new (string);
|
|
982 free(string);
|
|
983 gtk_widget_show (label);
|
|
984 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
|
|
985
|
|
986 if (GLWin.DRI)
|
|
987 string = g_strconcat ("Use DRI: ", "yes", NULL);
|
|
988 else
|
|
989 string = g_strconcat ("Use DRI: ", "no", NULL);
|
|
990 label = gtk_label_new (string);
|
|
991 free(string);
|
|
992 gtk_widget_show (label);
|
|
993 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
|
|
994
|
|
995 if (GLWin.DoubleBuffered)
|
|
996 string = g_strconcat ("Double buffered rendering: ", "yes", NULL);
|
|
997 else
|
|
998 string = g_strconcat ("Double buffered rendering: : ", "no", NULL);
|
|
999 label = gtk_label_new (string);
|
|
1000 free(string);
|
|
1001 gtk_widget_show (label);
|
|
1002 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
|
|
1003 }
|
|
1004 }
|
|
1005
|
|
1006 static void
|
|
1007 create_config_theme (GtkWidget * vbox_container)
|
|
1008 {
|
|
1009 GtkWidget *frame;
|
|
1010 GtkWidget *hbox;
|
|
1011 GtkWidget *table;
|
|
1012 GtkWidget *label;
|
|
1013 gint i, y;
|
|
1014
|
|
1015 frame = gtk_frame_new ("Themes priorities");
|
|
1016 gtk_box_pack_start (GTK_BOX (vbox_container), frame, TRUE, TRUE, 4);
|
|
1017
|
|
1018 hbox = gtk_hbox_new (FALSE, 2);
|
|
1019 gtk_widget_show (hbox);
|
|
1020 gtk_container_add (GTK_CONTAINER (frame), hbox);
|
|
1021
|
|
1022 table = gtk_table_new (2, THEME_NUMBER, FALSE);
|
|
1023 gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 12);
|
|
1024
|
|
1025 for (i = 0, y = 0; i < THEME_NUMBER; i++)
|
|
1026 {
|
|
1027 GtkObject *adjustment;
|
|
1028 GtkWidget *hscale;
|
|
1029
|
|
1030 label = gtk_label_new (theme[i].name);
|
|
1031 gtk_table_attach (GTK_TABLE (table), label, 0, 1, y, y + 1, GTK_EXPAND,
|
|
1032 0, 0, 8);
|
|
1033 adjustment =
|
|
1034 gtk_adjustment_new (theme[i].config->global->priority * 100.0, 0.0,
|
|
1035 100.0, 1.0, 10.0, 0);
|
|
1036 hscale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
|
|
1037 gtk_scale_set_digits (GTK_SCALE (hscale), 0);
|
|
1038 gtk_scale_set_value_pos (GTK_SCALE (hscale), GTK_POS_LEFT);
|
|
1039 gtk_table_attach (GTK_TABLE (table), hscale, 1, 2, y, y + 1,
|
|
1040 GTK_EXPAND | GTK_FILL, 0, 0, 8);
|
|
1041 gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
|
|
1042 GTK_SIGNAL_FUNC (priority_value_changed),
|
|
1043 (void *) i);
|
|
1044
|
|
1045 y++;
|
|
1046 }
|
|
1047
|
|
1048 gtk_widget_show (frame);
|
|
1049 }
|
|
1050
|
|
1051
|
|
1052 static void
|
|
1053 cb_select_monitor_config (GtkWidget * ctree, GtkCTreeNode * node)
|
|
1054 {
|
|
1055 gint row;
|
|
1056
|
|
1057 if (!GTK_CLIST (ctree)->selection)
|
|
1058 return;
|
|
1059 row =
|
|
1060 GPOINTER_TO_INT (gtk_ctree_node_get_row_data (GTK_CTREE (ctree), node));
|
|
1061 gtk_notebook_set_page (GTK_NOTEBOOK (config_notebook), row);
|
|
1062 }
|
|
1063
|
|
1064
|
|
1065 static GtkWidget *
|
|
1066 create_config_page (GtkNotebook * notebook, gchar * text, GtkCTree * ctree,
|
|
1067 GtkCTreeNode * node_parent, GtkCTreeNode ** node_result)
|
|
1068 {
|
|
1069 GtkWidget *vbox;
|
|
1070 GtkCTreeNode *node;
|
|
1071 gchar *title[1] = { text };
|
|
1072
|
|
1073 vbox = gtk_vbox_new (FALSE, 0);
|
|
1074 node = gtk_ctree_insert_node (ctree, node_parent, NULL, title, 0,
|
|
1075 NULL, NULL, NULL, NULL, FALSE, FALSE);
|
|
1076 gtk_ctree_node_set_row_data (ctree, node, GINT_TO_POINTER (config_page++));
|
|
1077 gtk_notebook_append_page (notebook, vbox, NULL);
|
|
1078 if (node_result)
|
|
1079 *node_result = node;
|
|
1080 return vbox;
|
|
1081 }
|
|
1082
|
|
1083
|
|
1084 void
|
|
1085 iris_first_init (void)
|
|
1086 {
|
|
1087 static gboolean init;
|
|
1088 int i;
|
|
1089
|
|
1090 if (!init)
|
|
1091 {
|
|
1092 theme_register ();
|
|
1093 theme_config_init ();
|
|
1094 /* here we collect information about resolutions supported by the display */
|
|
1095 /* get a connection */
|
|
1096 GLWin.dpy = XOpenDisplay (0);
|
|
1097 GLWin.screen = DefaultScreen (GLWin.dpy);
|
|
1098 XF86VidModeQueryVersion (GLWin.dpy, &GLWin.vidModeMajorVersion,
|
|
1099 &GLWin.vidModeMinorVersion);
|
|
1100 XF86VidModeGetAllModeLines (GLWin.dpy, GLWin.screen, &GLWin.modeNum,
|
|
1101 &GLWin.modes);
|
|
1102 /* save desktop-resolution before switching modes */
|
|
1103 GLWin.deskMode = *(GLWin.modes[0]);
|
|
1104
|
|
1105 /* fill an array of string for the config combo box */
|
|
1106 for (i = 0; i < GLWin.modeNum; i++)
|
|
1107 GLWin.glist =
|
|
1108 g_list_append (GLWin.glist,
|
|
1109 g_strdup_printf ("%dx%d", GLWin.modes[i]->hdisplay,
|
|
1110 GLWin.modes[i]->vdisplay));
|
|
1111
|
|
1112 init = TRUE;
|
|
1113 XCloseDisplay (GLWin.dpy);
|
|
1114 }
|
|
1115 }
|
|
1116
|
|
1117 void
|
|
1118 iris_configure (void)
|
|
1119 {
|
|
1120 GtkWidget *config_vbox;
|
|
1121
|
|
1122 GtkWidget *vbox, *buttonbox, *ok, *apply, *cancel;
|
|
1123 GtkWidget *config_hbox;
|
|
1124 GtkWidget *config_scrolled;
|
|
1125
|
|
1126 gchar *title[1] = { "iris config" };
|
|
1127 GtkCTreeNode *node;
|
|
1128 GtkCTreeNode *node_themes;
|
|
1129 gint i;
|
|
1130
|
|
1131 if (config_window)
|
|
1132 return;
|
|
1133 config_page = 0;
|
|
1134
|
|
1135 iris_first_init ();
|
|
1136 iris_config_read ();
|
|
1137 memcpy (&newconfig, &config, sizeof (iris_config));
|
|
1138
|
|
1139 config_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
1140 gtk_signal_connect (GTK_OBJECT (config_window), "delete_event",
|
|
1141 GTK_SIGNAL_FUNC (conf_closed), &config_window);
|
|
1142 gtk_container_set_border_width (GTK_CONTAINER (config_window), 6);
|
|
1143 gtk_window_set_title (GTK_WINDOW (config_window), "iris configuration");
|
|
1144
|
|
1145 config_hbox = gtk_hbox_new (FALSE, 4);
|
|
1146 gtk_container_add (GTK_CONTAINER (config_window), config_hbox);
|
|
1147
|
|
1148 config_scrolled = gtk_scrolled_window_new (NULL, NULL);
|
|
1149 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (config_scrolled),
|
|
1150 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
1151 gtk_box_pack_start (GTK_BOX (config_hbox), config_scrolled, TRUE, TRUE, 0);
|
|
1152
|
|
1153 config_vbox = gtk_vbox_new (FALSE, 4);
|
|
1154 gtk_box_pack_start (GTK_BOX (config_hbox), config_vbox, TRUE, TRUE, 0);
|
|
1155
|
|
1156 config_ctree = gtk_ctree_new_with_titles (1, 0, title);
|
|
1157 gtk_ctree_set_indent (GTK_CTREE (config_ctree), 16);
|
|
1158 gtk_clist_column_titles_passive (GTK_CLIST (config_ctree));
|
|
1159 gtk_widget_set_usize (config_ctree, 150, 0);
|
|
1160 gtk_container_add (GTK_CONTAINER (config_scrolled), config_ctree);
|
|
1161 gtk_signal_connect (GTK_OBJECT (config_ctree), "tree_select_row",
|
|
1162 (GtkSignalFunc) cb_select_monitor_config, NULL);
|
|
1163 config_notebook = gtk_notebook_new ();
|
|
1164 gtk_notebook_set_show_tabs (GTK_NOTEBOOK (config_notebook), FALSE);
|
|
1165 gtk_box_pack_start (GTK_BOX (config_vbox), config_notebook, TRUE, TRUE, 0);
|
|
1166
|
|
1167 vbox = create_config_page (GTK_NOTEBOOK (config_notebook), "Color",
|
|
1168 GTK_CTREE (config_ctree), NULL, &node);
|
|
1169 create_config_color (vbox);
|
|
1170 gtk_ctree_select (GTK_CTREE (config_ctree), node);
|
|
1171
|
|
1172 vbox = create_config_page (GTK_NOTEBOOK (config_notebook), "Beat",
|
|
1173 GTK_CTREE (config_ctree), NULL, NULL);
|
|
1174 create_config_beat (vbox);
|
|
1175
|
|
1176 vbox = create_config_page (GTK_NOTEBOOK (config_notebook),
|
|
1177 "Transition", GTK_CTREE (config_ctree),
|
|
1178 NULL, NULL);
|
|
1179 create_config_transition (vbox);
|
|
1180
|
|
1181 vbox = create_config_page (GTK_NOTEBOOK (config_notebook),
|
|
1182 "Fullscreen", GTK_CTREE (config_ctree),
|
|
1183 NULL, NULL);
|
|
1184 create_config_fs (vbox);
|
|
1185
|
|
1186 vbox = create_config_page (GTK_NOTEBOOK (config_notebook), "Themes",
|
|
1187 GTK_CTREE (config_ctree), NULL, &node_themes);
|
|
1188 create_config_theme (vbox);
|
|
1189
|
|
1190 for (i = 0; i < THEME_NUMBER; i++)
|
|
1191 {
|
|
1192 GtkWidget *tabs;
|
|
1193 GtkWidget *vbox_1, *vbox_2, *vbox_3;
|
|
1194 GtkWidget *label;
|
|
1195 vbox =
|
|
1196 create_config_page (GTK_NOTEBOOK (config_notebook),
|
|
1197 theme[i].name,
|
|
1198 GTK_CTREE (config_ctree), node_themes, &node);
|
|
1199
|
|
1200 tabs = gtk_notebook_new ();
|
|
1201 gtk_box_pack_start (GTK_BOX (vbox), tabs, TRUE, TRUE, 4);
|
|
1202
|
|
1203 /* first tab : global conf tab */
|
|
1204 vbox_1 = gtk_vbox_new (FALSE, 0);
|
|
1205 gtk_container_border_width (GTK_CONTAINER (vbox_1), 0);
|
|
1206 theme_config_global_widgets (vbox_1, i);
|
|
1207
|
|
1208 label = gtk_label_new ("global settings");
|
|
1209 gtk_notebook_append_page (GTK_NOTEBOOK (tabs), vbox_1, label);
|
|
1210
|
|
1211 /* second tab : specific theme tab */
|
|
1212 if (theme[i].config_create != NULL)
|
|
1213 {
|
|
1214 vbox_2 = gtk_vbox_new (FALSE, 2);
|
|
1215 theme[i].config_create (vbox_2);
|
|
1216
|
|
1217 label = gtk_label_new ("theme settings");
|
|
1218 gtk_notebook_append_page (GTK_NOTEBOOK (tabs), vbox_2, label);
|
|
1219 }
|
|
1220
|
|
1221 /* third tab : info tab */
|
|
1222 vbox_3 = gtk_vbox_new (FALSE, 0);
|
|
1223 gtk_container_border_width (GTK_CONTAINER (vbox_3), 0);
|
|
1224 theme_about (vbox_3, i);
|
|
1225
|
|
1226 label = gtk_label_new ("theme info");
|
|
1227 gtk_notebook_append_page (GTK_NOTEBOOK (tabs), vbox_3, label);
|
|
1228
|
|
1229 }
|
|
1230
|
|
1231 vbox = create_config_page (GTK_NOTEBOOK (config_notebook),
|
|
1232 "GLX infos", GTK_CTREE (config_ctree),
|
|
1233 NULL, NULL);
|
|
1234 create_config_glx_info (vbox);
|
|
1235
|
|
1236 // vbox = create_config_page(GTK_NOTEBOOK(config_notebook), _("About"),
|
|
1237 // GTK_CTREE(config_ctree), NULL, NULL);
|
|
1238 // create_config_about(vbox);
|
|
1239
|
|
1240 /* this is the box where are Ok, Cancel and Apply */
|
|
1241 buttonbox = gtk_hbutton_box_new ();
|
|
1242 gtk_box_pack_end (GTK_BOX (config_vbox), buttonbox, FALSE, FALSE, 8);
|
|
1243 gtk_hbutton_box_set_layout_default (GTK_BUTTONBOX_END);
|
|
1244 gtk_widget_show (buttonbox);
|
|
1245
|
|
1246 ok = gtk_button_new_with_label ("Quit\nand save");
|
|
1247 GTK_WIDGET_SET_FLAGS (ok, GTK_CAN_DEFAULT);
|
|
1248 gtk_box_pack_end (GTK_BOX (buttonbox), ok, FALSE, FALSE, 8);
|
|
1249 gtk_widget_show (ok);
|
|
1250
|
|
1251 cancel = gtk_button_new_with_label ("Quit\nwithout saving");
|
|
1252 GTK_WIDGET_SET_FLAGS (cancel, GTK_CAN_DEFAULT);
|
|
1253 gtk_box_pack_end (GTK_BOX (buttonbox), cancel, FALSE, FALSE, 8);
|
|
1254 gtk_widget_show (cancel);
|
|
1255
|
|
1256 apply = gtk_button_new_with_label ("Apply");
|
|
1257 GTK_WIDGET_SET_FLAGS (apply, GTK_CAN_DEFAULT);
|
|
1258 gtk_box_pack_end (GTK_BOX (buttonbox), apply, FALSE, FALSE, 8);
|
|
1259 gtk_widget_show (apply);
|
|
1260
|
|
1261 gtk_window_set_default (GTK_WINDOW (config_window), ok);
|
|
1262
|
|
1263 gtk_signal_connect (GTK_OBJECT (cancel), "clicked",
|
|
1264 GTK_SIGNAL_FUNC (cancel_clicked), config_window);
|
|
1265 gtk_signal_connect (GTK_OBJECT (ok), "clicked",
|
|
1266 GTK_SIGNAL_FUNC (ok_clicked), config_window);
|
|
1267 gtk_signal_connect (GTK_OBJECT (apply), "clicked",
|
|
1268 GTK_SIGNAL_FUNC (apply_clicked), config_window);
|
|
1269
|
|
1270 gtk_widget_show_all (config_window);
|
|
1271 }
|
|
1272
|
|
1273 /*
|
|
1274 ** Saves all window attributes (goal)
|
|
1275 ** saves only non-fullscreen window sizes for now
|
|
1276 ** ADDME : window position
|
|
1277 */
|
|
1278 void
|
|
1279 iris_save_window_attributes (void)
|
|
1280 {
|
|
1281 XWindowAttributes attr;
|
|
1282 if (!GLWin.fs)
|
|
1283 {
|
|
1284 XGetWindowAttributes (GLWin.dpy, GLWin.window, &attr);
|
|
1285 config.window_width = attr.width;
|
|
1286 config.window_height = attr.height;
|
|
1287 iris_config_write (&config);
|
|
1288 }
|
|
1289 }
|