Mercurial > audlegacy
annotate audacious/skin.c @ 566:ab7027a06ca9 trunk
[svn] convert mpg123 over... right now we don't use the "x86-optimized code", although I doubt it makes a lick of
difference anyway...
author | nenolod |
---|---|
date | Thu, 02 Feb 2006 14:42:17 -0800 |
parents | aedd5dbc1a1c |
children | 0a73d1faeb4e |
rev | line source |
---|---|
0 | 1 /* BMP - Cross-platform multimedia player |
2 * Copyright (C) 2003-2004 BMP development team. | |
3 * | |
4 * Based on XMMS: | |
5 * Copyright (C) 1998-2003 XMMS development team. | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
20 */ | |
21 | |
22 #ifdef HAVE_CONFIG_H | |
23 # include "config.h" | |
24 #endif | |
25 | |
26 /* TODO: enforce default sizes! */ | |
27 | |
28 #include <glib.h> | |
29 #include <stdio.h> | |
30 #include <stdlib.h> | |
31 #include <string.h> | |
32 #include <ctype.h> | |
33 | |
34 #include "equalizer.h" | |
35 #include "main.h" | |
383 | 36 #include "ui_playlist.h" |
0 | 37 #include "skin.h" |
38 #include "skinwin.h" | |
39 #include "util.h" | |
40 | |
41 #include "debug.h" | |
42 | |
43 #include <gdk/gdkx.h> | |
44 #include <X11/Xlib.h> | |
45 | |
442
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
46 #define EXTENSION_TARGETS 7 |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
47 |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
48 gchar *ext_targets[EXTENSION_TARGETS] = { "bmp", "xpm", "png", "svg", |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
49 "gif", "jpg", "jpeg" }; |
0 | 50 |
51 struct _SkinPixmapIdMapping { | |
52 SkinPixmapId id; | |
53 const gchar *name; | |
54 const gchar *alt_name; | |
55 gint width, height; | |
56 }; | |
57 | |
58 struct _SkinMaskInfo { | |
59 gint width, height; | |
60 gchar *inistr; | |
61 }; | |
62 | |
63 typedef struct _SkinPixmapIdMapping SkinPixmapIdMapping; | |
64 typedef struct _SkinMaskInfo SkinMaskInfo; | |
65 | |
66 | |
67 Skin *bmp_active_skin = NULL; | |
68 | |
69 static gint skin_current_num; | |
70 | |
71 static SkinMaskInfo skin_mask_info[] = { | |
72 {275, 116, "Normal"}, | |
73 {275, 16, "WindowShade"}, | |
74 {275, 116, "Equalizer"}, | |
75 {275, 16, "EqualizerWS"} | |
76 }; | |
77 | |
78 static SkinPixmapIdMapping skin_pixmap_id_map[] = { | |
79 {SKIN_MAIN, "main", NULL}, | |
80 {SKIN_CBUTTONS, "cbuttons", NULL}, | |
81 {SKIN_SHUFREP, "shufrep", NULL}, | |
82 {SKIN_TEXT, "text", NULL}, | |
83 {SKIN_TITLEBAR, "titlebar", NULL}, | |
84 {SKIN_VOLUME, "volume", NULL}, | |
85 {SKIN_BALANCE, "balance", "volume"}, | |
86 {SKIN_MONOSTEREO, "monoster", NULL}, | |
87 {SKIN_PLAYPAUSE, "playpaus", NULL}, | |
88 {SKIN_NUMBERS, "nums_ex", "numbers"}, | |
89 {SKIN_POSBAR, "posbar", NULL}, | |
90 {SKIN_EQMAIN, "eqmain", NULL}, | |
91 {SKIN_PLEDIT, "pledit", NULL}, | |
92 {SKIN_EQ_EX, "eq_ex", NULL} | |
93 }; | |
94 | |
95 static guint skin_pixmap_id_map_size = G_N_ELEMENTS(skin_pixmap_id_map); | |
96 | |
97 static const guchar skin_default_viscolor[24][3] = { | |
98 {9, 34, 53}, | |
99 {10, 18, 26}, | |
100 {0, 54, 108}, | |
101 {0, 58, 116}, | |
102 {0, 62, 124}, | |
103 {0, 66, 132}, | |
104 {0, 70, 140}, | |
105 {0, 74, 148}, | |
106 {0, 78, 156}, | |
107 {0, 82, 164}, | |
108 {0, 86, 172}, | |
109 {0, 92, 184}, | |
110 {0, 98, 196}, | |
111 {0, 104, 208}, | |
112 {0, 110, 220}, | |
113 {0, 116, 232}, | |
114 {0, 122, 244}, | |
115 {0, 128, 255}, | |
116 {0, 128, 255}, | |
117 {0, 104, 208}, | |
118 {0, 80, 160}, | |
119 {0, 56, 112}, | |
120 {0, 32, 64}, | |
121 {200, 200, 200} | |
122 }; | |
123 | |
124 static GdkBitmap * | |
125 skin_create_transparent_mask(const gchar *, | |
126 const gchar *, | |
127 const gchar *, | |
128 GdkWindow *, | |
129 gint, gint); | |
130 | |
131 static void | |
132 skin_setup_masks(Skin * skin); | |
133 | |
134 static void | |
135 skin_set_default_vis_color(Skin * skin); | |
136 | |
137 | |
138 void | |
139 skin_lock(Skin * skin) | |
140 { | |
141 g_mutex_lock(skin->lock); | |
142 } | |
143 | |
144 void | |
145 skin_unlock(Skin * skin) | |
146 { | |
147 g_mutex_unlock(skin->lock); | |
148 } | |
149 | |
150 gboolean | |
151 bmp_active_skin_reload(void) | |
152 { | |
153 return bmp_active_skin_load(bmp_active_skin->path); | |
154 } | |
155 | |
156 gboolean | |
157 bmp_active_skin_load(const gchar * path) | |
158 { | |
159 g_return_val_if_fail(bmp_active_skin != NULL, FALSE); | |
160 | |
161 if (!skin_load(bmp_active_skin, path)) | |
162 return FALSE; | |
163 | |
164 skin_setup_masks(bmp_active_skin); | |
165 draw_main_window(TRUE); | |
166 draw_playlist_window(TRUE); | |
167 draw_equalizer_window(TRUE); | |
168 | |
169 vis_set_window(mainwin_vis, mainwin->window); | |
170 playlistwin_update_list(); | |
171 | |
172 return TRUE; | |
173 } | |
174 | |
175 void | |
176 skin_pixmap_free(SkinPixmap * p) | |
177 { | |
178 g_return_if_fail(p != NULL); | |
179 g_return_if_fail(p->pixmap != NULL); | |
180 | |
181 g_object_unref(p->pixmap); | |
182 p->pixmap = NULL; | |
183 } | |
184 | |
185 Skin * | |
186 skin_new(void) | |
187 { | |
188 Skin *skin; | |
189 skin = g_new0(Skin, 1); | |
190 skin->lock = g_mutex_new(); | |
191 return skin; | |
192 } | |
193 | |
194 void | |
195 skin_free(Skin * skin) | |
196 { | |
197 gint i; | |
198 | |
199 g_return_if_fail(skin != NULL); | |
200 | |
201 skin_lock(skin); | |
202 | |
203 for (i = 0; i < SKIN_PIXMAP_COUNT; i++) | |
204 skin_pixmap_free(&skin->pixmaps[i]); | |
205 | |
206 for (i = 0; i < SKIN_PIXMAP_COUNT; i++) { | |
207 if (skin->masks[i]) | |
208 g_object_unref(skin->masks[i]); | |
209 | |
210 skin->masks[i] = NULL; | |
211 } | |
212 | |
213 skin_set_default_vis_color(skin); | |
214 skin_unlock(skin); | |
215 } | |
216 | |
217 void | |
218 skin_destroy(Skin * skin) | |
219 { | |
220 g_return_if_fail(skin != NULL); | |
221 skin_free(skin); | |
222 g_mutex_free(skin->lock); | |
223 g_free(skin); | |
224 } | |
225 | |
226 const SkinPixmapIdMapping * | |
227 skin_pixmap_id_lookup(gint id) | |
228 { | |
229 gint i; | |
230 | |
231 for (i = 0; i < skin_pixmap_id_map_size; i++) { | |
232 if (id == skin_pixmap_id_map[i].id) { | |
233 return &skin_pixmap_id_map[i]; | |
234 } | |
235 } | |
236 | |
237 return NULL; | |
238 } | |
239 | |
240 const gchar * | |
241 skin_pixmap_id_to_name(SkinPixmapId id) | |
242 { | |
243 gint i; | |
244 | |
245 for (i = 0; i < skin_pixmap_id_map_size; i++) { | |
246 if (id == skin_pixmap_id_map[i].id) | |
247 return skin_pixmap_id_map[i].name; | |
248 } | |
249 return NULL; | |
250 } | |
251 | |
252 static void | |
253 skin_set_default_vis_color(Skin * skin) | |
254 { | |
255 memcpy(skin->vis_color, skin_default_viscolor, | |
256 sizeof(skin_default_viscolor)); | |
257 } | |
258 | |
442
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
259 /* |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
260 * I have rewritten this to take an array of possible targets, |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
261 * once we find a matching target we now return, instead of loop |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
262 * recursively. This allows for us to support many possible format |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
263 * targets for our skinning engine than just the original winamp |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
264 * formats. |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
265 * |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
266 * -- nenolod, 16 January 2006 |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
267 */ |
0 | 268 gchar * |
442
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
269 skin_pixmap_locate(const gchar * dirname, gchar ** basenames) |
0 | 270 { |
271 gchar *filename; | |
442
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
272 gint i; |
0 | 273 |
442
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
274 for (i = 0; basenames[i]; i++) |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
275 if (!(filename = find_file_recursively(dirname, basenames[i]))) |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
276 g_free(filename); |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
277 else |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
278 return filename; |
0 | 279 |
442
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
280 /* can't find any targets -- sorry */ |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
281 return NULL; |
0 | 282 } |
283 | |
284 /* FIXME: this function is temporary. It will be removed when the skinning system | |
285 uses GdkPixbuf in place of GdkPixmap */ | |
286 | |
287 static GdkPixmap * | |
288 pixmap_new_from_file(const gchar * filename) | |
289 { | |
290 GdkPixbuf *pixbuf; | |
291 GdkPixmap *pixmap; | |
292 gint width, height; | |
293 | |
294 if (!(pixbuf = gdk_pixbuf_new_from_file(filename, NULL))) | |
295 return NULL; | |
296 | |
297 width = gdk_pixbuf_get_width(pixbuf); | |
298 height = gdk_pixbuf_get_height(pixbuf); | |
299 | |
300 if (!(pixmap = gdk_pixmap_new(mainwin->window, width, height, | |
301 gdk_rgb_get_visual()->depth))) { | |
302 g_object_unref(pixbuf); | |
303 return NULL; | |
304 } | |
305 | |
306 gdk_pixbuf_render_to_drawable(pixbuf, pixmap, mainwin_gc, 0, 0, 0, 0, | |
307 width, height, GDK_RGB_DITHER_MAX, 0, 0); | |
308 g_object_unref(pixbuf); | |
309 | |
310 return pixmap; | |
311 } | |
312 | |
313 static gboolean | |
314 skin_load_pixmap_id(Skin * skin, SkinPixmapId id, const gchar * path_p) | |
315 { | |
316 const gchar *path; | |
317 gchar *filename; | |
318 gint width, height; | |
319 const SkinPixmapIdMapping *pixmap_id_mapping; | |
320 GdkPixmap *gpm; | |
321 SkinPixmap *pm = NULL; | |
442
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
322 gchar *basenames[EXTENSION_TARGETS * 2 + 1]; /* alternate basenames */ |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
323 gint i, y; |
0 | 324 |
325 g_return_val_if_fail(skin != NULL, FALSE); | |
326 g_return_val_if_fail(id < SKIN_PIXMAP_COUNT, FALSE); | |
327 | |
328 pixmap_id_mapping = skin_pixmap_id_lookup(id); | |
329 g_return_val_if_fail(pixmap_id_mapping != NULL, FALSE); | |
330 | |
442
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
331 memset(&basenames, 0, sizeof(basenames)); |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
332 |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
333 for (i = 0, y = 0; ext_targets[i]; i++, y++) |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
334 { |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
335 basenames[y] = g_strdup_printf("%s.%s", pixmap_id_mapping->name, |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
336 ext_targets[i]); |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
337 |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
338 if (pixmap_id_mapping->alt_name) |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
339 basenames[++y] = g_strdup_printf("%s.%s", |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
340 pixmap_id_mapping->alt_name, ext_targets[i]); |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
341 } |
0 | 342 |
343 path = path_p ? path_p : skin->path; | |
442
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
344 filename = skin_pixmap_locate(path, basenames); |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
345 |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
346 for (i = 0; basenames[i] != NULL; i++) |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
347 { |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
348 g_free(basenames[i]); |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
349 basenames[i] = NULL; |
10535124cc8a
[svn] This commit allows for the use of alternate formats to bmp in skin
nenolod
parents:
383
diff
changeset
|
350 } |
0 | 351 |
352 if (!(gpm = pixmap_new_from_file(filename))) { | |
353 g_warning("loading of %s failed", filename); | |
354 g_free(filename); | |
355 return FALSE; | |
356 } | |
357 | |
358 g_free(filename); | |
359 | |
360 gdk_window_get_size(gpm, &width, &height); | |
361 pm = &skin->pixmaps[id]; | |
362 pm->pixmap = gpm; | |
363 pm->width = width; | |
364 pm->height = height; | |
365 pm->current_width = width; | |
366 pm->current_height = height; | |
367 | |
368 return TRUE; | |
369 } | |
370 | |
371 void | |
372 skin_mask_create(Skin * skin, | |
373 const gchar * path, | |
374 gint id, | |
375 GdkWindow * window) | |
376 { | |
377 skin->masks[id] = | |
378 skin_create_transparent_mask(path, "region.txt", | |
379 skin_mask_info[id].inistr, window, | |
380 skin_mask_info[id].width, | |
381 skin_mask_info[id].height); | |
382 } | |
383 | |
384 static void | |
385 skin_setup_masks(Skin * skin) | |
386 { | |
387 GdkBitmap *mask; | |
388 | |
389 if (cfg.show_wm_decorations) | |
390 return; | |
391 | |
392 if (cfg.player_visible) { | |
393 mask = skin_get_mask(skin, SKIN_MASK_MAIN + cfg.player_shaded); | |
394 gtk_widget_shape_combine_mask(mainwin, mask, 0, 0); | |
395 } | |
396 | |
397 mask = skin_get_mask(skin, SKIN_MASK_EQ + cfg.equalizer_shaded); | |
398 gtk_widget_shape_combine_mask(equalizerwin, mask, 0, 0); | |
399 } | |
400 | |
401 static GdkBitmap * | |
402 create_default_mask(GdkWindow * parent, gint w, gint h) | |
403 { | |
404 GdkBitmap *ret; | |
405 GdkGC *gc; | |
406 GdkColor pattern; | |
407 | |
408 ret = gdk_pixmap_new(parent, w, h, 1); | |
409 gc = gdk_gc_new(ret); | |
410 pattern.pixel = 1; | |
411 gdk_gc_set_foreground(gc, &pattern); | |
412 gdk_draw_rectangle(ret, gc, TRUE, 0, 0, w, h); | |
413 gdk_gc_destroy(gc); | |
414 | |
415 return ret; | |
416 } | |
417 | |
418 static void | |
419 skin_query_color(GdkColormap * cm, GdkColor * c) | |
420 { | |
421 XColor xc = { 0 }; | |
422 | |
423 xc.pixel = c->pixel; | |
424 XQueryColor(GDK_COLORMAP_XDISPLAY(cm), GDK_COLORMAP_XCOLORMAP(cm), &xc); | |
425 c->red = xc.red; | |
426 c->green = xc.green; | |
427 c->blue = xc.blue; | |
428 } | |
429 | |
430 static glong | |
431 skin_calc_luminance(GdkColor * c) | |
432 { | |
433 return (0.212671 * c->red + 0.715160 * c->green + 0.072169 * c->blue); | |
434 } | |
435 | |
436 static void | |
437 skin_get_textcolors(GdkPixmap * text, GdkColor * bgc, GdkColor * fgc) | |
438 { | |
439 /* | |
440 * Try to extract reasonable background and foreground colors | |
441 * from the font pixmap | |
442 */ | |
443 | |
444 GdkImage *gi; | |
445 GdkColormap *cm; | |
446 gint i; | |
447 | |
448 g_return_if_fail(text != NULL); | |
449 | |
450 /* Get the first line of text */ | |
451 gi = gdk_drawable_get_image(text, 0, 0, 152, 6); | |
452 cm = gdk_window_get_colormap(playlistwin->window); | |
453 g_return_if_fail(GDK_IS_WINDOW(playlistwin->window)); | |
454 | |
455 for (i = 0; i < 6; i++) { | |
456 GdkColor c; | |
457 gint x; | |
458 glong d, max_d; | |
459 | |
460 /* Get a pixel from the middle of the space character */ | |
461 bgc[i].pixel = gdk_image_get_pixel(gi, 151, i); | |
462 skin_query_color(cm, &bgc[i]); | |
463 | |
464 max_d = 0; | |
465 for (x = 1; x < 150; x++) { | |
466 c.pixel = gdk_image_get_pixel(gi, x, i); | |
467 skin_query_color(cm, &c); | |
468 | |
469 d = labs(skin_calc_luminance(&c) - skin_calc_luminance(&bgc[i])); | |
470 if (d > max_d) { | |
471 memcpy(&fgc[i], &c, sizeof(GdkColor)); | |
472 max_d = d; | |
473 } | |
474 } | |
475 } | |
476 gdk_image_destroy(gi); | |
477 } | |
478 | |
479 gboolean | |
480 init_skins(const gchar * path) | |
481 { | |
482 bmp_active_skin = skin_new(); | |
483 | |
484 if (!bmp_active_skin_load(path)) { | |
485 /* FIXME: Oddly, g_message() causes a crash if path is NULL on | |
486 * Solaris (see bug #165) */ | |
487 if (path) | |
488 g_message("Unable to load skin (%s), trying default...", path); | |
489 | |
490 /* can't load configured skin, retry with default */ | |
491 if (!bmp_active_skin_load(BMP_DEFAULT_SKIN_PATH)) { | |
492 g_message("Unable to load default skin (%s)! Giving up.", | |
493 BMP_DEFAULT_SKIN_PATH); | |
494 return FALSE; | |
495 } | |
496 } | |
497 | |
498 if (cfg.random_skin_on_play) | |
499 skinlist_update(); | |
500 | |
501 return TRUE; | |
502 } | |
503 | |
504 static guint | |
505 hex_chars_to_int(gchar hi, gchar lo) | |
506 { | |
507 /* | |
508 * Converts a value in the range 0x00-0xFF | |
509 * to a integer in the range 0-65535 | |
510 */ | |
511 gchar str[3]; | |
512 | |
513 str[0] = hi; | |
514 str[1] = lo; | |
515 str[2] = 0; | |
516 | |
517 return (CLAMP(strtol(str, NULL, 16), 0, 0xFF) << 8); | |
518 } | |
519 | |
520 GdkColor * | |
521 skin_load_color(const gchar * path, const gchar * file, | |
522 const gchar * section, const gchar * key) | |
523 { | |
524 gchar *filename, *value; | |
525 GdkColor *color = NULL; | |
526 | |
527 filename = find_file_recursively(path, file); | |
528 if (filename) { | |
529 value = read_ini_string(filename, section, key); | |
530 if (value) { | |
531 gchar *ptr = value; | |
532 gint len; | |
533 | |
534 color = g_new0(GdkColor, 1); | |
535 g_strstrip(value); | |
536 | |
537 if (value[0] == '#') | |
538 ptr++; | |
539 len = strlen(ptr); | |
540 | |
541 /* | |
542 * The handling of incomplete values is done this way | |
543 * to maximize winamp compatibility | |
544 */ | |
545 if (len >= 6) { | |
546 color->red = hex_chars_to_int(*ptr, *(ptr + 1)); | |
547 ptr += 2; | |
548 } | |
549 if (len >= 4) { | |
550 color->green = hex_chars_to_int(*ptr, *(ptr + 1)); | |
551 ptr += 2; | |
552 } | |
553 if (len >= 2) | |
554 color->blue = hex_chars_to_int(*ptr, *(ptr + 1)); | |
555 | |
556 | |
557 gdk_color_alloc(gdk_window_get_colormap(playlistwin->window), | |
558 color); | |
559 g_free(value); | |
560 } | |
561 g_free(filename); | |
562 } | |
563 return color; | |
564 } | |
565 | |
566 | |
567 | |
568 GdkBitmap * | |
569 skin_create_transparent_mask(const gchar * path, | |
570 const gchar * file, | |
571 const gchar * section, | |
572 GdkWindow * window, | |
573 gint width, | |
574 gint height) | |
575 { | |
576 GdkBitmap *mask = NULL; | |
577 GdkGC *gc = NULL; | |
578 GdkColor pattern; | |
579 GdkPoint *gpoints; | |
580 | |
581 gchar *filename = NULL; | |
582 gboolean created_mask = FALSE; | |
583 GArray *num, *point; | |
584 gint i, j, k; | |
585 | |
586 if (path) | |
587 filename = find_file_recursively(path, file); | |
588 | |
589 /* filename will be null if path wasn't set */ | |
590 if (!filename) { | |
591 return create_default_mask(window, width, height); | |
592 } | |
593 | |
594 if ((num = read_ini_array(filename, section, "NumPoints")) == NULL) { | |
595 g_free(filename); | |
596 return NULL; | |
597 } | |
598 | |
599 if ((point = read_ini_array(filename, section, "PointList")) == NULL) { | |
600 g_array_free(num, TRUE); | |
601 g_free(filename); | |
602 return NULL; | |
603 } | |
604 | |
605 mask = gdk_pixmap_new(window, width, height, 1); | |
606 gc = gdk_gc_new(mask); | |
607 | |
608 pattern.pixel = 0; | |
609 gdk_gc_set_foreground(gc, &pattern); | |
610 gdk_draw_rectangle(mask, gc, TRUE, 0, 0, width, height); | |
611 pattern.pixel = 1; | |
612 gdk_gc_set_foreground(gc, &pattern); | |
613 | |
614 j = 0; | |
615 for (i = 0; i < num->len; i++) { | |
616 if ((point->len - j) >= (g_array_index(num, gint, i) * 2)) { | |
617 created_mask = TRUE; | |
618 gpoints = g_new(GdkPoint, g_array_index(num, gint, i)); | |
619 for (k = 0; k < g_array_index(num, gint, i); k++) { | |
620 gpoints[k].x = g_array_index(point, gint, j + k * 2); | |
621 gpoints[k].y = g_array_index(point, gint, j + k * 2 + 1); | |
622 } | |
623 j += k * 2; | |
624 gdk_draw_polygon(mask, gc, TRUE, gpoints, | |
625 g_array_index(num, gint, i)); | |
626 g_free(gpoints); | |
627 } | |
628 } | |
629 g_array_free(num, TRUE); | |
630 g_array_free(point, TRUE); | |
631 g_free(filename); | |
632 | |
633 if (!created_mask) | |
634 gdk_draw_rectangle(mask, gc, TRUE, 0, 0, width, height); | |
635 | |
636 gdk_gc_destroy(gc); | |
637 | |
638 return mask; | |
639 } | |
640 | |
641 void | |
642 skin_load_viscolor(Skin * skin, const gchar * path, const gchar * basename) | |
643 { | |
644 FILE *file; | |
645 gint i, c; | |
646 gchar line[256], *filename; | |
647 GArray *a; | |
648 | |
649 g_return_if_fail(skin != NULL); | |
650 g_return_if_fail(path != NULL); | |
651 g_return_if_fail(basename != NULL); | |
652 | |
653 skin_set_default_vis_color(skin); | |
654 | |
655 filename = find_file_recursively(path, basename); | |
656 if (!filename) | |
657 return; | |
658 | |
659 if (!(file = fopen(filename, "r"))) { | |
660 g_free(filename); | |
661 return; | |
662 } | |
663 | |
664 g_free(filename); | |
665 | |
666 for (i = 0; i < 24; i++) { | |
667 if (fgets(line, 255, file)) { | |
668 a = string_to_garray(line); | |
669 if (a->len > 2) { | |
670 for (c = 0; c < 3; c++) | |
671 skin->vis_color[i][c] = g_array_index(a, gint, c); | |
672 } | |
673 g_array_free(a, TRUE); | |
674 } | |
675 else | |
676 break; | |
677 } | |
678 | |
679 fclose(file); | |
680 } | |
681 | |
682 #if 0 | |
683 static void | |
684 skin_numbers_generate_dash(Skin * skin) | |
685 { | |
686 GdkGC *gc; | |
687 GdkPixmap *pixmap; | |
688 SkinPixmap *numbers; | |
689 | |
690 g_return_if_fail(skin != NULL); | |
691 | |
692 numbers = &skin->pixmaps[SKIN_NUMBERS]; | |
693 if (!numbers->pixmap || numbers->current_width < 99) | |
694 return; | |
695 | |
696 gc = gdk_gc_new(numbers->pixmap); | |
697 pixmap = gdk_pixmap_new(mainwin->window, 108, | |
698 numbers->current_height, | |
699 -1); | |
700 | |
701 skin_draw_pixmap(skin, pixmap, gc, SKIN_NUMBERS, 0, 0, 0, 0, 99, 13); | |
702 skin_draw_pixmap(skin, pixmap, gc, SKIN_NUMBERS, 90, 0, 99, 0, 9, 13); | |
703 skin_draw_pixmap(skin, pixmap, gc, SKIN_NUMBERS, 20, 6, 101, 6, 5, 1); | |
704 | |
705 g_object_unref(numbers->pixmap); | |
706 g_object_unref(gc); | |
707 | |
708 numbers->pixmap = pixmap; | |
709 numbers->current_width = 108; | |
710 } | |
711 #endif | |
712 | |
713 static void | |
714 skin_load_cursor(Skin * skin, const gchar * dirname) | |
715 { | |
716 const gchar * basename = "normal.cur"; | |
717 gchar * filename = NULL; | |
718 GdkPixbuf * cursor_pixbuf = NULL; | |
719 GdkPixbufAnimation * cursor_animated = NULL; | |
720 GdkCursor * cursor_gdk = NULL; | |
721 GError * error = NULL; | |
722 | |
723 filename = find_file_recursively(dirname, basename); | |
724 | |
725 if (filename && cfg.custom_cursors) { | |
726 cursor_animated = gdk_pixbuf_animation_new_from_file(filename, &error); | |
727 cursor_pixbuf = gdk_pixbuf_animation_get_static_image(cursor_animated); | |
728 cursor_gdk = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), | |
729 cursor_pixbuf, 0, 0); | |
730 } else { | |
731 cursor_gdk = gdk_cursor_new(GDK_LEFT_PTR); | |
732 } | |
733 | |
734 gdk_window_set_cursor(mainwin->window, cursor_gdk); | |
735 gdk_window_set_cursor(playlistwin->window, cursor_gdk); | |
736 gdk_window_set_cursor(equalizerwin->window, cursor_gdk); | |
737 } | |
738 | |
739 static void | |
740 skin_load_pixmaps(Skin * skin, const gchar * path) | |
741 { | |
742 GdkPixmap *text_pm; | |
743 guint i; | |
744 | |
745 for (i = 0; i < SKIN_PIXMAP_COUNT; i++) | |
746 skin_load_pixmap_id(skin, i, path); | |
747 | |
748 text_pm = skin->pixmaps[SKIN_TEXT].pixmap; | |
749 | |
750 if (text_pm) | |
751 skin_get_textcolors(text_pm, skin->textbg, skin->textfg); | |
752 | |
753 #if 0 | |
754 if (skin->pixmaps[SKIN_NUMBERS].pixmap) | |
755 skin_numbers_generate_dash(skin); | |
756 #endif | |
757 | |
758 skin->colors[SKIN_PLEDIT_NORMAL] = | |
759 skin_load_color(path, "pledit.txt", "text", "normal"); | |
760 skin->colors[SKIN_PLEDIT_CURRENT] = | |
761 skin_load_color(path, "pledit.txt", "text", "current"); | |
762 skin->colors[SKIN_PLEDIT_NORMALBG] = | |
763 skin_load_color(path, "pledit.txt", "text", "normalbg"); | |
764 skin->colors[SKIN_PLEDIT_SELECTEDBG] = | |
765 skin_load_color(path, "pledit.txt", "text", "selectedbg"); | |
766 | |
767 skin_mask_create(skin, path, SKIN_MASK_MAIN, mainwin->window); | |
768 skin_mask_create(skin, path, SKIN_MASK_MAIN_SHADE, mainwin->window); | |
769 | |
770 skin_mask_create(skin, path, SKIN_MASK_EQ, equalizerwin->window); | |
771 skin_mask_create(skin, path, SKIN_MASK_EQ_SHADE, equalizerwin->window); | |
772 | |
773 skin_load_viscolor(skin, path, "viscolor.txt"); | |
774 } | |
775 | |
776 static gboolean | |
777 skin_load_nolock(Skin * skin, const gchar * path, gboolean force) | |
778 { | |
779 gchar *cpath; | |
780 | |
781 g_return_val_if_fail(skin != NULL, FALSE); | |
782 g_return_val_if_fail(path != NULL, FALSE); | |
783 REQUIRE_LOCK(skin->lock); | |
784 | |
785 if (!g_file_test(path, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_DIR)) | |
786 return FALSE; | |
787 | |
788 if (!force) { | |
789 if (skin->path) | |
790 if (!strcmp(skin->path, path)) | |
791 return FALSE; | |
792 } | |
793 | |
794 skin_current_num++; | |
795 | |
796 skin->path = g_strdup(path); | |
797 | |
798 | |
799 if (!file_is_archive(path)) { | |
800 skin_load_pixmaps(skin, path); | |
801 skin_load_cursor(skin, path); | |
802 return TRUE; | |
803 } | |
804 | |
805 if (!(cpath = archive_decompress(path))) { | |
806 g_message("Unable to extract skin archive (%s)", path); | |
807 return FALSE; | |
808 } | |
809 | |
810 skin_load_pixmaps(skin, cpath); | |
811 skin_load_cursor(skin, cpath); | |
812 del_directory(cpath); | |
813 g_free(cpath); | |
814 | |
815 return TRUE; | |
816 } | |
817 | |
818 void | |
819 skin_install_skin(const gchar * path) | |
820 { | |
821 gchar *command; | |
822 | |
823 g_return_if_fail(path != NULL); | |
824 | |
825 command = g_strdup_printf("cp %s %s", path, bmp_paths[BMP_PATH_USER_SKIN_DIR]); | |
826 if (system(command)) { | |
827 g_message("Unable to install skin (%s) into user directory (%s)", | |
828 path, bmp_paths[BMP_PATH_USER_SKIN_DIR]); | |
829 } | |
830 g_free(command); | |
831 } | |
832 | |
833 | |
834 gboolean | |
835 skin_load(Skin * skin, const gchar * path) | |
836 { | |
837 gboolean error; | |
838 | |
839 g_return_val_if_fail(skin != NULL, FALSE); | |
840 g_return_val_if_fail(path != NULL, FALSE); | |
841 | |
842 skin_lock(skin); | |
843 error = skin_load_nolock(skin, path, FALSE); | |
844 skin_unlock(skin); | |
845 | |
846 return error; | |
847 } | |
848 | |
849 gboolean | |
850 skin_reload_forced(void) | |
851 { | |
852 gboolean error; | |
853 | |
854 skin_lock(bmp_active_skin); | |
855 error = skin_load_nolock(bmp_active_skin, bmp_active_skin->path, TRUE); | |
856 skin_unlock(bmp_active_skin); | |
857 | |
858 return error; | |
859 } | |
860 | |
861 void | |
862 skin_reload(Skin * skin) | |
863 { | |
864 g_return_if_fail(skin != NULL); | |
865 skin_load_nolock(skin, skin->path, TRUE); | |
866 } | |
867 | |
868 | |
869 static SkinPixmap * | |
870 skin_get_pixmap(Skin * skin, SkinPixmapId map_id) | |
871 { | |
872 g_return_val_if_fail(skin != NULL, NULL); | |
873 g_return_val_if_fail(map_id < SKIN_PIXMAP_COUNT, NULL); | |
874 | |
875 return &skin->pixmaps[map_id]; | |
876 } | |
877 | |
878 GdkBitmap * | |
879 skin_get_mask(Skin * skin, SkinMaskId mi) | |
880 { | |
881 g_return_val_if_fail(skin != NULL, NULL); | |
882 g_return_val_if_fail(mi < SKIN_PIXMAP_COUNT, NULL); | |
883 | |
884 return skin->masks[mi]; | |
885 } | |
886 | |
887 GdkColor * | |
888 skin_get_color(Skin * skin, SkinColorId color_id) | |
889 { | |
890 GdkColor *ret = NULL; | |
891 | |
892 g_return_val_if_fail(skin != NULL, NULL); | |
893 | |
894 switch (color_id) { | |
895 case SKIN_TEXTBG: | |
896 if (skin->pixmaps[SKIN_TEXT].pixmap) | |
897 ret = skin->textbg; | |
898 else | |
899 ret = skin->def_textbg; | |
900 break; | |
901 case SKIN_TEXTFG: | |
902 if (skin->pixmaps[SKIN_TEXT].pixmap) | |
903 ret = skin->textfg; | |
904 else | |
905 ret = skin->def_textfg; | |
906 break; | |
907 default: | |
908 if (color_id < SKIN_COLOR_COUNT) | |
909 ret = skin->colors[color_id]; | |
910 break; | |
911 } | |
912 return ret; | |
913 } | |
914 | |
915 void | |
916 skin_get_viscolor(Skin * skin, guchar vis_color[24][3]) | |
917 { | |
918 gint i; | |
919 | |
920 g_return_if_fail(skin != NULL); | |
921 | |
922 for (i = 0; i < 24; i++) { | |
923 vis_color[i][0] = skin->vis_color[i][0]; | |
924 vis_color[i][1] = skin->vis_color[i][1]; | |
925 vis_color[i][2] = skin->vis_color[i][2]; | |
926 } | |
927 } | |
928 | |
929 gint | |
930 skin_get_id(void) | |
931 { | |
932 return skin_current_num; | |
933 } | |
934 | |
935 void | |
936 skin_draw_pixmap(Skin * skin, GdkDrawable * drawable, GdkGC * gc, | |
937 SkinPixmapId pixmap_id, | |
938 gint xsrc, gint ysrc, gint xdest, gint ydest, | |
939 gint width, gint height) | |
940 { | |
941 SkinPixmap *pixmap; | |
942 | |
943 g_return_if_fail(skin != NULL); | |
944 | |
945 pixmap = skin_get_pixmap(skin, pixmap_id); | |
946 g_return_if_fail(pixmap != NULL); | |
947 g_return_if_fail(pixmap->pixmap != NULL); | |
948 | |
949 if (xsrc > pixmap->width || ysrc > pixmap->height) | |
950 return; | |
951 | |
952 width = MIN(width, pixmap->width - xsrc); | |
953 height = MIN(height, pixmap->height - ysrc); | |
954 gdk_draw_pixmap(drawable, gc, pixmap->pixmap, xsrc, ysrc, | |
955 xdest, ydest, width, height); | |
956 } | |
957 | |
958 void | |
959 skin_get_eq_spline_colors(Skin * skin, guint32 colors[19]) | |
960 { | |
961 gint i; | |
962 GdkPixmap *pixmap; | |
963 GdkImage *img; | |
964 SkinPixmap *eqmainpm; | |
965 | |
966 g_return_if_fail(skin != NULL); | |
967 | |
968 eqmainpm = &skin->pixmaps[SKIN_EQMAIN]; | |
969 if (eqmainpm->pixmap && | |
970 eqmainpm->current_width >= 116 && eqmainpm->current_height >= 313) | |
971 pixmap = eqmainpm->pixmap; | |
972 else | |
973 return; | |
974 | |
975 if (!GDK_IS_DRAWABLE(pixmap)) | |
976 return; | |
977 | |
978 if (!(img = gdk_drawable_get_image(pixmap, 115, 294, 1, 19))) | |
979 return; | |
980 | |
981 for (i = 0; i < 19; i++) | |
982 colors[i] = gdk_image_get_pixel(img, 0, i); | |
983 | |
984 gdk_image_destroy(img); | |
985 } | |
986 | |
987 | |
988 static void | |
989 skin_draw_playlistwin_frame_top(Skin * skin, | |
990 GdkDrawable * drawable, | |
991 GdkGC * gc, | |
992 gint width, gint height, gboolean focus) | |
993 { | |
994 /* The title bar skin consists of 2 sets of 4 images, 1 set | |
995 * for focused state and the other for unfocused. The 4 images | |
996 * are: | |
997 * | |
998 * a. right corner (25,20) | |
999 * b. left corner (25,20) | |
1000 * c. tiler (25,20) | |
1001 * d. title (100,20) | |
1002 * | |
1003 * min allowed width = 100+25+25 = 150 | |
1004 */ | |
1005 | |
1006 gint i, y, c; | |
1007 | |
1008 /* get y offset of the pixmap set to use */ | |
1009 if (focus) | |
1010 y = 0; | |
1011 else | |
1012 y = 21; | |
1013 | |
1014 /* left corner */ | |
1015 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 0, y, 0, 0, 25, 20); | |
1016 | |
1017 /* titlebar title */ | |
1018 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 26, y, | |
1019 (width - 100) / 2, 0, 100, 20); | |
1020 | |
1021 /* titlebar right corner */ | |
1022 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 153, y, | |
1023 width - 25, 0, 25, 20); | |
1024 | |
1025 /* tile draw the remaining frame */ | |
1026 | |
1027 /* compute tile count */ | |
1028 c = (width - (100 + 25 + 25)) / 25; | |
1029 | |
1030 for (i = 0; i < c / 2; i++) { | |
1031 /* left of title */ | |
1032 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y, | |
1033 25 + i * 25, 0, 25, 20); | |
1034 | |
1035 /* right of title */ | |
1036 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y, | |
1037 (width + 100) / 2 + i * 25, 0, 25, 20); | |
1038 } | |
1039 | |
1040 if (c & 1) { | |
1041 /* Odd tile count, so one remaining to draw. Here we split | |
1042 * it into two and draw half on either side of the title */ | |
1043 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y, | |
1044 ((c / 2) * 25) + 25, 0, 12, 20); | |
1045 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 127, y, | |
1046 (width / 2) + ((c / 2) * 25) + 50, 0, 13, 20); | |
1047 } | |
1048 } | |
1049 | |
1050 static void | |
1051 skin_draw_playlistwin_frame_bottom(Skin * skin, | |
1052 GdkDrawable * drawable, | |
1053 GdkGC * gc, | |
1054 gint width, gint height, gboolean focus) | |
1055 { | |
1056 /* The bottom frame skin consists of 1 set of 4 images. The 4 | |
1057 * images are: | |
1058 * | |
1059 * a. left corner with menu buttons (125,38) | |
1060 * b. visualization window (75,38) | |
1061 * c. right corner with play buttons (150,38) | |
1062 * d. frame tile (25,38) | |
1063 * | |
1064 * (min allowed width = 125+150+25=300 | |
1065 */ | |
1066 | |
1067 gint i, c; | |
1068 | |
1069 /* bottom left corner (menu buttons) */ | |
1070 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 0, 72, | |
1071 0, height - 38, 125, 38); | |
1072 | |
1073 c = (width - 275) / 25; | |
1074 | |
1075 /* draw visualization window, if width allows */ | |
1076 if (c >= 3) { | |
1077 c -= 3; | |
1078 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 205, 0, | |
1079 width - (150 + 75), height - 38, 75, 38); | |
1080 } | |
1081 | |
1082 /* Bottom right corner (playbuttons etc) */ | |
1083 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, | |
1084 126, 72, width - 150, height - 38, 150, 38); | |
1085 | |
1086 /* Tile draw the remaining undrawn portions */ | |
1087 for (i = 0; i < c; i++) | |
1088 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 179, 0, | |
1089 125 + i * 25, height - 38, 25, 38); | |
1090 } | |
1091 | |
1092 static void | |
1093 skin_draw_playlistwin_frame_sides(Skin * skin, | |
1094 GdkDrawable * drawable, | |
1095 GdkGC * gc, | |
1096 gint width, gint height, gboolean focus) | |
1097 { | |
1098 /* The side frames consist of 2 tile images. 1 for the left, 1 for | |
1099 * the right. | |
1100 * a. left (12,29) | |
1101 * b. right (19,29) | |
1102 */ | |
1103 | |
1104 gint i; | |
1105 | |
1106 /* frame sides */ | |
1107 for (i = 0; i < (height - (20 + 38)) / 29; i++) { | |
1108 /* left */ | |
1109 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 0, 42, | |
1110 0, 20 + i * 29, 12, 29); | |
1111 | |
1112 /* right */ | |
1113 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 32, 42, | |
1114 width - 19, 20 + i * 29, 19, 29); | |
1115 } | |
1116 } | |
1117 | |
1118 | |
1119 void | |
1120 skin_draw_playlistwin_frame(Skin * skin, | |
1121 GdkDrawable * drawable, GdkGC * gc, | |
1122 gint width, gint height, gboolean focus) | |
1123 { | |
1124 skin_draw_playlistwin_frame_top(skin, drawable, gc, width, height, focus); | |
1125 skin_draw_playlistwin_frame_bottom(skin, drawable, gc, width, height, | |
1126 focus); | |
1127 skin_draw_playlistwin_frame_sides(skin, drawable, gc, width, height, | |
1128 focus); | |
1129 } | |
1130 | |
1131 | |
1132 void | |
1133 skin_draw_playlistwin_shaded(Skin * skin, | |
1134 GdkDrawable * drawable, GdkGC * gc, | |
1135 gint width, gboolean focus) | |
1136 { | |
1137 /* The shade mode titlebar skin consists of 4 images: | |
1138 * a) left corner offset (72,42) size (25,14) | |
1139 * b) right corner, focused offset (99,57) size (50,14) | |
1140 * c) right corner, unfocused offset (99,42) size (50,14) | |
1141 * d) bar tile offset (72,57) size (25,14) | |
1142 */ | |
1143 | |
1144 gint i; | |
1145 | |
1146 /* left corner */ | |
1147 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 72, 42, 0, 0, 25, 14); | |
1148 | |
1149 /* bar tile */ | |
1150 for (i = 0; i < (width - 75) / 25; i++) | |
1151 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 72, 57, | |
1152 (i * 25) + 25, 0, 25, 14); | |
1153 | |
1154 /* right corner */ | |
1155 skin_draw_pixmap(skin, drawable, gc, SKIN_PLEDIT, 99, focus ? 57 : 42, | |
1156 width - 50, 0, 50, 14); | |
1157 } | |
1158 | |
1159 | |
1160 void | |
1161 skin_draw_mainwin_titlebar(Skin * skin, | |
1162 GdkDrawable * drawable, GdkGC * gc, | |
1163 gboolean shaded, gboolean focus) | |
1164 { | |
1165 /* The titlebar skin consists of 2 sets of 2 images, one for for | |
1166 * shaded and the other for unshaded mode, giving a total of 4. | |
1167 * The images are exactly 275x14 pixels, aligned and arranged | |
1168 * vertically on each other in the pixmap in the following order: | |
1169 * | |
1170 * a) unshaded, focused offset (27, 0) | |
1171 * b) unshaded, unfocused offset (27, 15) | |
1172 * c) shaded, focused offset (27, 29) | |
1173 * d) shaded, unfocused offset (27, 42) | |
1174 */ | |
1175 | |
1176 gint y_offset; | |
1177 | |
1178 if (shaded) { | |
1179 if (focus) | |
1180 y_offset = 29; | |
1181 else | |
1182 y_offset = 42; | |
1183 } | |
1184 else { | |
1185 if (focus) | |
1186 y_offset = 0; | |
1187 else | |
1188 y_offset = 15; | |
1189 } | |
1190 | |
1191 skin_draw_pixmap(skin, drawable, gc, SKIN_TITLEBAR, 27, y_offset, | |
1192 0, 0, MAINWIN_WIDTH, MAINWIN_TITLEBAR_HEIGHT); | |
1193 } | |
1194 | |
1195 #if 0 | |
1196 void | |
1197 skin_draw_mainwin(Skin * skin, | |
1198 GdkDrawable * drawable, GdkGC gc, | |
1199 gboolean doublesize, gboolean shaded, gboolean focus) | |
1200 { | |
1201 | |
1202 } | |
1203 #endif |