]> Dogcows Code - chaz/openbox/blob - render/theme.c
97f5e1f5865df388219777d742fa36814b43e658
[chaz/openbox] / render / theme.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 theme.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
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 See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #include "render.h"
21 #include "color.h"
22 #include "font.h"
23 #include "mask.h"
24 #include "theme.h"
25 #include "icon.h"
26 #include "parser/parse.h"
27
28 #include <X11/Xlib.h>
29 #include <ctype.h>
30 #include <stdlib.h>
31 #include <string.h>
32
33 typedef struct {
34 xmlDocPtr doc;
35 const RrInstance *inst;
36 gchar *path;
37 } ParseState;
38
39 static void parse_style(gchar *tex, RrSurfaceColorType *grad,
40 RrReliefType *relief, RrBevelType *bevel,
41 gboolean *interlaced, gboolean *border,
42 gboolean allow_trans);
43 static gboolean read_mask(ParseState *ps, const gchar *maskname,
44 RrPixmapMask **value);
45 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data);
46 static void set_default_appearance(RrAppearance *a);
47 static xmlNodePtr find_node(xmlNodePtr n, const gchar *names[]);
48 static gboolean find_int(ParseState *ps, xmlNodePtr n, const gchar *names[],
49 gint *integer, gint lower, gint upper);
50 static gboolean find_string(ParseState *ps, xmlNodePtr n, const gchar *names[],
51 gchar **string);
52 static gboolean find_color(ParseState *ps, xmlNodePtr n, const gchar *names[],
53 RrColor **color, gchar *alpha);
54 static gboolean find_point(ParseState *ps, xmlNodePtr n, const gchar *names[],
55 gint *x, gint *y,
56 gint lowx, gint lowy, gint upx, gint upy);
57 static gboolean find_shadow(ParseState *ps, xmlNodePtr n, const gchar *names[],
58 RrAppearance *a);
59 static gboolean find_appearance(ParseState *ps, xmlNodePtr n, const gchar *names[],
60 RrAppearance *a, gboolean allow_trans);
61
62 /* make a null terminated array out of a list of strings */
63 #define L(args...) (const gchar*[]){args,NULL}
64 /* shortcut to the various find_* functions */
65 #define FIND(type, args...) find_##type(&ps, root, args)
66
67 RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
68 RrFont *active_window_font, RrFont *inactive_window_font,
69 RrFont *menu_title_font, RrFont *menu_item_font,
70 RrFont *osd_font)
71 {
72 ParseState ps;
73 xmlNodePtr root;
74 RrJustify winjust, mtitlejust;
75 gchar *str;
76 RrTheme *theme;
77 gboolean userdef;
78
79 if (name) {
80 if (!parse_load_theme(name, &ps.doc, &root, &ps.path)) {
81 g_message("Unable to load the theme '%s'", name);
82 g_message("Falling back to the default theme '%s'",
83 DEFAULT_THEME);
84 /* make it fall back to default theme */
85 name = NULL;
86 }
87 }
88 if (!name) {
89 if (!parse_load_theme(DEFAULT_THEME, &ps.doc, &root, &ps.path)) {
90 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
91 return NULL;
92 }
93 }
94 ps.inst = inst;
95
96 theme = g_new0(RrTheme, 1);
97 theme->inst = inst;
98
99 theme->a_disabled_focused_max = RrAppearanceNew(inst, 1);
100 theme->a_disabled_unfocused_max = RrAppearanceNew(inst, 1);
101 theme->a_hover_focused_max = RrAppearanceNew(inst, 1);
102 theme->a_hover_unfocused_max = RrAppearanceNew(inst, 1);
103 theme->a_toggled_focused_pressed_max = RrAppearanceNew(inst, 1);
104 theme->a_toggled_unfocused_pressed_max = RrAppearanceNew(inst, 1);
105 theme->a_toggled_focused_unpressed_max = RrAppearanceNew(inst, 1);
106 theme->a_toggled_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
107 theme->a_toggled_hover_focused_max = RrAppearanceNew(inst, 1);
108 theme->a_toggled_hover_unfocused_max = RrAppearanceNew(inst, 1);
109 theme->a_focused_unpressed_max = RrAppearanceNew(inst, 1);
110 theme->a_focused_pressed_max = RrAppearanceNew(inst, 1);
111 theme->a_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
112 theme->a_unfocused_pressed_max = RrAppearanceNew(inst, 1);
113 theme->a_focused_grip = RrAppearanceNew(inst, 0);
114 theme->a_unfocused_grip = RrAppearanceNew(inst, 0);
115 theme->a_focused_title = RrAppearanceNew(inst, 0);
116 theme->a_unfocused_title = RrAppearanceNew(inst, 0);
117 theme->a_focused_label = RrAppearanceNew(inst, 1);
118 theme->a_unfocused_label = RrAppearanceNew(inst, 1);
119 theme->a_icon = RrAppearanceNew(inst, 1);
120 theme->a_focused_handle = RrAppearanceNew(inst, 0);
121 theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
122 theme->a_menu = RrAppearanceNew(inst, 0);
123 theme->a_menu_title = RrAppearanceNew(inst, 0);
124 theme->a_menu_text_title = RrAppearanceNew(inst, 1);
125 theme->a_menu_normal = RrAppearanceNew(inst, 0);
126 theme->a_menu_disabled = RrAppearanceNew(inst, 0);
127 theme->a_menu_disabled_selected = RrAppearanceNew(inst, 0);
128 theme->a_menu_selected = RrAppearanceNew(inst, 0);
129 theme->a_menu_text_normal = RrAppearanceNew(inst, 1);
130 theme->a_menu_text_selected = RrAppearanceNew(inst, 1);
131 theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
132 theme->a_menu_text_disabled_selected = RrAppearanceNew(inst, 1);
133 theme->a_menu_bullet_normal = RrAppearanceNew(inst, 1);
134 theme->a_menu_bullet_selected = RrAppearanceNew(inst, 1);
135 theme->a_clear = RrAppearanceNew(inst, 0);
136 theme->a_clear_tex = RrAppearanceNew(inst, 1);
137
138 /* load the font stuff */
139
140 if (active_window_font) {
141 theme->win_font_focused = active_window_font;
142 RrFontRef(active_window_font);
143 } else
144 theme->win_font_focused = RrFontOpenDefault(inst);
145
146 if (inactive_window_font) {
147 theme->win_font_unfocused = inactive_window_font;
148 RrFontRef(inactive_window_font);
149 } else
150 theme->win_font_unfocused = RrFontOpenDefault(inst);
151
152 winjust = RR_JUSTIFY_LEFT;
153 if (FIND(string, L( "window", "justify"), &str)) {
154 if (strcmp(str, "right") == 0)
155 winjust = RR_JUSTIFY_RIGHT;
156 else if (strcmp(str, "center") == 0)
157 winjust = RR_JUSTIFY_CENTER;
158 g_free(str);
159 }
160
161 if (menu_title_font) {
162 theme->menu_title_font = menu_title_font;
163 RrFontRef(menu_title_font);
164 } else
165 theme->menu_title_font = RrFontOpenDefault(inst);
166
167 mtitlejust = RR_JUSTIFY_LEFT;
168 if (FIND(string, L("menu", "justify"), &str)) {
169 if (strcmp(str, "right") == 0)
170 mtitlejust = RR_JUSTIFY_RIGHT;
171 else if (strcmp(str, "center") == 0)
172 mtitlejust = RR_JUSTIFY_CENTER;
173 g_free(str);
174 }
175
176 if (menu_item_font) {
177 theme->menu_font = menu_item_font;
178 RrFontRef(menu_item_font);
179 } else
180 theme->menu_font = RrFontOpenDefault(inst);
181
182 if (osd_font) {
183 theme->osd_font = osd_font;
184 RrFontRef(osd_font);
185 } else
186 theme->osd_font = RrFontOpenDefault(inst);
187
188 /* load direct dimensions */
189 if (!FIND(int, L("menu","overlap"),
190 &theme->menu_overlap, -100, 100))
191 theme->menu_overlap = 0;
192
193 if (!FIND(int, L("dimensions","handle"), &theme->handle_height, 0, 100))
194 theme->handle_height = 6;
195
196 if (!FIND(point, L("dimensions","padding"),
197 &theme->paddingx, &theme->paddingy, 0, 100, 0, 100))
198 theme->paddingx = theme->paddingy = 3;
199
200 if (!FIND(int, L("dimensions","window","border"),
201 &theme->fbwidth, 0, 100))
202 theme->fbwidth = 1;
203
204 /* menu border width inherits from frame border width */
205 if (!FIND(int, L("dimensions","menu","border"),
206 &theme->mbwidth, 0, 100))
207 theme->mbwidth = theme->fbwidth;
208
209 if (!FIND(point, L("dimensions","window","clientpadding"),
210 &theme->cbwidthx, &theme->cbwidthy, 0, 100, 0, 100))
211 theme->cbwidthx = theme->cbwidthy = 1;
212
213 /* load colors */
214 if (!FIND(color, L("window","active","border"),
215 &theme->frame_focused_border_color, NULL))
216 theme->frame_focused_border_color = RrColorNew(inst, 0, 0, 0);
217 /* frame unfocused border color inherits from frame focused border color */
218 if (!FIND(color, L("window","inactive","border"),
219 &theme->frame_unfocused_border_color, NULL))
220 theme->frame_unfocused_border_color =
221 RrColorNew(inst,
222 theme->frame_focused_border_color->r,
223 theme->frame_focused_border_color->g,
224 theme->frame_focused_border_color->b);
225
226 /* menu border color inherits from frame focused border color */
227 if (!FIND(color, L("menu","border"),
228 &theme->menu_border_color, NULL))
229 theme->menu_border_color =
230 RrColorNew(inst,
231 theme->frame_focused_border_color->r,
232 theme->frame_focused_border_color->g,
233 theme->frame_focused_border_color->b);
234 if (!FIND(color, L("window","active","clientpadding"),
235 &theme->cb_focused_color, NULL))
236 theme->cb_focused_color = RrColorNew(inst, 255, 255, 255);
237 if (!FIND(color, L("window","inactive","clientpadding"),
238 &theme->cb_unfocused_color, NULL))
239 theme->cb_unfocused_color = RrColorNew(inst, 255, 255, 255);
240 if (!FIND(color, L("window","active","label","text","primary"),
241 &theme->title_focused_color, NULL))
242 theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0);
243 if (!FIND(color, L("osd","text","primary"),
244 &theme->osd_color, NULL))
245 theme->osd_color = RrColorNew(inst,
246 theme->title_focused_color->r,
247 theme->title_focused_color->g,
248 theme->title_focused_color->b);
249 if (!FIND(color, L("window","inactive","label","text","primary"),
250 &theme->title_unfocused_color, NULL))
251 theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
252 if (!FIND(color, L("window","active","buttons","unpressed","image"),
253 &theme->titlebut_focused_unpressed_color, NULL))
254 theme->titlebut_focused_unpressed_color = RrColorNew(inst, 0, 0, 0);
255 if (!FIND(color, L("window","inactive","buttons", "unpressed","image"),
256 &theme->titlebut_unfocused_unpressed_color, NULL))
257 theme->titlebut_unfocused_unpressed_color =
258 RrColorNew(inst, 0xff, 0xff, 0xff);
259 if (!FIND(color, L("window","active","buttons","pressed","image"),
260 &theme->titlebut_focused_pressed_color, NULL))
261 theme->titlebut_focused_pressed_color =
262 RrColorNew(inst,
263 theme->titlebut_focused_unpressed_color->r,
264 theme->titlebut_focused_unpressed_color->g,
265 theme->titlebut_focused_unpressed_color->b);
266 if (!FIND(color, L("window","inactive","buttons","pressed","image"),
267 &theme->titlebut_unfocused_pressed_color, NULL))
268 theme->titlebut_unfocused_pressed_color =
269 RrColorNew(inst,
270 theme->titlebut_unfocused_unpressed_color->r,
271 theme->titlebut_unfocused_unpressed_color->g,
272 theme->titlebut_unfocused_unpressed_color->b);
273 if (!FIND(color, L("window","active","buttons","disabled","image"),
274 &theme->titlebut_disabled_focused_color, NULL))
275 theme->titlebut_disabled_focused_color =
276 RrColorNew(inst, 0xff, 0xff, 0xff);
277 if (!FIND(color, L("window","inactive","buttons","disabled","image"),
278 &theme->titlebut_disabled_unfocused_color, NULL))
279 theme->titlebut_disabled_unfocused_color = RrColorNew(inst, 0, 0, 0);
280 if (!FIND(color,
281 L("window","active","buttons","hover","image"),
282 &theme->titlebut_hover_focused_color, NULL))
283 theme->titlebut_hover_focused_color =
284 RrColorNew(inst,
285 theme->titlebut_focused_unpressed_color->r,
286 theme->titlebut_focused_unpressed_color->g,
287 theme->titlebut_focused_unpressed_color->b);
288 if (!FIND(color, L("window","inactive","buttons","hover","image"),
289 &theme->titlebut_hover_unfocused_color, NULL))
290 theme->titlebut_hover_unfocused_color =
291 RrColorNew(inst,
292 theme->titlebut_unfocused_unpressed_color->r,
293 theme->titlebut_unfocused_unpressed_color->g,
294 theme->titlebut_unfocused_unpressed_color->b);
295 if (!FIND(color,
296 L("window","active","buttons","toggled-pressed","image"),
297 &theme->titlebut_toggled_focused_pressed_color, NULL))
298 theme->titlebut_toggled_focused_pressed_color =
299 RrColorNew(inst,
300 theme->titlebut_focused_pressed_color->r,
301 theme->titlebut_focused_pressed_color->g,
302 theme->titlebut_focused_pressed_color->b);
303 if (!FIND(color,
304 L("window","inactive","buttons","toggled-pressed","image"),
305 &theme->titlebut_toggled_unfocused_pressed_color, NULL))
306 theme->titlebut_toggled_unfocused_pressed_color =
307 RrColorNew(inst,
308 theme->titlebut_unfocused_pressed_color->r,
309 theme->titlebut_unfocused_pressed_color->g,
310 theme->titlebut_unfocused_pressed_color->b);
311 if (!FIND(color,
312 L("window","active","buttons","toggled-unpressed","image"),
313 &theme->titlebut_toggled_focused_unpressed_color, NULL))
314 theme->titlebut_toggled_focused_unpressed_color =
315 RrColorNew(inst,
316 theme->titlebut_focused_pressed_color->r,
317 theme->titlebut_focused_pressed_color->g,
318 theme->titlebut_focused_pressed_color->b);
319 if (!FIND(color,
320 L("window","inactive","buttons","toggled-unpressed","image"),
321 &theme->titlebut_toggled_unfocused_unpressed_color, NULL))
322 theme->titlebut_toggled_unfocused_unpressed_color =
323 RrColorNew(inst,
324 theme->titlebut_unfocused_pressed_color->r,
325 theme->titlebut_unfocused_pressed_color->g,
326 theme->titlebut_unfocused_pressed_color->b);
327 if (!FIND(color,
328 L("window","active","buttons","toggled-hover","image"),
329 &theme->titlebut_toggled_hover_focused_color, NULL))
330 theme->titlebut_toggled_hover_focused_color =
331 RrColorNew(inst,
332 theme->titlebut_toggled_focused_unpressed_color->r,
333 theme->titlebut_toggled_focused_unpressed_color->g,
334 theme->titlebut_toggled_focused_unpressed_color->b);
335 if (!FIND(color,
336 L("window","inactive","buttons","toggled-hover","image"),
337 &theme->titlebut_toggled_hover_unfocused_color, NULL))
338 theme->titlebut_toggled_hover_unfocused_color =
339 RrColorNew(inst,
340 theme->titlebut_toggled_unfocused_unpressed_color->r,
341 theme->titlebut_toggled_unfocused_unpressed_color->g,
342 theme->titlebut_toggled_unfocused_unpressed_color->b);
343 if (!FIND(color, L("menu","title","text","primary"),
344 &theme->menu_title_color, NULL))
345 theme->menu_title_color = RrColorNew(inst, 0, 0, 0);
346 if (!FIND(color, L("menu","inactive","primary"), &theme->menu_color, NULL))
347 theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff);
348 if (!FIND(color, L("menu","disabled","primary"),
349 &theme->menu_disabled_color, NULL))
350 theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0);
351 if (!FIND(color, L("menu","activedisabled","text","primary"),
352 &theme->menu_disabled_selected_color, NULL))
353 theme->menu_disabled_selected_color =
354 RrColorNew(inst,
355 theme->menu_disabled_color->r,
356 theme->menu_disabled_color->g,
357 theme->menu_disabled_color->b);
358 if (!FIND(color, L("menu","active","text","primary"),
359 &theme->menu_selected_color, NULL))
360 theme->menu_selected_color = RrColorNew(inst, 0, 0, 0);
361 if (!FIND(color, L("window","active","label","text","shadow","primary"),
362 &theme->title_focused_shadow_color,
363 &theme->title_focused_shadow_alpha))
364 {
365 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
366 theme->title_focused_shadow_alpha = 50;
367 }
368 if (!FIND(color, L("osd","text","shadow","primary"),
369 &theme->osd_shadow_color, &theme->osd_shadow_alpha))
370 {
371 theme->osd_shadow_color =
372 RrColorNew(inst, theme->title_focused_shadow_color->r,
373 theme->title_focused_shadow_color->g,
374 theme->title_focused_shadow_color->b);
375 theme->osd_shadow_alpha = theme->title_focused_shadow_alpha;
376 }
377 if (!FIND(color, L("window","inactive","label","text","shadow","primary"),
378 &theme->title_unfocused_shadow_color,
379 &theme->title_unfocused_shadow_alpha))
380 {
381 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
382 theme->title_unfocused_shadow_alpha = 50;
383 }
384 if (!FIND(color, L("menu","title","text","shadow","primary"),
385 &theme->menu_title_shadow_color,
386 &theme->menu_title_shadow_alpha))
387 {
388 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
389 theme->menu_title_shadow_alpha = 50;
390 }
391 if (!FIND(color, L("menu","inactive","shadow","primary"),
392 &theme->menu_text_normal_shadow_color,
393 &theme->menu_text_normal_shadow_alpha))
394 {
395 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
396 theme->menu_text_normal_shadow_alpha = 50;
397 }
398 if (!FIND(color, L("menu","active","text","shadow","primary"),
399 &theme->menu_text_selected_shadow_color,
400 &theme->menu_text_selected_shadow_alpha))
401 {
402 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
403 theme->menu_text_selected_shadow_alpha = 50;
404 }
405 if (!FIND(color, L("menu","disabled","shadow","primary"),
406 &theme->menu_text_disabled_shadow_color,
407 &theme->menu_text_disabled_shadow_alpha))
408 {
409 theme->menu_text_disabled_shadow_color =
410 RrColorNew(inst, theme->menu_text_normal_shadow_color->r,
411 theme->menu_text_normal_shadow_color->g,
412 theme->menu_text_normal_shadow_color->b);
413 theme->menu_text_disabled_shadow_alpha =
414 theme->menu_text_normal_shadow_alpha;
415 }
416 if (!FIND(color, L("menu","activedisabled","shadow","primary"),
417 &theme->menu_text_disabled_selected_shadow_color,
418 &theme->menu_text_disabled_selected_shadow_alpha))
419 {
420 theme->menu_text_disabled_selected_shadow_color =
421 RrColorNew(inst, theme->menu_text_disabled_shadow_color->r,
422 theme->menu_text_disabled_shadow_color->g,
423 theme->menu_text_disabled_shadow_color->b);
424 theme->menu_text_disabled_selected_shadow_alpha =
425 theme->menu_text_disabled_shadow_alpha;
426 }
427
428 /* load the image masks */
429
430 /* maximize button masks */
431 userdef = TRUE;
432 if (!read_mask(&ps, "max.xbm", &theme->max_mask)) {
433 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
434 theme->max_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
435 userdef = FALSE;
436 }
437 if (!read_mask(&ps, "max_toggled.xbm", &theme->max_toggled_mask)) {
438 if (userdef)
439 theme->max_toggled_mask = RrPixmapMaskCopy(theme->max_mask);
440 else {
441 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
442 theme->max_toggled_mask = RrPixmapMaskNew(inst, 6, 6,(gchar*)data);
443 }
444 }
445 if (!read_mask(&ps, "max_pressed.xbm", &theme->max_pressed_mask))
446 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
447 if (!read_mask(&ps, "max_disabled.xbm", &theme->max_disabled_mask))
448 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
449 if (!read_mask(&ps, "max_hover.xbm", &theme->max_hover_mask))
450 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
451 if (!read_mask(&ps, "max_toggled_pressed.xbm",
452 &theme->max_toggled_pressed_mask))
453 theme->max_toggled_pressed_mask =
454 RrPixmapMaskCopy(theme->max_toggled_mask);
455 if (!read_mask(&ps, "max_toggled_hover.xbm",
456 &theme->max_toggled_hover_mask))
457 theme->max_toggled_hover_mask =
458 RrPixmapMaskCopy(theme->max_toggled_mask);
459
460 /* iconify button masks */
461 if (!read_mask(&ps, "iconify.xbm", &theme->iconify_mask)) {
462 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
463 theme->iconify_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
464 }
465 if (!read_mask(&ps, "iconify_pressed.xbm", &theme->iconify_pressed_mask))
466 theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
467 if (!read_mask(&ps, "iconify_disabled.xbm", &theme->iconify_disabled_mask))
468 theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
469 if (!read_mask(&ps, "iconify_hover.xbm", &theme->iconify_hover_mask))
470 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
471
472 /* all desktops button masks */
473 userdef = TRUE;
474 if (!read_mask(&ps, "desk.xbm", &theme->desk_mask)) {
475 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
476 theme->desk_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
477 userdef = FALSE;
478 }
479 if (!read_mask(&ps, "desk_toggled.xbm", &theme->desk_toggled_mask)) {
480 if (userdef)
481 theme->desk_toggled_mask = RrPixmapMaskCopy(theme->desk_mask);
482 else {
483 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
484 theme->desk_toggled_mask =
485 RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
486 }
487 }
488 if (!read_mask(&ps, "desk_pressed.xbm", &theme->desk_pressed_mask))
489 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
490 if (!read_mask(&ps, "desk_disabled.xbm", &theme->desk_disabled_mask))
491 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
492 if (!read_mask(&ps, "desk_hover.xbm", &theme->desk_hover_mask))
493 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
494 if (!read_mask(&ps, "desk_toggled_pressed.xbm",
495 &theme->desk_toggled_pressed_mask))
496 theme->desk_toggled_pressed_mask =
497 RrPixmapMaskCopy(theme->desk_toggled_mask);
498 if (!read_mask(&ps, "desk_toggled_hover.xbm",
499 &theme->desk_toggled_hover_mask))
500 theme->desk_toggled_hover_mask =
501 RrPixmapMaskCopy(theme->desk_toggled_mask);
502
503 /* shade button masks */
504 if (!read_mask(&ps, "shade.xbm", &theme->shade_mask)) {
505 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
506 theme->shade_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
507 }
508 if (!read_mask(&ps, "shade_toggled.xbm", &theme->shade_toggled_mask))
509 theme->shade_toggled_mask = RrPixmapMaskCopy(theme->shade_mask);
510 if (!read_mask(&ps, "shade_pressed.xbm", &theme->shade_pressed_mask))
511 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
512 if (!read_mask(&ps, "shade_disabled.xbm", &theme->shade_disabled_mask))
513 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
514 if (!read_mask(&ps, "shade_hover.xbm", &theme->shade_hover_mask))
515 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
516 if (!read_mask(&ps, "shade_toggled_pressed.xbm",
517 &theme->shade_toggled_pressed_mask))
518 theme->shade_toggled_pressed_mask =
519 RrPixmapMaskCopy(theme->shade_toggled_mask);
520 if (!read_mask(&ps, "shade_toggled_hover.xbm",
521 &theme->shade_toggled_hover_mask))
522 theme->shade_toggled_hover_mask =
523 RrPixmapMaskCopy(theme->shade_toggled_mask);
524
525 /* close button masks */
526 if (!read_mask(&ps, "close.xbm", &theme->close_mask)) {
527 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
528 theme->close_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
529 }
530 if (!read_mask(&ps, "close_pressed.xbm", &theme->close_pressed_mask))
531 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
532 if (!read_mask(&ps, "close_disabled.xbm", &theme->close_disabled_mask))
533 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
534 if (!read_mask(&ps, "close_hover.xbm", &theme->close_hover_mask))
535 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
536
537 /* submenu bullet mask */
538 if (!read_mask(&ps, "bullet.xbm", &theme->menu_bullet_mask)) {
539 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
540 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
541 }
542
543 /* setup the default window icon */
544 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
545 OB_DEFAULT_ICON_HEIGHT,
546 OB_DEFAULT_ICON_pixel_data);
547
548 /* read the decoration textures */
549 if (!FIND(appearance, L("window","active","titlebar"),
550 theme->a_focused_title, FALSE))
551 set_default_appearance(theme->a_focused_title);
552 if (!FIND(appearance, L("window","inactive","titlebar"),
553 theme->a_unfocused_title, FALSE))
554 set_default_appearance(theme->a_unfocused_title);
555 if (!FIND(appearance, L("window","active","label"),
556 theme->a_focused_label, TRUE))
557 set_default_appearance(theme->a_focused_label);
558 if (!FIND(appearance, L("window","inactive","label"),
559 theme->a_unfocused_label, TRUE))
560 set_default_appearance(theme->a_unfocused_label);
561 if (!FIND(appearance, L("window","active","handle"),
562 theme->a_focused_handle, FALSE))
563 set_default_appearance(theme->a_focused_handle);
564 if (!FIND(appearance, L("window","inactive","handle"),
565 theme->a_unfocused_handle, FALSE))
566 set_default_appearance(theme->a_unfocused_handle);
567 if (!FIND(appearance, L("window","active","grip"),
568 theme->a_focused_grip, TRUE))
569 set_default_appearance(theme->a_focused_grip);
570 if (!FIND(appearance, L("window","inactive","grip"),
571 theme->a_unfocused_grip, TRUE))
572 set_default_appearance(theme->a_unfocused_grip);
573 if (!FIND(appearance, L("menu","entries"), theme->a_menu, FALSE))
574 set_default_appearance(theme->a_menu);
575 if (!FIND(appearance, L("menu","title"), theme->a_menu_title, TRUE))
576 set_default_appearance(theme->a_menu_title);
577 if (!FIND(appearance, L("menu", "active"), theme->a_menu_selected, TRUE))
578 set_default_appearance(theme->a_menu_selected);
579 if (!FIND(appearance, L("menu", "activedisabled"),
580 theme->a_menu_disabled_selected, TRUE))
581 theme->a_menu_disabled_selected =
582 RrAppearanceCopy(theme->a_menu_selected);
583
584 /* read the appearances for rendering non-decorations */
585 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
586 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
587 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
588 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_label);
589 else
590 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_title);
591 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
592 theme->osd_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_label);
593 else
594 theme->osd_unhilite_fg = RrAppearanceCopy(theme->a_unfocused_title);
595
596 /* read buttons textures */
597 if (!FIND(appearance, L("window","active","buttons","disabled"),
598 theme->a_disabled_focused_max, TRUE))
599 set_default_appearance(theme->a_disabled_focused_max);
600 if (!FIND(appearance, L("window","inactive","buttons","disabled"),
601 theme->a_disabled_unfocused_max, TRUE))
602 set_default_appearance(theme->a_disabled_unfocused_max);
603 if (!FIND(appearance, L("window","active","buttons","pressed"),
604 theme->a_focused_pressed_max, TRUE))
605 set_default_appearance(theme->a_focused_pressed_max);
606 if (!FIND(appearance, L("window","inactive","buttons","pressed"),
607 theme->a_unfocused_pressed_max, TRUE))
608 set_default_appearance(theme->a_unfocused_pressed_max);
609 if (!FIND(appearance, L("window","active","buttons","unpressed"),
610 theme->a_focused_unpressed_max, TRUE))
611 set_default_appearance(theme->a_focused_unpressed_max);
612 if (!FIND(appearance, L("window","inactive","buttons","unpressed"),
613 theme->a_unfocused_unpressed_max, TRUE))
614 set_default_appearance(theme->a_unfocused_unpressed_max);
615 if (!FIND(appearance, L("window","active","buttons","hover"),
616 theme->a_hover_focused_max, TRUE))
617 {
618 RrAppearanceFree(theme->a_hover_focused_max);
619 theme->a_hover_focused_max =
620 RrAppearanceCopy(theme->a_focused_unpressed_max);
621 }
622 if (!FIND(appearance, L("window","inactive","buttons","hover"),
623 theme->a_hover_unfocused_max, TRUE))
624 {
625 RrAppearanceFree(theme->a_hover_unfocused_max);
626 theme->a_hover_unfocused_max =
627 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
628 }
629 if (!FIND(appearance, L("window","active","buttons","toggled-pressed"),
630 theme->a_toggled_focused_pressed_max, TRUE))
631 {
632 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
633 theme->a_toggled_focused_pressed_max =
634 RrAppearanceCopy(theme->a_focused_pressed_max);
635 }
636 if (!FIND(appearance, L("window","inactive","buttons","toggled-pressed"),
637 theme->a_toggled_unfocused_pressed_max, TRUE))
638 {
639 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
640 theme->a_toggled_unfocused_pressed_max =
641 RrAppearanceCopy(theme->a_unfocused_pressed_max);
642 }
643 if (!FIND(appearance, L("window","active","buttons","toggled-unpressed"),
644 theme->a_toggled_focused_unpressed_max, TRUE))
645 {
646 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
647 theme->a_toggled_focused_unpressed_max =
648 RrAppearanceCopy(theme->a_focused_pressed_max);
649 }
650 if (!FIND(appearance, L("window","inactive","buttons","toggled-unpressed"),
651 theme->a_toggled_unfocused_unpressed_max, TRUE))
652 {
653 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
654 theme->a_toggled_unfocused_unpressed_max =
655 RrAppearanceCopy(theme->a_unfocused_pressed_max);
656 }
657 if (!FIND(appearance, L("window","active","buttons","toggled-hover"),
658 theme->a_toggled_hover_focused_max, TRUE))
659 {
660 RrAppearanceFree(theme->a_toggled_hover_focused_max);
661 theme->a_toggled_hover_focused_max =
662 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
663 }
664 if (!FIND(appearance, L("window","inactive","buttons","toggled-hover"),
665 theme->a_toggled_hover_unfocused_max, TRUE))
666 {
667 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
668 theme->a_toggled_hover_unfocused_max =
669 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
670 }
671
672 theme->a_disabled_focused_close =
673 RrAppearanceCopy(theme->a_disabled_focused_max);
674 theme->a_disabled_unfocused_close =
675 RrAppearanceCopy(theme->a_disabled_unfocused_max);
676 theme->a_hover_focused_close =
677 RrAppearanceCopy(theme->a_hover_focused_max);
678 theme->a_hover_unfocused_close =
679 RrAppearanceCopy(theme->a_hover_unfocused_max);
680 theme->a_unfocused_unpressed_close =
681 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
682 theme->a_unfocused_pressed_close =
683 RrAppearanceCopy(theme->a_unfocused_pressed_max);
684 theme->a_focused_unpressed_close =
685 RrAppearanceCopy(theme->a_focused_unpressed_max);
686 theme->a_focused_pressed_close =
687 RrAppearanceCopy(theme->a_focused_pressed_max);
688 theme->a_disabled_focused_desk =
689 RrAppearanceCopy(theme->a_disabled_focused_max);
690 theme->a_disabled_unfocused_desk =
691 RrAppearanceCopy(theme->a_disabled_unfocused_max);
692 theme->a_hover_focused_desk =
693 RrAppearanceCopy(theme->a_hover_focused_max);
694 theme->a_hover_unfocused_desk =
695 RrAppearanceCopy(theme->a_hover_unfocused_max);
696 theme->a_toggled_focused_pressed_desk =
697 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
698 theme->a_toggled_unfocused_pressed_desk =
699 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
700 theme->a_toggled_focused_unpressed_desk =
701 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
702 theme->a_toggled_unfocused_unpressed_desk =
703 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
704 theme->a_toggled_hover_focused_desk =
705 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
706 theme->a_toggled_hover_unfocused_desk =
707 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
708 theme->a_unfocused_unpressed_desk =
709 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
710 theme->a_unfocused_pressed_desk =
711 RrAppearanceCopy(theme->a_unfocused_pressed_max);
712 theme->a_focused_unpressed_desk =
713 RrAppearanceCopy(theme->a_focused_unpressed_max);
714 theme->a_focused_pressed_desk =
715 RrAppearanceCopy(theme->a_focused_pressed_max);
716 theme->a_disabled_focused_shade =
717 RrAppearanceCopy(theme->a_disabled_focused_max);
718 theme->a_disabled_unfocused_shade =
719 RrAppearanceCopy(theme->a_disabled_unfocused_max);
720 theme->a_hover_focused_shade =
721 RrAppearanceCopy(theme->a_hover_focused_max);
722 theme->a_hover_unfocused_shade =
723 RrAppearanceCopy(theme->a_hover_unfocused_max);
724 theme->a_toggled_focused_pressed_shade =
725 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
726 theme->a_toggled_unfocused_pressed_shade =
727 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
728 theme->a_toggled_focused_unpressed_shade =
729 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
730 theme->a_toggled_unfocused_unpressed_shade =
731 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
732 theme->a_toggled_hover_focused_shade =
733 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
734 theme->a_toggled_hover_unfocused_shade =
735 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
736 theme->a_unfocused_unpressed_shade =
737 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
738 theme->a_unfocused_pressed_shade =
739 RrAppearanceCopy(theme->a_unfocused_pressed_max);
740 theme->a_focused_unpressed_shade =
741 RrAppearanceCopy(theme->a_focused_unpressed_max);
742 theme->a_focused_pressed_shade =
743 RrAppearanceCopy(theme->a_focused_pressed_max);
744 theme->a_disabled_focused_iconify =
745 RrAppearanceCopy(theme->a_disabled_focused_max);
746 theme->a_disabled_unfocused_iconify =
747 RrAppearanceCopy(theme->a_disabled_focused_max);
748 theme->a_hover_focused_iconify =
749 RrAppearanceCopy(theme->a_hover_focused_max);
750 theme->a_hover_unfocused_iconify =
751 RrAppearanceCopy(theme->a_hover_unfocused_max);
752 theme->a_unfocused_unpressed_iconify =
753 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
754 theme->a_unfocused_pressed_iconify =
755 RrAppearanceCopy(theme->a_unfocused_pressed_max);
756 theme->a_focused_unpressed_iconify =
757 RrAppearanceCopy(theme->a_focused_unpressed_max);
758 theme->a_focused_pressed_iconify =
759 RrAppearanceCopy(theme->a_focused_pressed_max);
760
761 theme->a_icon->surface.grad =
762 theme->a_clear->surface.grad =
763 theme->a_clear_tex->surface.grad =
764 theme->a_menu_text_title->surface.grad =
765 theme->a_menu_normal->surface.grad =
766 theme->a_menu_disabled->surface.grad =
767 theme->a_menu_text_normal->surface.grad =
768 theme->a_menu_text_selected->surface.grad =
769 theme->a_menu_text_disabled->surface.grad =
770 theme->a_menu_text_disabled_selected->surface.grad =
771 theme->a_menu_bullet_normal->surface.grad =
772 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
773
774 /* set up the textures */
775 theme->a_focused_label->texture[0].type =
776 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
777 theme->a_focused_label->texture[0].data.text.justify = winjust;
778 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
779 theme->a_focused_label->texture[0].data.text.font =
780 theme->win_font_focused;
781 theme->osd_hilite_label->texture[0].data.text.font = theme->osd_font;
782 theme->a_focused_label->texture[0].data.text.color =
783 theme->title_focused_color;
784 theme->osd_hilite_label->texture[0].data.text.color =
785 theme->osd_color;
786
787 if (!FIND(shadow, L("window","active","label","text","shadow","offset"),
788 theme->a_focused_label))
789 theme->a_focused_label->texture[0].data.text.shadow_offset_x =
790 theme->a_focused_label->texture[0].data.text.shadow_offset_y = 0;
791 theme->a_focused_label->texture[0].data.text.shadow_color =
792 theme->title_focused_shadow_color;
793 theme->a_focused_label->texture[0].data.text.shadow_alpha =
794 theme->title_focused_shadow_alpha;
795
796 if (!FIND(shadow, L("osd","text","shadow","offset"),
797 theme->osd_hilite_label))
798 {
799 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x =
800 theme->a_focused_label->texture[0].data.text.shadow_offset_x;
801 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y =
802 theme->a_focused_label->texture[0].data.text.shadow_offset_y;
803 }
804 theme->osd_hilite_label->texture[0].data.text.shadow_color =
805 theme->osd_shadow_color;
806 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
807 theme->osd_shadow_alpha;
808
809 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
810 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
811 theme->a_unfocused_label->texture[0].data.text.font =
812 theme->win_font_unfocused;
813 theme->a_unfocused_label->texture[0].data.text.color =
814 theme->title_unfocused_color;
815
816 if (!FIND(shadow, L("window","inactive","label","text","shadow","offset"),
817 theme->a_unfocused_label))
818 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x =
819 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = 0;
820 theme->a_unfocused_label->texture[0].data.text.shadow_color =
821 theme->title_unfocused_shadow_color;
822 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
823 theme->title_unfocused_shadow_alpha;
824
825 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
826 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
827 theme->a_menu_text_title->texture[0].data.text.font =
828 theme->menu_title_font;
829 theme->a_menu_text_title->texture[0].data.text.color =
830 theme->menu_title_color;
831
832 if (!FIND(shadow, L("menu","title","text","shadow","offset"),
833 theme->a_menu_text_title))
834 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x =
835 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = 0;
836 theme->a_menu_text_title->texture[0].data.text.shadow_color =
837 theme->menu_title_shadow_color;
838 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
839 theme->menu_title_shadow_alpha;
840
841 theme->a_menu_text_normal->texture[0].type =
842 theme->a_menu_text_selected->texture[0].type =
843 theme->a_menu_text_disabled->texture[0].type =
844 theme->a_menu_text_disabled_selected->texture[0].type =
845 RR_TEXTURE_TEXT;
846 theme->a_menu_text_normal->texture[0].data.text.justify =
847 theme->a_menu_text_selected->texture[0].data.text.justify =
848 theme->a_menu_text_disabled->texture[0].data.text.justify =
849 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
850 RR_JUSTIFY_LEFT;
851 theme->a_menu_text_normal->texture[0].data.text.font =
852 theme->a_menu_text_selected->texture[0].data.text.font =
853 theme->a_menu_text_disabled->texture[0].data.text.font =
854 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
855 theme->menu_font;
856 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
857 theme->a_menu_text_selected->texture[0].data.text.color =
858 theme->menu_selected_color;
859 theme->a_menu_text_disabled->texture[0].data.text.color =
860 theme->menu_disabled_color;
861 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
862 theme->menu_disabled_selected_color;
863
864 if (!FIND(shadow, L("menu","inactive","shadow","offset"),
865 theme->a_menu_text_normal))
866 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_x =
867 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y =
868 0;
869 if (!FIND(shadow, L("menu","active","text","shadow","offset"),
870 theme->a_menu_text_selected))
871 theme->a_menu_text_selected->texture[0].data.text.shadow_offset_x =
872 theme->a_menu_text_selected->texture[0].data.text.shadow_offset_y =
873 0;
874 if (!FIND(shadow, L("menu","disabled","shadow","offset"),
875 theme->a_menu_text_disabled))
876 theme->a_menu_text_disabled->texture[0].data.text.shadow_offset_x =
877 theme->a_menu_text_disabled->texture[0].data.text.shadow_offset_y =
878 0;
879 if (!FIND(shadow, L("menu","activedisabled","shadow","offset"),
880 theme->a_menu_text_disabled_selected))
881 theme->a_menu_text_disabled_selected->
882 texture[0].data.text.shadow_offset_x = 0;
883 theme->a_menu_text_disabled_selected->
884 texture[0].data.text.shadow_offset_y = 0;
885 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
886 theme->menu_text_normal_shadow_color;
887 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
888 theme->menu_text_normal_shadow_alpha;
889 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
890 theme->menu_text_selected_shadow_color;
891 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
892 theme->menu_text_selected_shadow_alpha;
893 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
894 theme->menu_text_disabled_shadow_color;
895 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
896 theme->menu_text_disabled_shadow_alpha;
897 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
898 theme->menu_text_disabled_selected_shadow_color;
899 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
900 theme->menu_text_disabled_selected_shadow_alpha;
901
902 theme->a_disabled_focused_max->texture[0].type =
903 theme->a_disabled_unfocused_max->texture[0].type =
904 theme->a_hover_focused_max->texture[0].type =
905 theme->a_hover_unfocused_max->texture[0].type =
906 theme->a_toggled_focused_pressed_max->texture[0].type =
907 theme->a_toggled_unfocused_pressed_max->texture[0].type =
908 theme->a_toggled_focused_unpressed_max->texture[0].type =
909 theme->a_toggled_unfocused_unpressed_max->texture[0].type =
910 theme->a_toggled_hover_focused_max->texture[0].type =
911 theme->a_toggled_hover_unfocused_max->texture[0].type =
912 theme->a_focused_unpressed_max->texture[0].type =
913 theme->a_focused_pressed_max->texture[0].type =
914 theme->a_unfocused_unpressed_max->texture[0].type =
915 theme->a_unfocused_pressed_max->texture[0].type =
916 theme->a_disabled_focused_close->texture[0].type =
917 theme->a_disabled_unfocused_close->texture[0].type =
918 theme->a_hover_focused_close->texture[0].type =
919 theme->a_hover_unfocused_close->texture[0].type =
920 theme->a_focused_unpressed_close->texture[0].type =
921 theme->a_focused_pressed_close->texture[0].type =
922 theme->a_unfocused_unpressed_close->texture[0].type =
923 theme->a_unfocused_pressed_close->texture[0].type =
924 theme->a_disabled_focused_desk->texture[0].type =
925 theme->a_disabled_unfocused_desk->texture[0].type =
926 theme->a_hover_focused_desk->texture[0].type =
927 theme->a_hover_unfocused_desk->texture[0].type =
928 theme->a_toggled_focused_pressed_desk->texture[0].type =
929 theme->a_toggled_unfocused_pressed_desk->texture[0].type =
930 theme->a_toggled_focused_unpressed_desk->texture[0].type =
931 theme->a_toggled_unfocused_unpressed_desk->texture[0].type =
932 theme->a_toggled_hover_focused_desk->texture[0].type =
933 theme->a_toggled_hover_unfocused_desk->texture[0].type =
934 theme->a_focused_unpressed_desk->texture[0].type =
935 theme->a_focused_pressed_desk->texture[0].type =
936 theme->a_unfocused_unpressed_desk->texture[0].type =
937 theme->a_unfocused_pressed_desk->texture[0].type =
938 theme->a_disabled_focused_shade->texture[0].type =
939 theme->a_disabled_unfocused_shade->texture[0].type =
940 theme->a_hover_focused_shade->texture[0].type =
941 theme->a_hover_unfocused_shade->texture[0].type =
942 theme->a_toggled_focused_pressed_shade->texture[0].type =
943 theme->a_toggled_unfocused_pressed_shade->texture[0].type =
944 theme->a_toggled_focused_unpressed_shade->texture[0].type =
945 theme->a_toggled_unfocused_unpressed_shade->texture[0].type =
946 theme->a_toggled_hover_focused_shade->texture[0].type =
947 theme->a_toggled_hover_unfocused_shade->texture[0].type =
948 theme->a_focused_unpressed_shade->texture[0].type =
949 theme->a_focused_pressed_shade->texture[0].type =
950 theme->a_unfocused_unpressed_shade->texture[0].type =
951 theme->a_unfocused_pressed_shade->texture[0].type =
952 theme->a_disabled_focused_iconify->texture[0].type =
953 theme->a_disabled_unfocused_iconify->texture[0].type =
954 theme->a_hover_focused_iconify->texture[0].type =
955 theme->a_hover_unfocused_iconify->texture[0].type =
956 theme->a_focused_unpressed_iconify->texture[0].type =
957 theme->a_focused_pressed_iconify->texture[0].type =
958 theme->a_unfocused_unpressed_iconify->texture[0].type =
959 theme->a_unfocused_pressed_iconify->texture[0].type =
960 theme->a_menu_bullet_normal->texture[0].type =
961 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
962
963 theme->a_disabled_focused_max->texture[0].data.mask.mask =
964 theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
965 theme->max_disabled_mask;
966 theme->a_hover_focused_max->texture[0].data.mask.mask =
967 theme->a_hover_unfocused_max->texture[0].data.mask.mask =
968 theme->max_hover_mask;
969 theme->a_focused_pressed_max->texture[0].data.mask.mask =
970 theme->a_unfocused_pressed_max->texture[0].data.mask.mask =
971 theme->max_pressed_mask;
972 theme->a_focused_unpressed_max->texture[0].data.mask.mask =
973 theme->a_unfocused_unpressed_max->texture[0].data.mask.mask =
974 theme->max_mask;
975 theme->a_toggled_focused_pressed_max->texture[0].data.mask.mask =
976 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.mask =
977 theme->max_toggled_pressed_mask;
978 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.mask =
979 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.mask =
980 theme->max_toggled_mask;
981 theme->a_toggled_hover_focused_max->texture[0].data.mask.mask =
982 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.mask =
983 theme->max_toggled_hover_mask;
984 theme->a_disabled_focused_close->texture[0].data.mask.mask =
985 theme->a_disabled_unfocused_close->texture[0].data.mask.mask =
986 theme->close_disabled_mask;
987 theme->a_hover_focused_close->texture[0].data.mask.mask =
988 theme->a_hover_unfocused_close->texture[0].data.mask.mask =
989 theme->close_hover_mask;
990 theme->a_focused_pressed_close->texture[0].data.mask.mask =
991 theme->a_unfocused_pressed_close->texture[0].data.mask.mask =
992 theme->close_pressed_mask;
993 theme->a_focused_unpressed_close->texture[0].data.mask.mask =
994 theme->a_unfocused_unpressed_close->texture[0].data.mask.mask =
995 theme->close_mask;
996 theme->a_disabled_focused_desk->texture[0].data.mask.mask =
997 theme->a_disabled_unfocused_desk->texture[0].data.mask.mask =
998 theme->desk_disabled_mask;
999 theme->a_hover_focused_desk->texture[0].data.mask.mask =
1000 theme->a_hover_unfocused_desk->texture[0].data.mask.mask =
1001 theme->desk_hover_mask;
1002 theme->a_focused_pressed_desk->texture[0].data.mask.mask =
1003 theme->a_unfocused_pressed_desk->texture[0].data.mask.mask =
1004 theme->desk_pressed_mask;
1005 theme->a_focused_unpressed_desk->texture[0].data.mask.mask =
1006 theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask =
1007 theme->desk_mask;
1008 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.mask =
1009 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.mask =
1010 theme->desk_toggled_pressed_mask;
1011 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.mask =
1012 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.mask =
1013 theme->desk_toggled_mask;
1014 theme->a_toggled_hover_focused_desk->texture[0].data.mask.mask =
1015 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.mask =
1016 theme->desk_toggled_hover_mask;
1017 theme->a_disabled_focused_shade->texture[0].data.mask.mask =
1018 theme->a_disabled_unfocused_shade->texture[0].data.mask.mask =
1019 theme->shade_disabled_mask;
1020 theme->a_hover_focused_shade->texture[0].data.mask.mask =
1021 theme->a_hover_unfocused_shade->texture[0].data.mask.mask =
1022 theme->shade_hover_mask;
1023 theme->a_focused_pressed_shade->texture[0].data.mask.mask =
1024 theme->a_unfocused_pressed_shade->texture[0].data.mask.mask =
1025 theme->shade_pressed_mask;
1026 theme->a_focused_unpressed_shade->texture[0].data.mask.mask =
1027 theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask =
1028 theme->shade_mask;
1029 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.mask =
1030 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.mask =
1031 theme->shade_toggled_pressed_mask;
1032 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.mask =
1033 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.mask =
1034 theme->shade_toggled_mask;
1035 theme->a_toggled_hover_focused_shade->texture[0].data.mask.mask =
1036 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.mask =
1037 theme->shade_toggled_hover_mask;
1038 theme->a_disabled_focused_iconify->texture[0].data.mask.mask =
1039 theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask =
1040 theme->iconify_disabled_mask;
1041 theme->a_hover_focused_iconify->texture[0].data.mask.mask =
1042 theme->a_hover_unfocused_iconify->texture[0].data.mask.mask =
1043 theme->iconify_hover_mask;
1044 theme->a_focused_pressed_iconify->texture[0].data.mask.mask =
1045 theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask =
1046 theme->iconify_pressed_mask;
1047 theme->a_focused_unpressed_iconify->texture[0].data.mask.mask =
1048 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask =
1049 theme->iconify_mask;
1050 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1051 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1052 theme->menu_bullet_mask;
1053 theme->a_disabled_focused_max->texture[0].data.mask.color =
1054 theme->a_disabled_focused_close->texture[0].data.mask.color =
1055 theme->a_disabled_focused_desk->texture[0].data.mask.color =
1056 theme->a_disabled_focused_shade->texture[0].data.mask.color =
1057 theme->a_disabled_focused_iconify->texture[0].data.mask.color =
1058 theme->titlebut_disabled_focused_color;
1059 theme->a_disabled_unfocused_max->texture[0].data.mask.color =
1060 theme->a_disabled_unfocused_close->texture[0].data.mask.color =
1061 theme->a_disabled_unfocused_desk->texture[0].data.mask.color =
1062 theme->a_disabled_unfocused_shade->texture[0].data.mask.color =
1063 theme->a_disabled_unfocused_iconify->texture[0].data.mask.color =
1064 theme->titlebut_disabled_unfocused_color;
1065 theme->a_hover_focused_max->texture[0].data.mask.color =
1066 theme->a_hover_focused_close->texture[0].data.mask.color =
1067 theme->a_hover_focused_desk->texture[0].data.mask.color =
1068 theme->a_hover_focused_shade->texture[0].data.mask.color =
1069 theme->a_hover_focused_iconify->texture[0].data.mask.color =
1070 theme->titlebut_hover_focused_color;
1071 theme->a_hover_unfocused_max->texture[0].data.mask.color =
1072 theme->a_hover_unfocused_close->texture[0].data.mask.color =
1073 theme->a_hover_unfocused_desk->texture[0].data.mask.color =
1074 theme->a_hover_unfocused_shade->texture[0].data.mask.color =
1075 theme->a_hover_unfocused_iconify->texture[0].data.mask.color =
1076 theme->titlebut_hover_unfocused_color;
1077 theme->a_toggled_hover_focused_max->texture[0].data.mask.color =
1078 theme->a_toggled_hover_focused_desk->texture[0].data.mask.color =
1079 theme->a_toggled_hover_focused_shade->texture[0].data.mask.color =
1080 theme->titlebut_toggled_hover_focused_color;
1081 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.color =
1082 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.color =
1083 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.color =
1084 theme->titlebut_toggled_hover_unfocused_color;
1085 theme->a_toggled_focused_pressed_max->texture[0].data.mask.color =
1086 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.color =
1087 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.color =
1088 theme->titlebut_toggled_focused_pressed_color;
1089 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.color =
1090 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.color =
1091 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.color =
1092 theme->titlebut_toggled_unfocused_pressed_color;
1093 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.color =
1094 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.color =
1095 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.color =
1096 theme->titlebut_toggled_focused_unpressed_color;
1097 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.color =
1098 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.color =
1099 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.color=
1100 theme->titlebut_toggled_unfocused_unpressed_color;
1101 theme->a_focused_unpressed_max->texture[0].data.mask.color =
1102 theme->a_focused_unpressed_close->texture[0].data.mask.color =
1103 theme->a_focused_unpressed_desk->texture[0].data.mask.color =
1104 theme->a_focused_unpressed_shade->texture[0].data.mask.color =
1105 theme->a_focused_unpressed_iconify->texture[0].data.mask.color =
1106 theme->titlebut_focused_unpressed_color;
1107 theme->a_focused_pressed_max->texture[0].data.mask.color =
1108 theme->a_focused_pressed_close->texture[0].data.mask.color =
1109 theme->a_focused_pressed_desk->texture[0].data.mask.color =
1110 theme->a_focused_pressed_shade->texture[0].data.mask.color =
1111 theme->a_focused_pressed_iconify->texture[0].data.mask.color =
1112 theme->titlebut_focused_pressed_color;
1113 theme->a_unfocused_unpressed_max->texture[0].data.mask.color =
1114 theme->a_unfocused_unpressed_close->texture[0].data.mask.color =
1115 theme->a_unfocused_unpressed_desk->texture[0].data.mask.color =
1116 theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
1117 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
1118 theme->titlebut_unfocused_unpressed_color;
1119 theme->a_unfocused_pressed_max->texture[0].data.mask.color =
1120 theme->a_unfocused_pressed_close->texture[0].data.mask.color =
1121 theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
1122 theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
1123 theme->a_unfocused_pressed_iconify->texture[0].data.mask.color =
1124 theme->titlebut_unfocused_pressed_color;
1125 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1126 theme->menu_color;
1127 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1128 theme->menu_selected_color;
1129
1130 g_free(ps.path);
1131 parse_close(ps.doc);
1132
1133 {
1134 gint ft, fb, fl, fr, ut, ub, ul, ur;
1135 RrAppearance *a, *b, *c, *d;
1136
1137 /* caluclate the font heights*/
1138 a = theme->a_focused_label;
1139 theme->win_font_height =
1140 RrFontHeight(theme->win_font_focused,
1141 a->texture[0].data.text.shadow_offset_y);
1142 a = theme->a_unfocused_label;
1143 theme->win_font_height =
1144 MAX(theme->win_font_height,
1145 RrFontHeight(theme->win_font_unfocused,
1146 a->texture[0].data.text.shadow_offset_y));
1147 a = theme->a_menu_text_title;
1148 theme->menu_title_font_height =
1149 RrFontHeight(theme->menu_title_font,
1150 a->texture[0].data.text.shadow_offset_y);
1151 a = theme->a_menu_text_normal;
1152 b = theme->a_menu_text_selected;
1153 c = theme->a_menu_text_disabled;
1154 d = theme->a_menu_text_disabled_selected;
1155 theme->menu_font_height =
1156 RrFontHeight(theme->menu_font,
1157 MAX(a->texture[0].data.text.shadow_offset_y,
1158 MAX(b->texture[0].data.text.shadow_offset_y,
1159 MAX(c->texture[0].data.text.shadow_offset_y,
1160 d->texture[0].data.text.shadow_offset_y
1161 ))));
1162
1163 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1164 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1165 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1166 theme->label_height += theme->label_height & 1;
1167
1168 /* this would be nice I think, since padding.width can now be 0,
1169 but it breaks frame.c horribly and I don't feel like fixing that
1170 right now, so if anyone complains, here is how to keep text from
1171 going over the title's bevel/border with a padding.width of 0 and a
1172 bevelless/borderless label
1173 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1174 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1175 theme->title_height = theme->label_height +
1176 MAX(MAX(theme->padding * 2, ft + fb),
1177 MAX(theme->padding * 2, ut + ub));
1178 */
1179 theme->title_height = theme->label_height + theme->paddingy * 2;
1180
1181 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1182 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1183 theme->menu_title_height = theme->menu_title_label_height +
1184 theme->paddingy * 2;
1185 }
1186 theme->button_size = theme->label_height - 2;
1187 theme->grip_width = 25;
1188
1189 return theme;
1190 }
1191
1192 void RrThemeFree(RrTheme *theme)
1193 {
1194 if (theme) {
1195 RrColorFree(theme->menu_border_color);
1196 RrColorFree(theme->frame_focused_border_color);
1197 RrColorFree(theme->frame_unfocused_border_color);
1198 RrColorFree(theme->cb_unfocused_color);
1199 RrColorFree(theme->cb_focused_color);
1200 RrColorFree(theme->title_focused_color);
1201 RrColorFree(theme->title_unfocused_color);
1202 RrColorFree(theme->titlebut_disabled_focused_color);
1203 RrColorFree(theme->titlebut_disabled_unfocused_color);
1204 RrColorFree(theme->titlebut_hover_focused_color);
1205 RrColorFree(theme->titlebut_hover_unfocused_color);
1206 RrColorFree(theme->titlebut_focused_pressed_color);
1207 RrColorFree(theme->titlebut_unfocused_pressed_color);
1208 RrColorFree(theme->titlebut_focused_unpressed_color);
1209 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1210 RrColorFree(theme->titlebut_toggled_hover_focused_color);
1211 RrColorFree(theme->titlebut_toggled_hover_unfocused_color);
1212 RrColorFree(theme->titlebut_toggled_focused_pressed_color);
1213 RrColorFree(theme->titlebut_toggled_unfocused_pressed_color);
1214 RrColorFree(theme->titlebut_toggled_focused_unpressed_color);
1215 RrColorFree(theme->titlebut_toggled_unfocused_unpressed_color);
1216 RrColorFree(theme->menu_title_color);
1217 RrColorFree(theme->menu_color);
1218 RrColorFree(theme->menu_selected_color);
1219 RrColorFree(theme->menu_disabled_color);
1220 RrColorFree(theme->menu_disabled_selected_color);
1221 RrColorFree(theme->title_focused_shadow_color);
1222 RrColorFree(theme->title_unfocused_shadow_color);
1223 RrColorFree(theme->osd_color);
1224 RrColorFree(theme->osd_shadow_color);
1225 RrColorFree(theme->menu_title_shadow_color);
1226 RrColorFree(theme->menu_text_normal_shadow_color);
1227 RrColorFree(theme->menu_text_selected_shadow_color);
1228 RrColorFree(theme->menu_text_disabled_shadow_color);
1229 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1230
1231 g_free(theme->def_win_icon);
1232
1233 RrPixmapMaskFree(theme->max_mask);
1234 RrPixmapMaskFree(theme->max_toggled_mask);
1235 RrPixmapMaskFree(theme->max_toggled_hover_mask);
1236 RrPixmapMaskFree(theme->max_toggled_pressed_mask);
1237 RrPixmapMaskFree(theme->max_disabled_mask);
1238 RrPixmapMaskFree(theme->max_hover_mask);
1239 RrPixmapMaskFree(theme->max_pressed_mask);
1240 RrPixmapMaskFree(theme->desk_mask);
1241 RrPixmapMaskFree(theme->desk_toggled_mask);
1242 RrPixmapMaskFree(theme->desk_toggled_hover_mask);
1243 RrPixmapMaskFree(theme->desk_toggled_pressed_mask);
1244 RrPixmapMaskFree(theme->desk_disabled_mask);
1245 RrPixmapMaskFree(theme->desk_hover_mask);
1246 RrPixmapMaskFree(theme->desk_pressed_mask);
1247 RrPixmapMaskFree(theme->shade_mask);
1248 RrPixmapMaskFree(theme->shade_toggled_mask);
1249 RrPixmapMaskFree(theme->shade_toggled_hover_mask);
1250 RrPixmapMaskFree(theme->shade_toggled_pressed_mask);
1251 RrPixmapMaskFree(theme->shade_disabled_mask);
1252 RrPixmapMaskFree(theme->shade_hover_mask);
1253 RrPixmapMaskFree(theme->shade_pressed_mask);
1254 RrPixmapMaskFree(theme->iconify_mask);
1255 RrPixmapMaskFree(theme->iconify_disabled_mask);
1256 RrPixmapMaskFree(theme->iconify_hover_mask);
1257 RrPixmapMaskFree(theme->iconify_pressed_mask);
1258 RrPixmapMaskFree(theme->close_mask);
1259 RrPixmapMaskFree(theme->close_disabled_mask);
1260 RrPixmapMaskFree(theme->close_hover_mask);
1261 RrPixmapMaskFree(theme->close_pressed_mask);
1262 RrPixmapMaskFree(theme->menu_bullet_mask);
1263
1264 RrFontClose(theme->win_font_focused);
1265 RrFontClose(theme->win_font_unfocused);
1266 RrFontClose(theme->menu_title_font);
1267 RrFontClose(theme->menu_font);
1268
1269 RrAppearanceFree(theme->a_disabled_focused_max);
1270 RrAppearanceFree(theme->a_disabled_unfocused_max);
1271 RrAppearanceFree(theme->a_hover_focused_max);
1272 RrAppearanceFree(theme->a_hover_unfocused_max);
1273 RrAppearanceFree(theme->a_focused_unpressed_max);
1274 RrAppearanceFree(theme->a_focused_pressed_max);
1275 RrAppearanceFree(theme->a_unfocused_unpressed_max);
1276 RrAppearanceFree(theme->a_unfocused_pressed_max);
1277 RrAppearanceFree(theme->a_toggled_hover_focused_max);
1278 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
1279 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
1280 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
1281 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
1282 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
1283 RrAppearanceFree(theme->a_disabled_focused_close);
1284 RrAppearanceFree(theme->a_disabled_unfocused_close);
1285 RrAppearanceFree(theme->a_hover_focused_close);
1286 RrAppearanceFree(theme->a_hover_unfocused_close);
1287 RrAppearanceFree(theme->a_focused_unpressed_close);
1288 RrAppearanceFree(theme->a_focused_pressed_close);
1289 RrAppearanceFree(theme->a_unfocused_unpressed_close);
1290 RrAppearanceFree(theme->a_unfocused_pressed_close);
1291 RrAppearanceFree(theme->a_disabled_focused_desk);
1292 RrAppearanceFree(theme->a_disabled_unfocused_desk);
1293 RrAppearanceFree(theme->a_hover_focused_desk);
1294 RrAppearanceFree(theme->a_hover_unfocused_desk);
1295 RrAppearanceFree(theme->a_focused_unpressed_desk);
1296 RrAppearanceFree(theme->a_focused_pressed_desk);
1297 RrAppearanceFree(theme->a_unfocused_unpressed_desk);
1298 RrAppearanceFree(theme->a_unfocused_pressed_desk);
1299 RrAppearanceFree(theme->a_toggled_hover_focused_desk);
1300 RrAppearanceFree(theme->a_toggled_hover_unfocused_desk);
1301 RrAppearanceFree(theme->a_toggled_focused_unpressed_desk);
1302 RrAppearanceFree(theme->a_toggled_focused_pressed_desk);
1303 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_desk);
1304 RrAppearanceFree(theme->a_toggled_unfocused_pressed_desk);
1305 RrAppearanceFree(theme->a_disabled_focused_shade);
1306 RrAppearanceFree(theme->a_disabled_unfocused_shade);
1307 RrAppearanceFree(theme->a_hover_focused_shade);
1308 RrAppearanceFree(theme->a_hover_unfocused_shade);
1309 RrAppearanceFree(theme->a_focused_unpressed_shade);
1310 RrAppearanceFree(theme->a_focused_pressed_shade);
1311 RrAppearanceFree(theme->a_unfocused_unpressed_shade);
1312 RrAppearanceFree(theme->a_unfocused_pressed_shade);
1313 RrAppearanceFree(theme->a_toggled_hover_focused_shade);
1314 RrAppearanceFree(theme->a_toggled_hover_unfocused_shade);
1315 RrAppearanceFree(theme->a_toggled_focused_unpressed_shade);
1316 RrAppearanceFree(theme->a_toggled_focused_pressed_shade);
1317 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_shade);
1318 RrAppearanceFree(theme->a_toggled_unfocused_pressed_shade);
1319 RrAppearanceFree(theme->a_disabled_focused_iconify);
1320 RrAppearanceFree(theme->a_disabled_unfocused_iconify);
1321 RrAppearanceFree(theme->a_hover_focused_iconify);
1322 RrAppearanceFree(theme->a_hover_unfocused_iconify);
1323 RrAppearanceFree(theme->a_focused_unpressed_iconify);
1324 RrAppearanceFree(theme->a_focused_pressed_iconify);
1325 RrAppearanceFree(theme->a_unfocused_unpressed_iconify);
1326 RrAppearanceFree(theme->a_unfocused_pressed_iconify);
1327 RrAppearanceFree(theme->a_focused_grip);
1328 RrAppearanceFree(theme->a_unfocused_grip);
1329 RrAppearanceFree(theme->a_focused_title);
1330 RrAppearanceFree(theme->a_unfocused_title);
1331 RrAppearanceFree(theme->a_focused_label);
1332 RrAppearanceFree(theme->a_unfocused_label);
1333 RrAppearanceFree(theme->a_icon);
1334 RrAppearanceFree(theme->a_focused_handle);
1335 RrAppearanceFree(theme->a_unfocused_handle);
1336 RrAppearanceFree(theme->a_menu);
1337 RrAppearanceFree(theme->a_menu_title);
1338 RrAppearanceFree(theme->a_menu_text_title);
1339 RrAppearanceFree(theme->a_menu_normal);
1340 RrAppearanceFree(theme->a_menu_selected);
1341 RrAppearanceFree(theme->a_menu_disabled);
1342 RrAppearanceFree(theme->a_menu_disabled_selected);
1343 RrAppearanceFree(theme->a_menu_text_normal);
1344 RrAppearanceFree(theme->a_menu_text_selected);
1345 RrAppearanceFree(theme->a_menu_text_disabled);
1346 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1347 RrAppearanceFree(theme->a_menu_bullet_normal);
1348 RrAppearanceFree(theme->a_menu_bullet_selected);
1349 RrAppearanceFree(theme->a_clear);
1350 RrAppearanceFree(theme->a_clear_tex);
1351 RrAppearanceFree(theme->osd_hilite_bg);
1352 RrAppearanceFree(theme->osd_hilite_fg);
1353 RrAppearanceFree(theme->osd_hilite_label);
1354 RrAppearanceFree(theme->osd_unhilite_fg);
1355
1356 g_free(theme);
1357 }
1358 }
1359
1360 static gboolean read_mask(ParseState *ps, const gchar *maskname,
1361 RrPixmapMask **value)
1362 {
1363 gboolean ret = FALSE;
1364 gchar *s;
1365 gint hx, hy; /* ignored */
1366 guint w, h;
1367 guchar *b;
1368
1369 s = g_build_filename(ps->path, maskname, NULL);
1370 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1371 ret = TRUE;
1372 *value = RrPixmapMaskNew(ps->inst, w, h, (gchar*)b);
1373 XFree(b);
1374 }
1375 g_free(s);
1376
1377 return ret;
1378 }
1379
1380 static void set_default_appearance(RrAppearance *a)
1381 {
1382 a->surface.grad = RR_SURFACE_SOLID;
1383 a->surface.relief = RR_RELIEF_FLAT;
1384 a->surface.bevel = RR_BEVEL_1;
1385 a->surface.interlaced = FALSE;
1386 a->surface.border = FALSE;
1387 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1388 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
1389 }
1390
1391 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1392 an RrTextureRGBA. */
1393 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
1394 {
1395 RrPixel32 *im, *p;
1396 gint i;
1397
1398 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
1399
1400 for (i = 0; i < width * height; ++i) {
1401 guchar a = ((*p >> 24) & 0xff);
1402 guchar b = ((*p >> 16) & 0xff);
1403 guchar g = ((*p >> 8) & 0xff);
1404 guchar r = ((*p >> 0) & 0xff);
1405
1406 *p = ((r << RrDefaultRedOffset) +
1407 (g << RrDefaultGreenOffset) +
1408 (b << RrDefaultBlueOffset) +
1409 (a << RrDefaultAlphaOffset));
1410 p++;
1411 }
1412
1413 return im;
1414 }
1415
1416 static void parse_style(gchar *tex, RrSurfaceColorType *grad,
1417 RrReliefType *relief, RrBevelType *bevel,
1418 gboolean *interlaced, gboolean *border,
1419 gboolean allow_trans)
1420 {
1421 gchar *t;
1422
1423 /* convert to all lowercase */
1424 for (t = tex; *t != '\0'; ++t)
1425 *t = g_ascii_tolower(*t);
1426
1427 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1428 *grad = RR_SURFACE_PARENTREL;
1429 } else {
1430 if (strstr(tex, "gradient") != NULL) {
1431 if (strstr(tex, "crossdiagonal") != NULL)
1432 *grad = RR_SURFACE_CROSS_DIAGONAL;
1433 else if (strstr(tex, "pyramid") != NULL)
1434 *grad = RR_SURFACE_PYRAMID;
1435 else if (strstr(tex, "mirrorhorizontal") != NULL)
1436 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1437 else if (strstr(tex, "horizontal") != NULL)
1438 *grad = RR_SURFACE_HORIZONTAL;
1439 else if (strstr(tex, "splitvertical") != NULL)
1440 *grad = RR_SURFACE_SPLIT_VERTICAL;
1441 else if (strstr(tex, "vertical") != NULL)
1442 *grad = RR_SURFACE_VERTICAL;
1443 else
1444 *grad = RR_SURFACE_DIAGONAL;
1445 } else {
1446 *grad = RR_SURFACE_SOLID;
1447 }
1448
1449 if (strstr(tex, "sunken") != NULL)
1450 *relief = RR_RELIEF_SUNKEN;
1451 else if (strstr(tex, "flat") != NULL)
1452 *relief = RR_RELIEF_FLAT;
1453 else
1454 *relief = RR_RELIEF_RAISED;
1455
1456 *border = FALSE;
1457 if (*relief == RR_RELIEF_FLAT) {
1458 if (strstr(tex, "border") != NULL)
1459 *border = TRUE;
1460 } else {
1461 if (strstr(tex, "bevel2") != NULL)
1462 *bevel = RR_BEVEL_2;
1463 else
1464 *bevel = RR_BEVEL_1;
1465 }
1466
1467 if (strstr(tex, "interlaced") != NULL)
1468 *interlaced = TRUE;
1469 else
1470 *interlaced = FALSE;
1471 }
1472 }
1473
1474 static xmlNodePtr find_node(xmlNodePtr n, const gchar *names[])
1475 {
1476 gint i;
1477
1478 for (i = 0; names[i] && n; ++i)
1479 n = parse_find_node(names[i], n->children);
1480 return n;
1481 }
1482
1483 static gboolean find_int(ParseState *ps, xmlNodePtr n, const gchar *names[],
1484 gint *integer, gint lower, gint upper)
1485 {
1486 gint i;
1487
1488 if ((n = find_node(n, names))) {
1489 i = parse_int(ps->doc, n);
1490 if (i >= lower && i <= upper) {
1491 *integer = i;
1492 return TRUE;
1493 }
1494 }
1495 return FALSE;
1496 }
1497
1498 static gboolean find_string(ParseState *ps, xmlNodePtr n, const gchar *names[],
1499 gchar **string)
1500 {
1501 if ((n = find_node(n, names))) {
1502 *string = parse_string(ps->doc, n);
1503 return TRUE;
1504 }
1505 return FALSE;
1506 }
1507
1508 static gboolean find_color(ParseState *ps, xmlNodePtr n, const gchar *names[],
1509 RrColor **color, gchar *alpha)
1510 {
1511 if ((n = find_node(n, names))) {
1512 int r,g,b,a;
1513 if (parse_attr_int("r", n, &r) &&
1514 parse_attr_int("g", n, &g) &&
1515 parse_attr_int("b", n, &b) &&
1516 parse_attr_int("a", n, &a) &&
1517 r >= 0 && g >= 0 && b >= 0 && a >= 0 &&
1518 r < 256 && g < 256 && b < 256 && a < 256)
1519 {
1520 *color = RrColorNew(ps->inst, r, g, b);
1521 if (alpha) *alpha = a;
1522 return TRUE;
1523 }
1524 }
1525 return FALSE;
1526 }
1527
1528 static gboolean find_point(ParseState *ps, xmlNodePtr n, const gchar *names[],
1529 gint *x, gint *y,
1530 gint lowx, gint upx, gint lowy, gint upy)
1531 {
1532 if ((n = find_node(n, names))) {
1533 gint a, b;
1534 if (parse_attr_int("x", n, &a) &&
1535 parse_attr_int("y", n, &b) &&
1536 a >= lowx && a <= upx && b >= lowy && b <= upy)
1537 {
1538 *x = a; *y = b;
1539 return TRUE;
1540 }
1541 }
1542 return FALSE;
1543 }
1544
1545 static gboolean find_shadow(ParseState *ps, xmlNodePtr n, const gchar *names[],
1546 RrAppearance *a)
1547 {
1548 return find_point(ps, n, names,
1549 &a->texture[0].data.text.shadow_offset_x,
1550 &a->texture[0].data.text.shadow_offset_y,
1551 -20, 20, -20, 20);
1552 }
1553
1554 static gboolean find_appearance(ParseState *ps, xmlNodePtr n, const gchar *names[],
1555 RrAppearance *a, gboolean allow_trans)
1556 {
1557 xmlNodePtr n2;
1558
1559 if (!(n = find_node(n, names)))
1560 return FALSE;
1561
1562 if ((n2 = find_node(n, L("style")))) {
1563 gchar *s = parse_string(ps->doc, n2);
1564 parse_style(s, &a->surface.grad, &a->surface.relief,
1565 &a->surface.bevel, &a->surface.interlaced,
1566 &a->surface.border, allow_trans);
1567 g_free(s);
1568 } else
1569 return FALSE;
1570
1571 if (!find_color(ps, n, L("primary"), &a->surface.primary, NULL))
1572 a->surface.primary = RrColorNew(ps->inst, 0, 0, 0);
1573 if (!find_color(ps, n, L("secondary"), &a->surface.secondary, NULL))
1574 a->surface.secondary = RrColorNew(ps->inst, 0, 0, 0);
1575 if (a->surface.border)
1576 if (!find_color(ps, n, L("border"),
1577 &a->surface.border_color, NULL))
1578 a->surface.border_color = RrColorNew(ps->inst, 0, 0, 0);
1579 if (a->surface.interlaced)
1580 if (!find_color(ps, n, L("interlace"),
1581 &a->surface.interlace_color, NULL))
1582 a->surface.interlace_color = RrColorNew(ps->inst, 0, 0, 0);
1583
1584 return TRUE;
1585 }
This page took 0.124521 seconds and 3 git commands to generate.