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