1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 theme.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
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.
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.
17 See the COPYING file for a copy of the GNU General Public License.
26 #include "parser/parse.h"
29 #include <X11/Xresource.h>
34 static XrmDatabase loaddb(const gchar *name, gchar **path);
35 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value);
36 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value);
37 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
38 const gchar *rname, RrColor **value);
39 static gboolean read_mask(const RrInstance *inst, const gchar *path,
40 RrTheme *theme, const gchar *maskname,
41 RrPixmapMask **value);
42 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
43 const gchar *rname, RrAppearance *value,
44 gboolean allow_trans);
45 static int parse_inline_number(const char *p);
46 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data);
47 static void set_default_appearance(RrAppearance *a);
49 #define READ_INT(x_resstr, x_var, x_min, x_max, x_def) \
50 if (!read_int(db, x_resstr, & x_var) || \
51 x_var < x_min || x_var > x_max) \
54 #define READ_COLOR(x_resstr, x_var, x_def) \
55 if (!read_color(db, inst, x_resstr, & x_var)) \
58 #define READ_COLOR_(x_res1, x_res2, x_var, x_def) \
59 if (!read_color(db, inst, x_res1, & x_var) && \
60 !read_color(db, inst, x_res2, & x_var)) \
63 #define READ_MASK_COPY(x_file, x_var, x_copysrc) \
64 if (!read_mask(inst, path, theme, x_file, & x_var)) \
65 x_var = RrPixmapMaskCopy(x_copysrc);
67 #define READ_APPEARANCE(x_resstr, x_var, x_parrel) \
68 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) \
69 set_default_appearance(x_var);
71 #define READ_APPEARANCE_COPY(x_resstr, x_var, x_parrel, x_defval) \
72 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) {\
73 RrAppearanceFree(x_var); \
74 x_var = RrAppearanceCopy(x_defval); }
76 #define READ_APPEARANCE_(x_res1, x_res2, x_var, x_parrel, x_defval) \
77 if (!read_appearance(db, inst, x_res1, x_var, x_parrel) && \
78 !read_appearance(db, inst, x_res2, x_var, x_parrel)) {\
79 RrAppearanceFree(x_var); \
80 x_var = RrAppearanceCopy(x_defval); }
82 RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
83 gboolean allow_fallback,
84 RrFont *active_window_font, RrFont *inactive_window_font,
85 RrFont *menu_title_font, RrFont *menu_item_font,
88 XrmDatabase db = NULL;
89 RrJustify winjust, mtitlejust;
96 db = loaddb(name, &path);
98 g_message("Unable to load the theme '%s'", name);
100 g_message("Falling back to the default theme '%s'",
102 /* fallback to the default theme */
107 if (allow_fallback) {
108 db = loaddb(DEFAULT_THEME, &path);
110 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
117 theme = g_new0(RrTheme, 1);
120 theme->name = g_strdup(name ? name : DEFAULT_THEME);
122 theme->a_disabled_focused_max = RrAppearanceNew(inst, 1);
123 theme->a_disabled_unfocused_max = RrAppearanceNew(inst, 1);
124 theme->a_hover_focused_max = RrAppearanceNew(inst, 1);
125 theme->a_hover_unfocused_max = RrAppearanceNew(inst, 1);
126 theme->a_toggled_focused_unpressed_max = RrAppearanceNew(inst, 1);
127 theme->a_toggled_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
128 theme->a_toggled_hover_focused_max = RrAppearanceNew(inst, 1);
129 theme->a_toggled_hover_unfocused_max = RrAppearanceNew(inst, 1);
130 theme->a_toggled_focused_pressed_max = RrAppearanceNew(inst, 1);
131 theme->a_toggled_unfocused_pressed_max = RrAppearanceNew(inst, 1);
132 theme->a_focused_unpressed_max = RrAppearanceNew(inst, 1);
133 theme->a_focused_pressed_max = RrAppearanceNew(inst, 1);
134 theme->a_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
135 theme->a_unfocused_pressed_max = RrAppearanceNew(inst, 1);
136 theme->a_focused_grip = RrAppearanceNew(inst, 0);
137 theme->a_unfocused_grip = RrAppearanceNew(inst, 0);
138 theme->a_focused_title = RrAppearanceNew(inst, 0);
139 theme->a_unfocused_title = RrAppearanceNew(inst, 0);
140 theme->a_focused_label = RrAppearanceNew(inst, 1);
141 theme->a_unfocused_label = RrAppearanceNew(inst, 1);
142 theme->a_icon = RrAppearanceNew(inst, 1);
143 theme->a_focused_handle = RrAppearanceNew(inst, 0);
144 theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
145 theme->a_menu = RrAppearanceNew(inst, 0);
146 theme->a_menu_title = RrAppearanceNew(inst, 0);
147 theme->a_menu_text_title = RrAppearanceNew(inst, 1);
148 theme->a_menu_normal = RrAppearanceNew(inst, 0);
149 theme->a_menu_selected = RrAppearanceNew(inst, 0);
150 theme->a_menu_disabled = RrAppearanceNew(inst, 0);
151 /* a_menu_disabled_selected is copied from a_menu_selected */
152 theme->a_menu_text_normal = RrAppearanceNew(inst, 1);
153 theme->a_menu_text_selected = RrAppearanceNew(inst, 1);
154 theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
155 theme->a_menu_text_disabled_selected = RrAppearanceNew(inst, 1);
156 theme->a_menu_bullet_normal = RrAppearanceNew(inst, 1);
157 theme->a_menu_bullet_selected = RrAppearanceNew(inst, 1);
158 theme->a_clear = RrAppearanceNew(inst, 0);
159 theme->a_clear_tex = RrAppearanceNew(inst, 1);
160 theme->osd_hilite_bg = RrAppearanceNew(inst, 0);
161 theme->osd_hilite_label = RrAppearanceNew(inst, 1);
162 theme->osd_hilite_fg = RrAppearanceNew(inst, 0);
163 theme->osd_unhilite_fg = RrAppearanceNew(inst, 0);
165 /* load the font stuff */
166 if (active_window_font) {
167 theme->win_font_focused = active_window_font;
168 RrFontRef(active_window_font);
170 theme->win_font_focused = RrFontOpenDefault(inst);
172 if (inactive_window_font) {
173 theme->win_font_unfocused = inactive_window_font;
174 RrFontRef(inactive_window_font);
176 theme->win_font_unfocused = RrFontOpenDefault(inst);
178 winjust = RR_JUSTIFY_LEFT;
179 if (read_string(db, "window.label.text.justify", &str)) {
180 if (!g_ascii_strcasecmp(str, "right"))
181 winjust = RR_JUSTIFY_RIGHT;
182 else if (!g_ascii_strcasecmp(str, "center"))
183 winjust = RR_JUSTIFY_CENTER;
186 if (menu_title_font) {
187 theme->menu_title_font = menu_title_font;
188 RrFontRef(menu_title_font);
190 theme->menu_title_font = RrFontOpenDefault(inst);
192 mtitlejust = RR_JUSTIFY_LEFT;
193 if (read_string(db, "menu.title.text.justify", &str)) {
194 if (!g_ascii_strcasecmp(str, "right"))
195 mtitlejust = RR_JUSTIFY_RIGHT;
196 else if (!g_ascii_strcasecmp(str, "center"))
197 mtitlejust = RR_JUSTIFY_CENTER;
200 if (menu_item_font) {
201 theme->menu_font = menu_item_font;
202 RrFontRef(menu_item_font);
204 theme->menu_font = RrFontOpenDefault(inst);
207 theme->osd_font = osd_font;
210 theme->osd_font = RrFontOpenDefault(inst);
212 /* load direct dimensions */
213 READ_INT("menu.overlap", theme->menu_overlap, -100, 100, 0);
214 READ_INT("window.handle.width", theme->handle_height, 0, 100, 6);
215 READ_INT("padding.width", theme->paddingx, 0, 100, 3);
216 READ_INT("padding.height", theme->paddingy, 0, 100, theme->paddingx);
217 READ_INT("border.width", theme->fbwidth, 0, 100, 1);
218 READ_INT("menu.border.width", theme->mbwidth, 0, 100, theme->fbwidth);
219 READ_INT("osd.border.width", theme->obwidth, 0, 100, theme->fbwidth);
220 READ_INT("window.client.padding.width", theme->cbwidthx, 0, 100,
222 READ_INT("window.client.padding.height", theme->cbwidthy, 0, 100,
226 READ_COLOR_("window.active.border.color", "border.color",
227 theme->frame_focused_border_color, RrColorNew(inst, 0, 0, 0));
229 /* title separator focused color inherits from focused boder color */
230 READ_COLOR("window.active.title.separator.color",
231 theme->title_separator_focused_color,
232 RrColorCopy(theme->frame_focused_border_color));
234 /* unfocused border color inherits from frame focused border color */
235 READ_COLOR("window.inactive.border.color",
236 theme->frame_unfocused_border_color,
237 RrColorCopy(theme->frame_focused_border_color));
239 /* title separator unfocused color inherits from unfocused boder color */
240 READ_COLOR("window.inactive.title.separator.color",
241 theme->title_separator_unfocused_color,
242 RrColorCopy(theme->frame_unfocused_border_color));
244 /* menu border color inherits from frame focused border color */
245 READ_COLOR("menu.border.color", theme->menu_border_color,
246 RrColorCopy(theme->frame_focused_border_color));
248 /* osd border color inherits from frame focused border color */
249 READ_COLOR("osd.border.color", theme->osd_border_color,
250 RrColorCopy(theme->frame_focused_border_color));
252 READ_COLOR("window.active.client.color", theme->cb_focused_color,
253 RrColorNew(inst, 0xff, 0xff, 0xff));
255 READ_COLOR("window.inactive.client.color", theme->cb_unfocused_color,
256 RrColorNew(inst, 0xff, 0xff, 0xff));
258 READ_COLOR("window.active.label.text.color", theme->title_focused_color,
259 RrColorNew(inst, 0x0, 0x0, 0x0));
261 READ_COLOR("osd.label.text.color", theme->osd_color,
262 RrColorCopy(theme->title_focused_color));
264 READ_COLOR("window.inactive.label.text.color",
265 theme->title_unfocused_color,
266 RrColorNew(inst, 0xff, 0xff, 0xff));
268 READ_COLOR("window.active.button.unpressed.image.color",
269 theme->titlebut_focused_unpressed_color,
270 RrColorNew(inst, 0, 0, 0));
272 READ_COLOR("window.inactive.button.unpressed.image.color",
273 theme->titlebut_unfocused_unpressed_color,
274 RrColorNew(inst, 0xff, 0xff, 0xff));
276 READ_COLOR("window.active.button.pressed.image.color",
277 theme->titlebut_focused_pressed_color,
278 RrColorCopy(theme->titlebut_focused_unpressed_color));
280 READ_COLOR("window.inactive.button.pressed.image.color",
281 theme->titlebut_unfocused_pressed_color,
282 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
284 READ_COLOR("window.active.button.disabled.image.color",
285 theme->titlebut_disabled_focused_color,
286 RrColorNew(inst, 0xff, 0xff, 0xff));
288 READ_COLOR("window.inactive.button.disabled.image.color",
289 theme->titlebut_disabled_unfocused_color,
290 RrColorNew(inst, 0, 0, 0));
292 READ_COLOR("window.active.button.hover.image.color",
293 theme->titlebut_hover_focused_color,
294 RrColorCopy(theme->titlebut_focused_unpressed_color));
296 READ_COLOR("window.inactive.button.hover.image.color",
297 theme->titlebut_hover_unfocused_color,
298 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
300 READ_COLOR_("window.active.button.toggled.unpressed.image.color",
301 "window.active.button.toggled.image.color",
302 theme->titlebut_toggled_focused_unpressed_color,
303 RrColorCopy(theme->titlebut_focused_pressed_color));
305 READ_COLOR_("window.inactive.button.toggled.unpressed.image.color",
306 "window.inactive.button.toggled.image.color",
307 theme->titlebut_toggled_unfocused_unpressed_color,
308 RrColorCopy(theme->titlebut_unfocused_pressed_color));
310 READ_COLOR("window.active.button.toggled.hover.image.color",
311 theme->titlebut_toggled_hover_focused_color,
312 RrColorCopy(theme->titlebut_toggled_focused_unpressed_color));
314 READ_COLOR("window.inactive.button.toggled.hover.image.color",
315 theme->titlebut_toggled_hover_unfocused_color,
316 RrColorCopy(theme->titlebut_toggled_unfocused_unpressed_color));
318 READ_COLOR("window.active.button.toggled.pressed.image.color",
319 theme->titlebut_toggled_focused_pressed_color,
320 RrColorCopy(theme->titlebut_focused_pressed_color));
322 READ_COLOR("window.inactive.button.toggled.pressed.image.color",
323 theme->titlebut_toggled_unfocused_pressed_color,
324 RrColorCopy(theme->titlebut_unfocused_pressed_color));
326 READ_COLOR("menu.title.text.color", theme->menu_title_color,
327 RrColorNew(inst, 0, 0, 0));
329 READ_COLOR("menu.items.text.color", theme->menu_color,
330 RrColorNew(inst, 0xff, 0xff, 0xff));
332 READ_COLOR("menu.items.disabled.text.color", theme->menu_disabled_color,
333 RrColorNew(inst, 0, 0, 0));
335 READ_COLOR("menu.items.active.disabled.text.color",
336 theme->menu_disabled_selected_color,
337 RrColorCopy(theme->menu_disabled_color));
339 READ_COLOR("menu.items.active.text.color", theme->menu_selected_color,
340 RrColorNew(inst, 0, 0, 0));
343 /* load the image masks */
345 /* maximize button masks */
347 if (!read_mask(inst, path, theme, "max.xbm", &theme->max_mask)) {
348 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
349 theme->max_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
352 if (!read_mask(inst, path, theme, "max_toggled.xbm",
353 &theme->max_toggled_mask))
356 theme->max_toggled_mask = RrPixmapMaskCopy(theme->max_mask);
358 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
359 theme->max_toggled_mask = RrPixmapMaskNew(inst, 6, 6,(gchar*)data);
362 READ_MASK_COPY("max_pressed.xbm", theme->max_pressed_mask,
364 READ_MASK_COPY("max_disabled.xbm", theme->max_disabled_mask,
366 READ_MASK_COPY("max_hover.xbm", theme->max_hover_mask, theme->max_mask);
367 READ_MASK_COPY("max_toggled_pressed.xbm", theme->max_toggled_pressed_mask,
368 theme->max_toggled_mask);
369 READ_MASK_COPY("max_toggled_hover.xbm", theme->max_toggled_hover_mask,
370 theme->max_toggled_mask);
372 /* iconify button masks */
373 if (!read_mask(inst, path, theme, "iconify.xbm", &theme->iconify_mask)) {
374 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
375 theme->iconify_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
377 READ_MASK_COPY("iconify_pressed.xbm", theme->iconify_pressed_mask,
378 theme->iconify_mask);
379 READ_MASK_COPY("iconify_disabled.xbm", theme->iconify_disabled_mask,
380 theme->iconify_mask);
381 READ_MASK_COPY("iconify_hover.xbm", theme->iconify_hover_mask,
382 theme->iconify_mask);
384 /* all desktops button masks */
386 if (!read_mask(inst, path, theme, "desk.xbm", &theme->desk_mask)) {
387 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
388 theme->desk_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
391 if (!read_mask(inst, path, theme, "desk_toggled.xbm",
392 &theme->desk_toggled_mask)) {
394 theme->desk_toggled_mask = RrPixmapMaskCopy(theme->desk_mask);
396 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
397 theme->desk_toggled_mask =
398 RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
401 READ_MASK_COPY("desk_pressed.xbm", theme->desk_pressed_mask,
403 READ_MASK_COPY("desk_disabled.xbm", theme->desk_disabled_mask,
405 READ_MASK_COPY("desk_hover.xbm", theme->desk_hover_mask, theme->desk_mask);
406 READ_MASK_COPY("desk_toggled_pressed.xbm",
407 theme->desk_toggled_pressed_mask, theme->desk_toggled_mask);
408 READ_MASK_COPY("desk_toggled_hover.xbm", theme->desk_toggled_hover_mask,
409 theme->desk_toggled_mask);
411 /* shade button masks */
412 if (!read_mask(inst, path, theme, "shade.xbm", &theme->shade_mask)) {
413 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
414 theme->shade_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
416 READ_MASK_COPY("shade_toggled.xbm", theme->shade_toggled_mask,
418 READ_MASK_COPY("shade_pressed.xbm", theme->shade_pressed_mask,
420 READ_MASK_COPY("shade_disabled.xbm", theme->shade_disabled_mask,
422 READ_MASK_COPY("shade_hover.xbm", theme->shade_hover_mask,
424 READ_MASK_COPY("shade_toggled_pressed.xbm",
425 theme->shade_toggled_pressed_mask,
426 theme->shade_toggled_mask);
427 READ_MASK_COPY("shade_toggled_hover.xbm",
428 theme->shade_toggled_hover_mask, theme->shade_toggled_mask);
430 /* close button masks */
431 if (!read_mask(inst, path, theme, "close.xbm", &theme->close_mask)) {
432 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
433 theme->close_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
435 READ_MASK_COPY("close_pressed.xbm", theme->close_pressed_mask,
437 READ_MASK_COPY("close_disabled.xbm", theme->close_disabled_mask,
439 READ_MASK_COPY("close_hover.xbm", theme->close_hover_mask,
442 /* submenu bullet mask */
443 if (!read_mask(inst, path, theme, "bullet.xbm", &theme->menu_bullet_mask))
445 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
446 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
449 /* setup the default window icon */
450 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
451 OB_DEFAULT_ICON_HEIGHT,
452 OB_DEFAULT_ICON_pixel_data);
454 /* read the decoration textures */
455 READ_APPEARANCE("window.active.title.bg", theme->a_focused_title, FALSE);
456 READ_APPEARANCE("window.inactive.title.bg", theme->a_unfocused_title,
458 READ_APPEARANCE("window.active.label.bg", theme->a_focused_label, TRUE);
459 READ_APPEARANCE("window.inactive.label.bg", theme->a_unfocused_label,
461 READ_APPEARANCE("window.active.handle.bg", theme->a_focused_handle, FALSE);
462 READ_APPEARANCE("window.inactive.handle.bg",theme->a_unfocused_handle,
464 READ_APPEARANCE("window.active.grip.bg", theme->a_focused_grip, TRUE);
465 READ_APPEARANCE("window.inactive.grip.bg", theme->a_unfocused_grip, TRUE);
466 READ_APPEARANCE("menu.items.bg", theme->a_menu, FALSE);
467 READ_APPEARANCE("menu.title.bg", theme->a_menu_title, TRUE);
468 READ_APPEARANCE("menu.items.active.bg", theme->a_menu_selected, TRUE);
470 theme->a_menu_disabled_selected =
471 RrAppearanceCopy(theme->a_menu_selected);
473 /* read appearances for non-decorations (on-screen-display) */
474 if (!read_appearance(db, inst, "osd.bg", theme->osd_hilite_bg, FALSE)) {
475 RrAppearanceFree(theme->osd_hilite_bg);
476 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
478 if (!read_appearance(db, inst, "osd.label.bg",
479 theme->osd_hilite_label, TRUE)) {
480 RrAppearanceFree(theme->osd_hilite_label);
481 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
483 /* osd_hilite_fg can't be parentrel */
484 if (!read_appearance(db, inst, "osd.hilight.bg",
485 theme->osd_hilite_fg, FALSE)) {
486 RrAppearanceFree(theme->osd_hilite_fg);
487 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
488 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_label);
490 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_title);
492 /* osd_unhilite_fg can't be parentrel either */
493 if (!read_appearance(db, inst, "osd.unhilight.bg",
494 theme->osd_unhilite_fg, FALSE)) {
495 RrAppearanceFree(theme->osd_unhilite_fg);
496 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
497 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_label);
499 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_title);
502 /* read buttons textures */
503 READ_APPEARANCE("window.active.button.disabled.bg",
504 theme->a_disabled_focused_max, TRUE);
505 READ_APPEARANCE("window.inactive.button.disabled.bg",
506 theme->a_disabled_unfocused_max, TRUE);
507 READ_APPEARANCE("window.active.button.pressed.bg",
508 theme->a_focused_pressed_max, TRUE);
509 READ_APPEARANCE("window.inactive.button.pressed.bg",
510 theme->a_unfocused_pressed_max, TRUE);
512 READ_APPEARANCE_("window.active.button.toggled.unpressed.bg",
513 "window.active.button.toggled.bg",
514 theme->a_toggled_focused_unpressed_max, TRUE,
515 theme->a_focused_pressed_max);
516 READ_APPEARANCE_("window.inactive.button.toggled.unpressed.bg",
517 "window.inactive.button.toggled.bg",
518 theme->a_toggled_unfocused_unpressed_max, TRUE,
519 theme->a_unfocused_pressed_max);
521 READ_APPEARANCE_COPY("window.active.button.toggled.hover.bg",
522 theme->a_toggled_hover_focused_max, TRUE,
523 theme->a_toggled_focused_unpressed_max);
524 READ_APPEARANCE_COPY("window.inactive.button.toggled.hover.bg",
525 theme->a_toggled_hover_unfocused_max, TRUE,
526 theme->a_toggled_unfocused_unpressed_max);
528 READ_APPEARANCE_COPY("window.active.button.toggled.pressed.bg",
529 theme->a_toggled_focused_pressed_max, TRUE,
530 theme->a_focused_pressed_max);
531 READ_APPEARANCE_COPY("window.inactive.button.toggled.pressed.bg",
532 theme->a_toggled_unfocused_pressed_max, TRUE,
533 theme->a_unfocused_pressed_max);
535 READ_APPEARANCE("window.active.button.unpressed.bg",
536 theme->a_focused_unpressed_max, TRUE);
537 READ_APPEARANCE("window.inactive.button.unpressed.bg",
538 theme->a_unfocused_unpressed_max, TRUE);
540 READ_APPEARANCE_COPY("window.active.button.hover.bg",
541 theme->a_hover_focused_max, TRUE,
542 theme->a_focused_unpressed_max);
543 READ_APPEARANCE_COPY("window.inactive.button.hover.bg",
544 theme->a_hover_unfocused_max, TRUE,
545 theme->a_unfocused_unpressed_max);
547 theme->a_disabled_focused_close =
548 RrAppearanceCopy(theme->a_disabled_focused_max);
549 theme->a_disabled_unfocused_close =
550 RrAppearanceCopy(theme->a_disabled_unfocused_max);
551 theme->a_hover_focused_close =
552 RrAppearanceCopy(theme->a_hover_focused_max);
553 theme->a_hover_unfocused_close =
554 RrAppearanceCopy(theme->a_hover_unfocused_max);
555 theme->a_unfocused_unpressed_close =
556 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
557 theme->a_unfocused_pressed_close =
558 RrAppearanceCopy(theme->a_unfocused_pressed_max);
559 theme->a_focused_unpressed_close =
560 RrAppearanceCopy(theme->a_focused_unpressed_max);
561 theme->a_focused_pressed_close =
562 RrAppearanceCopy(theme->a_focused_pressed_max);
563 theme->a_disabled_focused_desk =
564 RrAppearanceCopy(theme->a_disabled_focused_max);
565 theme->a_disabled_unfocused_desk =
566 RrAppearanceCopy(theme->a_disabled_unfocused_max);
567 theme->a_hover_focused_desk =
568 RrAppearanceCopy(theme->a_hover_focused_max);
569 theme->a_hover_unfocused_desk =
570 RrAppearanceCopy(theme->a_hover_unfocused_max);
571 theme->a_toggled_hover_focused_desk =
572 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
573 theme->a_toggled_hover_unfocused_desk =
574 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
575 theme->a_toggled_focused_unpressed_desk =
576 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
577 theme->a_toggled_unfocused_unpressed_desk =
578 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
579 theme->a_toggled_focused_pressed_desk =
580 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
581 theme->a_toggled_unfocused_pressed_desk =
582 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
583 theme->a_unfocused_unpressed_desk =
584 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
585 theme->a_unfocused_pressed_desk =
586 RrAppearanceCopy(theme->a_unfocused_pressed_max);
587 theme->a_focused_unpressed_desk =
588 RrAppearanceCopy(theme->a_focused_unpressed_max);
589 theme->a_focused_pressed_desk =
590 RrAppearanceCopy(theme->a_focused_pressed_max);
591 theme->a_disabled_focused_shade =
592 RrAppearanceCopy(theme->a_disabled_focused_max);
593 theme->a_disabled_unfocused_shade =
594 RrAppearanceCopy(theme->a_disabled_unfocused_max);
595 theme->a_hover_focused_shade =
596 RrAppearanceCopy(theme->a_hover_focused_max);
597 theme->a_hover_unfocused_shade =
598 RrAppearanceCopy(theme->a_hover_unfocused_max);
599 theme->a_toggled_hover_focused_shade =
600 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
601 theme->a_toggled_hover_unfocused_shade =
602 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
603 theme->a_toggled_focused_unpressed_shade =
604 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
605 theme->a_toggled_unfocused_unpressed_shade =
606 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
607 theme->a_toggled_focused_pressed_shade =
608 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
609 theme->a_toggled_unfocused_pressed_shade =
610 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
611 theme->a_unfocused_unpressed_shade =
612 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
613 theme->a_unfocused_pressed_shade =
614 RrAppearanceCopy(theme->a_unfocused_pressed_max);
615 theme->a_focused_unpressed_shade =
616 RrAppearanceCopy(theme->a_focused_unpressed_max);
617 theme->a_focused_pressed_shade =
618 RrAppearanceCopy(theme->a_focused_pressed_max);
619 theme->a_disabled_focused_iconify =
620 RrAppearanceCopy(theme->a_disabled_focused_max);
621 theme->a_disabled_unfocused_iconify =
622 RrAppearanceCopy(theme->a_disabled_focused_max);
623 theme->a_hover_focused_iconify =
624 RrAppearanceCopy(theme->a_hover_focused_max);
625 theme->a_hover_unfocused_iconify =
626 RrAppearanceCopy(theme->a_hover_unfocused_max);
627 theme->a_unfocused_unpressed_iconify =
628 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
629 theme->a_unfocused_pressed_iconify =
630 RrAppearanceCopy(theme->a_unfocused_pressed_max);
631 theme->a_focused_unpressed_iconify =
632 RrAppearanceCopy(theme->a_focused_unpressed_max);
633 theme->a_focused_pressed_iconify =
634 RrAppearanceCopy(theme->a_focused_pressed_max);
636 theme->a_icon->surface.grad =
637 theme->a_clear->surface.grad =
638 theme->a_clear_tex->surface.grad =
639 theme->a_menu_text_title->surface.grad =
640 theme->a_menu_normal->surface.grad =
641 theme->a_menu_disabled->surface.grad =
642 theme->a_menu_text_normal->surface.grad =
643 theme->a_menu_text_selected->surface.grad =
644 theme->a_menu_text_disabled->surface.grad =
645 theme->a_menu_text_disabled_selected->surface.grad =
646 theme->a_menu_bullet_normal->surface.grad =
647 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
649 /* set up the textures */
650 theme->a_focused_label->texture[0].type = RR_TEXTURE_TEXT;
651 theme->a_focused_label->texture[0].data.text.justify = winjust;
652 theme->a_focused_label->texture[0].data.text.font=theme->win_font_focused;
653 theme->a_focused_label->texture[0].data.text.color =
654 theme->title_focused_color;
656 if (read_string(db, "window.active.label.text.font", &str)) {
660 if (strstr(str, "shadow=y")) {
661 if ((p = strstr(str, "shadowoffset=")))
662 i = parse_inline_number(p + strlen("shadowoffset="));
665 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
666 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
668 if ((p = strstr(str, "shadowtint=")))
670 i = parse_inline_number(p + strlen("shadowtint="));
671 j = (i > 0 ? 0 : 255);
674 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
675 theme->title_focused_shadow_alpha = i;
677 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
678 theme->title_focused_shadow_alpha = 50;
682 theme->a_focused_label->texture[0].data.text.shadow_color =
683 theme->title_focused_shadow_color;
684 theme->a_focused_label->texture[0].data.text.shadow_alpha =
685 theme->title_focused_shadow_alpha;
687 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
688 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
689 theme->osd_hilite_label->texture[0].data.text.font = theme->osd_font;
690 theme->osd_hilite_label->texture[0].data.text.color = theme->osd_color;
692 if (read_string(db, "osd.label.text.font", &str)) {
696 if (strstr(str, "shadow=y")) {
697 if ((p = strstr(str, "shadowoffset=")))
698 i = parse_inline_number(p + strlen("shadowoffset="));
701 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
702 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
703 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
704 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
706 if ((p = strstr(str, "shadowtint=")))
708 i = parse_inline_number(p + strlen("shadowtint="));
709 j = (i > 0 ? 0 : 255);
712 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
713 theme->title_focused_shadow_alpha = i;
714 theme->osd_shadow_color = RrColorNew(inst, j, j, j);
715 theme->osd_shadow_alpha = i;
717 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
718 theme->title_focused_shadow_alpha = 50;
719 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
720 theme->osd_shadow_alpha = 50;
723 /* inherit the font settings from the focused label */
724 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x =
725 theme->a_focused_label->texture[0].data.text.shadow_offset_x;
726 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y =
727 theme->a_focused_label->texture[0].data.text.shadow_offset_y;
728 if (theme->title_focused_shadow_color)
729 theme->osd_shadow_color =
731 theme->title_focused_shadow_color->r,
732 theme->title_focused_shadow_color->g,
733 theme->title_focused_shadow_color->b);
735 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
736 theme->osd_shadow_alpha = theme->title_focused_shadow_alpha;
739 theme->osd_hilite_label->texture[0].data.text.shadow_color =
740 theme->osd_shadow_color;
741 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
742 theme->osd_shadow_alpha;
744 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
745 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
746 theme->a_unfocused_label->texture[0].data.text.font =
747 theme->win_font_unfocused;
748 theme->a_unfocused_label->texture[0].data.text.color =
749 theme->title_unfocused_color;
751 if (read_string(db, "window.inactive.label.text.font", &str)) {
755 if (strstr(str, "shadow=y")) {
756 if ((p = strstr(str, "shadowoffset=")))
757 i = parse_inline_number(p + strlen("shadowoffset="));
760 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
761 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
763 if ((p = strstr(str, "shadowtint=")))
765 i = parse_inline_number(p + strlen("shadowtint="));
766 j = (i > 0 ? 0 : 255);
769 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
770 theme->title_unfocused_shadow_alpha = i;
772 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
773 theme->title_unfocused_shadow_alpha = 50;
777 theme->a_unfocused_label->texture[0].data.text.shadow_color =
778 theme->title_unfocused_shadow_color;
779 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
780 theme->title_unfocused_shadow_alpha;
782 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
783 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
784 theme->a_menu_text_title->texture[0].data.text.font =
785 theme->menu_title_font;
786 theme->a_menu_text_title->texture[0].data.text.color =
787 theme->menu_title_color;
789 if (read_string(db, "menu.title.text.font", &str)) {
793 if (strstr(str, "shadow=y")) {
794 if ((p = strstr(str, "shadowoffset=")))
795 i = parse_inline_number(p + strlen("shadowoffset="));
798 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
799 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
801 if ((p = strstr(str, "shadowtint=")))
803 i = parse_inline_number(p + strlen("shadowtint="));
804 j = (i > 0 ? 0 : 255);
807 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
808 theme->menu_title_shadow_alpha = i;
810 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
811 theme->menu_title_shadow_alpha = 50;
815 theme->a_menu_text_title->texture[0].data.text.shadow_color =
816 theme->menu_title_shadow_color;
817 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
818 theme->menu_title_shadow_alpha;
820 theme->a_menu_text_normal->texture[0].type =
821 theme->a_menu_text_selected->texture[0].type =
822 theme->a_menu_text_disabled->texture[0].type =
823 theme->a_menu_text_disabled_selected->texture[0].type =
825 theme->a_menu_text_normal->texture[0].data.text.justify =
826 theme->a_menu_text_selected->texture[0].data.text.justify =
827 theme->a_menu_text_disabled->texture[0].data.text.justify =
828 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
830 theme->a_menu_text_normal->texture[0].data.text.font =
831 theme->a_menu_text_selected->texture[0].data.text.font =
832 theme->a_menu_text_disabled->texture[0].data.text.font =
833 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
835 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
836 theme->a_menu_text_selected->texture[0].data.text.color =
837 theme->menu_selected_color;
838 theme->a_menu_text_disabled->texture[0].data.text.color =
839 theme->menu_disabled_color;
840 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
841 theme->menu_disabled_selected_color;
843 if (read_string(db, "menu.items.font", &str)) {
847 if (strstr(str, "shadow=y")) {
848 if ((p = strstr(str, "shadowoffset=")))
849 i = parse_inline_number(p + strlen("shadowoffset="));
852 theme->a_menu_text_normal->
853 texture[0].data.text.shadow_offset_x = i;
854 theme->a_menu_text_normal->
855 texture[0].data.text.shadow_offset_y = i;
856 theme->a_menu_text_selected->
857 texture[0].data.text.shadow_offset_x = i;
858 theme->a_menu_text_selected->
859 texture[0].data.text.shadow_offset_y = i;
860 theme->a_menu_text_disabled->
861 texture[0].data.text.shadow_offset_x = i;
862 theme->a_menu_text_disabled->
863 texture[0].data.text.shadow_offset_y = i;
864 theme->a_menu_text_disabled_selected->
865 texture[0].data.text.shadow_offset_x = i;
866 theme->a_menu_text_disabled_selected->
867 texture[0].data.text.shadow_offset_y = i;
869 if ((p = strstr(str, "shadowtint=")))
871 i = parse_inline_number(p + strlen("shadowtint="));
872 j = (i > 0 ? 0 : 255);
875 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
876 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
877 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
878 theme->menu_text_normal_shadow_alpha = i;
879 theme->menu_text_selected_shadow_alpha = i;
880 theme->menu_text_disabled_shadow_alpha = i;
881 theme->menu_text_disabled_selected_shadow_alpha = i;
883 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
884 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
885 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
886 theme->menu_text_normal_shadow_alpha = 50;
887 theme->menu_text_selected_shadow_alpha = 50;
888 theme->menu_text_disabled_selected_shadow_alpha = 50;
892 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
893 theme->menu_text_normal_shadow_color;
894 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
895 theme->menu_text_normal_shadow_alpha;
896 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
897 theme->menu_text_selected_shadow_color;
898 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
899 theme->menu_text_selected_shadow_alpha;
900 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
901 theme->menu_text_disabled_shadow_color;
902 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
903 theme->menu_text_disabled_shadow_alpha;
904 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
905 theme->menu_text_disabled_shadow_color;
906 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
907 theme->menu_text_disabled_shadow_alpha;
909 theme->a_disabled_focused_max->texture[0].type =
910 theme->a_disabled_unfocused_max->texture[0].type =
911 theme->a_hover_focused_max->texture[0].type =
912 theme->a_hover_unfocused_max->texture[0].type =
913 theme->a_toggled_hover_focused_max->texture[0].type =
914 theme->a_toggled_hover_unfocused_max->texture[0].type =
915 theme->a_toggled_focused_unpressed_max->texture[0].type =
916 theme->a_toggled_unfocused_unpressed_max->texture[0].type =
917 theme->a_toggled_focused_pressed_max->texture[0].type =
918 theme->a_toggled_unfocused_pressed_max->texture[0].type =
919 theme->a_focused_unpressed_max->texture[0].type =
920 theme->a_focused_pressed_max->texture[0].type =
921 theme->a_unfocused_unpressed_max->texture[0].type =
922 theme->a_unfocused_pressed_max->texture[0].type =
923 theme->a_disabled_focused_close->texture[0].type =
924 theme->a_disabled_unfocused_close->texture[0].type =
925 theme->a_hover_focused_close->texture[0].type =
926 theme->a_hover_unfocused_close->texture[0].type =
927 theme->a_focused_unpressed_close->texture[0].type =
928 theme->a_focused_pressed_close->texture[0].type =
929 theme->a_unfocused_unpressed_close->texture[0].type =
930 theme->a_unfocused_pressed_close->texture[0].type =
931 theme->a_disabled_focused_desk->texture[0].type =
932 theme->a_disabled_unfocused_desk->texture[0].type =
933 theme->a_hover_focused_desk->texture[0].type =
934 theme->a_hover_unfocused_desk->texture[0].type =
935 theme->a_toggled_hover_focused_desk->texture[0].type =
936 theme->a_toggled_hover_unfocused_desk->texture[0].type =
937 theme->a_toggled_focused_unpressed_desk->texture[0].type =
938 theme->a_toggled_unfocused_unpressed_desk->texture[0].type =
939 theme->a_toggled_focused_pressed_desk->texture[0].type =
940 theme->a_toggled_unfocused_pressed_desk->texture[0].type =
941 theme->a_focused_unpressed_desk->texture[0].type =
942 theme->a_focused_pressed_desk->texture[0].type =
943 theme->a_unfocused_unpressed_desk->texture[0].type =
944 theme->a_unfocused_pressed_desk->texture[0].type =
945 theme->a_disabled_focused_shade->texture[0].type =
946 theme->a_disabled_unfocused_shade->texture[0].type =
947 theme->a_hover_focused_shade->texture[0].type =
948 theme->a_hover_unfocused_shade->texture[0].type =
949 theme->a_toggled_hover_focused_shade->texture[0].type =
950 theme->a_toggled_hover_unfocused_shade->texture[0].type =
951 theme->a_toggled_focused_unpressed_shade->texture[0].type =
952 theme->a_toggled_unfocused_unpressed_shade->texture[0].type =
953 theme->a_toggled_focused_pressed_shade->texture[0].type =
954 theme->a_toggled_unfocused_pressed_shade->texture[0].type =
955 theme->a_focused_unpressed_shade->texture[0].type =
956 theme->a_focused_pressed_shade->texture[0].type =
957 theme->a_unfocused_unpressed_shade->texture[0].type =
958 theme->a_unfocused_pressed_shade->texture[0].type =
959 theme->a_disabled_focused_iconify->texture[0].type =
960 theme->a_disabled_unfocused_iconify->texture[0].type =
961 theme->a_hover_focused_iconify->texture[0].type =
962 theme->a_hover_unfocused_iconify->texture[0].type =
963 theme->a_focused_unpressed_iconify->texture[0].type =
964 theme->a_focused_pressed_iconify->texture[0].type =
965 theme->a_unfocused_unpressed_iconify->texture[0].type =
966 theme->a_unfocused_pressed_iconify->texture[0].type =
967 theme->a_menu_bullet_normal->texture[0].type =
968 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
970 theme->a_disabled_focused_max->texture[0].data.mask.mask =
971 theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
972 theme->max_disabled_mask;
973 theme->a_hover_focused_max->texture[0].data.mask.mask =
974 theme->a_hover_unfocused_max->texture[0].data.mask.mask =
975 theme->max_hover_mask;
976 theme->a_focused_pressed_max->texture[0].data.mask.mask =
977 theme->a_unfocused_pressed_max->texture[0].data.mask.mask =
978 theme->max_pressed_mask;
979 theme->a_focused_unpressed_max->texture[0].data.mask.mask =
980 theme->a_unfocused_unpressed_max->texture[0].data.mask.mask =
982 theme->a_toggled_hover_focused_max->texture[0].data.mask.mask =
983 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.mask =
984 theme->max_toggled_hover_mask;
985 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.mask =
986 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.mask =
987 theme->max_toggled_mask;
988 theme->a_toggled_focused_pressed_max->texture[0].data.mask.mask =
989 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.mask =
990 theme->max_toggled_pressed_mask;
991 theme->a_disabled_focused_close->texture[0].data.mask.mask =
992 theme->a_disabled_unfocused_close->texture[0].data.mask.mask =
993 theme->close_disabled_mask;
994 theme->a_hover_focused_close->texture[0].data.mask.mask =
995 theme->a_hover_unfocused_close->texture[0].data.mask.mask =
996 theme->close_hover_mask;
997 theme->a_focused_pressed_close->texture[0].data.mask.mask =
998 theme->a_unfocused_pressed_close->texture[0].data.mask.mask =
999 theme->close_pressed_mask;
1000 theme->a_focused_unpressed_close->texture[0].data.mask.mask =
1001 theme->a_unfocused_unpressed_close->texture[0].data.mask.mask =
1003 theme->a_disabled_focused_desk->texture[0].data.mask.mask =
1004 theme->a_disabled_unfocused_desk->texture[0].data.mask.mask =
1005 theme->desk_disabled_mask;
1006 theme->a_hover_focused_desk->texture[0].data.mask.mask =
1007 theme->a_hover_unfocused_desk->texture[0].data.mask.mask =
1008 theme->desk_hover_mask;
1009 theme->a_focused_pressed_desk->texture[0].data.mask.mask =
1010 theme->a_unfocused_pressed_desk->texture[0].data.mask.mask =
1011 theme->desk_pressed_mask;
1012 theme->a_focused_unpressed_desk->texture[0].data.mask.mask =
1013 theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask =
1015 theme->a_toggled_hover_focused_desk->texture[0].data.mask.mask =
1016 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.mask =
1017 theme->desk_toggled_hover_mask;
1018 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.mask =
1019 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.mask =
1020 theme->desk_toggled_mask;
1021 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.mask =
1022 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.mask =
1023 theme->desk_toggled_pressed_mask;
1024 theme->a_disabled_focused_shade->texture[0].data.mask.mask =
1025 theme->a_disabled_unfocused_shade->texture[0].data.mask.mask =
1026 theme->shade_disabled_mask;
1027 theme->a_hover_focused_shade->texture[0].data.mask.mask =
1028 theme->a_hover_unfocused_shade->texture[0].data.mask.mask =
1029 theme->shade_hover_mask;
1030 theme->a_focused_pressed_shade->texture[0].data.mask.mask =
1031 theme->a_unfocused_pressed_shade->texture[0].data.mask.mask =
1032 theme->shade_pressed_mask;
1033 theme->a_focused_unpressed_shade->texture[0].data.mask.mask =
1034 theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask =
1036 theme->a_toggled_hover_focused_shade->texture[0].data.mask.mask =
1037 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.mask =
1038 theme->shade_toggled_hover_mask;
1039 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.mask =
1040 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.mask =
1041 theme->shade_toggled_mask;
1042 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.mask =
1043 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.mask =
1044 theme->shade_toggled_pressed_mask;
1045 theme->a_disabled_focused_iconify->texture[0].data.mask.mask =
1046 theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask =
1047 theme->iconify_disabled_mask;
1048 theme->a_hover_focused_iconify->texture[0].data.mask.mask =
1049 theme->a_hover_unfocused_iconify->texture[0].data.mask.mask =
1050 theme->iconify_hover_mask;
1051 theme->a_focused_pressed_iconify->texture[0].data.mask.mask =
1052 theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask =
1053 theme->iconify_pressed_mask;
1054 theme->a_focused_unpressed_iconify->texture[0].data.mask.mask =
1055 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask =
1056 theme->iconify_mask;
1057 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1058 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1059 theme->menu_bullet_mask;
1060 theme->a_disabled_focused_max->texture[0].data.mask.color =
1061 theme->a_disabled_focused_close->texture[0].data.mask.color =
1062 theme->a_disabled_focused_desk->texture[0].data.mask.color =
1063 theme->a_disabled_focused_shade->texture[0].data.mask.color =
1064 theme->a_disabled_focused_iconify->texture[0].data.mask.color =
1065 theme->titlebut_disabled_focused_color;
1066 theme->a_disabled_unfocused_max->texture[0].data.mask.color =
1067 theme->a_disabled_unfocused_close->texture[0].data.mask.color =
1068 theme->a_disabled_unfocused_desk->texture[0].data.mask.color =
1069 theme->a_disabled_unfocused_shade->texture[0].data.mask.color =
1070 theme->a_disabled_unfocused_iconify->texture[0].data.mask.color =
1071 theme->titlebut_disabled_unfocused_color;
1072 theme->a_hover_focused_max->texture[0].data.mask.color =
1073 theme->a_hover_focused_close->texture[0].data.mask.color =
1074 theme->a_hover_focused_desk->texture[0].data.mask.color =
1075 theme->a_hover_focused_shade->texture[0].data.mask.color =
1076 theme->a_hover_focused_iconify->texture[0].data.mask.color =
1077 theme->titlebut_hover_focused_color;
1078 theme->a_hover_unfocused_max->texture[0].data.mask.color =
1079 theme->a_hover_unfocused_close->texture[0].data.mask.color =
1080 theme->a_hover_unfocused_desk->texture[0].data.mask.color =
1081 theme->a_hover_unfocused_shade->texture[0].data.mask.color =
1082 theme->a_hover_unfocused_iconify->texture[0].data.mask.color =
1083 theme->titlebut_hover_unfocused_color;
1084 theme->a_toggled_hover_focused_max->texture[0].data.mask.color =
1085 theme->a_toggled_hover_focused_desk->texture[0].data.mask.color =
1086 theme->a_toggled_hover_focused_shade->texture[0].data.mask.color =
1087 theme->titlebut_toggled_hover_focused_color;
1088 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.color =
1089 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.color =
1090 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.color =
1091 theme->titlebut_toggled_hover_unfocused_color;
1092 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.color =
1093 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.color =
1094 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.color =
1095 theme->titlebut_toggled_focused_unpressed_color;
1096 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.color =
1097 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.color =
1098 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.color=
1099 theme->titlebut_toggled_unfocused_unpressed_color;
1100 theme->a_toggled_focused_pressed_max->texture[0].data.mask.color =
1101 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.color =
1102 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.color =
1103 theme->titlebut_toggled_focused_pressed_color;
1104 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.color =
1105 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.color =
1106 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.color =
1107 theme->titlebut_toggled_unfocused_pressed_color;
1108 theme->a_focused_unpressed_max->texture[0].data.mask.color =
1109 theme->a_focused_unpressed_close->texture[0].data.mask.color =
1110 theme->a_focused_unpressed_desk->texture[0].data.mask.color =
1111 theme->a_focused_unpressed_shade->texture[0].data.mask.color =
1112 theme->a_focused_unpressed_iconify->texture[0].data.mask.color =
1113 theme->titlebut_focused_unpressed_color;
1114 theme->a_focused_pressed_max->texture[0].data.mask.color =
1115 theme->a_focused_pressed_close->texture[0].data.mask.color =
1116 theme->a_focused_pressed_desk->texture[0].data.mask.color =
1117 theme->a_focused_pressed_shade->texture[0].data.mask.color =
1118 theme->a_focused_pressed_iconify->texture[0].data.mask.color =
1119 theme->titlebut_focused_pressed_color;
1120 theme->a_unfocused_unpressed_max->texture[0].data.mask.color =
1121 theme->a_unfocused_unpressed_close->texture[0].data.mask.color =
1122 theme->a_unfocused_unpressed_desk->texture[0].data.mask.color =
1123 theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
1124 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
1125 theme->titlebut_unfocused_unpressed_color;
1126 theme->a_unfocused_pressed_max->texture[0].data.mask.color =
1127 theme->a_unfocused_pressed_close->texture[0].data.mask.color =
1128 theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
1129 theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
1130 theme->a_unfocused_pressed_iconify->texture[0].data.mask.color =
1131 theme->titlebut_unfocused_pressed_color;
1132 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1134 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1135 theme->menu_selected_color;
1138 XrmDestroyDatabase(db);
1140 /* set the font heights */
1141 theme->win_font_height = RrFontHeight
1142 (theme->win_font_focused,
1143 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1144 theme->win_font_height =
1145 MAX(theme->win_font_height,
1147 (theme->win_font_focused,
1148 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1149 theme->menu_title_font_height = RrFontHeight
1150 (theme->menu_title_font,
1151 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1152 theme->menu_font_height = RrFontHeight
1154 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1156 /* calculate some last extents */
1158 gint ft, fb, fl, fr, ut, ub, ul, ur;
1160 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1161 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1162 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1163 theme->label_height += theme->label_height % 2;
1165 /* this would be nice I think, since padding.width can now be 0,
1166 but it breaks frame.c horribly and I don't feel like fixing that
1167 right now, so if anyone complains, here is how to keep text from
1168 going over the title's bevel/border with a padding.width of 0 and a
1169 bevelless/borderless label
1170 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1171 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1172 theme->title_height = theme->label_height +
1173 MAX(MAX(theme->padding * 2, ft + fb),
1174 MAX(theme->padding * 2, ut + ub));
1176 theme->title_height = theme->label_height + theme->paddingy * 2;
1178 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1179 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1180 theme->menu_title_height = theme->menu_title_label_height +
1181 theme->paddingy * 2;
1183 theme->button_size = theme->label_height - 2;
1184 theme->grip_width = 25;
1189 void RrThemeFree(RrTheme *theme)
1192 g_free(theme->name);
1194 RrColorFree(theme->menu_border_color);
1195 RrColorFree(theme->osd_border_color);
1196 RrColorFree(theme->frame_focused_border_color);
1197 RrColorFree(theme->frame_unfocused_border_color);
1198 RrColorFree(theme->title_separator_focused_color);
1199 RrColorFree(theme->title_separator_unfocused_color);
1200 RrColorFree(theme->cb_unfocused_color);
1201 RrColorFree(theme->cb_focused_color);
1202 RrColorFree(theme->title_focused_color);
1203 RrColorFree(theme->title_unfocused_color);
1204 RrColorFree(theme->titlebut_disabled_focused_color);
1205 RrColorFree(theme->titlebut_disabled_unfocused_color);
1206 RrColorFree(theme->titlebut_hover_focused_color);
1207 RrColorFree(theme->titlebut_hover_unfocused_color);
1208 RrColorFree(theme->titlebut_toggled_hover_focused_color);
1209 RrColorFree(theme->titlebut_toggled_hover_unfocused_color);
1210 RrColorFree(theme->titlebut_toggled_focused_pressed_color);
1211 RrColorFree(theme->titlebut_toggled_unfocused_pressed_color);
1212 RrColorFree(theme->titlebut_toggled_focused_unpressed_color);
1213 RrColorFree(theme->titlebut_toggled_unfocused_unpressed_color);
1214 RrColorFree(theme->titlebut_focused_pressed_color);
1215 RrColorFree(theme->titlebut_unfocused_pressed_color);
1216 RrColorFree(theme->titlebut_focused_unpressed_color);
1217 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1218 RrColorFree(theme->menu_title_color);
1219 RrColorFree(theme->menu_color);
1220 RrColorFree(theme->menu_selected_color);
1221 RrColorFree(theme->menu_disabled_color);
1222 RrColorFree(theme->menu_disabled_selected_color);
1223 RrColorFree(theme->title_focused_shadow_color);
1224 RrColorFree(theme->title_unfocused_shadow_color);
1225 RrColorFree(theme->osd_color);
1226 RrColorFree(theme->osd_shadow_color);
1227 RrColorFree(theme->menu_title_shadow_color);
1228 RrColorFree(theme->menu_text_normal_shadow_color);
1229 RrColorFree(theme->menu_text_selected_shadow_color);
1230 RrColorFree(theme->menu_text_disabled_shadow_color);
1231 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1233 g_free(theme->def_win_icon);
1235 RrPixmapMaskFree(theme->max_mask);
1236 RrPixmapMaskFree(theme->max_toggled_mask);
1237 RrPixmapMaskFree(theme->max_toggled_hover_mask);
1238 RrPixmapMaskFree(theme->max_toggled_pressed_mask);
1239 RrPixmapMaskFree(theme->max_disabled_mask);
1240 RrPixmapMaskFree(theme->max_hover_mask);
1241 RrPixmapMaskFree(theme->max_pressed_mask);
1242 RrPixmapMaskFree(theme->desk_mask);
1243 RrPixmapMaskFree(theme->desk_toggled_mask);
1244 RrPixmapMaskFree(theme->desk_toggled_hover_mask);
1245 RrPixmapMaskFree(theme->desk_toggled_pressed_mask);
1246 RrPixmapMaskFree(theme->desk_disabled_mask);
1247 RrPixmapMaskFree(theme->desk_hover_mask);
1248 RrPixmapMaskFree(theme->desk_pressed_mask);
1249 RrPixmapMaskFree(theme->shade_mask);
1250 RrPixmapMaskFree(theme->shade_toggled_mask);
1251 RrPixmapMaskFree(theme->shade_toggled_hover_mask);
1252 RrPixmapMaskFree(theme->shade_toggled_pressed_mask);
1253 RrPixmapMaskFree(theme->shade_disabled_mask);
1254 RrPixmapMaskFree(theme->shade_hover_mask);
1255 RrPixmapMaskFree(theme->shade_pressed_mask);
1256 RrPixmapMaskFree(theme->iconify_mask);
1257 RrPixmapMaskFree(theme->iconify_disabled_mask);
1258 RrPixmapMaskFree(theme->iconify_hover_mask);
1259 RrPixmapMaskFree(theme->iconify_pressed_mask);
1260 RrPixmapMaskFree(theme->close_mask);
1261 RrPixmapMaskFree(theme->close_disabled_mask);
1262 RrPixmapMaskFree(theme->close_hover_mask);
1263 RrPixmapMaskFree(theme->close_pressed_mask);
1264 RrPixmapMaskFree(theme->menu_bullet_mask);
1266 RrFontClose(theme->win_font_focused);
1267 RrFontClose(theme->win_font_unfocused);
1268 RrFontClose(theme->menu_title_font);
1269 RrFontClose(theme->menu_font);
1271 RrAppearanceFree(theme->a_disabled_focused_max);
1272 RrAppearanceFree(theme->a_disabled_unfocused_max);
1273 RrAppearanceFree(theme->a_hover_focused_max);
1274 RrAppearanceFree(theme->a_hover_unfocused_max);
1275 RrAppearanceFree(theme->a_toggled_hover_focused_max);
1276 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
1277 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
1278 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
1279 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
1280 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
1281 RrAppearanceFree(theme->a_focused_unpressed_max);
1282 RrAppearanceFree(theme->a_focused_pressed_max);
1283 RrAppearanceFree(theme->a_unfocused_unpressed_max);
1284 RrAppearanceFree(theme->a_unfocused_pressed_max);
1285 RrAppearanceFree(theme->a_disabled_focused_close);
1286 RrAppearanceFree(theme->a_disabled_unfocused_close);
1287 RrAppearanceFree(theme->a_hover_focused_close);
1288 RrAppearanceFree(theme->a_hover_unfocused_close);
1289 RrAppearanceFree(theme->a_focused_unpressed_close);
1290 RrAppearanceFree(theme->a_focused_pressed_close);
1291 RrAppearanceFree(theme->a_unfocused_unpressed_close);
1292 RrAppearanceFree(theme->a_unfocused_pressed_close);
1293 RrAppearanceFree(theme->a_disabled_focused_desk);
1294 RrAppearanceFree(theme->a_disabled_unfocused_desk);
1295 RrAppearanceFree(theme->a_hover_focused_desk);
1296 RrAppearanceFree(theme->a_hover_unfocused_desk);
1297 RrAppearanceFree(theme->a_toggled_hover_focused_desk);
1298 RrAppearanceFree(theme->a_toggled_hover_unfocused_desk);
1299 RrAppearanceFree(theme->a_toggled_focused_unpressed_desk);
1300 RrAppearanceFree(theme->a_toggled_focused_pressed_desk);
1301 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_desk);
1302 RrAppearanceFree(theme->a_toggled_unfocused_pressed_desk);
1303 RrAppearanceFree(theme->a_focused_unpressed_desk);
1304 RrAppearanceFree(theme->a_focused_pressed_desk);
1305 RrAppearanceFree(theme->a_unfocused_unpressed_desk);
1306 RrAppearanceFree(theme->a_unfocused_pressed_desk);
1307 RrAppearanceFree(theme->a_disabled_focused_shade);
1308 RrAppearanceFree(theme->a_disabled_unfocused_shade);
1309 RrAppearanceFree(theme->a_hover_focused_shade);
1310 RrAppearanceFree(theme->a_hover_unfocused_shade);
1311 RrAppearanceFree(theme->a_toggled_hover_focused_shade);
1312 RrAppearanceFree(theme->a_toggled_hover_unfocused_shade);
1313 RrAppearanceFree(theme->a_toggled_focused_unpressed_shade);
1314 RrAppearanceFree(theme->a_toggled_focused_pressed_shade);
1315 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_shade);
1316 RrAppearanceFree(theme->a_toggled_unfocused_pressed_shade);
1317 RrAppearanceFree(theme->a_focused_unpressed_shade);
1318 RrAppearanceFree(theme->a_focused_pressed_shade);
1319 RrAppearanceFree(theme->a_unfocused_unpressed_shade);
1320 RrAppearanceFree(theme->a_unfocused_pressed_shade);
1321 RrAppearanceFree(theme->a_disabled_focused_iconify);
1322 RrAppearanceFree(theme->a_disabled_unfocused_iconify);
1323 RrAppearanceFree(theme->a_hover_focused_iconify);
1324 RrAppearanceFree(theme->a_hover_unfocused_iconify);
1325 RrAppearanceFree(theme->a_focused_unpressed_iconify);
1326 RrAppearanceFree(theme->a_focused_pressed_iconify);
1327 RrAppearanceFree(theme->a_unfocused_unpressed_iconify);
1328 RrAppearanceFree(theme->a_unfocused_pressed_iconify);
1329 RrAppearanceFree(theme->a_focused_grip);
1330 RrAppearanceFree(theme->a_unfocused_grip);
1331 RrAppearanceFree(theme->a_focused_title);
1332 RrAppearanceFree(theme->a_unfocused_title);
1333 RrAppearanceFree(theme->a_focused_label);
1334 RrAppearanceFree(theme->a_unfocused_label);
1335 RrAppearanceFree(theme->a_icon);
1336 RrAppearanceFree(theme->a_focused_handle);
1337 RrAppearanceFree(theme->a_unfocused_handle);
1338 RrAppearanceFree(theme->a_menu);
1339 RrAppearanceFree(theme->a_menu_title);
1340 RrAppearanceFree(theme->a_menu_text_title);
1341 RrAppearanceFree(theme->a_menu_normal);
1342 RrAppearanceFree(theme->a_menu_selected);
1343 RrAppearanceFree(theme->a_menu_disabled);
1344 RrAppearanceFree(theme->a_menu_disabled_selected);
1345 RrAppearanceFree(theme->a_menu_text_normal);
1346 RrAppearanceFree(theme->a_menu_text_selected);
1347 RrAppearanceFree(theme->a_menu_text_disabled);
1348 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1349 RrAppearanceFree(theme->a_menu_bullet_normal);
1350 RrAppearanceFree(theme->a_menu_bullet_selected);
1351 RrAppearanceFree(theme->a_clear);
1352 RrAppearanceFree(theme->a_clear_tex);
1353 RrAppearanceFree(theme->osd_hilite_bg);
1354 RrAppearanceFree(theme->osd_hilite_fg);
1355 RrAppearanceFree(theme->osd_hilite_label);
1356 RrAppearanceFree(theme->osd_unhilite_fg);
1362 static XrmDatabase loaddb(const gchar *name, gchar **path)
1365 XrmDatabase db = NULL;
1368 if (name[0] == '/') {
1369 s = g_build_filename(name, "openbox-3", "themerc", NULL);
1370 if ((db = XrmGetFileDatabase(s)))
1371 *path = g_path_get_dirname(s);
1374 /* XXX backwards compatibility, remove me sometime later */
1375 s = g_build_filename(g_get_home_dir(), ".themes", name,
1376 "openbox-3", "themerc", NULL);
1377 if ((db = XrmGetFileDatabase(s)))
1378 *path = g_path_get_dirname(s);
1381 for (it = parse_xdg_data_dir_paths(); !db && it;
1382 it = g_slist_next(it))
1384 s = g_build_filename(it->data, "themes", name,
1385 "openbox-3", "themerc", NULL);
1386 if ((db = XrmGetFileDatabase(s)))
1387 *path = g_path_get_dirname(s);
1393 s = g_build_filename(name, "themerc", NULL);
1394 if ((db = XrmGetFileDatabase(s)))
1395 *path = g_path_get_dirname(s);
1402 static gchar *create_class_name(const gchar *rname)
1404 gchar *rclass = g_strdup(rname);
1409 p = strchr(p+1, '.');
1410 if (p == NULL) break;
1412 if (*p == '\0') break;
1417 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1419 gboolean ret = FALSE;
1420 gchar *rclass = create_class_name(rname);
1421 gchar *rettype, *end;
1424 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1425 retvalue.addr != NULL) {
1426 *value = (gint)strtol(retvalue.addr, &end, 10);
1427 if (end != retvalue.addr)
1435 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1437 gboolean ret = FALSE;
1438 gchar *rclass = create_class_name(rname);
1442 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1443 retvalue.addr != NULL) {
1444 *value = retvalue.addr;
1452 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1453 const gchar *rname, RrColor **value)
1455 gboolean ret = FALSE;
1456 gchar *rclass = create_class_name(rname);
1460 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1461 retvalue.addr != NULL) {
1462 RrColor *c = RrColorParse(inst, retvalue.addr);
1473 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1474 RrTheme *theme, const gchar *maskname,
1475 RrPixmapMask **value)
1477 gboolean ret = FALSE;
1479 gint hx, hy; /* ignored */
1483 s = g_build_filename(path, maskname, NULL);
1484 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1486 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1494 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1495 RrReliefType *relief, RrBevelType *bevel,
1496 gboolean *interlaced, gboolean *border,
1497 gboolean allow_trans)
1501 /* convert to all lowercase */
1502 for (t = tex; *t != '\0'; ++t)
1503 *t = g_ascii_tolower(*t);
1505 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1506 *grad = RR_SURFACE_PARENTREL;
1508 if (strstr(tex, "gradient") != NULL) {
1509 if (strstr(tex, "crossdiagonal") != NULL)
1510 *grad = RR_SURFACE_CROSS_DIAGONAL;
1511 else if (strstr(tex, "pyramid") != NULL)
1512 *grad = RR_SURFACE_PYRAMID;
1513 else if (strstr(tex, "mirrorhorizontal") != NULL)
1514 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1515 else if (strstr(tex, "horizontal") != NULL)
1516 *grad = RR_SURFACE_HORIZONTAL;
1517 else if (strstr(tex, "splitvertical") != NULL)
1518 *grad = RR_SURFACE_SPLIT_VERTICAL;
1519 else if (strstr(tex, "vertical") != NULL)
1520 *grad = RR_SURFACE_VERTICAL;
1522 *grad = RR_SURFACE_DIAGONAL;
1524 *grad = RR_SURFACE_SOLID;
1528 if (strstr(tex, "sunken") != NULL)
1529 *relief = RR_RELIEF_SUNKEN;
1530 else if (strstr(tex, "flat") != NULL)
1531 *relief = RR_RELIEF_FLAT;
1532 else if (strstr(tex, "raised") != NULL)
1533 *relief = RR_RELIEF_RAISED;
1535 *relief = (*grad == RR_SURFACE_PARENTREL) ?
1536 RR_RELIEF_FLAT : RR_RELIEF_RAISED;
1539 if (*relief == RR_RELIEF_FLAT) {
1540 if (strstr(tex, "border") != NULL)
1543 if (strstr(tex, "bevel2") != NULL)
1544 *bevel = RR_BEVEL_2;
1546 *bevel = RR_BEVEL_1;
1549 if (strstr(tex, "interlaced") != NULL)
1552 *interlaced = FALSE;
1556 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1557 const gchar *rname, RrAppearance *value,
1558 gboolean allow_trans)
1560 gboolean ret = FALSE;
1561 gchar *rclass = create_class_name(rname);
1562 gchar *cname, *ctoname, *bcname, *icname, *hname, *sname;
1563 gchar *csplitname, *ctosplitname;
1568 cname = g_strconcat(rname, ".color", NULL);
1569 ctoname = g_strconcat(rname, ".colorTo", NULL);
1570 bcname = g_strconcat(rname, ".border.color", NULL);
1571 icname = g_strconcat(rname, ".interlace.color", NULL);
1572 hname = g_strconcat(rname, ".highlight", NULL);
1573 sname = g_strconcat(rname, ".shadow", NULL);
1574 csplitname = g_strconcat(rname, ".color.splitTo", NULL);
1575 ctosplitname = g_strconcat(rname, ".colorTo.splitTo", NULL);
1577 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1578 retvalue.addr != NULL) {
1579 parse_appearance(retvalue.addr,
1580 &value->surface.grad,
1581 &value->surface.relief,
1582 &value->surface.bevel,
1583 &value->surface.interlaced,
1584 &value->surface.border,
1586 if (!read_color(db, inst, cname, &value->surface.primary))
1587 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1588 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1589 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1590 if (value->surface.border)
1591 if (!read_color(db, inst, bcname,
1592 &value->surface.border_color))
1593 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1594 if (value->surface.interlaced)
1595 if (!read_color(db, inst, icname,
1596 &value->surface.interlace_color))
1597 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1598 if (read_int(db, hname, &i) && i >= 0)
1599 value->surface.bevel_light_adjust = i;
1600 if (read_int(db, sname, &i) && i >= 0 && i <= 256)
1601 value->surface.bevel_dark_adjust = i;
1603 if (value->surface.grad == RR_SURFACE_SPLIT_VERTICAL) {
1606 if (!read_color(db, inst, csplitname,
1607 &value->surface.split_primary))
1609 r = value->surface.primary->r;
1611 g = value->surface.primary->g;
1613 b = value->surface.primary->b;
1615 if (r > 0xFF) r = 0xFF;
1616 if (g > 0xFF) g = 0xFF;
1617 if (b > 0xFF) b = 0xFF;
1618 value->surface.split_primary = RrColorNew(inst, r, g, b);
1621 if (!read_color(db, inst, ctosplitname,
1622 &value->surface.split_secondary))
1624 r = value->surface.secondary->r;
1626 g = value->surface.secondary->g;
1628 b = value->surface.secondary->b;
1630 if (r > 0xFF) r = 0xFF;
1631 if (g > 0xFF) g = 0xFF;
1632 if (b > 0xFF) b = 0xFF;
1633 value->surface.split_secondary = RrColorNew(inst, r, g, b);
1640 g_free(ctosplitname);
1652 static int parse_inline_number(const char *p)
1660 for (; isdigit(*p); ++p)
1661 res = res * 10 + *p - '0';
1666 static void set_default_appearance(RrAppearance *a)
1668 a->surface.grad = RR_SURFACE_SOLID;
1669 a->surface.relief = RR_RELIEF_FLAT;
1670 a->surface.bevel = RR_BEVEL_1;
1671 a->surface.interlaced = FALSE;
1672 a->surface.border = FALSE;
1673 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1674 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
1677 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1678 an RrTextureRGBA. */
1679 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
1684 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
1686 for (i = 0; i < width * height; ++i) {
1687 guchar a = ((*p >> 24) & 0xff);
1688 guchar b = ((*p >> 16) & 0xff);
1689 guchar g = ((*p >> 8) & 0xff);
1690 guchar r = ((*p >> 0) & 0xff);
1692 *p = ((r << RrDefaultRedOffset) +
1693 (g << RrDefaultGreenOffset) +
1694 (b << RrDefaultBlueOffset) +
1695 (a << RrDefaultAlphaOffset));