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