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