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