Mercurial > audlegacy
annotate src/audacious/skin.c @ 3545:7a2b667bab4b trunk
Add volumecontrol flow implementation.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Tue, 18 Sep 2007 10:41:40 -0500 |
parents | 6cadc2ddf4cd |
children | 968144b94ece |
rev | line source |
---|---|
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3076
diff
changeset
|
1 /* Audacious |
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3076
diff
changeset
|
2 * Copyright (C) 2005-2007 Audacious development team. |
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3076
diff
changeset
|
3 * |
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3076
diff
changeset
|
4 * BMP - Cross-platform multimedia player |
2313 | 5 * Copyright (C) 2003-2004 BMP development team. |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3076
diff
changeset
|
12 * the Free Software Foundation; under version 3 of the License. |
2313 | 13 * |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3076
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
21 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
22 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
23 * Audacious or using our public API to be a derived work. |
2313 | 24 */ |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 # include "config.h" | |
28 #endif | |
29 | |
30 /* TODO: enforce default sizes! */ | |
31 | |
32 #include <glib.h> | |
33 #include <stdio.h> | |
34 #include <stdlib.h> | |
35 #include <string.h> | |
36 #include <ctype.h> | |
37 | |
3251 | 38 #include "skin.h" |
2313 | 39 #include "ui_equalizer.h" |
40 #include "main.h" | |
41 #include "ui_playlist.h" | |
42 #include "ui_skinselector.h" | |
43 #include "util.h" | |
44 | |
45 #include "debug.h" | |
46 | |
47 #include "platform/smartinclude.h" | |
48 #include "vfs.h" | |
49 | |
2525 | 50 #include "ui_skinned_window.h" |
51 | |
2313 | 52 #define EXTENSION_TARGETS 7 |
53 | |
2529 | 54 static gchar *ext_targets[EXTENSION_TARGETS] = |
55 { "bmp", "xpm", "png", "svg", "gif", "jpg", "jpeg" }; | |
2313 | 56 |
57 struct _SkinPixmapIdMapping { | |
58 SkinPixmapId id; | |
59 const gchar *name; | |
60 const gchar *alt_name; | |
61 gint width, height; | |
62 }; | |
63 | |
64 struct _SkinMaskInfo { | |
65 gint width, height; | |
66 gchar *inistr; | |
67 }; | |
68 | |
69 typedef struct _SkinPixmapIdMapping SkinPixmapIdMapping; | |
70 typedef struct _SkinMaskInfo SkinMaskInfo; | |
71 | |
72 | |
73 Skin *bmp_active_skin = NULL; | |
74 | |
75 static gint skin_current_num; | |
76 | |
77 static SkinMaskInfo skin_mask_info[] = { | |
78 {275, 116, "Normal"}, | |
79 {275, 16, "WindowShade"}, | |
80 {275, 116, "Equalizer"}, | |
81 {275, 16, "EqualizerWS"} | |
82 }; | |
83 | |
84 static SkinPixmapIdMapping skin_pixmap_id_map[] = { | |
85 {SKIN_MAIN, "main", NULL, 0, 0}, | |
86 {SKIN_CBUTTONS, "cbuttons", NULL, 0, 0}, | |
87 {SKIN_SHUFREP, "shufrep", NULL, 0, 0}, | |
88 {SKIN_TEXT, "text", NULL, 0, 0}, | |
89 {SKIN_TITLEBAR, "titlebar", NULL, 0, 0}, | |
90 {SKIN_VOLUME, "volume", NULL, 0, 0}, | |
91 {SKIN_BALANCE, "balance", "volume", 0, 0}, | |
92 {SKIN_MONOSTEREO, "monoster", NULL, 0, 0}, | |
93 {SKIN_PLAYPAUSE, "playpaus", NULL, 0, 0}, | |
94 {SKIN_NUMBERS, "nums_ex", "numbers", 0, 0}, | |
95 {SKIN_POSBAR, "posbar", NULL, 0, 0}, | |
96 {SKIN_EQMAIN, "eqmain", NULL, 0, 0}, | |
97 {SKIN_PLEDIT, "pledit", NULL, 0, 0}, | |
98 {SKIN_EQ_EX, "eq_ex", NULL, 0, 0} | |
99 }; | |
100 | |
101 static guint skin_pixmap_id_map_size = G_N_ELEMENTS(skin_pixmap_id_map); | |
102 | |
103 static const guchar skin_default_viscolor[24][3] = { | |
104 {9, 34, 53}, | |
105 {10, 18, 26}, | |
106 {0, 54, 108}, | |
107 {0, 58, 116}, | |
108 {0, 62, 124}, | |
109 {0, 66, 132}, | |
110 {0, 70, 140}, | |
111 {0, 74, 148}, | |
112 {0, 78, 156}, | |
113 {0, 82, 164}, | |
114 {0, 86, 172}, | |
115 {0, 92, 184}, | |
116 {0, 98, 196}, | |
117 {0, 104, 208}, | |
118 {0, 110, 220}, | |
119 {0, 116, 232}, | |
120 {0, 122, 244}, | |
121 {0, 128, 255}, | |
122 {0, 128, 255}, | |
123 {0, 104, 208}, | |
124 {0, 80, 160}, | |
125 {0, 56, 112}, | |
126 {0, 32, 64}, | |
127 {200, 200, 200} | |
128 }; | |
129 | |
130 static GdkBitmap *skin_create_transparent_mask(const gchar *, | |
131 const gchar *, | |
132 const gchar *, | |
133 GdkWindow *, | |
134 gint, gint, gboolean); | |
135 | |
136 static void skin_setup_masks(Skin * skin); | |
137 | |
138 static void skin_set_default_vis_color(Skin * skin); | |
139 | |
140 void | |
141 skin_lock(Skin * skin) | |
142 { | |
143 g_mutex_lock(skin->lock); | |
144 } | |
145 | |
146 void | |
147 skin_unlock(Skin * skin) | |
148 { | |
149 g_mutex_unlock(skin->lock); | |
150 } | |
151 | |
152 gboolean | |
153 bmp_active_skin_reload(void) | |
154 { | |
2529 | 155 return bmp_active_skin_load(bmp_active_skin->path); |
2313 | 156 } |
157 | |
158 gboolean | |
159 bmp_active_skin_load(const gchar * path) | |
160 { | |
161 g_return_val_if_fail(bmp_active_skin != NULL, FALSE); | |
162 | |
163 memset(&bmp_active_skin->properties, 0, sizeof(SkinProperties)); | |
164 | |
165 if (!skin_load(bmp_active_skin, path)) | |
166 return FALSE; | |
167 | |
168 skin_setup_masks(bmp_active_skin); | |
169 | |
3221
9583cd62231f
implement ui_skinned_window_expose
Tomasz Mon <desowin@gmail.com>
parents:
3186
diff
changeset
|
170 ui_skinned_window_draw_all(mainwin); |
9583cd62231f
implement ui_skinned_window_expose
Tomasz Mon <desowin@gmail.com>
parents:
3186
diff
changeset
|
171 ui_skinned_window_draw_all(equalizerwin); |
9583cd62231f
implement ui_skinned_window_expose
Tomasz Mon <desowin@gmail.com>
parents:
3186
diff
changeset
|
172 ui_skinned_window_draw_all(playlistwin); |
2313 | 173 |
174 playlistwin_update_list(playlist_get_active()); | |
175 | |
3305
6cadc2ddf4cd
revise 19ad8ea66a03: fix skins with non-standard size posbar
Tomasz Mon <desowin@gmail.com>
parents:
3300
diff
changeset
|
176 SkinPixmap *pixmap; |
6cadc2ddf4cd
revise 19ad8ea66a03: fix skins with non-standard size posbar
Tomasz Mon <desowin@gmail.com>
parents:
3300
diff
changeset
|
177 pixmap = &bmp_active_skin->pixmaps[SKIN_POSBAR]; |
6cadc2ddf4cd
revise 19ad8ea66a03: fix skins with non-standard size posbar
Tomasz Mon <desowin@gmail.com>
parents:
3300
diff
changeset
|
178 /* last 59 pixels of SKIN_POSBAR are knobs (normal and selected) */ |
6cadc2ddf4cd
revise 19ad8ea66a03: fix skins with non-standard size posbar
Tomasz Mon <desowin@gmail.com>
parents:
3300
diff
changeset
|
179 gtk_widget_set_size_request(mainwin_position, pixmap->width - 59, pixmap->height); |
6cadc2ddf4cd
revise 19ad8ea66a03: fix skins with non-standard size posbar
Tomasz Mon <desowin@gmail.com>
parents:
3300
diff
changeset
|
180 |
2313 | 181 return TRUE; |
182 } | |
183 | |
184 void | |
185 skin_pixmap_free(SkinPixmap * p) | |
186 { | |
187 g_return_if_fail(p != NULL); | |
188 g_return_if_fail(p->pixmap != NULL); | |
189 | |
190 g_object_unref(p->pixmap); | |
191 p->pixmap = NULL; | |
192 } | |
193 | |
194 Skin * | |
195 skin_new(void) | |
196 { | |
197 Skin *skin; | |
198 skin = g_new0(Skin, 1); | |
199 skin->lock = g_mutex_new(); | |
200 return skin; | |
201 } | |
202 | |
203 void | |
204 skin_free(Skin * skin) | |
205 { | |
206 gint i; | |
207 | |
208 g_return_if_fail(skin != NULL); | |
209 | |
210 skin_lock(skin); | |
211 | |
212 for (i = 0; i < SKIN_PIXMAP_COUNT; i++) | |
213 skin_pixmap_free(&skin->pixmaps[i]); | |
214 | |
215 for (i = 0; i < SKIN_PIXMAP_COUNT; i++) { | |
216 if (skin->masks[i]) | |
217 g_object_unref(skin->masks[i]); | |
218 if (skin->ds_masks[i]) | |
219 g_object_unref(skin->ds_masks[i]); | |
220 | |
221 skin->masks[i] = NULL; | |
222 skin->ds_masks[i] = NULL; | |
223 } | |
224 | |
225 skin_set_default_vis_color(skin); | |
226 skin_unlock(skin); | |
227 } | |
228 | |
229 void | |
230 skin_destroy(Skin * skin) | |
231 { | |
232 g_return_if_fail(skin != NULL); | |
233 skin_free(skin); | |
234 g_mutex_free(skin->lock); | |
235 g_free(skin); | |
236 } | |
237 | |
238 const SkinPixmapIdMapping * | |
239 skin_pixmap_id_lookup(guint id) | |
240 { | |
241 guint i; | |
242 | |
243 for (i = 0; i < skin_pixmap_id_map_size; i++) { | |
244 if (id == skin_pixmap_id_map[i].id) { | |
245 return &skin_pixmap_id_map[i]; | |
246 } | |
247 } | |
248 | |
249 return NULL; | |
250 } | |
251 | |
252 const gchar * | |
253 skin_pixmap_id_to_name(SkinPixmapId id) | |
254 { | |
255 guint i; | |
256 | |
257 for (i = 0; i < skin_pixmap_id_map_size; i++) { | |
258 if (id == skin_pixmap_id_map[i].id) | |
259 return skin_pixmap_id_map[i].name; | |
260 } | |
261 return NULL; | |
262 } | |
263 | |
264 static void | |
265 skin_set_default_vis_color(Skin * skin) | |
266 { | |
267 memcpy(skin->vis_color, skin_default_viscolor, | |
268 sizeof(skin_default_viscolor)); | |
269 } | |
270 | |
271 /* | |
272 * I have rewritten this to take an array of possible targets, | |
273 * once we find a matching target we now return, instead of loop | |
274 * recursively. This allows for us to support many possible format | |
275 * targets for our skinning engine than just the original winamp | |
276 * formats. | |
277 * | |
278 * -- nenolod, 16 January 2006 | |
279 */ | |
280 gchar * | |
281 skin_pixmap_locate(const gchar * dirname, gchar ** basenames) | |
282 { | |
283 gchar *filename; | |
284 gint i; | |
285 | |
286 for (i = 0; basenames[i]; i++) | |
2989
15f6c9949cde
Add and use find_path_recursively() which search the FS without using VFS (for GTK).
William Pitcock <nenolod@atheme-project.org>
parents:
2654
diff
changeset
|
287 if (!(filename = find_path_recursively(dirname, basenames[i]))) |
2529 | 288 g_free(filename); |
289 else | |
290 return filename; | |
2313 | 291 |
292 /* can't find any targets -- sorry */ | |
293 return NULL; | |
294 } | |
295 | |
296 /* FIXME: this function is temporary. It will be removed when the skinning system | |
297 uses GdkPixbuf in place of GdkPixmap */ | |
298 | |
299 static GdkPixmap * | |
300 pixmap_new_from_file(const gchar * filename) | |
301 { | |
302 GdkPixbuf *pixbuf, *pixbuf2; | |
303 GdkPixmap *pixmap; | |
304 gint width, height; | |
305 | |
306 if (!(pixbuf = gdk_pixbuf_new_from_file(filename, NULL))) | |
307 return NULL; | |
308 | |
309 width = gdk_pixbuf_get_width(pixbuf); | |
310 height = gdk_pixbuf_get_height(pixbuf); | |
311 | |
312 /* create the windows if they haven't been created yet, needed for bootstrapping */ | |
313 if (mainwin == NULL) | |
314 { | |
315 mainwin_create(); | |
316 equalizerwin_create(); | |
317 playlistwin_create(); | |
318 } | |
319 | |
320 if (!(pixmap = gdk_pixmap_new(mainwin->window, width, height, | |
321 gdk_rgb_get_visual()->depth))) { | |
322 g_object_unref(pixbuf); | |
323 return NULL; | |
324 } | |
325 | |
326 pixbuf2 = audacious_create_colorized_pixbuf(pixbuf, cfg.colorize_r, cfg.colorize_g, cfg.colorize_b); | |
327 g_object_unref(pixbuf); | |
328 | |
3223 | 329 GdkGC *gc; |
330 gc = gdk_gc_new(pixmap); | |
331 gdk_draw_pixbuf(pixmap, gc, pixbuf2, 0, 0, 0, 0, width, height, GDK_RGB_DITHER_MAX, 0, 0); | |
332 g_object_unref(gc); | |
2313 | 333 g_object_unref(pixbuf2); |
334 | |
335 return pixmap; | |
336 } | |
337 | |
338 static gboolean | |
339 skin_load_pixmap_id(Skin * skin, SkinPixmapId id, const gchar * path_p) | |
340 { | |
341 const gchar *path; | |
342 gchar *filename; | |
343 gint width, height; | |
344 const SkinPixmapIdMapping *pixmap_id_mapping; | |
345 GdkPixmap *gpm; | |
346 SkinPixmap *pm = NULL; | |
347 gchar *basenames[EXTENSION_TARGETS * 2 + 1]; /* alternate basenames */ | |
348 gint i, y; | |
349 | |
350 g_return_val_if_fail(skin != NULL, FALSE); | |
351 g_return_val_if_fail(id < SKIN_PIXMAP_COUNT, FALSE); | |
352 | |
353 pixmap_id_mapping = skin_pixmap_id_lookup(id); | |
354 g_return_val_if_fail(pixmap_id_mapping != NULL, FALSE); | |
355 | |
356 memset(&basenames, 0, sizeof(basenames)); | |
357 | |
358 for (i = 0, y = 0; i < EXTENSION_TARGETS; i++, y++) | |
359 { | |
2529 | 360 basenames[y] = |
361 g_strdup_printf("%s.%s", pixmap_id_mapping->name, ext_targets[i]); | |
2313 | 362 |
363 if (pixmap_id_mapping->alt_name) | |
2529 | 364 basenames[++y] = |
365 g_strdup_printf("%s.%s", pixmap_id_mapping->alt_name, | |
366 ext_targets[i]); | |
2313 | 367 } |
368 | |
369 path = path_p ? path_p : skin->path; | |
370 filename = skin_pixmap_locate(path, basenames); | |
371 | |
372 for (i = 0; basenames[i] != NULL; i++) | |
373 { | |
374 g_free(basenames[i]); | |
375 basenames[i] = NULL; | |
376 } | |
377 | |
378 if (!(gpm = pixmap_new_from_file(filename))) { | |
379 g_warning("loading of %s failed", filename); | |
380 g_free(filename); | |
381 return FALSE; | |
382 } | |
383 | |
384 g_free(filename); | |
385 | |
386 gdk_drawable_get_size(GDK_DRAWABLE(gpm), &width, &height); | |
387 pm = &skin->pixmaps[id]; | |
388 pm->pixmap = gpm; | |
389 pm->width = width; | |
390 pm->height = height; | |
391 pm->current_width = width; | |
392 pm->current_height = height; | |
393 | |
394 return TRUE; | |
395 } | |
396 | |
397 void | |
398 skin_mask_create(Skin * skin, | |
399 const gchar * path, | |
400 gint id, | |
401 GdkWindow * window) | |
402 { | |
403 skin->masks[id] = | |
404 skin_create_transparent_mask(path, "region.txt", | |
405 skin_mask_info[id].inistr, window, | |
406 skin_mask_info[id].width, | |
407 skin_mask_info[id].height, FALSE); | |
408 | |
409 skin->ds_masks[id] = | |
410 skin_create_transparent_mask(path, "region.txt", | |
411 skin_mask_info[id].inistr, window, | |
412 skin_mask_info[id].width * 2, | |
413 skin_mask_info[id].height * 2, TRUE); | |
414 } | |
415 | |
416 static void | |
417 skin_setup_masks(Skin * skin) | |
418 { | |
419 GdkBitmap *mask; | |
420 | |
421 if (cfg.show_wm_decorations) | |
422 return; | |
423 | |
424 if (cfg.player_visible) { | |
425 mask = skin_get_mask(skin, SKIN_MASK_MAIN + cfg.player_shaded); | |
426 gtk_widget_shape_combine_mask(mainwin, mask, 0, 0); | |
427 } | |
428 | |
429 mask = skin_get_mask(skin, SKIN_MASK_EQ + cfg.equalizer_shaded); | |
430 gtk_widget_shape_combine_mask(equalizerwin, mask, 0, 0); | |
431 } | |
432 | |
433 static GdkBitmap * | |
434 create_default_mask(GdkWindow * parent, gint w, gint h) | |
435 { | |
436 GdkBitmap *ret; | |
437 GdkGC *gc; | |
438 GdkColor pattern; | |
439 | |
440 ret = gdk_pixmap_new(parent, w, h, 1); | |
441 gc = gdk_gc_new(ret); | |
442 pattern.pixel = 1; | |
443 gdk_gc_set_foreground(gc, &pattern); | |
444 gdk_draw_rectangle(ret, gc, TRUE, 0, 0, w, h); | |
445 g_object_unref(gc); | |
446 | |
447 return ret; | |
448 } | |
449 | |
450 static void | |
451 skin_query_color(GdkColormap * cm, GdkColor * c) | |
452 { | |
453 #ifdef GDK_WINDOWING_X11 | |
454 XColor xc = { 0,0,0,0,0,0 }; | |
455 | |
456 xc.pixel = c->pixel; | |
457 XQueryColor(GDK_COLORMAP_XDISPLAY(cm), GDK_COLORMAP_XCOLORMAP(cm), &xc); | |
458 c->red = xc.red; | |
459 c->green = xc.green; | |
460 c->blue = xc.blue; | |
461 #else | |
462 /* do nothing. see what breaks? */ | |
463 #endif | |
464 } | |
465 | |
466 static glong | |
467 skin_calc_luminance(GdkColor * c) | |
468 { | |
469 return (0.212671 * c->red + 0.715160 * c->green + 0.072169 * c->blue); | |
470 } | |
471 | |
472 static void | |
473 skin_get_textcolors(GdkPixmap * text, GdkColor * bgc, GdkColor * fgc) | |
474 { | |
475 /* | |
476 * Try to extract reasonable background and foreground colors | |
477 * from the font pixmap | |
478 */ | |
479 | |
480 GdkImage *gi; | |
481 GdkColormap *cm; | |
482 gint i; | |
483 | |
484 g_return_if_fail(text != NULL); | |
485 g_return_if_fail(GDK_IS_WINDOW(playlistwin->window)); | |
486 | |
487 /* Get the first line of text */ | |
488 gi = gdk_drawable_get_image(text, 0, 0, 152, 6); | |
489 cm = gdk_drawable_get_colormap(playlistwin->window); | |
490 | |
491 for (i = 0; i < 6; i++) { | |
492 GdkColor c; | |
493 gint x; | |
494 glong d, max_d; | |
495 | |
496 /* Get a pixel from the middle of the space character */ | |
497 bgc[i].pixel = gdk_image_get_pixel(gi, 151, i); | |
498 skin_query_color(cm, &bgc[i]); | |
499 | |
500 max_d = 0; | |
501 for (x = 1; x < 150; x++) { | |
502 c.pixel = gdk_image_get_pixel(gi, x, i); | |
503 skin_query_color(cm, &c); | |
504 | |
505 d = labs(skin_calc_luminance(&c) - skin_calc_luminance(&bgc[i])); | |
506 if (d > max_d) { | |
507 memcpy(&fgc[i], &c, sizeof(GdkColor)); | |
508 max_d = d; | |
509 } | |
510 } | |
511 } | |
512 g_object_unref(gi); | |
513 } | |
514 | |
515 gboolean | |
516 init_skins(const gchar * path) | |
517 { | |
518 bmp_active_skin = skin_new(); | |
519 | |
520 if (!bmp_active_skin_load(path)) { | |
521 /* FIXME: Oddly, g_message() causes a crash if path is NULL on | |
522 * Solaris (see bug #165) */ | |
523 if (path) | |
524 g_message("Unable to load skin (%s), trying default...", path); | |
525 | |
526 /* can't load configured skin, retry with default */ | |
527 if (!bmp_active_skin_load(BMP_DEFAULT_SKIN_PATH)) { | |
528 g_message("Unable to load default skin (%s)! Giving up.", | |
529 BMP_DEFAULT_SKIN_PATH); | |
530 return FALSE; | |
531 } | |
532 } | |
533 | |
534 if (cfg.random_skin_on_play) | |
535 skinlist_update(); | |
536 | |
537 return TRUE; | |
538 } | |
539 | |
540 /* | |
541 * Opens and parses a skin's hints file. | |
542 * Hints files are somewhat like "scripts" in Winamp3/5. | |
543 * We'll probably add scripts to it next. | |
544 */ | |
545 void | |
546 skin_parse_hints(Skin * skin, gchar *path_p) | |
547 { | |
548 gchar *filename, *tmp; | |
2529 | 549 INIFile *inifile; |
2313 | 550 |
551 path_p = path_p ? path_p : skin->path; | |
552 | |
2578
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
553 skin->properties.mainwin_othertext = FALSE; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
554 skin->properties.mainwin_vis_x = 24; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
555 skin->properties.mainwin_vis_y = 43; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
556 skin->properties.mainwin_vis_width = 76; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
557 skin->properties.mainwin_text_x = 112; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
558 skin->properties.mainwin_text_y = 27; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
559 skin->properties.mainwin_text_width = 153; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
560 skin->properties.mainwin_infobar_x = 112; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
561 skin->properties.mainwin_infobar_y = 43; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
562 skin->properties.mainwin_number_0_x = 36; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
563 skin->properties.mainwin_number_0_y = 26; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
564 skin->properties.mainwin_number_1_x = 48; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
565 skin->properties.mainwin_number_1_y = 26; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
566 skin->properties.mainwin_number_2_x = 60; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
567 skin->properties.mainwin_number_2_y = 26; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
568 skin->properties.mainwin_number_3_x = 78; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
569 skin->properties.mainwin_number_3_y = 26; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
570 skin->properties.mainwin_number_4_x = 90; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
571 skin->properties.mainwin_number_4_y = 26; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
572 skin->properties.mainwin_playstatus_x = 24; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
573 skin->properties.mainwin_playstatus_y = 28; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
574 skin->properties.mainwin_menurow_visible = TRUE; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
575 skin->properties.mainwin_volume_x = 107; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
576 skin->properties.mainwin_volume_y = 57; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
577 skin->properties.mainwin_balance_x = 177; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
578 skin->properties.mainwin_balance_y = 57; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
579 skin->properties.mainwin_position_x = 16; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
580 skin->properties.mainwin_position_y = 72; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
581 skin->properties.mainwin_othertext_is_status = FALSE; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
582 skin->properties.mainwin_othertext_visible = skin->properties.mainwin_othertext; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
583 skin->properties.mainwin_text_visible = TRUE; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
584 skin->properties.mainwin_vis_visible = TRUE; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
585 skin->properties.mainwin_previous_x = 16; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
586 skin->properties.mainwin_previous_y = 88; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
587 skin->properties.mainwin_play_x = 39; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
588 skin->properties.mainwin_play_y = 88; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
589 skin->properties.mainwin_pause_x = 62; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
590 skin->properties.mainwin_pause_y = 88; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
591 skin->properties.mainwin_stop_x = 85; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
592 skin->properties.mainwin_stop_y = 88; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
593 skin->properties.mainwin_next_x = 108; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
594 skin->properties.mainwin_next_y = 88; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
595 skin->properties.mainwin_eject_x = 136; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
596 skin->properties.mainwin_eject_y = 89; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
597 skin->properties.mainwin_width = 275; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
598 skin_mask_info[0].width = skin->properties.mainwin_width; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
599 skin->properties.mainwin_height = 116; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
600 skin_mask_info[0].height = skin->properties.mainwin_height; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
601 skin->properties.mainwin_about_x = 247; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
602 skin->properties.mainwin_about_y = 83; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
603 skin->properties.mainwin_shuffle_x = 164; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
604 skin->properties.mainwin_shuffle_y = 89; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
605 skin->properties.mainwin_repeat_x = 210; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
606 skin->properties.mainwin_repeat_y = 89; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
607 skin->properties.mainwin_eqbutton_x = 219; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
608 skin->properties.mainwin_eqbutton_y = 58; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
609 skin->properties.mainwin_plbutton_x = 242; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
610 skin->properties.mainwin_plbutton_y = 58; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
611 skin->properties.textbox_bitmap_font_width = 5; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
612 skin->properties.textbox_bitmap_font_height = 6; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
613 skin->properties.mainwin_minimize_x = 244; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
614 skin->properties.mainwin_minimize_y = 3; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
615 skin->properties.mainwin_shade_x = 254; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
616 skin->properties.mainwin_shade_y = 3; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
617 skin->properties.mainwin_close_x = 264; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
618 skin->properties.mainwin_close_y = 3; |
33911de063cb
[svn] - change the order that hints are processed in.
nenolod
parents:
2577
diff
changeset
|
619 |
2313 | 620 filename = find_file_recursively(path_p, "skin.hints"); |
2577 | 621 |
622 if (filename == NULL) | |
623 return; | |
624 | |
2529 | 625 inifile = open_ini_file(filename); |
2313 | 626 |
2529 | 627 tmp = read_ini_string(inifile, "skin", "mainwinOthertext"); |
2313 | 628 |
629 if (tmp != NULL) | |
630 { | |
631 skin->properties.mainwin_othertext = atoi(tmp); | |
632 g_free(tmp); | |
633 } | |
634 | |
2529 | 635 tmp = read_ini_string(inifile, "skin", "mainwinVisX"); |
2313 | 636 |
637 if (tmp != NULL) | |
638 { | |
639 skin->properties.mainwin_vis_x = atoi(tmp); | |
640 g_free(tmp); | |
641 } | |
642 | |
2529 | 643 tmp = read_ini_string(inifile, "skin", "mainwinVisY"); |
2313 | 644 |
645 if (tmp != NULL) | |
646 { | |
647 skin->properties.mainwin_vis_y = atoi(tmp); | |
648 g_free(tmp); | |
649 } | |
650 | |
2529 | 651 tmp = read_ini_string(inifile, "skin", "mainwinVisWidth"); |
2313 | 652 |
653 if (tmp != NULL) | |
654 { | |
655 skin->properties.mainwin_vis_width = atoi(tmp); | |
656 g_free(tmp); | |
657 } | |
658 | |
2529 | 659 tmp = read_ini_string(inifile, "skin", "mainwinTextX"); |
2313 | 660 |
661 if (tmp != NULL) | |
662 { | |
663 skin->properties.mainwin_text_x = atoi(tmp); | |
664 g_free(tmp); | |
665 } | |
666 | |
2529 | 667 tmp = read_ini_string(inifile, "skin", "mainwinTextY"); |
2313 | 668 |
669 if (tmp != NULL) | |
670 { | |
671 skin->properties.mainwin_text_y = atoi(tmp); | |
672 g_free(tmp); | |
673 } | |
674 | |
2529 | 675 tmp = read_ini_string(inifile, "skin", "mainwinTextWidth"); |
2313 | 676 |
677 if (tmp != NULL) | |
678 { | |
679 skin->properties.mainwin_text_width = atoi(tmp); | |
680 g_free(tmp); | |
681 } | |
682 | |
2529 | 683 tmp = read_ini_string(inifile, "skin", "mainwinInfoBarX"); |
2313 | 684 |
685 if (tmp != NULL) | |
686 { | |
687 skin->properties.mainwin_infobar_x = atoi(tmp); | |
688 g_free(tmp); | |
689 } | |
690 | |
2529 | 691 tmp = read_ini_string(inifile, "skin", "mainwinInfoBarY"); |
2313 | 692 |
693 if (tmp != NULL) | |
694 { | |
695 skin->properties.mainwin_infobar_y = atoi(tmp); | |
696 g_free(tmp); | |
697 } | |
698 | |
2529 | 699 tmp = read_ini_string(inifile, "skin", "mainwinNumber0X"); |
2313 | 700 |
701 if (tmp != NULL) | |
702 { | |
703 skin->properties.mainwin_number_0_x = atoi(tmp); | |
704 g_free(tmp); | |
705 } | |
706 | |
2529 | 707 tmp = read_ini_string(inifile, "skin", "mainwinNumber0Y"); |
2313 | 708 |
709 if (tmp != NULL) | |
710 { | |
711 skin->properties.mainwin_number_0_y = atoi(tmp); | |
712 g_free(tmp); | |
713 } | |
714 | |
2529 | 715 tmp = read_ini_string(inifile, "skin", "mainwinNumber1X"); |
2313 | 716 |
717 if (tmp != NULL) | |
718 { | |
719 skin->properties.mainwin_number_1_x = atoi(tmp); | |
720 g_free(tmp); | |
721 } | |
722 | |
2529 | 723 tmp = read_ini_string(inifile, "skin", "mainwinNumber1Y"); |
2313 | 724 |
725 if (tmp != NULL) | |
726 { | |
727 skin->properties.mainwin_number_1_y = atoi(tmp); | |
728 g_free(tmp); | |
729 } | |
730 | |
2529 | 731 tmp = read_ini_string(inifile, "skin", "mainwinNumber2X"); |
2313 | 732 |
733 if (tmp != NULL) | |
734 { | |
735 skin->properties.mainwin_number_2_x = atoi(tmp); | |
736 g_free(tmp); | |
737 } | |
738 | |
2529 | 739 tmp = read_ini_string(inifile, "skin", "mainwinNumber2Y"); |
2313 | 740 |
741 if (tmp != NULL) | |
742 { | |
743 skin->properties.mainwin_number_2_y = atoi(tmp); | |
744 g_free(tmp); | |
745 } | |
746 | |
2529 | 747 tmp = read_ini_string(inifile, "skin", "mainwinNumber3X"); |
2313 | 748 |
749 if (tmp != NULL) | |
750 { | |
751 skin->properties.mainwin_number_3_x = atoi(tmp); | |
752 g_free(tmp); | |
753 } | |
754 | |
2529 | 755 tmp = read_ini_string(inifile, "skin", "mainwinNumber3Y"); |
2313 | 756 |
757 if (tmp != NULL) | |
758 { | |
759 skin->properties.mainwin_number_3_y = atoi(tmp); | |
760 g_free(tmp); | |
761 } | |
762 | |
2529 | 763 tmp = read_ini_string(inifile, "skin", "mainwinNumber4X"); |
2313 | 764 |
765 if (tmp != NULL) | |
766 { | |
767 skin->properties.mainwin_number_4_x = atoi(tmp); | |
768 g_free(tmp); | |
769 } | |
770 | |
2529 | 771 tmp = read_ini_string(inifile, "skin", "mainwinNumber4Y"); |
2313 | 772 |
773 if (tmp != NULL) | |
774 { | |
775 skin->properties.mainwin_number_4_y = atoi(tmp); | |
776 g_free(tmp); | |
777 } | |
778 | |
2529 | 779 tmp = read_ini_string(inifile, "skin", "mainwinPlayStatusX"); |
2313 | 780 |
781 if (tmp != NULL) | |
782 { | |
783 skin->properties.mainwin_playstatus_x = atoi(tmp); | |
784 g_free(tmp); | |
785 } | |
786 | |
2529 | 787 tmp = read_ini_string(inifile, "skin", "mainwinPlayStatusY"); |
2313 | 788 |
789 if (tmp != NULL) | |
790 { | |
791 skin->properties.mainwin_playstatus_y = atoi(tmp); | |
792 g_free(tmp); | |
793 } | |
794 | |
2529 | 795 tmp = read_ini_string(inifile, "skin", "mainwinMenurowVisible"); |
2313 | 796 |
797 if (tmp != NULL) | |
798 { | |
799 skin->properties.mainwin_menurow_visible = atoi(tmp); | |
800 g_free(tmp); | |
801 } | |
802 | |
2529 | 803 tmp = read_ini_string(inifile, "skin", "mainwinVolumeX"); |
2313 | 804 |
805 if (tmp != NULL) | |
806 { | |
807 skin->properties.mainwin_volume_x = atoi(tmp); | |
808 g_free(tmp); | |
809 } | |
810 | |
2529 | 811 tmp = read_ini_string(inifile, "skin", "mainwinVolumeY"); |
2313 | 812 |
813 if (tmp != NULL) | |
814 { | |
815 skin->properties.mainwin_volume_y = atoi(tmp); | |
816 g_free(tmp); | |
817 } | |
818 | |
2529 | 819 tmp = read_ini_string(inifile, "skin", "mainwinBalanceX"); |
2313 | 820 |
821 if (tmp != NULL) | |
822 { | |
823 skin->properties.mainwin_balance_x = atoi(tmp); | |
824 g_free(tmp); | |
825 } | |
826 | |
2529 | 827 tmp = read_ini_string(inifile, "skin", "mainwinBalanceY"); |
2313 | 828 |
829 if (tmp != NULL) | |
830 { | |
831 skin->properties.mainwin_balance_y = atoi(tmp); | |
832 g_free(tmp); | |
833 } | |
834 | |
2529 | 835 tmp = read_ini_string(inifile, "skin", "mainwinPositionX"); |
2313 | 836 |
837 if (tmp != NULL) | |
838 { | |
839 skin->properties.mainwin_position_x = atoi(tmp); | |
840 g_free(tmp); | |
841 } | |
842 | |
2529 | 843 tmp = read_ini_string(inifile, "skin", "mainwinPositionY"); |
2313 | 844 |
845 if (tmp != NULL) | |
846 { | |
847 skin->properties.mainwin_position_y = atoi(tmp); | |
848 g_free(tmp); | |
849 } | |
850 | |
2529 | 851 tmp = read_ini_string(inifile, "skin", "mainwinOthertextIsStatus"); |
2313 | 852 |
853 if (tmp != NULL) | |
854 { | |
855 skin->properties.mainwin_othertext_is_status = atoi(tmp); | |
856 g_free(tmp); | |
857 } | |
858 | |
2529 | 859 tmp = read_ini_string(inifile, "skin", "mainwinOthertextVisible"); |
2313 | 860 |
861 if (tmp != NULL) | |
862 { | |
863 skin->properties.mainwin_othertext_visible = atoi(tmp); | |
864 g_free(tmp); | |
865 } | |
866 | |
2529 | 867 tmp = read_ini_string(inifile, "skin", "mainwinTextVisible"); |
2313 | 868 |
869 if (tmp != NULL) | |
870 { | |
871 skin->properties.mainwin_text_visible = atoi(tmp); | |
872 g_free(tmp); | |
873 } | |
874 | |
2529 | 875 tmp = read_ini_string(inifile, "skin", "mainwinVisVisible"); |
2313 | 876 |
877 if (tmp != NULL) | |
878 { | |
879 skin->properties.mainwin_vis_visible = atoi(tmp); | |
880 g_free(tmp); | |
881 } | |
882 | |
2529 | 883 tmp = read_ini_string(inifile, "skin", "mainwinPreviousX"); |
2313 | 884 |
885 if (tmp != NULL) | |
886 { | |
887 skin->properties.mainwin_previous_x = atoi(tmp); | |
888 g_free(tmp); | |
889 } | |
890 | |
2529 | 891 tmp = read_ini_string(inifile, "skin", "mainwinPreviousY"); |
2313 | 892 |
893 if (tmp != NULL) | |
894 { | |
895 skin->properties.mainwin_previous_y = atoi(tmp); | |
896 g_free(tmp); | |
897 } | |
898 | |
2529 | 899 tmp = read_ini_string(inifile, "skin", "mainwinPlayX"); |
2313 | 900 |
901 if (tmp != NULL) | |
902 { | |
903 skin->properties.mainwin_play_x = atoi(tmp); | |
904 g_free(tmp); | |
905 } | |
906 | |
2529 | 907 tmp = read_ini_string(inifile, "skin", "mainwinPlayY"); |
2313 | 908 |
909 if (tmp != NULL) | |
910 { | |
911 skin->properties.mainwin_play_y = atoi(tmp); | |
912 g_free(tmp); | |
913 } | |
914 | |
2529 | 915 tmp = read_ini_string(inifile, "skin", "mainwinPauseX"); |
2313 | 916 |
917 if (tmp != NULL) | |
918 { | |
919 skin->properties.mainwin_pause_x = atoi(tmp); | |
920 g_free(tmp); | |
921 } | |
922 | |
2529 | 923 tmp = read_ini_string(inifile, "skin", "mainwinPauseY"); |
2313 | 924 |
925 if (tmp != NULL) | |
926 { | |
927 skin->properties.mainwin_pause_y = atoi(tmp); | |
928 g_free(tmp); | |
929 } | |
930 | |
2529 | 931 tmp = read_ini_string(inifile, "skin", "mainwinStopX"); |
2313 | 932 |
933 if (tmp != NULL) | |
934 { | |
935 skin->properties.mainwin_stop_x = atoi(tmp); | |
936 g_free(tmp); | |
937 } | |
938 | |
2529 | 939 tmp = read_ini_string(inifile, "skin", "mainwinStopY"); |
2313 | 940 |
941 if (tmp != NULL) | |
942 { | |
943 skin->properties.mainwin_stop_y = atoi(tmp); | |
944 g_free(tmp); | |
945 } | |
946 | |
2529 | 947 tmp = read_ini_string(inifile, "skin", "mainwinNextX"); |
2313 | 948 |
949 if (tmp != NULL) | |
950 { | |
951 skin->properties.mainwin_next_x = atoi(tmp); | |
952 g_free(tmp); | |
953 } | |
954 | |
2529 | 955 tmp = read_ini_string(inifile, "skin", "mainwinNextY"); |
2313 | 956 |
957 if (tmp != NULL) | |
958 { | |
959 skin->properties.mainwin_next_y = atoi(tmp); | |
960 g_free(tmp); | |
961 } | |
962 | |
2529 | 963 tmp = read_ini_string(inifile, "skin", "mainwinEjectX"); |
2313 | 964 |
965 if (tmp != NULL) | |
966 { | |
967 skin->properties.mainwin_eject_x = atoi(tmp); | |
968 g_free(tmp); | |
969 } | |
970 | |
2529 | 971 tmp = read_ini_string(inifile, "skin", "mainwinEjectY"); |
2313 | 972 |
973 if (tmp != NULL) | |
974 { | |
975 skin->properties.mainwin_eject_y = atoi(tmp); | |
976 g_free(tmp); | |
977 } | |
978 | |
2529 | 979 tmp = read_ini_string(inifile, "skin", "mainwinWidth"); |
2313 | 980 |
981 if (tmp != NULL) | |
982 { | |
983 skin->properties.mainwin_width = atoi(tmp); | |
984 g_free(tmp); | |
985 } | |
986 | |
2581 | 987 skin_mask_info[0].width = skin->properties.mainwin_width; |
988 | |
2529 | 989 tmp = read_ini_string(inifile, "skin", "mainwinHeight"); |
2313 | 990 |
991 if (tmp != NULL) | |
992 { | |
993 skin->properties.mainwin_height = atoi(tmp); | |
994 g_free(tmp); | |
995 } | |
996 | |
2581 | 997 skin_mask_info[0].height = skin->properties.mainwin_height; |
998 | |
2529 | 999 tmp = read_ini_string(inifile, "skin", "mainwinAboutX"); |
2313 | 1000 |
1001 if (tmp != NULL) | |
1002 { | |
1003 skin->properties.mainwin_about_x = atoi(tmp); | |
1004 g_free(tmp); | |
1005 } | |
1006 | |
2529 | 1007 tmp = read_ini_string(inifile, "skin", "mainwinAboutY"); |
2313 | 1008 |
1009 if (tmp != NULL) | |
1010 { | |
1011 skin->properties.mainwin_about_y = atoi(tmp); | |
1012 g_free(tmp); | |
1013 } | |
1014 | |
2529 | 1015 tmp = read_ini_string(inifile, "skin", "mainwinShuffleX"); |
2313 | 1016 |
1017 if (tmp != NULL) | |
1018 { | |
1019 skin->properties.mainwin_shuffle_x = atoi(tmp); | |
1020 g_free(tmp); | |
1021 } | |
1022 | |
2529 | 1023 tmp = read_ini_string(inifile, "skin", "mainwinShuffleY"); |
2313 | 1024 |
1025 if (tmp != NULL) | |
1026 { | |
1027 skin->properties.mainwin_shuffle_y = atoi(tmp); | |
1028 g_free(tmp); | |
1029 } | |
1030 | |
2529 | 1031 tmp = read_ini_string(inifile, "skin", "mainwinRepeatX"); |
2313 | 1032 |
1033 if (tmp != NULL) | |
1034 { | |
1035 skin->properties.mainwin_repeat_x = atoi(tmp); | |
1036 g_free(tmp); | |
1037 } | |
1038 | |
2529 | 1039 tmp = read_ini_string(inifile, "skin", "mainwinRepeatY"); |
2313 | 1040 |
1041 if (tmp != NULL) | |
1042 { | |
1043 skin->properties.mainwin_repeat_y = atoi(tmp); | |
1044 g_free(tmp); | |
1045 } | |
1046 | |
2529 | 1047 tmp = read_ini_string(inifile, "skin", "mainwinEQButtonX"); |
2313 | 1048 |
1049 if (tmp != NULL) | |
1050 { | |
1051 skin->properties.mainwin_eqbutton_x = atoi(tmp); | |
1052 g_free(tmp); | |
1053 } | |
1054 | |
2529 | 1055 tmp = read_ini_string(inifile, "skin", "mainwinEQButtonY"); |
2313 | 1056 |
1057 if (tmp != NULL) | |
1058 { | |
1059 skin->properties.mainwin_eqbutton_y = atoi(tmp); | |
1060 g_free(tmp); | |
1061 } | |
1062 | |
2529 | 1063 tmp = read_ini_string(inifile, "skin", "mainwinPLButtonX"); |
2313 | 1064 |
1065 if (tmp != NULL) | |
1066 { | |
1067 skin->properties.mainwin_plbutton_x = atoi(tmp); | |
1068 g_free(tmp); | |
1069 } | |
1070 | |
2529 | 1071 tmp = read_ini_string(inifile, "skin", "mainwinPLButtonY"); |
2313 | 1072 |
1073 if (tmp != NULL) | |
1074 { | |
1075 skin->properties.mainwin_plbutton_y = atoi(tmp); | |
1076 g_free(tmp); | |
1077 } | |
1078 | |
2529 | 1079 tmp = read_ini_string(inifile, "skin", "textboxBitmapFontWidth"); |
2313 | 1080 |
1081 if (tmp != NULL) | |
1082 { | |
1083 skin->properties.textbox_bitmap_font_width = atoi(tmp); | |
1084 g_free(tmp); | |
1085 } | |
1086 | |
2529 | 1087 tmp = read_ini_string(inifile, "skin", "textboxBitmapFontHeight"); |
2313 | 1088 |
1089 if (tmp != NULL) | |
1090 { | |
1091 skin->properties.textbox_bitmap_font_height = atoi(tmp); | |
1092 g_free(tmp); | |
1093 } | |
1094 | |
2529 | 1095 tmp = read_ini_string(inifile, "skin", "mainwinMinimizeX"); |
2313 | 1096 |
1097 if (tmp != NULL) | |
1098 { | |
1099 skin->properties.mainwin_minimize_x = atoi(tmp); | |
1100 g_free(tmp); | |
1101 } | |
1102 | |
2529 | 1103 tmp = read_ini_string(inifile, "skin", "mainwinMinimizeY"); |
2313 | 1104 |
1105 if (tmp != NULL) | |
1106 { | |
1107 skin->properties.mainwin_minimize_y = atoi(tmp); | |
1108 g_free(tmp); | |
1109 } | |
1110 | |
2529 | 1111 tmp = read_ini_string(inifile, "skin", "mainwinShadeX"); |
2313 | 1112 |
1113 if (tmp != NULL) | |
1114 { | |
1115 skin->properties.mainwin_shade_x = atoi(tmp); | |
1116 g_free(tmp); | |
1117 } | |
1118 | |
2529 | 1119 tmp = read_ini_string(inifile, "skin", "mainwinShadeY"); |
2313 | 1120 |
1121 if (tmp != NULL) | |
1122 { | |
1123 skin->properties.mainwin_shade_y = atoi(tmp); | |
1124 g_free(tmp); | |
1125 } | |
1126 | |
2529 | 1127 tmp = read_ini_string(inifile, "skin", "mainwinCloseX"); |
2313 | 1128 |
1129 if (tmp != NULL) | |
1130 { | |
1131 skin->properties.mainwin_close_x = atoi(tmp); | |
1132 g_free(tmp); | |
1133 } | |
1134 | |
2529 | 1135 tmp = read_ini_string(inifile, "skin", "mainwinCloseY"); |
2313 | 1136 |
1137 if (tmp != NULL) | |
1138 { | |
1139 skin->properties.mainwin_close_y = atoi(tmp); | |
1140 g_free(tmp); | |
1141 } | |
1142 | |
1143 if (filename != NULL) | |
1144 g_free(filename); | |
2529 | 1145 |
1146 close_ini_file(inifile); | |
2313 | 1147 } |
1148 | |
1149 static guint | |
1150 hex_chars_to_int(gchar hi, gchar lo) | |
1151 { | |
1152 /* | |
1153 * Converts a value in the range 0x00-0xFF | |
1154 * to a integer in the range 0-65535 | |
1155 */ | |
1156 gchar str[3]; | |
1157 | |
1158 str[0] = hi; | |
1159 str[1] = lo; | |
1160 str[2] = 0; | |
1161 | |
1162 return (CLAMP(strtol(str, NULL, 16), 0, 0xFF) << 8); | |
1163 } | |
1164 | |
2529 | 1165 static GdkColor * |
1166 skin_load_color(INIFile *inifile, | |
2313 | 1167 const gchar * section, const gchar * key, |
1168 gchar * default_hex) | |
1169 { | |
2529 | 1170 gchar *value; |
2313 | 1171 GdkColor *color = NULL; |
1172 | |
2529 | 1173 if (inifile || default_hex) { |
1174 if (inifile) { | |
2587
2ef492ad3904
[svn] - always make sure we are operating on a copy of the ini string
nenolod
parents:
2581
diff
changeset
|
1175 value = g_strdup(read_ini_string(inifile, section, key)); |
2313 | 1176 if (value == NULL) { |
1177 value = g_strdup(default_hex); | |
1178 } | |
1179 } else { | |
1180 value = g_strdup(default_hex); | |
1181 } | |
1182 if (value) { | |
1183 gchar *ptr = value; | |
1184 gint len; | |
1185 | |
1186 color = g_new0(GdkColor, 1); | |
1187 g_strstrip(value); | |
1188 | |
1189 if (value[0] == '#') | |
1190 ptr++; | |
1191 len = strlen(ptr); | |
1192 /* | |
1193 * The handling of incomplete values is done this way | |
1194 * to maximize winamp compatibility | |
1195 */ | |
1196 if (len >= 6) { | |
1197 color->red = hex_chars_to_int(*ptr, *(ptr + 1)); | |
1198 ptr += 2; | |
1199 } | |
1200 if (len >= 4) { | |
1201 color->green = hex_chars_to_int(*ptr, *(ptr + 1)); | |
1202 ptr += 2; | |
1203 } | |
1204 if (len >= 2) | |
1205 color->blue = hex_chars_to_int(*ptr, *(ptr + 1)); | |
1206 | |
1207 gdk_colormap_alloc_color(gdk_drawable_get_colormap(playlistwin->window), | |
1208 color, TRUE, TRUE); | |
1209 g_free(value); | |
1210 } | |
1211 } | |
1212 return color; | |
1213 } | |
1214 | |
1215 | |
1216 | |
1217 GdkBitmap * | |
1218 skin_create_transparent_mask(const gchar * path, | |
1219 const gchar * file, | |
1220 const gchar * section, | |
1221 GdkWindow * window, | |
1222 gint width, | |
1223 gint height, gboolean doublesize) | |
1224 { | |
1225 GdkBitmap *mask = NULL; | |
1226 GdkGC *gc = NULL; | |
1227 GdkColor pattern; | |
1228 GdkPoint *gpoints; | |
1229 | |
1230 gchar *filename = NULL; | |
2529 | 1231 INIFile *inifile = NULL; |
2313 | 1232 gboolean created_mask = FALSE; |
1233 GArray *num, *point; | |
1234 guint i, j; | |
1235 gint k; | |
1236 | |
1237 if (path) | |
1238 filename = find_file_recursively(path, file); | |
1239 | |
1240 /* filename will be null if path wasn't set */ | |
2529 | 1241 if (!filename) |
2313 | 1242 return create_default_mask(window, width, height); |
2529 | 1243 |
1244 inifile = open_ini_file(filename); | |
2313 | 1245 |
2529 | 1246 if ((num = read_ini_array(inifile, section, "NumPoints")) == NULL) { |
2313 | 1247 g_free(filename); |
2529 | 1248 close_ini_file(inifile); |
2313 | 1249 return NULL; |
1250 } | |
1251 | |
2529 | 1252 if ((point = read_ini_array(inifile, section, "PointList")) == NULL) { |
2313 | 1253 g_array_free(num, TRUE); |
1254 g_free(filename); | |
2529 | 1255 close_ini_file(inifile); |
2313 | 1256 return NULL; |
1257 } | |
1258 | |
2529 | 1259 close_ini_file(inifile); |
1260 | |
2313 | 1261 mask = gdk_pixmap_new(window, width, height, 1); |
1262 gc = gdk_gc_new(mask); | |
1263 | |
1264 pattern.pixel = 0; | |
1265 gdk_gc_set_foreground(gc, &pattern); | |
1266 gdk_draw_rectangle(mask, gc, TRUE, 0, 0, width, height); | |
1267 pattern.pixel = 1; | |
1268 gdk_gc_set_foreground(gc, &pattern); | |
1269 | |
1270 j = 0; | |
1271 for (i = 0; i < num->len; i++) { | |
1272 if ((int)(point->len - j) >= (g_array_index(num, gint, i) * 2)) { | |
1273 created_mask = TRUE; | |
1274 gpoints = g_new(GdkPoint, g_array_index(num, gint, i)); | |
1275 for (k = 0; k < g_array_index(num, gint, i); k++) { | |
1276 gpoints[k].x = | |
1277 g_array_index(point, gint, j + k * 2) * (1 + doublesize); | |
1278 gpoints[k].y = | |
1279 g_array_index(point, gint, | |
1280 j + k * 2 + 1) * (1 + doublesize); | |
1281 } | |
1282 j += k * 2; | |
1283 gdk_draw_polygon(mask, gc, TRUE, gpoints, | |
1284 g_array_index(num, gint, i)); | |
1285 g_free(gpoints); | |
1286 } | |
1287 } | |
1288 g_array_free(num, TRUE); | |
1289 g_array_free(point, TRUE); | |
1290 g_free(filename); | |
1291 | |
1292 if (!created_mask) | |
1293 gdk_draw_rectangle(mask, gc, TRUE, 0, 0, width, height); | |
1294 | |
1295 g_object_unref(gc); | |
1296 | |
1297 return mask; | |
1298 } | |
1299 | |
1300 void | |
1301 skin_load_viscolor(Skin * skin, const gchar * path, const gchar * basename) | |
1302 { | |
1303 VFSFile *file; | |
1304 gint i, c; | |
1305 gchar line[256], *filename; | |
1306 GArray *a; | |
1307 | |
1308 g_return_if_fail(skin != NULL); | |
1309 g_return_if_fail(path != NULL); | |
1310 g_return_if_fail(basename != NULL); | |
1311 | |
1312 skin_set_default_vis_color(skin); | |
1313 | |
1314 filename = find_file_recursively(path, basename); | |
1315 if (!filename) | |
1316 return; | |
1317 | |
1318 if (!(file = vfs_fopen(filename, "r"))) { | |
1319 g_free(filename); | |
1320 return; | |
1321 } | |
1322 | |
1323 g_free(filename); | |
1324 | |
1325 for (i = 0; i < 24; i++) { | |
1326 if (vfs_fgets(line, 255, file)) { | |
1327 a = string_to_garray(line); | |
1328 if (a->len > 2) { | |
1329 for (c = 0; c < 3; c++) | |
1330 skin->vis_color[i][c] = g_array_index(a, gint, c); | |
1331 } | |
1332 g_array_free(a, TRUE); | |
1333 } | |
1334 else | |
1335 break; | |
1336 } | |
1337 | |
1338 vfs_fclose(file); | |
1339 } | |
1340 | |
1341 #if 0 | |
1342 static void | |
1343 skin_numbers_generate_dash(Skin * skin) | |
1344 { | |
1345 GdkGC *gc; | |
1346 GdkPixmap *pixmap; | |
1347 SkinPixmap *numbers; | |
1348 | |
1349 g_return_if_fail(skin != NULL); | |
1350 | |
1351 numbers = &skin->pixmaps[SKIN_NUMBERS]; | |
1352 if (!numbers->pixmap || numbers->current_width < 99) | |
1353 return; | |
1354 | |
1355 gc = gdk_gc_new(numbers->pixmap); | |
1356 pixmap = gdk_pixmap_new(mainwin->window, 108, | |
1357 numbers->current_height, | |
1358 -1); | |
1359 | |
1360 skin_draw_pixmap(skin, pixmap, gc, SKIN_NUMBERS, 0, 0, 0, 0, 99, 13); | |
1361 skin_draw_pixmap(skin, pixmap, gc, SKIN_NUMBERS, 90, 0, 99, 0, 9, 13); | |
1362 skin_draw_pixmap(skin, pixmap, gc, SKIN_NUMBERS, 20, 6, 101, 6, 5, 1); | |
1363 | |
1364 g_object_unref(numbers->pixmap); | |
1365 g_object_unref(gc); | |
1366 | |
1367 numbers->pixmap = pixmap; | |
1368 numbers->current_width = 108; | |
1369 } | |
1370 #endif | |
1371 | |
1372 static void | |
1373 skin_load_cursor(Skin * skin, const gchar * dirname) | |
1374 { | |
1375 const gchar * basename = "normal.cur"; | |
1376 gchar * filename = NULL; | |
1377 GdkPixbuf * cursor_pixbuf = NULL; | |
1378 GdkPixbufAnimation * cursor_animated = NULL; | |
1379 GdkCursor * cursor_gdk = NULL; | |
1380 GError * error = NULL; | |
1381 | |
1382 filename = find_file_recursively(dirname, basename); | |
1383 | |
3186 | 1384 if (filename && cfg.custom_cursors) |
2529 | 1385 cursor_animated = gdk_pixbuf_animation_new_from_file(filename, &error); |
3186 | 1386 |
1387 if (cursor_animated) { | |
2313 | 1388 cursor_pixbuf = gdk_pixbuf_animation_get_static_image(cursor_animated); |
1389 cursor_gdk = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), | |
1390 cursor_pixbuf, 0, 0); | |
3186 | 1391 } |
1392 else | |
2313 | 1393 cursor_gdk = gdk_cursor_new(GDK_LEFT_PTR); |
1394 | |
1395 gdk_window_set_cursor(mainwin->window, cursor_gdk); | |
1396 gdk_window_set_cursor(playlistwin->window, cursor_gdk); | |
1397 gdk_window_set_cursor(equalizerwin->window, cursor_gdk); | |
1398 gdk_cursor_unref(cursor_gdk); | |
1399 } | |
1400 | |
1401 static void | |
1402 skin_load_pixmaps(Skin * skin, const gchar * path) | |
1403 { | |
1404 GdkPixmap *text_pm; | |
1405 guint i; | |
2654 | 1406 gchar *filename; |
1407 INIFile *inifile; | |
2313 | 1408 |
1409 for (i = 0; i < SKIN_PIXMAP_COUNT; i++) | |
1410 skin_load_pixmap_id(skin, i, path); | |
1411 | |
1412 text_pm = skin->pixmaps[SKIN_TEXT].pixmap; | |
1413 | |
1414 if (text_pm) | |
1415 skin_get_textcolors(text_pm, skin->textbg, skin->textfg); | |
1416 | |
1417 #if 0 | |
1418 if (skin->pixmaps[SKIN_NUMBERS].pixmap) | |
1419 skin_numbers_generate_dash(skin); | |
1420 #endif | |
1421 | |
2654 | 1422 filename = find_file_recursively(path, "pledit.txt"); |
1423 inifile = open_ini_file(filename); | |
2529 | 1424 |
2313 | 1425 skin->colors[SKIN_PLEDIT_NORMAL] = |
2529 | 1426 skin_load_color(inifile, "Text", "Normal", "#2499ff"); |
2313 | 1427 skin->colors[SKIN_PLEDIT_CURRENT] = |
2529 | 1428 skin_load_color(inifile, "Text", "Current", "#ffeeff"); |
2313 | 1429 skin->colors[SKIN_PLEDIT_NORMALBG] = |
2529 | 1430 skin_load_color(inifile, "Text", "NormalBG", "#0a120a"); |
2313 | 1431 skin->colors[SKIN_PLEDIT_SELECTEDBG] = |
2529 | 1432 skin_load_color(inifile, "Text", "SelectedBG", "#0a124a"); |
1433 | |
1434 if (filename) | |
1435 g_free(filename); | |
1436 close_ini_file(inifile); | |
2313 | 1437 |
1438 skin_mask_create(skin, path, SKIN_MASK_MAIN, mainwin->window); | |
1439 skin_mask_create(skin, path, SKIN_MASK_MAIN_SHADE, mainwin->window); | |
1440 | |
1441 skin_mask_create(skin, path, SKIN_MASK_EQ, equalizerwin->window); | |
1442 skin_mask_create(skin, path, SKIN_MASK_EQ_SHADE, equalizerwin->window); | |
1443 | |
1444 skin_load_viscolor(skin, path, "viscolor.txt"); | |
1445 } | |
1446 | |
1447 static gboolean | |
1448 skin_load_nolock(Skin * skin, const gchar * path, gboolean force) | |
1449 { | |
1450 gchar *cpath; | |
1451 | |
1452 g_return_val_if_fail(skin != NULL, FALSE); | |
1453 g_return_val_if_fail(path != NULL, FALSE); | |
1454 REQUIRE_LOCK(skin->lock); | |
1455 | |
1456 if (!g_file_test(path, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_DIR)) | |
2529 | 1457 return FALSE; |
2313 | 1458 |
1459 if (!force) { | |
1460 if (skin->path) | |
1461 if (!strcmp(skin->path, path)) | |
1462 return FALSE; | |
1463 } | |
1464 | |
1465 skin_current_num++; | |
1466 | |
1467 skin->path = g_strdup(path); | |
1468 | |
1469 if (!file_is_archive(path)) { | |
1470 /* Parse the hints for this skin. */ | |
1471 skin_parse_hints(skin, NULL); | |
1472 | |
1473 skin_load_pixmaps(skin, path); | |
1474 skin_load_cursor(skin, path); | |
1475 | |
1476 return TRUE; | |
1477 } | |
1478 | |
1479 if (!(cpath = archive_decompress(path))) { | |
1480 g_message("Unable to extract skin archive (%s)", path); | |
1481 return FALSE; | |
1482 } | |
1483 | |
1484 /* Parse the hints for this skin. */ | |
1485 skin_parse_hints(skin, cpath); | |
1486 | |
1487 skin_load_pixmaps(skin, cpath); | |
1488 skin_load_cursor(skin, cpath); | |
1489 | |
1490 del_directory(cpath); | |
1491 g_free(cpath); | |
1492 | |
1493 return TRUE; | |
1494 } | |
1495 | |
1496 void | |
1497 skin_install_skin(const gchar * path) | |
1498 { | |
1499 gchar *command; | |
1500 | |
1501 g_return_if_fail(path != NULL); | |
1502 | |
2529 | 1503 command = g_strdup_printf("cp %s %s", |
1504 path, bmp_paths[BMP_PATH_USER_SKIN_DIR]); | |
2313 | 1505 if (system(command)) { |
1506 g_message("Unable to install skin (%s) into user directory (%s)", | |
1507 path, bmp_paths[BMP_PATH_USER_SKIN_DIR]); | |
1508 } | |
1509 g_free(command); | |
1510 } | |
1511 | |
1512 | |
1513 gboolean | |
1514 skin_load(Skin * skin, const gchar * path) | |
1515 { | |
1516 gboolean error; | |
1517 | |
1518 g_return_val_if_fail(skin != NULL, FALSE); | |
1519 | |
1520 if (!path) | |
1521 return FALSE; | |
1522 | |
1523 skin_lock(skin); | |
1524 error = skin_load_nolock(skin, path, FALSE); | |
1525 skin_unlock(skin); | |
1526 | |
1527 return error; | |
1528 } | |
1529 | |
1530 gboolean | |
1531 skin_reload_forced(void) | |
1532 { | |
1533 gboolean error; | |
1534 | |
1535 skin_lock(bmp_active_skin); | |
1536 error = skin_load_nolock(bmp_active_skin, bmp_active_skin->path, TRUE); | |
1537 skin_unlock(bmp_active_skin); | |
1538 | |
1539 return error; | |
1540 } | |
1541 | |
1542 void | |
1543 skin_reload(Skin * skin) | |
1544 { | |
1545 g_return_if_fail(skin != NULL); | |
1546 skin_load_nolock(skin, skin->path, TRUE); | |
1547 } | |
1548 | |
1549 | |
1550 static SkinPixmap * | |
1551 skin_get_pixmap(Skin * skin, SkinPixmapId map_id) | |
1552 { | |
1553 g_return_val_if_fail(skin != NULL, NULL); | |
1554 g_return_val_if_fail(map_id < SKIN_PIXMAP_COUNT, NULL); | |
1555 | |
1556 return &skin->pixmaps[map_id]; | |
1557 } | |
1558 | |
1559 GdkBitmap * | |
1560 skin_get_mask(Skin * skin, SkinMaskId mi) | |
1561 { | |
1562 GdkBitmap **masks; | |
1563 | |
1564 g_return_val_if_fail(skin != NULL, NULL); | |
1565 g_return_val_if_fail(mi < SKIN_PIXMAP_COUNT, NULL); | |
1566 | |
1567 masks = cfg.doublesize ? skin->ds_masks : skin->masks; | |
1568 return masks[mi]; | |
1569 } | |
1570 | |
1571 GdkColor * | |
1572 skin_get_color(Skin * skin, SkinColorId color_id) | |
1573 { | |
1574 GdkColor *ret = NULL; | |
1575 | |
1576 g_return_val_if_fail(skin != NULL, NULL); | |
1577 | |
1578 switch (color_id) { | |
1579 case SKIN_TEXTBG: | |
1580 if (skin->pixmaps[SKIN_TEXT].pixmap) | |
1581 ret = skin->textbg; | |
1582 else | |
1583 ret = skin->def_textbg; | |
1584 break; | |
1585 case SKIN_TEXTFG: | |
1586 if (skin->pixmaps[SKIN_TEXT].pixmap) | |
1587 ret = skin->textfg; | |
1588 else | |
1589 ret = skin->def_textfg; | |
1590 break; | |
1591 default: | |
1592 if (color_id < SKIN_COLOR_COUNT) | |
1593 ret = skin->colors[color_id]; | |
1594 break; | |
1595 } | |
1596 return ret; | |
1597 } | |
1598 | |
1599 void | |
1600 skin_get_viscolor(Skin * skin, guchar vis_color[24][3]) | |
1601 { | |
1602 gint i; | |
1603 | |
1604 g_return_if_fail(skin != NULL); | |
1605 | |
1606 for (i = 0; i < 24; i++) { | |
1607 vis_color[i][0] = skin->vis_color[i][0]; | |
1608 vis_color[i][1] = skin->vis_color[i][1]; | |
1609 vis_color[i][2] = skin->vis_color[i][2]; | |
1610 } | |
1611 } | |
1612 | |
1613 gint | |
1614 skin_get_id(void) | |
1615 { | |
1616 return skin_current_num; | |
1617 } | |
1618 | |
1619 void | |
1620 skin_draw_pixmap(Skin * skin, GdkDrawable * drawable, GdkGC * gc, | |
1621 SkinPixmapId pixmap_id, | |
1622 gint xsrc, gint ysrc, gint xdest, gint ydest, | |
1623 gint width, gint height) | |
1624 { | |
1625 SkinPixmap *pixmap; | |
1626 | |
1627 g_return_if_fail(skin != NULL); | |
1628 | |
1629 pixmap = skin_get_pixmap(skin, pixmap_id); | |
1630 g_return_if_fail(pixmap != NULL); | |
1631 g_return_if_fail(pixmap->pixmap != NULL); | |
1632 | |
3001
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2989
diff
changeset
|
1633 if (xsrc+width > pixmap->width || ysrc+height > pixmap->height) { |
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2989
diff
changeset
|
1634 if (pixmap_id == SKIN_NUMBERS) |
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2989
diff
changeset
|
1635 xsrc = 90; |
3045
464ae313343c
mainwin_volume and mainwin_balance are UiSkinnedHorizontalSliders now; add workaround for skins with too strait SKIN_VOLUME
Tomasz Mon <desowin@gmail.com>
parents:
3020
diff
changeset
|
1636 else if (pixmap_id == SKIN_VOLUME) { |
464ae313343c
mainwin_volume and mainwin_balance are UiSkinnedHorizontalSliders now; add workaround for skins with too strait SKIN_VOLUME
Tomasz Mon <desowin@gmail.com>
parents:
3020
diff
changeset
|
1637 /* some winamp skins have too strait SKIN_VOLUME, so let's copy what's remain from SKIN_MAIN */ |
464ae313343c
mainwin_volume and mainwin_balance are UiSkinnedHorizontalSliders now; add workaround for skins with too strait SKIN_VOLUME
Tomasz Mon <desowin@gmail.com>
parents:
3020
diff
changeset
|
1638 gdk_draw_drawable(drawable, gc, skin_get_pixmap(bmp_active_skin, SKIN_MAIN)->pixmap, |
464ae313343c
mainwin_volume and mainwin_balance are UiSkinnedHorizontalSliders now; add workaround for skins with too strait SKIN_VOLUME
Tomasz Mon <desowin@gmail.com>
parents:
3020
diff
changeset
|
1639 skin->properties.mainwin_volume_x, skin->properties.mainwin_volume_y, |
464ae313343c
mainwin_volume and mainwin_balance are UiSkinnedHorizontalSliders now; add workaround for skins with too strait SKIN_VOLUME
Tomasz Mon <desowin@gmail.com>
parents:
3020
diff
changeset
|
1640 pixmap->width, ydest, width - pixmap->width, height); |
464ae313343c
mainwin_volume and mainwin_balance are UiSkinnedHorizontalSliders now; add workaround for skins with too strait SKIN_VOLUME
Tomasz Mon <desowin@gmail.com>
parents:
3020
diff
changeset
|
1641 width = pixmap->width; |
3075
5854741efa0d
some skins have SKIN_MONOSTEREO with size 58x20
Tomasz Mon <desowin@gmail.com>
parents:
3056
diff
changeset
|
1642 } else if (pixmap_id == SKIN_MONOSTEREO) { |
5854741efa0d
some skins have SKIN_MONOSTEREO with size 58x20
Tomasz Mon <desowin@gmail.com>
parents:
3056
diff
changeset
|
1643 /* XMMS skins seems to have SKIN_MONOSTEREO with size 58x20 instead of 58x24 */ |
5854741efa0d
some skins have SKIN_MONOSTEREO with size 58x20
Tomasz Mon <desowin@gmail.com>
parents:
3056
diff
changeset
|
1644 gdk_draw_drawable(drawable, gc, skin_get_pixmap(bmp_active_skin, SKIN_MAIN)->pixmap, |
5854741efa0d
some skins have SKIN_MONOSTEREO with size 58x20
Tomasz Mon <desowin@gmail.com>
parents:
3056
diff
changeset
|
1645 212 + xdest, 41, xdest, ydest, width, height); |
3076 | 1646 height = pixmap->height/2; |
3045
464ae313343c
mainwin_volume and mainwin_balance are UiSkinnedHorizontalSliders now; add workaround for skins with too strait SKIN_VOLUME
Tomasz Mon <desowin@gmail.com>
parents:
3020
diff
changeset
|
1647 } else |
3001
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2989
diff
changeset
|
1648 return; |
6d4b7b739232
fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2989
diff
changeset
|
1649 } |
2313 | 1650 |
1651 width = MIN(width, pixmap->width - xsrc); | |
1652 height = MIN(height, pixmap->height - ysrc); | |
1653 gdk_draw_drawable(drawable, gc, pixmap->pixmap, xsrc, ysrc, | |
1654 xdest, ydest, width, height); | |
1655 } | |
1656 | |
1657 void | |
1658 skin_get_eq_spline_colors(Skin * skin, guint32 colors[19]) | |
1659 { | |
1660 gint i; | |
1661 GdkPixmap *pixmap; | |
1662 GdkImage *img; | |
1663 SkinPixmap *eqmainpm; | |
1664 | |
1665 g_return_if_fail(skin != NULL); | |
1666 | |
1667 eqmainpm = &skin->pixmaps[SKIN_EQMAIN]; | |
1668 if (eqmainpm->pixmap && | |
1669 eqmainpm->current_width >= 116 && eqmainpm->current_height >= 313) | |
1670 pixmap = eqmainpm->pixmap; | |
1671 else | |
1672 return; | |
1673 | |
1674 if (!GDK_IS_DRAWABLE(pixmap)) | |
1675 return; | |
1676 | |
1677 if (!(img = gdk_drawable_get_image(pixmap, 115, 294, 1, 19))) | |
1678 return; | |
1679 | |
1680 for (i = 0; i < 19; i++) | |
1681 colors[i] = gdk_image_get_pixel(img, 0, i); | |
1682 | |
1683 g_object_unref(img); | |
1684 } | |
1685 | |
1686 | |
1687 static void | |
1688 skin_draw_playlistwin_frame_top(Skin * skin, | |
1689 GdkDrawable * drawable, | |
1690 GdkGC * gc, | |
1691 gint width, gint height, gboolean focus) | |
1692 { | |
1693 /* The title bar skin consists of 2 sets of 4 images, 1 set | |
1694 * for focused state and the other for unfocused. The 4 images | |
1695 * are: | |
1696 * | |
1697 * a. right corner (25,20) | |
1698 * b. left corner (25,20) | |
1699 * c. tiler (25,20) | |
1700 * d. title (100,20) | |
1701 * | |
1702 * min allowed width = 100+25+25 = 150 | |
1703 */ | |
1704 | |
1705 gint i, y, c; | |
1706 | |
1707 /* get y offset of the pixmap set to use */ | |
1708 if (focus) | |
1709 y = 0; | |
1710 else | |
1711 y = 21; | |
1712 | |
1713 /* left corner */ | |
1714 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 0, y, 0, 0, 25, 20); | |
1715 | |
1716 /* titlebar title */ | |
1717 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 26, y, | |
1718 (width - 100) / 2, 0, 100, 20); | |
1719 | |
1720 /* titlebar right corner */ | |
1721 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 153, y, | |
1722 width - 25, 0, 25, 20); | |
1723 | |
1724 /* tile draw the remaining frame */ | |
1725 | |
1726 /* compute tile count */ | |
1727 c = (width - (100 + 25 + 25)) / 25; | |
1728 | |
1729 for (i = 0; i < c / 2; i++) { | |
1730 /* left of title */ | |
1731 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y, | |
1732 25 + i * 25, 0, 25, 20); | |
1733 | |
1734 /* right of title */ | |
1735 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y, | |
1736 (width + 100) / 2 + i * 25, 0, 25, 20); | |
1737 } | |
1738 | |
1739 if (c & 1) { | |
1740 /* Odd tile count, so one remaining to draw. Here we split | |
1741 * it into two and draw half on either side of the title */ | |
1742 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y, | |
1743 ((c / 2) * 25) + 25, 0, 12, 20); | |
1744 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y, | |
1745 (width / 2) + ((c / 2) * 25) + 50, 0, 13, 20); | |
1746 } | |
1747 } | |
1748 | |
1749 static void | |
1750 skin_draw_playlistwin_frame_bottom(Skin * skin, | |
1751 GdkDrawable * drawable, | |
1752 GdkGC * gc, | |
1753 gint width, gint height, gboolean focus) | |
1754 { | |
1755 /* The bottom frame skin consists of 1 set of 4 images. The 4 | |
1756 * images are: | |
1757 * | |
1758 * a. left corner with menu buttons (125,38) | |
1759 * b. visualization window (75,38) | |
1760 * c. right corner with play buttons (150,38) | |
1761 * d. frame tile (25,38) | |
1762 * | |
1763 * (min allowed width = 125+150+25=300 | |
1764 */ | |
1765 | |
1766 gint i, c; | |
1767 | |
1768 /* bottom left corner (menu buttons) */ | |
1769 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 0, 72, | |
1770 0, height - 38, 125, 38); | |
1771 | |
1772 c = (width - 275) / 25; | |
1773 | |
1774 /* draw visualization window, if width allows */ | |
1775 if (c >= 3) { | |
1776 c -= 3; | |
1777 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 205, 0, | |
1778 width - (150 + 75), height - 38, 75, 38); | |
1779 } | |
1780 | |
1781 /* Bottom right corner (playbuttons etc) */ | |
1782 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, | |
1783 126, 72, width - 150, height - 38, 150, 38); | |
1784 | |
1785 /* Tile draw the remaining undrawn portions */ | |
1786 for (i = 0; i < c; i++) | |
1787 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 179, 0, | |
1788 125 + i * 25, height - 38, 25, 38); | |
1789 } | |
1790 | |
1791 static void | |
1792 skin_draw_playlistwin_frame_sides(Skin * skin, | |
1793 GdkDrawable * drawable, | |
1794 GdkGC * gc, | |
1795 gint width, gint height, gboolean focus) | |
1796 { | |
1797 /* The side frames consist of 2 tile images. 1 for the left, 1 for | |
1798 * the right. | |
1799 * a. left (12,29) | |
1800 * b. right (19,29) | |
1801 */ | |
1802 | |
1803 gint i; | |
1804 | |
1805 /* frame sides */ | |
1806 for (i = 0; i < (height - (20 + 38)) / 29; i++) { | |
1807 /* left */ | |
1808 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 0, 42, | |
1809 0, 20 + i * 29, 12, 29); | |
1810 | |
1811 /* right */ | |
1812 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 32, 42, | |
1813 width - 19, 20 + i * 29, 19, 29); | |
1814 } | |
1815 } | |
1816 | |
1817 | |
1818 void | |
1819 skin_draw_playlistwin_frame(Skin * skin, | |
1820 GdkDrawable * drawable, GdkGC * gc, | |
1821 gint width, gint height, gboolean focus) | |
1822 { | |
1823 skin_draw_playlistwin_frame_top(skin, drawable, gc, width, height, focus); | |
1824 skin_draw_playlistwin_frame_bottom(skin, drawable, gc, width, height, | |
1825 focus); | |
1826 skin_draw_playlistwin_frame_sides(skin, drawable, gc, width, height, | |
1827 focus); | |
1828 } | |
1829 | |
1830 | |
1831 void | |
1832 skin_draw_playlistwin_shaded(Skin * skin, | |
1833 GdkDrawable * drawable, GdkGC * gc, | |
1834 gint width, gboolean focus) | |
1835 { | |
1836 /* The shade mode titlebar skin consists of 4 images: | |
1837 * a) left corner offset (72,42) size (25,14) | |
1838 * b) right corner, focused offset (99,57) size (50,14) | |
1839 * c) right corner, unfocused offset (99,42) size (50,14) | |
1840 * d) bar tile offset (72,57) size (25,14) | |
1841 */ | |
1842 | |
1843 gint i; | |
1844 | |
1845 /* left corner */ | |
1846 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 72, 42, 0, 0, 25, 14); | |
1847 | |
1848 /* bar tile */ | |
1849 for (i = 0; i < (width - 75) / 25; i++) | |
1850 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 72, 57, | |
1851 (i * 25) + 25, 0, 25, 14); | |
1852 | |
1853 /* right corner */ | |
1854 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 99, focus ? 42 : 57, | |
1855 width - 50, 0, 50, 14); | |
1856 } | |
1857 | |
1858 | |
1859 void | |
1860 skin_draw_mainwin_titlebar(Skin * skin, | |
1861 GdkDrawable * drawable, GdkGC * gc, | |
1862 gboolean shaded, gboolean focus) | |
1863 { | |
1864 /* The titlebar skin consists of 2 sets of 2 images, one for for | |
1865 * shaded and the other for unshaded mode, giving a total of 4. | |
1866 * The images are exactly 275x14 pixels, aligned and arranged | |
1867 * vertically on each other in the pixmap in the following order: | |
1868 * | |
1869 * a) unshaded, focused offset (27, 0) | |
1870 * b) unshaded, unfocused offset (27, 15) | |
1871 * c) shaded, focused offset (27, 29) | |
1872 * d) shaded, unfocused offset (27, 42) | |
1873 */ | |
1874 | |
1875 gint y_offset; | |
1876 | |
1877 if (shaded) { | |
1878 if (focus) | |
1879 y_offset = 29; | |
1880 else | |
1881 y_offset = 42; | |
1882 } | |
1883 else { | |
1884 if (focus) | |
1885 y_offset = 0; | |
1886 else | |
1887 y_offset = 15; | |
1888 } | |
1889 | |
1890 skin_draw_pixmap(skin, drawable, gc, SKIN_TITLEBAR, 27, y_offset, | |
1891 0, 0, bmp_active_skin->properties.mainwin_width, MAINWIN_TITLEBAR_HEIGHT); | |
1892 } | |
2443
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2313
diff
changeset
|
1893 |
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2313
diff
changeset
|
1894 |
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2313
diff
changeset
|
1895 void |
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2313
diff
changeset
|
1896 skin_set_random_skin(void) |
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2313
diff
changeset
|
1897 { |
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2313
diff
changeset
|
1898 SkinNode *node; |
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2313
diff
changeset
|
1899 guint32 randval; |
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2313
diff
changeset
|
1900 |
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2313
diff
changeset
|
1901 /* Get a random value to select the skin to use */ |
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2313
diff
changeset
|
1902 randval = g_random_int_range(0, g_list_length(skinlist)); |
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2313
diff
changeset
|
1903 node = g_list_nth(skinlist, randval)->data; |
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2313
diff
changeset
|
1904 bmp_active_skin_load(node->path); |
93686e8815a4
[svn] - Changed playback_set_random_skin() to skin_set_random_skin()
mf0102
parents:
2313
diff
changeset
|
1905 } |