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