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