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