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