|
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 <stdlib.h>
|
|
|
20 #include "iris.h"
|
|
|
21
|
|
|
22 /* declaration of all the themes start here */
|
|
|
23 extern iris_theme theme_original;
|
|
|
24 extern iris_theme theme_spectrum;
|
|
|
25 extern iris_theme theme_spectrotoy;
|
|
|
26 extern iris_theme theme_squarefield;
|
|
|
27 extern iris_theme theme_waves;
|
|
|
28 extern iris_theme theme_pyramid;
|
|
|
29 extern iris_theme theme_knot;
|
|
|
30 extern iris_theme theme_pinwheel;
|
|
|
31 extern iris_theme theme_pipes;
|
|
|
32 extern iris_theme theme_float;
|
|
|
33 extern iris_theme theme_fountain;
|
|
|
34 extern iris_theme theme_flash;
|
|
|
35
|
|
|
36 /* this is the array where all the themes are */
|
|
|
37 iris_theme theme[THEME_NUMBER];
|
|
|
38
|
|
|
39
|
|
|
40 /* this initialize the theme registry */
|
|
|
41 void
|
|
|
42 theme_register (void)
|
|
|
43 {
|
|
|
44 theme[0] = theme_original;
|
|
|
45 theme[1] = theme_spectrum;
|
|
|
46 theme[2] = theme_spectrotoy;
|
|
|
47 theme[3] = theme_squarefield;
|
|
|
48 theme[4] = theme_waves;
|
|
|
49 theme[5] = theme_pyramid;
|
|
|
50 theme[6] = theme_knot;
|
|
|
51 theme[7] = theme_pinwheel;
|
|
|
52 theme[8] = theme_pipes;
|
|
|
53 theme[9] = theme_float;
|
|
|
54 theme[10] = theme_fountain;
|
|
|
55 theme[11] = theme_flash;}
|
|
|
56
|
|
|
57
|
|
|
58 /* allocate memory for the config struct of the themes */
|
|
|
59 void
|
|
|
60 theme_config_init (void)
|
|
|
61 {
|
|
|
62 int i;
|
|
|
63
|
|
|
64 for (i = 0; i < THEME_NUMBER; i++)
|
|
|
65 {
|
|
|
66 theme[i].config->global = g_malloc (sizeof (config_global));
|
|
|
67 theme[i].config_new->global = g_malloc (sizeof (config_global));
|
|
|
68 }
|
|
|
69 }
|
|
|
70
|
|
|
71
|
|
|
72 /* set the default global config of a theme */
|
|
|
73 void
|
|
|
74 theme_config_global_default (int num)
|
|
|
75 {
|
|
|
76 theme[num].config->global->priority = 1.0; /* priority set to max */
|
|
|
77 theme[num].config->global->transparency = -1; /* transparency random */
|
|
|
78 theme[num].config->global->wireframe = 0; /* wireframe off */
|
|
|
79 }
|
|
|
80
|
|
|
81
|
|
|
82 /* read the global config of a theme
|
|
|
83 (priority, transparency, wireframe) */
|
|
|
84 void
|
|
|
85 theme_config_global_read (ConfigDb * db, char *section_name, int num)
|
|
|
86 {
|
|
|
87 char *string;
|
|
|
88
|
|
|
89 string = g_strconcat (theme[num].key, "_", "priority", NULL);
|
|
|
90 bmp_cfg_db_get_float (db, section_name, string, &theme[num].config->global->priority);
|
|
|
91 g_free (string);
|
|
|
92
|
|
|
93 string = g_strconcat (theme[num].key, "_", "transparency", NULL);
|
|
|
94 bmp_cfg_db_get_int (db, section_name, string, &theme[num].config->global->transparency);
|
|
|
95 g_free (string);
|
|
|
96
|
|
|
97 string = g_strconcat (theme[num].key, "_", "wireframe", NULL);
|
|
|
98 bmp_cfg_db_get_int (db, section_name, string, &theme[num].config->global->wireframe);
|
|
|
99 g_free (string);
|
|
|
100 }
|
|
|
101
|
|
|
102
|
|
|
103 /* write the global config of a theme */
|
|
|
104 void
|
|
|
105 theme_config_global_write (ConfigDb * db, char *section_name, int num)
|
|
|
106 {
|
|
|
107 char *string;
|
|
|
108
|
|
|
109 string = g_strconcat (theme[num].key, "_", "priority", NULL);
|
|
|
110 bmp_cfg_db_set_float (db, section_name, string, theme[num].config->global->priority);
|
|
|
111 g_free (string);
|
|
|
112
|
|
|
113 string = g_strconcat (theme[num].key, "_", "transparency", NULL);
|
|
|
114 bmp_cfg_db_set_int (db, section_name, string, theme[num].config->global->transparency);
|
|
|
115 g_free (string);
|
|
|
116
|
|
|
117 string = g_strconcat (theme[num].key, "_", "wireframe", NULL);
|
|
|
118 bmp_cfg_db_set_int (db, section_name, string, theme[num].config->global->wireframe);
|
|
|
119 g_free (string);
|
|
|
120 }
|
|
|
121
|
|
|
122
|
|
|
123 /* the following 6 functions are callbacks for the theme_config_global_widgets function */
|
|
|
124 void
|
|
|
125 on_rb_transparency_random (GtkWidget * widget, gpointer data)
|
|
|
126 {
|
|
|
127 theme[(int) data].config_new->global->transparency = -1;
|
|
|
128 }
|
|
|
129
|
|
|
130
|
|
|
131 void
|
|
|
132 on_rb_transparency_on (GtkWidget * widget, gpointer data)
|
|
|
133 {
|
|
|
134 theme[(int) data].config_new->global->transparency = 1;
|
|
|
135 }
|
|
|
136
|
|
|
137
|
|
|
138 void
|
|
|
139 on_rb_transparency_off (GtkWidget * widget, gpointer data)
|
|
|
140 {
|
|
|
141 theme[(int) data].config_new->global->transparency = 0;
|
|
|
142 }
|
|
|
143
|
|
|
144
|
|
|
145 void
|
|
|
146 on_rb_wireframe_random (GtkWidget * widget, gpointer data)
|
|
|
147 {
|
|
|
148 theme[(int) data].config_new->global->wireframe = -1;
|
|
|
149 }
|
|
|
150
|
|
|
151
|
|
|
152 void
|
|
|
153 on_rb_wireframe_on (GtkWidget * widget, gpointer data)
|
|
|
154 {
|
|
|
155 theme[(int) data].config_new->global->wireframe = 1;
|
|
|
156 }
|
|
|
157
|
|
|
158
|
|
|
159 void
|
|
|
160 on_rb_wireframe_off (GtkWidget * widget, gpointer data)
|
|
|
161 {
|
|
|
162 theme[(int) data].config_new->global->wireframe = 0;
|
|
|
163 }
|
|
|
164
|
|
|
165
|
|
|
166 void
|
|
|
167 theme_config_apply (int num)
|
|
|
168 {
|
|
|
169 memcpy (theme[num].config->private, theme[num].config_new->private,
|
|
|
170 theme[num].config_private_size);
|
|
|
171 }
|
|
|
172
|
|
|
173
|
|
|
174 /* create the config widgets of all the themes */
|
|
|
175 void
|
|
|
176 theme_config_global_widgets (GtkWidget * vbox, int num)
|
|
|
177 {
|
|
|
178 GtkWidget *hbox;
|
|
|
179 GtkWidget *label;
|
|
|
180 GtkWidget *radio_button_on1;
|
|
|
181 GtkWidget *radio_button_off1;
|
|
|
182 GtkWidget *radio_button_random1;
|
|
|
183 GSList *group;
|
|
|
184
|
|
|
185 memcpy (theme[num].config_new->global, theme[num].config->global,
|
|
|
186 sizeof (config_global));
|
|
|
187
|
|
|
188 /* transparency mode */
|
|
|
189 hbox = gtk_hbox_new (FALSE, 2);
|
|
|
190 gtk_widget_show (hbox);
|
|
|
191 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
|
|
|
192
|
|
|
193 label = gtk_label_new ("Transparency");
|
|
|
194 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
|
|
|
195 radio_button_random1 = gtk_radio_button_new_with_label (NULL, "Random");
|
|
|
196 gtk_box_pack_start (GTK_BOX (hbox), radio_button_random1, FALSE, FALSE, 4);
|
|
|
197
|
|
|
198 group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button_random1));
|
|
|
199 radio_button_on1 = gtk_radio_button_new_with_label (group, "On");
|
|
|
200 gtk_box_pack_start (GTK_BOX (hbox), radio_button_on1, FALSE, FALSE, 4);
|
|
|
201
|
|
|
202 group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button_on1));
|
|
|
203 radio_button_off1 = gtk_radio_button_new_with_label (group, "Off");
|
|
|
204 gtk_box_pack_start (GTK_BOX (hbox), radio_button_off1, FALSE, FALSE, 4);
|
|
|
205
|
|
|
206 switch (theme[num].config->global->transparency)
|
|
|
207 {
|
|
|
208 case -1:
|
|
|
209 {
|
|
|
210 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
|
|
211 (radio_button_random1), TRUE);
|
|
|
212 break;
|
|
|
213 }
|
|
|
214 case 0:
|
|
|
215 {
|
|
|
216 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
|
|
217 (radio_button_off1), TRUE);
|
|
|
218 break;
|
|
|
219 }
|
|
|
220 case 1:
|
|
|
221 {
|
|
|
222 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
|
|
223 (radio_button_on1), TRUE);
|
|
|
224 }
|
|
|
225 }
|
|
|
226
|
|
|
227 gtk_signal_connect (GTK_OBJECT (radio_button_random1), "toggled",
|
|
|
228 GTK_SIGNAL_FUNC (on_rb_transparency_random),
|
|
|
229 (gpointer) num);
|
|
|
230 gtk_signal_connect (GTK_OBJECT (radio_button_off1), "toggled",
|
|
|
231 GTK_SIGNAL_FUNC (on_rb_transparency_off),
|
|
|
232 (gpointer) num);
|
|
|
233 gtk_signal_connect (GTK_OBJECT (radio_button_on1), "toggled",
|
|
|
234 GTK_SIGNAL_FUNC (on_rb_transparency_on),
|
|
|
235 (gpointer) num);
|
|
|
236
|
|
|
237 /* wireframe mode */
|
|
|
238 hbox = gtk_hbox_new (FALSE, 2);
|
|
|
239 gtk_widget_show (hbox);
|
|
|
240 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4);
|
|
|
241
|
|
|
242 label = gtk_label_new ("Wireframe");
|
|
|
243 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4);
|
|
|
244 radio_button_random1 = gtk_radio_button_new_with_label (NULL, "Random");
|
|
|
245 gtk_box_pack_start (GTK_BOX (hbox), radio_button_random1, FALSE, FALSE, 4);
|
|
|
246
|
|
|
247 group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button_random1));
|
|
|
248 radio_button_on1 = gtk_radio_button_new_with_label (group, "On");
|
|
|
249 gtk_box_pack_start (GTK_BOX (hbox), radio_button_on1, FALSE, FALSE, 4);
|
|
|
250
|
|
|
251 group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button_on1));
|
|
|
252 radio_button_off1 = gtk_radio_button_new_with_label (group, "Off");
|
|
|
253 gtk_box_pack_start (GTK_BOX (hbox), radio_button_off1, FALSE, FALSE, 4);
|
|
|
254
|
|
|
255 switch (theme[num].config->global->wireframe)
|
|
|
256 {
|
|
|
257 case -1:
|
|
|
258 {
|
|
|
259 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
|
|
260 (radio_button_random1), TRUE);
|
|
|
261 break;
|
|
|
262 }
|
|
|
263 case 0:
|
|
|
264 {
|
|
|
265 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
|
|
266 (radio_button_off1), TRUE);
|
|
|
267 break;
|
|
|
268 }
|
|
|
269 case 1:
|
|
|
270 {
|
|
|
271 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
|
|
|
272 (radio_button_on1), TRUE);
|
|
|
273 }
|
|
|
274 }
|
|
|
275
|
|
|
276 gtk_signal_connect (GTK_OBJECT (radio_button_random1), "toggled",
|
|
|
277 GTK_SIGNAL_FUNC (on_rb_wireframe_random),
|
|
|
278 (gpointer) num);
|
|
|
279 gtk_signal_connect (GTK_OBJECT (radio_button_off1), "toggled",
|
|
|
280 GTK_SIGNAL_FUNC (on_rb_wireframe_off), (gpointer) num);
|
|
|
281 gtk_signal_connect (GTK_OBJECT (radio_button_on1), "toggled",
|
|
|
282 GTK_SIGNAL_FUNC (on_rb_wireframe_on), (gpointer) num);
|
|
|
283
|
|
|
284 }
|
|
|
285
|
|
|
286
|
|
|
287 /* create the theme about vbox */
|
|
|
288 void
|
|
|
289 theme_about (GtkWidget * vbox_about, int num)
|
|
|
290 {
|
|
|
291 GtkWidget *label;
|
|
|
292 GtkWidget *vbox;
|
|
|
293
|
|
|
294 vbox = gtk_vbox_new (FALSE, 4);
|
|
|
295 label = gtk_label_new (g_strconcat ("Theme name: ", theme[num].name, NULL));
|
|
|
296 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
|
|
|
297
|
|
|
298 label =
|
|
|
299 gtk_label_new (g_strconcat ("Theme author: ", theme[num].author, NULL));
|
|
|
300 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
|
|
|
301
|
|
|
302 label =
|
|
|
303 gtk_label_new (g_strconcat
|
|
|
304 ("Theme description: ", theme[num].description, NULL));
|
|
|
305 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4);
|
|
|
306
|
|
|
307 gtk_box_pack_start (GTK_BOX (vbox_about), vbox, FALSE, FALSE, 4);
|
|
|
308 }
|