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