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