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