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