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