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 "obt/paths.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);
48 static void read_button_colors(XrmDatabase db, const RrInstance *inst,
49 const RrTheme *theme, RrButton *btn,
50 const gchar *btnname);
52 static RrFont *get_font(RrFont *target, RrFont **default_font,
53 const RrInstance *inst)
59 /* Only load the default font once */
61 RrFontRef(*default_font);
63 *default_font = RrFontOpenDefault(inst);
69 #define READ_INT(x_resstr, x_var, x_min, x_max, x_def) \
70 if (!read_int(db, x_resstr, & x_var) || \
71 x_var < x_min || x_var > x_max) \
74 #define READ_COLOR(x_resstr, x_var, x_def) \
75 if (!read_color(db, inst, x_resstr, & x_var)) \
78 #define READ_COLOR_(x_res1, x_res2, x_var, x_def) \
79 if (!read_color(db, inst, x_res1, & x_var) && \
80 !read_color(db, inst, x_res2, & x_var)) \
83 #define READ_MASK_COPY(x_file, x_var, x_copysrc) \
84 if (!read_mask(inst, path, theme, x_file, & x_var)) \
85 x_var = RrPixmapMaskCopy(x_copysrc);
87 #define READ_APPEARANCE(x_resstr, x_var, x_parrel) \
88 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) \
89 set_default_appearance(x_var);
91 #define READ_APPEARANCE_COPY(x_resstr, x_var, x_parrel, x_defval) \
92 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) {\
93 RrAppearanceFree(x_var); \
94 x_var = RrAppearanceCopy(x_defval); }
96 #define READ_APPEARANCE_COPY_TEXTURES(x_resstr, x_var, x_parrel, x_defval, n_tex) \
97 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) {\
98 RrAppearanceFree(x_var); \
99 x_var = RrAppearanceCopy(x_defval); \
100 RrAppearanceRemoveTextures(x_var); \
101 RrAppearanceAddTextures(x_var, 5); }
103 #define READ_APPEARANCE_(x_res1, x_res2, x_var, x_parrel, x_defval) \
104 if (!read_appearance(db, inst, x_res1, x_var, x_parrel) && \
105 !read_appearance(db, inst, x_res2, x_var, x_parrel)) {\
106 RrAppearanceFree(x_var); \
107 x_var = RrAppearanceCopy(x_defval); }
109 RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
110 gboolean allow_fallback,
111 RrFont *active_window_font, RrFont *inactive_window_font,
112 RrFont *menu_title_font, RrFont *menu_item_font,
113 RrFont *active_osd_font, RrFont *inactive_osd_font)
115 XrmDatabase db = NULL;
116 RrJustify winjust, mtitlejust;
119 RrFont *default_font = NULL;
122 gint menu_overlap = 0;
123 RrAppearance *a_disabled_focused_tmp;
124 RrAppearance *a_disabled_unfocused_tmp;
125 RrAppearance *a_hover_focused_tmp;
126 RrAppearance *a_hover_unfocused_tmp;
127 RrAppearance *a_focused_unpressed_tmp;
128 RrAppearance *a_focused_pressed_tmp;
129 RrAppearance *a_unfocused_unpressed_tmp;
130 RrAppearance *a_unfocused_pressed_tmp;
131 RrAppearance *a_toggled_hover_focused_tmp;
132 RrAppearance *a_toggled_hover_unfocused_tmp;
133 RrAppearance *a_toggled_focused_unpressed_tmp;
134 RrAppearance *a_toggled_focused_pressed_tmp;
135 RrAppearance *a_toggled_unfocused_unpressed_tmp;
136 RrAppearance *a_toggled_unfocused_pressed_tmp;
139 db = loaddb(name, &path);
141 g_message("Unable to load the theme '%s'", name);
143 g_message("Falling back to the default theme '%s'",
145 /* fallback to the default theme */
150 if (allow_fallback) {
151 db = loaddb(DEFAULT_THEME, &path);
153 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
160 /* initialize temp reading textures */
161 a_disabled_focused_tmp = RrAppearanceNew(inst, 1);
162 a_disabled_unfocused_tmp = RrAppearanceNew(inst, 1);
163 a_hover_focused_tmp = RrAppearanceNew(inst, 1);
164 a_hover_unfocused_tmp = RrAppearanceNew(inst, 1);
165 a_toggled_focused_unpressed_tmp = RrAppearanceNew(inst, 1);
166 a_toggled_unfocused_unpressed_tmp = RrAppearanceNew(inst, 1);
167 a_toggled_hover_focused_tmp = RrAppearanceNew(inst, 1);
168 a_toggled_hover_unfocused_tmp = RrAppearanceNew(inst, 1);
169 a_toggled_focused_pressed_tmp = RrAppearanceNew(inst, 1);
170 a_toggled_unfocused_pressed_tmp = RrAppearanceNew(inst, 1);
171 a_focused_unpressed_tmp = RrAppearanceNew(inst, 1);
172 a_focused_pressed_tmp = RrAppearanceNew(inst, 1);
173 a_unfocused_unpressed_tmp = RrAppearanceNew(inst, 1);
174 a_unfocused_pressed_tmp = RrAppearanceNew(inst, 1);
176 /* initialize theme */
177 theme = g_slice_new0(RrTheme);
180 theme->name = g_strdup(name ? name : DEFAULT_THEME);
183 theme->btn_max = RrButtonNew(inst);
184 theme->btn_close = RrButtonNew(inst);
185 theme->btn_desk = RrButtonNew(inst);
186 theme->btn_shade = RrButtonNew(inst);
187 theme->btn_iconify = RrButtonNew(inst);
189 /* init appearances */
190 theme->a_focused_grip = RrAppearanceNew(inst, 0);
191 theme->a_unfocused_grip = RrAppearanceNew(inst, 0);
192 theme->a_focused_title = RrAppearanceNew(inst, 0);
193 theme->a_unfocused_title = RrAppearanceNew(inst, 0);
194 theme->a_focused_label = RrAppearanceNew(inst, 1);
195 theme->a_unfocused_label = RrAppearanceNew(inst, 1);
196 theme->a_icon = RrAppearanceNew(inst, 1);
197 theme->a_focused_handle = RrAppearanceNew(inst, 0);
198 theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
199 theme->a_menu = RrAppearanceNew(inst, 0);
200 theme->a_menu_title = RrAppearanceNew(inst, 0);
201 theme->a_menu_text_title = RrAppearanceNew(inst, 1);
202 theme->a_menu_normal = RrAppearanceNew(inst, 0);
203 theme->a_menu_selected = RrAppearanceNew(inst, 0);
204 theme->a_menu_disabled = RrAppearanceNew(inst, 0);
205 /* a_menu_disabled_selected is copied from a_menu_selected */
206 theme->a_menu_text_normal = RrAppearanceNew(inst, 1);
207 theme->a_menu_text_selected = RrAppearanceNew(inst, 1);
208 theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
209 theme->a_menu_text_disabled_selected = RrAppearanceNew(inst, 1);
210 theme->a_menu_bullet_normal = RrAppearanceNew(inst, 1);
211 theme->a_menu_bullet_selected = RrAppearanceNew(inst, 1);
212 theme->a_clear = RrAppearanceNew(inst, 0);
213 theme->a_clear_tex = RrAppearanceNew(inst, 1);
214 theme->osd_bg = RrAppearanceNew(inst, 0);
215 theme->osd_hilite_label = RrAppearanceNew(inst, 1);
216 theme->osd_hilite_bg = RrAppearanceNew(inst, 0);
217 theme->osd_unhilite_label = RrAppearanceNew(inst, 1);
218 theme->osd_unhilite_bg = RrAppearanceNew(inst, 0);
219 theme->osd_unpressed_button = RrAppearanceNew(inst, 1);
220 theme->osd_pressed_button = RrAppearanceNew(inst, 5);
221 theme->osd_focused_button = RrAppearanceNew(inst, 5);
223 /* load the font stuff */
224 theme->win_font_focused = get_font(active_window_font,
225 &default_font, inst);
226 theme->win_font_unfocused = get_font(inactive_window_font,
227 &default_font, inst);
229 winjust = RR_JUSTIFY_LEFT;
230 if (read_string(db, "window.label.text.justify", &str)) {
231 if (!g_ascii_strcasecmp(str, "right"))
232 winjust = RR_JUSTIFY_RIGHT;
233 else if (!g_ascii_strcasecmp(str, "center"))
234 winjust = RR_JUSTIFY_CENTER;
237 theme->menu_title_font = get_font(menu_title_font, &default_font, inst);
239 mtitlejust = RR_JUSTIFY_LEFT;
240 if (read_string(db, "menu.title.text.justify", &str)) {
241 if (!g_ascii_strcasecmp(str, "right"))
242 mtitlejust = RR_JUSTIFY_RIGHT;
243 else if (!g_ascii_strcasecmp(str, "center"))
244 mtitlejust = RR_JUSTIFY_CENTER;
247 theme->menu_font = get_font(menu_item_font, &default_font, inst);
249 theme->osd_font_hilite = get_font(active_osd_font, &default_font, inst);
250 theme->osd_font_unhilite = get_font(inactive_osd_font, &default_font,inst);
252 /* load direct dimensions */
253 READ_INT("menu.overlap", menu_overlap, -100, 100, 0);
254 READ_INT("menu.overlap.x", theme->menu_overlap_x, -100, 100, menu_overlap);
255 READ_INT("menu.overlap.y", theme->menu_overlap_y, -100, 100, menu_overlap);
256 READ_INT("window.handle.width", theme->handle_height, 0, 100, 6);
257 READ_INT("padding.width", theme->paddingx, 0, 100, 3);
258 READ_INT("padding.height", theme->paddingy, 0, 100, theme->paddingx);
259 READ_INT("border.width", theme->fbwidth, 0, 100, 1);
260 READ_INT("menu.border.width", theme->mbwidth, 0, 100, theme->fbwidth);
261 READ_INT("osd.border.width", theme->obwidth, 0, 100, theme->fbwidth);
262 READ_INT("menu.separator.width", theme->menu_sep_width, 1, 100, 1);
263 READ_INT("menu.separator.padding.width", theme->menu_sep_paddingx, 0, 100, 6);
264 READ_INT("menu.separator.padding.height", theme->menu_sep_paddingy, 0, 100, 3);
265 READ_INT("window.client.padding.width", theme->cbwidthx, 0, 100,
267 READ_INT("window.client.padding.height", theme->cbwidthy, 0, 100,
271 READ_COLOR_("window.active.border.color", "border.color",
272 theme->frame_focused_border_color, RrColorNew(inst, 0, 0, 0));
274 /* title separator focused color inherits from focused border color */
275 READ_COLOR("window.active.title.separator.color",
276 theme->title_separator_focused_color,
277 RrColorCopy(theme->frame_focused_border_color));
279 /* unfocused border color inherits from frame focused border color */
280 READ_COLOR("window.inactive.border.color",
281 theme->frame_unfocused_border_color,
282 RrColorCopy(theme->frame_focused_border_color));
284 /* title separator unfocused color inherits from unfocused border color */
285 READ_COLOR("window.inactive.title.separator.color",
286 theme->title_separator_unfocused_color,
287 RrColorCopy(theme->frame_unfocused_border_color));
289 /* menu border color inherits from frame focused border color */
290 READ_COLOR("menu.border.color", theme->menu_border_color,
291 RrColorCopy(theme->frame_focused_border_color));
293 /* osd border color inherits from frame focused border color */
294 READ_COLOR("osd.border.color", theme->osd_border_color,
295 RrColorCopy(theme->frame_focused_border_color));
297 READ_COLOR("window.active.client.color", theme->cb_focused_color,
298 RrColorNew(inst, 0xff, 0xff, 0xff));
300 READ_COLOR("window.inactive.client.color", theme->cb_unfocused_color,
301 RrColorNew(inst, 0xff, 0xff, 0xff));
303 READ_COLOR("window.active.label.text.color", theme->title_focused_color,
304 RrColorNew(inst, 0x0, 0x0, 0x0));
306 READ_COLOR("window.inactive.label.text.color", theme->title_unfocused_color,
307 RrColorCopy(theme->title_unfocused_color));
309 READ_COLOR_("osd.active.label.text.color",
310 "osd.label.text.color",
311 theme->osd_text_active_color, RrColorCopy(theme->title_focused_color));
313 READ_COLOR_("osd.inactive.label.text.color",
314 "osd.label.text.color",
315 theme->osd_text_inactive_color, RrColorCopy(theme->title_unfocused_color));
317 READ_COLOR("window.active.button.unpressed.image.color",
318 theme->titlebut_focused_unpressed_color,
319 RrColorNew(inst, 0, 0, 0));
321 READ_COLOR("window.inactive.button.unpressed.image.color",
322 theme->titlebut_unfocused_unpressed_color,
323 RrColorNew(inst, 0xff, 0xff, 0xff));
325 READ_COLOR("window.active.button.pressed.image.color",
326 theme->titlebut_focused_pressed_color,
327 RrColorCopy(theme->titlebut_focused_unpressed_color));
329 READ_COLOR("window.inactive.button.pressed.image.color",
330 theme->titlebut_unfocused_pressed_color,
331 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
333 READ_COLOR("window.active.button.disabled.image.color",
334 theme->titlebut_disabled_focused_color,
335 RrColorNew(inst, 0xff, 0xff, 0xff));
337 READ_COLOR("window.inactive.button.disabled.image.color",
338 theme->titlebut_disabled_unfocused_color,
339 RrColorNew(inst, 0, 0, 0));
341 READ_COLOR("window.active.button.hover.image.color",
342 theme->titlebut_hover_focused_color,
343 RrColorCopy(theme->titlebut_focused_unpressed_color));
345 READ_COLOR("window.inactive.button.hover.image.color",
346 theme->titlebut_hover_unfocused_color,
347 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
349 READ_COLOR_("window.active.button.toggled.unpressed.image.color",
350 "window.active.button.toggled.image.color",
351 theme->titlebut_toggled_focused_unpressed_color,
352 RrColorCopy(theme->titlebut_focused_pressed_color));
354 READ_COLOR_("window.inactive.button.toggled.unpressed.image.color",
355 "window.inactive.button.toggled.image.color",
356 theme->titlebut_toggled_unfocused_unpressed_color,
357 RrColorCopy(theme->titlebut_unfocused_pressed_color));
359 READ_COLOR("window.active.button.toggled.hover.image.color",
360 theme->titlebut_toggled_hover_focused_color,
361 RrColorCopy(theme->titlebut_toggled_focused_unpressed_color));
363 READ_COLOR("window.inactive.button.toggled.hover.image.color",
364 theme->titlebut_toggled_hover_unfocused_color,
365 RrColorCopy(theme->titlebut_toggled_unfocused_unpressed_color));
367 READ_COLOR("window.active.button.toggled.pressed.image.color",
368 theme->titlebut_toggled_focused_pressed_color,
369 RrColorCopy(theme->titlebut_focused_pressed_color));
371 READ_COLOR("window.inactive.button.toggled.pressed.image.color",
372 theme->titlebut_toggled_unfocused_pressed_color,
373 RrColorCopy(theme->titlebut_unfocused_pressed_color));
375 READ_COLOR("menu.title.text.color", theme->menu_title_color,
376 RrColorNew(inst, 0, 0, 0));
378 READ_COLOR("menu.items.text.color", theme->menu_color,
379 RrColorNew(inst, 0xff, 0xff, 0xff));
381 READ_COLOR("menu.bullet.image.color", theme->menu_bullet_color,
382 RrColorCopy(theme->menu_color));
384 READ_COLOR("menu.items.disabled.text.color", theme->menu_disabled_color,
385 RrColorNew(inst, 0, 0, 0));
387 READ_COLOR("menu.items.active.disabled.text.color",
388 theme->menu_disabled_selected_color,
389 RrColorCopy(theme->menu_disabled_color));
391 READ_COLOR("menu.items.active.text.color", theme->menu_selected_color,
392 RrColorNew(inst, 0, 0, 0));
394 READ_COLOR("menu.separator.color", theme->menu_sep_color,
395 RrColorCopy(theme->menu_color));
397 READ_COLOR("menu.bullet.selected.image.color",
398 theme->menu_bullet_selected_color,
399 RrColorCopy(theme->menu_selected_color));
401 READ_COLOR("osd.button.unpressed.text.color", theme->osd_unpressed_color,
402 RrColorCopy(theme->osd_text_active_color));
403 READ_COLOR("osd.button.pressed.text.color", theme->osd_pressed_color,
404 RrColorCopy(theme->osd_text_active_color));
405 READ_COLOR("osd.button.focused.text.color", theme->osd_focused_color,
406 RrColorCopy(theme->osd_text_active_color));
407 READ_COLOR("osd.button.pressed.box.color", theme->osd_pressed_lineart,
408 RrColorCopy(theme->titlebut_focused_pressed_color));
409 READ_COLOR("osd.button.focused.box.color", theme->osd_focused_lineart,
410 RrColorCopy(theme->titlebut_hover_focused_color));
412 /* load the image masks */
414 /* maximize button masks */
416 if (!read_mask(inst, path, theme, "max.xbm", &theme->btn_max->mask)) {
417 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
418 theme->btn_max->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
421 if (!read_mask(inst, path, theme, "max_toggled.xbm",
422 &theme->btn_max->toggled_mask))
425 theme->btn_max->toggled_mask = RrPixmapMaskCopy(theme->btn_max->mask);
427 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
428 theme->btn_max->toggled_mask = RrPixmapMaskNew(inst, 6, 6,(gchar*)data);
431 READ_MASK_COPY("max_pressed.xbm", theme->btn_max->pressed_mask,
432 theme->btn_max->mask);
433 READ_MASK_COPY("max_disabled.xbm", theme->btn_max->disabled_mask,
434 theme->btn_max->mask);
435 READ_MASK_COPY("max_hover.xbm", theme->btn_max->hover_mask,
436 theme->btn_max->mask);
437 READ_MASK_COPY("max_toggled_pressed.xbm",
438 theme->btn_max->toggled_pressed_mask,
439 theme->btn_max->toggled_mask);
440 READ_MASK_COPY("max_toggled_hover.xbm",
441 theme->btn_max->toggled_hover_mask,
442 theme->btn_max->toggled_mask);
444 /* iconify button masks */
445 if (!read_mask(inst, path, theme, "iconify.xbm", &theme->btn_iconify->mask)) {
446 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
447 theme->btn_iconify->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
449 READ_MASK_COPY("iconify_pressed.xbm", theme->btn_iconify->pressed_mask,
450 theme->btn_iconify->mask);
451 READ_MASK_COPY("iconify_disabled.xbm", theme->btn_iconify->disabled_mask,
452 theme->btn_iconify->mask);
453 READ_MASK_COPY("iconify_hover.xbm", theme->btn_iconify->hover_mask,
454 theme->btn_iconify->mask);
456 /* all desktops button masks */
458 if (!read_mask(inst, path, theme, "desk.xbm", &theme->btn_desk->mask)) {
459 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
460 theme->btn_desk->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
463 if (!read_mask(inst, path, theme, "desk_toggled.xbm",
464 &theme->btn_desk->toggled_mask)) {
466 theme->btn_desk->toggled_mask = RrPixmapMaskCopy(theme->btn_desk->mask);
468 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
469 theme->btn_desk->toggled_mask =
470 RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
473 READ_MASK_COPY("desk_pressed.xbm", theme->btn_desk->pressed_mask,
474 theme->btn_desk->mask);
475 READ_MASK_COPY("desk_disabled.xbm", theme->btn_desk->disabled_mask,
476 theme->btn_desk->mask);
477 READ_MASK_COPY("desk_hover.xbm", theme->btn_desk->hover_mask, theme->btn_desk->mask);
478 READ_MASK_COPY("desk_toggled_pressed.xbm",
479 theme->btn_desk->toggled_pressed_mask, theme->btn_desk->toggled_mask);
480 READ_MASK_COPY("desk_toggled_hover.xbm", theme->btn_desk->toggled_hover_mask,
481 theme->btn_desk->toggled_mask);
483 /* shade button masks */
484 if (!read_mask(inst, path, theme, "shade.xbm", &theme->btn_shade->mask)) {
485 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
486 theme->btn_shade->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
488 READ_MASK_COPY("shade_toggled.xbm", theme->btn_shade->toggled_mask,
489 theme->btn_shade->mask);
490 READ_MASK_COPY("shade_pressed.xbm", theme->btn_shade->pressed_mask,
491 theme->btn_shade->mask);
492 READ_MASK_COPY("shade_disabled.xbm", theme->btn_shade->disabled_mask,
493 theme->btn_shade->mask);
494 READ_MASK_COPY("shade_hover.xbm", theme->btn_shade->hover_mask,
495 theme->btn_shade->mask);
496 READ_MASK_COPY("shade_toggled_pressed.xbm",
497 theme->btn_shade->toggled_pressed_mask,
498 theme->btn_shade->toggled_mask);
499 READ_MASK_COPY("shade_toggled_hover.xbm",
500 theme->btn_shade->toggled_hover_mask,
501 theme->btn_shade->toggled_mask);
503 /* close button masks */
504 if (!read_mask(inst, path, theme, "close.xbm", &theme->btn_close->mask)) {
505 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
506 theme->btn_close->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
508 READ_MASK_COPY("close_pressed.xbm", theme->btn_close->pressed_mask,
509 theme->btn_close->mask);
510 READ_MASK_COPY("close_disabled.xbm", theme->btn_close->disabled_mask,
511 theme->btn_close->mask);
512 READ_MASK_COPY("close_hover.xbm", theme->btn_close->hover_mask,
513 theme->btn_close->mask);
515 /* submenu bullet mask */
516 if (!read_mask(inst, path, theme, "bullet.xbm", &theme->menu_bullet_mask))
518 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
519 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
522 /* up and down arrows */
524 guchar data[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 };
525 theme->down_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
528 guchar data[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 };
529 theme->up_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
532 /* setup the default window icon */
533 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
534 OB_DEFAULT_ICON_HEIGHT,
535 OB_DEFAULT_ICON_pixel_data);
536 theme->def_win_icon_w = OB_DEFAULT_ICON_WIDTH;
537 theme->def_win_icon_h = OB_DEFAULT_ICON_HEIGHT;
539 /* the toggled hover mask = the toggled unpressed mask (i.e. no change) */
540 theme->btn_max->toggled_hover_mask =
541 RrPixmapMaskCopy(theme->btn_max->toggled_mask);
542 theme->btn_desk->toggled_hover_mask =
543 RrPixmapMaskCopy(theme->btn_desk->toggled_mask);
544 theme->btn_shade->toggled_hover_mask =
545 RrPixmapMaskCopy(theme->btn_shade->toggled_mask);
546 /* the toggled pressed mask = the toggled unpressed mask (i.e. no change)*/
547 theme->btn_max->toggled_pressed_mask =
548 RrPixmapMaskCopy(theme->btn_max->toggled_mask);
549 theme->btn_desk->toggled_pressed_mask =
550 RrPixmapMaskCopy(theme->btn_desk->toggled_mask);
551 theme->btn_shade->toggled_pressed_mask =
552 RrPixmapMaskCopy(theme->btn_shade->toggled_mask);
554 /* read the decoration textures */
555 READ_APPEARANCE("window.active.title.bg", theme->a_focused_title, FALSE);
556 READ_APPEARANCE("window.inactive.title.bg", theme->a_unfocused_title,
558 READ_APPEARANCE("window.active.label.bg", theme->a_focused_label, TRUE);
559 READ_APPEARANCE("window.inactive.label.bg", theme->a_unfocused_label,
561 READ_APPEARANCE("window.active.handle.bg", theme->a_focused_handle, FALSE);
562 READ_APPEARANCE("window.inactive.handle.bg",theme->a_unfocused_handle,
564 READ_APPEARANCE("window.active.grip.bg", theme->a_focused_grip, TRUE);
565 READ_APPEARANCE("window.inactive.grip.bg", theme->a_unfocused_grip, TRUE);
566 READ_APPEARANCE("menu.items.bg", theme->a_menu, FALSE);
567 READ_APPEARANCE("menu.title.bg", theme->a_menu_title, TRUE);
568 READ_APPEARANCE("menu.items.active.bg", theme->a_menu_selected, TRUE);
570 theme->a_menu_disabled_selected =
571 RrAppearanceCopy(theme->a_menu_selected);
573 /* read appearances for non-decorations (on-screen-display) */
574 if (!read_appearance(db, inst, "osd.bg", theme->osd_bg, FALSE)) {
575 RrAppearanceFree(theme->osd_bg);
576 theme->osd_bg = RrAppearanceCopy(theme->a_focused_title);
578 if (!read_appearance(db, inst, "osd.active.label.bg",
579 theme->osd_hilite_label, TRUE) &&
580 !read_appearance(db, inst, "osd.label.bg",
581 theme->osd_hilite_label, TRUE)) {
582 RrAppearanceFree(theme->osd_hilite_label);
583 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
585 if (!read_appearance(db, inst, "osd.inactive.label.bg",
586 theme->osd_unhilite_label, TRUE)) {
587 RrAppearanceFree(theme->osd_unhilite_label);
588 theme->osd_unhilite_label = RrAppearanceCopy(theme->a_unfocused_label);
590 /* osd_hilite_fg can't be parentrel */
591 if (!read_appearance(db, inst, "osd.hilight.bg",
592 theme->osd_hilite_bg, FALSE)) {
593 RrAppearanceFree(theme->osd_hilite_bg);
594 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
595 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_label);
597 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
599 /* osd_unhilite_fg can't be parentrel either */
600 if (!read_appearance(db, inst, "osd.unhilight.bg",
601 theme->osd_unhilite_bg, FALSE)) {
602 RrAppearanceFree(theme->osd_unhilite_bg);
603 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
604 theme->osd_unhilite_bg=RrAppearanceCopy(theme->a_unfocused_label);
606 theme->osd_unhilite_bg=RrAppearanceCopy(theme->a_unfocused_title);
609 /* read buttons textures */
611 /* bases: unpressed, pressed, disabled */
612 READ_APPEARANCE("window.active.button.unpressed.bg",
613 a_focused_unpressed_tmp, TRUE);
614 READ_APPEARANCE("window.inactive.button.unpressed.bg",
615 a_unfocused_unpressed_tmp, TRUE);
616 READ_APPEARANCE("window.active.button.pressed.bg",
617 a_focused_pressed_tmp, TRUE);
618 READ_APPEARANCE("window.inactive.button.pressed.bg",
619 a_unfocused_pressed_tmp, TRUE);
620 READ_APPEARANCE("window.active.button.disabled.bg",
621 a_disabled_focused_tmp, TRUE);
622 READ_APPEARANCE("window.inactive.button.disabled.bg",
623 a_disabled_unfocused_tmp, TRUE);
626 READ_APPEARANCE_COPY("window.active.button.hover.bg",
627 a_hover_focused_tmp, TRUE,
628 a_focused_unpressed_tmp);
629 READ_APPEARANCE_COPY("window.inactive.button.hover.bg",
630 a_hover_unfocused_tmp, TRUE,
631 a_unfocused_unpressed_tmp);
633 /* toggled unpressed */
634 READ_APPEARANCE_("window.active.button.toggled.unpressed.bg",
635 "window.active.button.toggled.bg",
636 a_toggled_focused_unpressed_tmp, TRUE,
637 a_focused_pressed_tmp);
638 READ_APPEARANCE_("window.inactive.button.toggled.unpressed.bg",
639 "window.inactive.button.toggled.bg",
640 a_toggled_unfocused_unpressed_tmp, TRUE,
641 a_unfocused_pressed_tmp);
643 /* toggled pressed */
644 READ_APPEARANCE_COPY("window.active.button.toggled.pressed.bg",
645 a_toggled_focused_pressed_tmp, TRUE,
646 a_focused_pressed_tmp);
647 READ_APPEARANCE_COPY("window.inactive.button.toggled.pressed.bg",
648 a_toggled_unfocused_pressed_tmp, TRUE,
649 a_unfocused_pressed_tmp);
652 READ_APPEARANCE_COPY("window.active.button.toggled.hover.bg",
653 a_toggled_hover_focused_tmp, TRUE,
654 a_toggled_focused_unpressed_tmp);
655 READ_APPEARANCE_COPY("window.inactive.button.toggled.hover.bg",
656 a_toggled_hover_unfocused_tmp, TRUE,
657 a_toggled_unfocused_unpressed_tmp);
660 /* now do individual buttons, if specified */
663 read_button_colors(db, inst, theme, theme->btn_max, "max");
665 /* bases: unpressed, pressed, disabled */
666 READ_APPEARANCE_COPY("window.active.button.max.unpressed.bg",
667 theme->btn_max->a_focused_unpressed, TRUE,
668 a_focused_unpressed_tmp);
669 READ_APPEARANCE_COPY("window.inactive.button.max.unpressed.bg",
670 theme->btn_max->a_unfocused_unpressed, TRUE,
671 a_unfocused_unpressed_tmp);
672 READ_APPEARANCE_COPY("window.active.button.max.pressed.bg",
673 theme->btn_max->a_focused_pressed, TRUE,
674 a_focused_pressed_tmp);
675 READ_APPEARANCE_COPY("window.inactive.button.max.pressed.bg",
676 theme->btn_max->a_unfocused_pressed, TRUE,
677 a_unfocused_pressed_tmp);
678 READ_APPEARANCE_COPY("window.active.button.max.disabled.bg",
679 theme->btn_max->a_disabled_focused, TRUE,
680 a_disabled_focused_tmp);
681 READ_APPEARANCE_COPY("window.inactive.button.max.disabled.bg",
682 theme->btn_max->a_disabled_unfocused, TRUE,
683 a_disabled_unfocused_tmp);
686 READ_APPEARANCE_COPY("window.active.button.max.hover.bg",
687 theme->btn_max->a_hover_focused, TRUE,
688 theme->btn_max->a_focused_unpressed);
689 READ_APPEARANCE_COPY("window.inactive.button.max.hover.bg",
690 theme->btn_max->a_hover_unfocused, TRUE,
691 theme->btn_max->a_unfocused_unpressed);
693 /* toggled unpressed */
694 READ_APPEARANCE_("window.active.button.max.toggled.unpressed.bg",
695 "window.active.button.max.toggled.bg",
696 theme->btn_max->a_toggled_focused_unpressed, TRUE,
697 theme->btn_max->a_focused_pressed);
698 READ_APPEARANCE_("window.inactive.button.max.toggled.unpressed.bg",
699 "window.inactive.button.max.toggled.bg",
700 theme->btn_max->a_toggled_unfocused_unpressed, TRUE,
701 theme->btn_max->a_unfocused_pressed);
703 /* toggled pressed */
704 READ_APPEARANCE_COPY("window.active.button.max.toggled.pressed.bg",
705 theme->btn_max->a_toggled_focused_pressed, TRUE,
706 theme->btn_max->a_focused_pressed);
707 READ_APPEARANCE_COPY("window.inactive.button.max.toggled.pressed.bg",
708 theme->btn_max->a_toggled_unfocused_pressed, TRUE,
709 theme->btn_max->a_unfocused_pressed);
712 READ_APPEARANCE_COPY("window.active.button.max.toggled.hover.bg",
713 theme->btn_max->a_toggled_hover_focused, TRUE,
714 theme->btn_max->a_toggled_focused_unpressed);
715 READ_APPEARANCE_COPY("window.inactive.button.max.toggled.hover.bg",
716 theme->btn_max->a_toggled_hover_unfocused, TRUE,
717 theme->btn_max->a_toggled_unfocused_unpressed);
720 read_button_colors(db, inst, theme, theme->btn_close, "close");
722 READ_APPEARANCE_COPY("window.active.button.close.unpressed.bg",
723 theme->btn_close->a_focused_unpressed, TRUE,
724 a_focused_unpressed_tmp);
725 READ_APPEARANCE_COPY("window.inactive.button.close.unpressed.bg",
726 theme->btn_close->a_unfocused_unpressed, TRUE,
727 a_unfocused_unpressed_tmp);
728 READ_APPEARANCE_COPY("window.active.button.close.pressed.bg",
729 theme->btn_close->a_focused_pressed, TRUE,
730 a_focused_pressed_tmp);
731 READ_APPEARANCE_COPY("window.inactive.button.close.pressed.bg",
732 theme->btn_close->a_unfocused_pressed, TRUE,
733 a_unfocused_pressed_tmp);
734 READ_APPEARANCE_COPY("window.active.button.close.disabled.bg",
735 theme->btn_close->a_disabled_focused, TRUE,
736 a_disabled_focused_tmp);
737 READ_APPEARANCE_COPY("window.inactive.button.close.disabled.bg",
738 theme->btn_close->a_disabled_unfocused, TRUE,
739 a_disabled_unfocused_tmp);
740 READ_APPEARANCE_COPY("window.active.button.close.hover.bg",
741 theme->btn_close->a_hover_focused, TRUE,
742 theme->btn_close->a_focused_unpressed);
743 READ_APPEARANCE_COPY("window.inactive.button.close.hover.bg",
744 theme->btn_close->a_hover_unfocused, TRUE,
745 theme->btn_close->a_unfocused_unpressed);
748 read_button_colors(db, inst, theme, theme->btn_desk, "desk");
750 /* bases: unpressed, pressed, disabled */
751 READ_APPEARANCE_COPY("window.active.button.desk.unpressed.bg",
752 theme->btn_desk->a_focused_unpressed, TRUE,
753 a_focused_unpressed_tmp);
754 READ_APPEARANCE_COPY("window.inactive.button.desk.unpressed.bg",
755 theme->btn_desk->a_unfocused_unpressed, TRUE,
756 a_unfocused_unpressed_tmp);
757 READ_APPEARANCE_COPY("window.active.button.desk.pressed.bg",
758 theme->btn_desk->a_focused_pressed, TRUE,
759 a_focused_pressed_tmp);
760 READ_APPEARANCE_COPY("window.inactive.button.desk.pressed.bg",
761 theme->btn_desk->a_unfocused_pressed, TRUE,
762 a_unfocused_pressed_tmp);
763 READ_APPEARANCE_COPY("window.active.button.desk.disabled.bg",
764 theme->btn_desk->a_disabled_focused, TRUE,
765 a_disabled_focused_tmp);
766 READ_APPEARANCE_COPY("window.inactive.button.desk.disabled.bg",
767 theme->btn_desk->a_disabled_unfocused, TRUE,
768 a_disabled_unfocused_tmp);
771 READ_APPEARANCE_COPY("window.active.button.desk.hover.bg",
772 theme->btn_desk->a_hover_focused, TRUE,
773 theme->btn_desk->a_focused_unpressed);
774 READ_APPEARANCE_COPY("window.inactive.button.desk.hover.bg",
775 theme->btn_desk->a_hover_unfocused, TRUE,
776 theme->btn_desk->a_unfocused_unpressed);
778 /* toggled unpressed */
779 READ_APPEARANCE_("window.active.button.desk.toggled.unpressed.bg",
780 "window.active.button.desk.toggled.bg",
781 theme->btn_desk->a_toggled_focused_unpressed, TRUE,
782 theme->btn_desk->a_focused_pressed);
783 READ_APPEARANCE_("window.inactive.button.desk.toggled.unpressed.bg",
784 "window.inactive.button.desk.toggled.bg",
785 theme->btn_desk->a_toggled_unfocused_unpressed, TRUE,
786 theme->btn_desk->a_unfocused_pressed);
788 /* toggled pressed */
789 READ_APPEARANCE_COPY("window.active.button.desk.toggled.pressed.bg",
790 theme->btn_desk->a_toggled_focused_pressed, TRUE,
791 theme->btn_desk->a_focused_pressed);
792 READ_APPEARANCE_COPY("window.inactive.button.desk.toggled.pressed.bg",
793 theme->btn_desk->a_toggled_unfocused_pressed, TRUE,
794 theme->btn_desk->a_unfocused_pressed);
797 READ_APPEARANCE_COPY("window.active.button.desk.toggled.hover.bg",
798 theme->btn_desk->a_toggled_hover_focused, TRUE,
799 theme->btn_desk->a_toggled_focused_unpressed);
800 READ_APPEARANCE_COPY("window.inactive.button.desk.toggled.hover.bg",
801 theme->btn_desk->a_toggled_hover_unfocused, TRUE,
802 theme->btn_desk->a_toggled_unfocused_unpressed);
805 read_button_colors(db, inst, theme, theme->btn_shade, "shade");
807 /* bases: unpressed, pressed, disabled */
808 READ_APPEARANCE_COPY("window.active.button.shade.unpressed.bg",
809 theme->btn_shade->a_focused_unpressed, TRUE,
810 a_focused_unpressed_tmp);
811 READ_APPEARANCE_COPY("window.inactive.button.shade.unpressed.bg",
812 theme->btn_shade->a_unfocused_unpressed, TRUE,
813 a_unfocused_unpressed_tmp);
814 READ_APPEARANCE_COPY("window.active.button.shade.pressed.bg",
815 theme->btn_shade->a_focused_pressed, TRUE,
816 a_focused_pressed_tmp);
817 READ_APPEARANCE_COPY("window.inactive.button.shade.pressed.bg",
818 theme->btn_shade->a_unfocused_pressed, TRUE,
819 a_unfocused_pressed_tmp);
820 READ_APPEARANCE_COPY("window.active.button.shade.disabled.bg",
821 theme->btn_shade->a_disabled_focused, TRUE,
822 a_disabled_focused_tmp);
823 READ_APPEARANCE_COPY("window.inactive.button.shade.disabled.bg",
824 theme->btn_shade->a_disabled_unfocused, TRUE,
825 a_disabled_unfocused_tmp);
828 READ_APPEARANCE_COPY("window.active.button.shade.hover.bg",
829 theme->btn_shade->a_hover_focused, TRUE,
830 theme->btn_shade->a_focused_unpressed);
831 READ_APPEARANCE_COPY("window.inactive.button.shade.hover.bg",
832 theme->btn_shade->a_hover_unfocused, TRUE,
833 theme->btn_shade->a_unfocused_unpressed);
835 /* toggled unpressed */
836 READ_APPEARANCE_("window.active.button.shade.toggled.unpressed.bg",
837 "window.active.button.shade.toggled.bg",
838 theme->btn_shade->a_toggled_focused_unpressed, TRUE,
839 theme->btn_shade->a_focused_pressed);
840 READ_APPEARANCE_("window.inactive.button.shade.toggled.unpressed.bg",
841 "window.inactive.button.shade.toggled.bg",
842 theme->btn_shade->a_toggled_unfocused_unpressed, TRUE,
843 theme->btn_shade->a_unfocused_pressed);
845 /* toggled pressed */
846 READ_APPEARANCE_COPY("window.active.button.shade.toggled.pressed.bg",
847 theme->btn_shade->a_toggled_focused_pressed, TRUE,
848 theme->btn_shade->a_focused_pressed);
849 READ_APPEARANCE_COPY("window.inactive.button.shade.toggled.pressed.bg",
850 theme->btn_shade->a_toggled_unfocused_pressed, TRUE,
851 theme->btn_shade->a_unfocused_pressed);
854 READ_APPEARANCE_COPY("window.active.button.shade.toggled.hover.bg",
855 theme->btn_shade->a_toggled_hover_focused, TRUE,
856 theme->btn_shade->a_toggled_focused_unpressed);
857 READ_APPEARANCE_COPY("window.inactive.button.shade.toggled.hover.bg",
858 theme->btn_shade->a_toggled_hover_unfocused, TRUE,
859 theme->btn_shade->a_toggled_unfocused_unpressed);
862 read_button_colors(db, inst, theme, theme->btn_iconify, "iconify");
864 READ_APPEARANCE_COPY("window.active.button.iconify.unpressed.bg",
865 theme->btn_iconify->a_focused_unpressed, TRUE,
866 a_focused_unpressed_tmp);
867 READ_APPEARANCE_COPY("window.inactive.button.iconify.unpressed.bg",
868 theme->btn_iconify->a_unfocused_unpressed, TRUE,
869 a_unfocused_unpressed_tmp);
870 READ_APPEARANCE_COPY("window.active.button.iconify.pressed.bg",
871 theme->btn_iconify->a_focused_pressed, TRUE,
872 a_focused_pressed_tmp);
873 READ_APPEARANCE_COPY("window.inactive.button.iconify.pressed.bg",
874 theme->btn_iconify->a_unfocused_pressed, TRUE,
875 a_unfocused_pressed_tmp);
876 READ_APPEARANCE_COPY("window.active.button.iconify.disabled.bg",
877 theme->btn_iconify->a_disabled_focused, TRUE,
878 a_disabled_focused_tmp);
879 READ_APPEARANCE_COPY("window.inactive.button.iconify.disabled.bg",
880 theme->btn_iconify->a_disabled_unfocused, TRUE,
881 a_disabled_unfocused_tmp);
882 READ_APPEARANCE_COPY("window.active.button.iconify.hover.bg",
883 theme->btn_iconify->a_hover_focused, TRUE,
884 theme->btn_iconify->a_focused_unpressed);
885 READ_APPEARANCE_COPY("window.inactive.button.iconify.hover.bg",
886 theme->btn_iconify->a_hover_unfocused, TRUE,
887 theme->btn_iconify->a_unfocused_unpressed);
890 READ_APPEARANCE_COPY("osd.button.unpressed.bg", theme->osd_unpressed_button, TRUE, a_focused_unpressed_tmp);
891 READ_APPEARANCE_COPY_TEXTURES("osd.button.pressed.bg", theme->osd_pressed_button, TRUE, a_focused_pressed_tmp, 5);
892 READ_APPEARANCE_COPY_TEXTURES("osd.button.focused.bg", theme->osd_focused_button, TRUE, a_focused_unpressed_tmp, 5);
894 theme->a_icon->surface.grad =
895 theme->a_clear->surface.grad =
896 theme->a_clear_tex->surface.grad =
897 theme->a_menu_text_title->surface.grad =
898 theme->a_menu_normal->surface.grad =
899 theme->a_menu_disabled->surface.grad =
900 theme->a_menu_text_normal->surface.grad =
901 theme->a_menu_text_selected->surface.grad =
902 theme->a_menu_text_disabled->surface.grad =
903 theme->a_menu_text_disabled_selected->surface.grad =
904 theme->a_menu_bullet_normal->surface.grad =
905 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
907 /* set up the textures */
908 theme->a_focused_label->texture[0].type = RR_TEXTURE_TEXT;
909 theme->a_focused_label->texture[0].data.text.justify = winjust;
910 theme->a_focused_label->texture[0].data.text.font=theme->win_font_focused;
911 theme->a_focused_label->texture[0].data.text.color =
912 theme->title_focused_color;
914 if (read_string(db, "window.active.label.text.font", &str)) {
918 if (strstr(str, "shadow=y")) {
919 if ((p = strstr(str, "shadowoffset=")))
920 i = parse_inline_number(p + strlen("shadowoffset="));
923 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
924 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
926 if ((p = strstr(str, "shadowtint=")))
928 i = parse_inline_number(p + strlen("shadowtint="));
929 j = (i > 0 ? 0 : 255);
932 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
933 theme->title_focused_shadow_alpha = i;
935 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
936 theme->title_focused_shadow_alpha = 50;
940 theme->a_focused_label->texture[0].data.text.shadow_color =
941 theme->title_focused_shadow_color;
942 theme->a_focused_label->texture[0].data.text.shadow_alpha =
943 theme->title_focused_shadow_alpha;
945 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
946 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
947 theme->osd_hilite_label->texture[0].data.text.font =
948 theme->osd_font_hilite;
949 theme->osd_hilite_label->texture[0].data.text.color =
950 theme->osd_text_active_color;
952 if (read_string(db, "osd.active.label.text.font", &str) ||
953 read_string(db, "osd.label.text.font", &str))
958 if (strstr(str, "shadow=y")) {
959 if ((p = strstr(str, "shadowoffset=")))
960 i = parse_inline_number(p + strlen("shadowoffset="));
963 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
964 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
966 if ((p = strstr(str, "shadowtint=")))
968 i = parse_inline_number(p + strlen("shadowtint="));
969 j = (i > 0 ? 0 : 255);
972 theme->osd_text_active_shadow_color = RrColorNew(inst, j, j, j);
973 theme->osd_text_active_shadow_alpha = i;
975 theme->osd_text_active_shadow_color = RrColorNew(inst, 0, 0, 0);
976 theme->osd_text_active_shadow_alpha = 50;
979 /* inherit the font settings from the focused label */
980 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x =
981 theme->a_focused_label->texture[0].data.text.shadow_offset_x;
982 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y =
983 theme->a_focused_label->texture[0].data.text.shadow_offset_y;
984 if (theme->title_focused_shadow_color)
985 theme->osd_text_active_shadow_color =
986 RrColorCopy(theme->title_focused_shadow_color);
988 theme->osd_text_active_shadow_color = RrColorNew(inst, 0, 0, 0);
989 theme->osd_text_active_shadow_alpha =
990 theme->title_focused_shadow_alpha;
993 theme->osd_hilite_label->texture[0].data.text.shadow_color =
994 theme->osd_text_active_shadow_color;
995 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
996 theme->osd_text_active_shadow_alpha;
998 theme->osd_unpressed_button->texture[0].type =
999 theme->osd_pressed_button->texture[0].type =
1000 theme->osd_focused_button->texture[0].type =
1003 theme->osd_unpressed_button->texture[0].data.text.justify =
1004 theme->osd_pressed_button->texture[0].data.text.justify =
1005 theme->osd_focused_button->texture[0].data.text.justify =
1008 theme->osd_unpressed_button->texture[0].data.text.font =
1009 theme->osd_pressed_button->texture[0].data.text.font =
1010 theme->osd_focused_button->texture[0].data.text.font =
1011 theme->osd_font_hilite;
1013 theme->osd_unpressed_button->texture[0].data.text.color =
1014 theme->osd_unpressed_color;
1015 theme->osd_pressed_button->texture[0].data.text.color =
1016 theme->osd_pressed_color;
1017 theme->osd_focused_button->texture[0].data.text.color =
1018 theme->osd_focused_color;
1020 theme->osd_pressed_button->texture[1].data.lineart.color =
1021 theme->osd_pressed_button->texture[2].data.lineart.color =
1022 theme->osd_pressed_button->texture[3].data.lineart.color =
1023 theme->osd_pressed_button->texture[4].data.lineart.color =
1024 theme->osd_pressed_lineart;
1026 theme->osd_focused_button->texture[1].data.lineart.color =
1027 theme->osd_focused_button->texture[2].data.lineart.color =
1028 theme->osd_focused_button->texture[3].data.lineart.color =
1029 theme->osd_focused_button->texture[4].data.lineart.color =
1030 theme->osd_focused_lineart;
1032 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
1033 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
1034 theme->a_unfocused_label->texture[0].data.text.font =
1035 theme->win_font_unfocused;
1036 theme->a_unfocused_label->texture[0].data.text.color =
1037 theme->title_unfocused_color;
1039 if (read_string(db, "window.inactive.label.text.font", &str)) {
1043 if (strstr(str, "shadow=y")) {
1044 if ((p = strstr(str, "shadowoffset=")))
1045 i = parse_inline_number(p + strlen("shadowoffset="));
1048 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
1049 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
1051 if ((p = strstr(str, "shadowtint=")))
1053 i = parse_inline_number(p + strlen("shadowtint="));
1054 j = (i > 0 ? 0 : 255);
1057 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
1058 theme->title_unfocused_shadow_alpha = i;
1060 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
1061 theme->title_unfocused_shadow_alpha = 50;
1065 theme->a_unfocused_label->texture[0].data.text.shadow_color =
1066 theme->title_unfocused_shadow_color;
1067 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
1068 theme->title_unfocused_shadow_alpha;
1070 theme->osd_unhilite_label->texture[0].type = RR_TEXTURE_TEXT;
1071 theme->osd_unhilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
1072 theme->osd_unhilite_label->texture[0].data.text.font =
1073 theme->osd_font_unhilite;
1074 theme->osd_unhilite_label->texture[0].data.text.color =
1075 theme->osd_text_inactive_color;
1077 if (read_string(db, "osd.inactive.label.text.font", &str))
1082 if (strstr(str, "shadow=y")) {
1083 if ((p = strstr(str, "shadowoffset=")))
1084 i = parse_inline_number(p + strlen("shadowoffset="));
1087 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_x=i;
1088 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_y=i;
1090 if ((p = strstr(str, "shadowtint=")))
1092 i = parse_inline_number(p + strlen("shadowtint="));
1093 j = (i > 0 ? 0 : 255);
1096 theme->osd_text_inactive_shadow_color = RrColorNew(inst, j, j, j);
1097 theme->osd_text_inactive_shadow_alpha = i;
1099 theme->osd_text_inactive_shadow_color = RrColorNew(inst, 0, 0, 0);
1100 theme->osd_text_inactive_shadow_alpha = 50;
1103 /* inherit the font settings from the unfocused label */
1104 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_x =
1105 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x;
1106 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_y =
1107 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y;
1108 if (theme->title_unfocused_shadow_color)
1109 theme->osd_text_inactive_shadow_color =
1110 RrColorCopy(theme->title_unfocused_shadow_color);
1112 theme->osd_text_inactive_shadow_color = RrColorNew(inst, 0, 0, 0);
1113 theme->osd_text_inactive_shadow_alpha =
1114 theme->title_unfocused_shadow_alpha;
1117 theme->osd_unhilite_label->texture[0].data.text.shadow_color =
1118 theme->osd_text_inactive_shadow_color;
1119 theme->osd_unhilite_label->texture[0].data.text.shadow_alpha =
1120 theme->osd_text_inactive_shadow_alpha;
1122 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
1123 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
1124 theme->a_menu_text_title->texture[0].data.text.font =
1125 theme->menu_title_font;
1126 theme->a_menu_text_title->texture[0].data.text.color =
1127 theme->menu_title_color;
1129 if (read_string(db, "menu.title.text.font", &str)) {
1133 if (strstr(str, "shadow=y")) {
1134 if ((p = strstr(str, "shadowoffset=")))
1135 i = parse_inline_number(p + strlen("shadowoffset="));
1138 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
1139 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
1141 if ((p = strstr(str, "shadowtint=")))
1143 i = parse_inline_number(p + strlen("shadowtint="));
1144 j = (i > 0 ? 0 : 255);
1147 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
1148 theme->menu_title_shadow_alpha = i;
1150 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
1151 theme->menu_title_shadow_alpha = 50;
1155 theme->a_menu_text_title->texture[0].data.text.shadow_color =
1156 theme->menu_title_shadow_color;
1157 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
1158 theme->menu_title_shadow_alpha;
1160 theme->a_menu_text_normal->texture[0].type =
1161 theme->a_menu_text_selected->texture[0].type =
1162 theme->a_menu_text_disabled->texture[0].type =
1163 theme->a_menu_text_disabled_selected->texture[0].type =
1165 theme->a_menu_text_normal->texture[0].data.text.justify =
1166 theme->a_menu_text_selected->texture[0].data.text.justify =
1167 theme->a_menu_text_disabled->texture[0].data.text.justify =
1168 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
1170 theme->a_menu_text_normal->texture[0].data.text.font =
1171 theme->a_menu_text_selected->texture[0].data.text.font =
1172 theme->a_menu_text_disabled->texture[0].data.text.font =
1173 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
1175 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
1176 theme->a_menu_text_selected->texture[0].data.text.color =
1177 theme->menu_selected_color;
1178 theme->a_menu_text_disabled->texture[0].data.text.color =
1179 theme->menu_disabled_color;
1180 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
1181 theme->menu_disabled_selected_color;
1183 if (read_string(db, "menu.items.font", &str)) {
1187 if (strstr(str, "shadow=y")) {
1188 if ((p = strstr(str, "shadowoffset=")))
1189 i = parse_inline_number(p + strlen("shadowoffset="));
1192 theme->a_menu_text_normal->
1193 texture[0].data.text.shadow_offset_x = i;
1194 theme->a_menu_text_normal->
1195 texture[0].data.text.shadow_offset_y = i;
1196 theme->a_menu_text_selected->
1197 texture[0].data.text.shadow_offset_x = i;
1198 theme->a_menu_text_selected->
1199 texture[0].data.text.shadow_offset_y = i;
1200 theme->a_menu_text_disabled->
1201 texture[0].data.text.shadow_offset_x = i;
1202 theme->a_menu_text_disabled->
1203 texture[0].data.text.shadow_offset_y = i;
1204 theme->a_menu_text_disabled_selected->
1205 texture[0].data.text.shadow_offset_x = i;
1206 theme->a_menu_text_disabled_selected->
1207 texture[0].data.text.shadow_offset_y = i;
1209 if ((p = strstr(str, "shadowtint=")))
1211 i = parse_inline_number(p + strlen("shadowtint="));
1212 j = (i > 0 ? 0 : 255);
1215 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
1216 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
1217 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
1218 theme->menu_text_normal_shadow_alpha = i;
1219 theme->menu_text_selected_shadow_alpha = i;
1220 theme->menu_text_disabled_shadow_alpha = i;
1221 theme->menu_text_disabled_selected_shadow_alpha = i;
1223 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
1224 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
1225 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
1226 theme->menu_text_normal_shadow_alpha = 50;
1227 theme->menu_text_selected_shadow_alpha = 50;
1228 theme->menu_text_disabled_selected_shadow_alpha = 50;
1232 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
1233 theme->menu_text_normal_shadow_color;
1234 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
1235 theme->menu_text_normal_shadow_alpha;
1236 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
1237 theme->menu_text_selected_shadow_color;
1238 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
1239 theme->menu_text_selected_shadow_alpha;
1240 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
1241 theme->menu_text_disabled_shadow_color;
1242 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
1243 theme->menu_text_disabled_shadow_alpha;
1244 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
1245 theme->menu_text_disabled_shadow_color;
1246 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
1247 theme->menu_text_disabled_shadow_alpha;
1249 theme->btn_max->a_disabled_focused->texture[0].type =
1250 theme->btn_max->a_disabled_unfocused->texture[0].type =
1251 theme->btn_max->a_hover_focused->texture[0].type =
1252 theme->btn_max->a_hover_unfocused->texture[0].type =
1253 theme->btn_max->a_toggled_hover_focused->texture[0].type =
1254 theme->btn_max->a_toggled_hover_unfocused->texture[0].type =
1255 theme->btn_max->a_toggled_focused_unpressed->texture[0].type =
1256 theme->btn_max->a_toggled_unfocused_unpressed->texture[0].type =
1257 theme->btn_max->a_toggled_focused_pressed->texture[0].type =
1258 theme->btn_max->a_toggled_unfocused_pressed->texture[0].type =
1259 theme->btn_max->a_focused_unpressed->texture[0].type =
1260 theme->btn_max->a_focused_pressed->texture[0].type =
1261 theme->btn_max->a_unfocused_unpressed->texture[0].type =
1262 theme->btn_max->a_unfocused_pressed->texture[0].type =
1263 theme->btn_close->a_disabled_focused->texture[0].type =
1264 theme->btn_close->a_disabled_unfocused->texture[0].type =
1265 theme->btn_close->a_hover_focused->texture[0].type =
1266 theme->btn_close->a_hover_unfocused->texture[0].type =
1267 theme->btn_close->a_focused_unpressed->texture[0].type =
1268 theme->btn_close->a_focused_pressed->texture[0].type =
1269 theme->btn_close->a_unfocused_unpressed->texture[0].type =
1270 theme->btn_close->a_unfocused_pressed->texture[0].type =
1271 theme->btn_desk->a_disabled_focused->texture[0].type =
1272 theme->btn_desk->a_disabled_unfocused->texture[0].type =
1273 theme->btn_desk->a_hover_focused->texture[0].type =
1274 theme->btn_desk->a_hover_unfocused->texture[0].type =
1275 theme->btn_desk->a_toggled_hover_focused->texture[0].type =
1276 theme->btn_desk->a_toggled_hover_unfocused->texture[0].type =
1277 theme->btn_desk->a_toggled_focused_unpressed->texture[0].type =
1278 theme->btn_desk->a_toggled_unfocused_unpressed->texture[0].type =
1279 theme->btn_desk->a_toggled_focused_pressed->texture[0].type =
1280 theme->btn_desk->a_toggled_unfocused_pressed->texture[0].type =
1281 theme->btn_desk->a_focused_unpressed->texture[0].type =
1282 theme->btn_desk->a_focused_pressed->texture[0].type =
1283 theme->btn_desk->a_unfocused_unpressed->texture[0].type =
1284 theme->btn_desk->a_unfocused_pressed->texture[0].type =
1285 theme->btn_shade->a_disabled_focused->texture[0].type =
1286 theme->btn_shade->a_disabled_unfocused->texture[0].type =
1287 theme->btn_shade->a_hover_focused->texture[0].type =
1288 theme->btn_shade->a_hover_unfocused->texture[0].type =
1289 theme->btn_shade->a_toggled_hover_focused->texture[0].type =
1290 theme->btn_shade->a_toggled_hover_unfocused->texture[0].type =
1291 theme->btn_shade->a_toggled_focused_unpressed->texture[0].type =
1292 theme->btn_shade->a_toggled_unfocused_unpressed->texture[0].type =
1293 theme->btn_shade->a_toggled_focused_pressed->texture[0].type =
1294 theme->btn_shade->a_toggled_unfocused_pressed->texture[0].type =
1295 theme->btn_shade->a_focused_unpressed->texture[0].type =
1296 theme->btn_shade->a_focused_pressed->texture[0].type =
1297 theme->btn_shade->a_unfocused_unpressed->texture[0].type =
1298 theme->btn_shade->a_unfocused_pressed->texture[0].type =
1299 theme->btn_iconify->a_disabled_focused->texture[0].type =
1300 theme->btn_iconify->a_disabled_unfocused->texture[0].type =
1301 theme->btn_iconify->a_hover_focused->texture[0].type =
1302 theme->btn_iconify->a_hover_unfocused->texture[0].type =
1303 theme->btn_iconify->a_focused_unpressed->texture[0].type =
1304 theme->btn_iconify->a_focused_pressed->texture[0].type =
1305 theme->btn_iconify->a_unfocused_unpressed->texture[0].type =
1306 theme->btn_iconify->a_unfocused_pressed->texture[0].type =
1307 theme->a_menu_bullet_normal->texture[0].type =
1308 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
1310 theme->btn_max->a_disabled_focused->texture[0].data.mask.mask =
1311 theme->btn_max->a_disabled_unfocused->texture[0].data.mask.mask =
1312 theme->btn_max->disabled_mask;
1313 theme->btn_max->a_hover_focused->texture[0].data.mask.mask =
1314 theme->btn_max->a_hover_unfocused->texture[0].data.mask.mask =
1315 theme->btn_max->hover_mask;
1316 theme->btn_max->a_focused_pressed->texture[0].data.mask.mask =
1317 theme->btn_max->a_unfocused_pressed->texture[0].data.mask.mask =
1318 theme->btn_max->pressed_mask;
1319 theme->btn_max->a_focused_unpressed->texture[0].data.mask.mask =
1320 theme->btn_max->a_unfocused_unpressed->texture[0].data.mask.mask =
1321 theme->btn_max->mask;
1322 theme->btn_max->a_toggled_hover_focused->texture[0].data.mask.mask =
1323 theme->btn_max->a_toggled_hover_unfocused->texture[0].data.mask.mask =
1324 theme->btn_max->toggled_hover_mask;
1325 theme->btn_max->a_toggled_focused_unpressed->texture[0].data.mask.mask =
1326 theme->btn_max->a_toggled_unfocused_unpressed->
1327 texture[0].data.mask.mask = theme->btn_max->toggled_mask;
1328 theme->btn_max->a_toggled_focused_pressed->texture[0].data.mask.mask =
1329 theme->btn_max->a_toggled_unfocused_pressed->texture[0].data.mask.mask
1330 = theme->btn_max->toggled_pressed_mask;
1331 theme->btn_close->a_disabled_focused->texture[0].data.mask.mask =
1332 theme->btn_close->a_disabled_unfocused->texture[0].data.mask.mask =
1333 theme->btn_close->disabled_mask;
1334 theme->btn_close->a_hover_focused->texture[0].data.mask.mask =
1335 theme->btn_close->a_hover_unfocused->texture[0].data.mask.mask =
1336 theme->btn_close->hover_mask;
1337 theme->btn_close->a_focused_pressed->texture[0].data.mask.mask =
1338 theme->btn_close->a_unfocused_pressed->texture[0].data.mask.mask =
1339 theme->btn_close->pressed_mask;
1340 theme->btn_close->a_focused_unpressed->texture[0].data.mask.mask =
1341 theme->btn_close->a_unfocused_unpressed->texture[0].data.mask.mask =
1342 theme->btn_close->mask;
1343 theme->btn_desk->a_disabled_focused->texture[0].data.mask.mask =
1344 theme->btn_desk->a_disabled_unfocused->texture[0].data.mask.mask =
1345 theme->btn_desk->disabled_mask;
1346 theme->btn_desk->a_hover_focused->texture[0].data.mask.mask =
1347 theme->btn_desk->a_hover_unfocused->texture[0].data.mask.mask =
1348 theme->btn_desk->hover_mask;
1349 theme->btn_desk->a_focused_pressed->texture[0].data.mask.mask =
1350 theme->btn_desk->a_unfocused_pressed->texture[0].data.mask.mask =
1351 theme->btn_desk->pressed_mask;
1352 theme->btn_desk->a_focused_unpressed->texture[0].data.mask.mask =
1353 theme->btn_desk->a_unfocused_unpressed->texture[0].data.mask.mask =
1354 theme->btn_desk->mask;
1355 theme->btn_desk->a_toggled_hover_focused->texture[0].data.mask.mask =
1356 theme->btn_desk->a_toggled_hover_unfocused->texture[0].data.mask.mask =
1357 theme->btn_desk->toggled_hover_mask;
1358 theme->btn_desk->a_toggled_focused_unpressed->texture[0].data.mask.mask =
1359 theme->btn_desk->a_toggled_unfocused_unpressed->
1360 texture[0].data.mask.mask = theme->btn_desk->toggled_mask;
1361 theme->btn_desk->a_toggled_focused_pressed->texture[0].data.mask.mask =
1362 theme->btn_desk->a_toggled_unfocused_pressed->texture[0].data.mask.mask
1363 = theme->btn_desk->toggled_pressed_mask;
1364 theme->btn_shade->a_disabled_focused->texture[0].data.mask.mask =
1365 theme->btn_shade->a_disabled_unfocused->texture[0].data.mask.mask =
1366 theme->btn_shade->disabled_mask;
1367 theme->btn_shade->a_hover_focused->texture[0].data.mask.mask =
1368 theme->btn_shade->a_hover_unfocused->texture[0].data.mask.mask =
1369 theme->btn_shade->hover_mask;
1370 theme->btn_shade->a_focused_pressed->texture[0].data.mask.mask =
1371 theme->btn_shade->a_unfocused_pressed->texture[0].data.mask.mask =
1372 theme->btn_shade->pressed_mask;
1373 theme->btn_shade->a_focused_unpressed->texture[0].data.mask.mask =
1374 theme->btn_shade->a_unfocused_unpressed->texture[0].data.mask.mask =
1375 theme->btn_shade->mask;
1376 theme->btn_shade->a_toggled_hover_focused->texture[0].data.mask.mask =
1377 theme->btn_shade->a_toggled_hover_unfocused->texture[0].data.mask.mask
1378 = theme->btn_shade->toggled_hover_mask;
1379 theme->btn_shade->a_toggled_focused_unpressed->texture[0].data.mask.mask =
1380 theme->btn_shade->a_toggled_unfocused_unpressed->
1381 texture[0].data.mask.mask = theme->btn_shade->toggled_mask;
1382 theme->btn_shade->a_toggled_focused_pressed->texture[0].data.mask.mask =
1383 theme->btn_shade->a_toggled_unfocused_pressed->
1384 texture[0].data.mask.mask = theme->btn_shade->toggled_pressed_mask;
1385 theme->btn_iconify->a_disabled_focused->texture[0].data.mask.mask =
1386 theme->btn_iconify->a_disabled_unfocused->texture[0].data.mask.mask =
1387 theme->btn_iconify->disabled_mask;
1388 theme->btn_iconify->a_hover_focused->texture[0].data.mask.mask =
1389 theme->btn_iconify->a_hover_unfocused->texture[0].data.mask.mask =
1390 theme->btn_iconify->hover_mask;
1391 theme->btn_iconify->a_focused_pressed->texture[0].data.mask.mask =
1392 theme->btn_iconify->a_unfocused_pressed->texture[0].data.mask.mask =
1393 theme->btn_iconify->pressed_mask;
1394 theme->btn_iconify->a_focused_unpressed->texture[0].data.mask.mask =
1395 theme->btn_iconify->a_unfocused_unpressed->texture[0].data.mask.mask =
1396 theme->btn_iconify->mask;
1397 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1398 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1399 theme->menu_bullet_mask;
1400 theme->btn_max->a_disabled_focused->texture[0].data.mask.color =
1401 theme->btn_max->disabled_focused_color;
1402 theme->btn_close->a_disabled_focused->texture[0].data.mask.color =
1403 theme->btn_close->disabled_focused_color;
1404 theme->btn_desk->a_disabled_focused->texture[0].data.mask.color =
1405 theme->btn_desk->disabled_focused_color;
1406 theme->btn_shade->a_disabled_focused->texture[0].data.mask.color =
1407 theme->btn_shade->disabled_focused_color;
1408 theme->btn_iconify->a_disabled_focused->texture[0].data.mask.color =
1409 theme->btn_iconify->disabled_focused_color;
1410 theme->btn_max->a_disabled_unfocused->texture[0].data.mask.color =
1411 theme->btn_max->disabled_unfocused_color;
1412 theme->btn_close->a_disabled_unfocused->texture[0].data.mask.color =
1413 theme->btn_close->disabled_unfocused_color;
1414 theme->btn_desk->a_disabled_unfocused->texture[0].data.mask.color =
1415 theme->btn_desk->disabled_unfocused_color;
1416 theme->btn_shade->a_disabled_unfocused->texture[0].data.mask.color =
1417 theme->btn_shade->disabled_unfocused_color;
1418 theme->btn_iconify->a_disabled_unfocused->texture[0].data.mask.color =
1419 theme->btn_iconify->disabled_unfocused_color;
1420 theme->btn_max->a_hover_focused->texture[0].data.mask.color =
1421 theme->btn_max->hover_focused_color;
1422 theme->btn_close->a_hover_focused->texture[0].data.mask.color =
1423 theme->btn_close->hover_focused_color;
1424 theme->btn_desk->a_hover_focused->texture[0].data.mask.color =
1425 theme->btn_desk->hover_focused_color;
1426 theme->btn_shade->a_hover_focused->texture[0].data.mask.color =
1427 theme->btn_shade->hover_focused_color;
1428 theme->btn_iconify->a_hover_focused->texture[0].data.mask.color =
1429 theme->btn_iconify->hover_focused_color;
1430 theme->btn_max->a_hover_unfocused->texture[0].data.mask.color =
1431 theme->btn_max->hover_unfocused_color;
1432 theme->btn_close->a_hover_unfocused->texture[0].data.mask.color =
1433 theme->btn_close->hover_unfocused_color;
1434 theme->btn_desk->a_hover_unfocused->texture[0].data.mask.color =
1435 theme->btn_desk->hover_unfocused_color;
1436 theme->btn_shade->a_hover_unfocused->texture[0].data.mask.color =
1437 theme->btn_shade->hover_unfocused_color;
1438 theme->btn_iconify->a_hover_unfocused->texture[0].data.mask.color =
1439 theme->btn_iconify->hover_unfocused_color;
1440 theme->btn_max->a_toggled_hover_focused->texture[0].data.mask.color =
1441 theme->btn_max->toggled_hover_focused_color;
1442 theme->btn_desk->a_toggled_hover_focused->texture[0].data.mask.color =
1443 theme->btn_desk->toggled_hover_focused_color;
1444 theme->btn_shade->a_toggled_hover_focused->texture[0].data.mask.color =
1445 theme->btn_shade->toggled_hover_focused_color;
1446 theme->btn_max->a_toggled_hover_unfocused->texture[0].data.mask.color =
1447 theme->btn_max->toggled_hover_unfocused_color;
1448 theme->btn_desk->a_toggled_hover_unfocused->texture[0].data.mask.color =
1449 theme->btn_desk->toggled_hover_unfocused_color;
1450 theme->btn_shade->a_toggled_hover_unfocused->texture[0].data.mask.color =
1451 theme->btn_shade->toggled_hover_unfocused_color;
1452 theme->btn_max->a_toggled_focused_unpressed->texture[0].data.mask.color =
1453 theme->btn_max->toggled_focused_unpressed_color;
1454 theme->btn_desk->a_toggled_focused_unpressed->texture[0].data.mask.color =
1455 theme->btn_desk->toggled_focused_unpressed_color;
1456 theme->btn_shade->a_toggled_focused_unpressed->texture[0].data.mask.color =
1457 theme->btn_shade->toggled_focused_unpressed_color;
1458 theme->btn_max->a_toggled_unfocused_unpressed->texture[0].data.mask.color =
1459 theme->btn_max->toggled_unfocused_unpressed_color;
1460 theme->btn_desk->a_toggled_unfocused_unpressed->texture[0].data.mask.color
1461 = theme->btn_desk->toggled_unfocused_unpressed_color;
1462 theme->btn_shade->a_toggled_unfocused_unpressed->texture[0].data.mask.color
1463 = theme->btn_shade->toggled_unfocused_unpressed_color;
1464 theme->btn_max->a_toggled_focused_pressed->texture[0].data.mask.color =
1465 theme->btn_max->toggled_focused_pressed_color;
1466 theme->btn_desk->a_toggled_focused_pressed->texture[0].data.mask.color =
1467 theme->btn_desk->toggled_focused_pressed_color;
1468 theme->btn_shade->a_toggled_focused_pressed->texture[0].data.mask.color =
1469 theme->btn_shade->toggled_focused_pressed_color;
1470 theme->btn_max->a_toggled_unfocused_pressed->texture[0].data.mask.color =
1471 theme->btn_max->toggled_unfocused_pressed_color;
1472 theme->btn_desk->a_toggled_unfocused_pressed->texture[0].data.mask.color =
1473 theme->btn_desk->toggled_unfocused_pressed_color;
1474 theme->btn_shade->a_toggled_unfocused_pressed->texture[0].data.mask.color =
1475 theme->btn_shade->toggled_unfocused_pressed_color;
1476 theme->btn_max->a_focused_unpressed->texture[0].data.mask.color =
1477 theme->btn_max->focused_unpressed_color;
1478 theme->btn_close->a_focused_unpressed->texture[0].data.mask.color =
1479 theme->btn_close->focused_unpressed_color;
1480 theme->btn_desk->a_focused_unpressed->texture[0].data.mask.color =
1481 theme->btn_desk->focused_unpressed_color;
1482 theme->btn_shade->a_focused_unpressed->texture[0].data.mask.color =
1483 theme->btn_shade->focused_unpressed_color;
1484 theme->btn_iconify->a_focused_unpressed->texture[0].data.mask.color =
1485 theme->btn_iconify->focused_unpressed_color;
1486 theme->btn_max->a_focused_pressed->texture[0].data.mask.color =
1487 theme->btn_max->focused_pressed_color;
1488 theme->btn_close->a_focused_pressed->texture[0].data.mask.color =
1489 theme->btn_close->focused_pressed_color;
1490 theme->btn_desk->a_focused_pressed->texture[0].data.mask.color =
1491 theme->btn_desk->focused_pressed_color;
1492 theme->btn_shade->a_focused_pressed->texture[0].data.mask.color =
1493 theme->btn_shade->focused_pressed_color;
1494 theme->btn_iconify->a_focused_pressed->texture[0].data.mask.color =
1495 theme->btn_iconify->focused_pressed_color;
1496 theme->btn_max->a_unfocused_unpressed->texture[0].data.mask.color =
1497 theme->btn_max->unfocused_unpressed_color;
1498 theme->btn_close->a_unfocused_unpressed->texture[0].data.mask.color =
1499 theme->btn_close->unfocused_unpressed_color;
1500 theme->btn_desk->a_unfocused_unpressed->texture[0].data.mask.color =
1501 theme->btn_desk->unfocused_unpressed_color;
1502 theme->btn_shade->a_unfocused_unpressed->texture[0].data.mask.color =
1503 theme->btn_shade->unfocused_unpressed_color;
1504 theme->btn_iconify->a_unfocused_unpressed->texture[0].data.mask.color =
1505 theme->btn_iconify->unfocused_unpressed_color;
1506 theme->btn_max->a_unfocused_pressed->texture[0].data.mask.color =
1507 theme->btn_max->unfocused_pressed_color;
1508 theme->btn_close->a_unfocused_pressed->texture[0].data.mask.color =
1509 theme->btn_close->unfocused_pressed_color;
1510 theme->btn_desk->a_unfocused_pressed->texture[0].data.mask.color =
1511 theme->btn_desk->unfocused_pressed_color;
1512 theme->btn_shade->a_unfocused_pressed->texture[0].data.mask.color =
1513 theme->btn_shade->unfocused_pressed_color;
1514 theme->btn_iconify->a_unfocused_pressed->texture[0].data.mask.color =
1515 theme->btn_iconify->unfocused_pressed_color;
1516 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1517 theme->menu_bullet_color;
1518 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1519 theme->menu_bullet_selected_color;
1522 XrmDestroyDatabase(db);
1524 /* set the font heights */
1525 theme->win_font_height = RrFontHeight
1526 (theme->win_font_focused,
1527 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1528 theme->win_font_height =
1529 MAX(theme->win_font_height,
1531 (theme->win_font_focused,
1532 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1533 theme->menu_title_font_height = RrFontHeight
1534 (theme->menu_title_font,
1535 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1536 theme->menu_font_height = RrFontHeight
1538 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1540 /* calculate some last extents */
1542 gint ft, fb, fl, fr, ut, ub, ul, ur;
1544 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1545 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1546 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1547 theme->label_height += theme->label_height % 2;
1549 /* this would be nice I think, since padding.width can now be 0,
1550 but it breaks frame.c horribly and I don't feel like fixing that
1551 right now, so if anyone complains, here is how to keep text from
1552 going over the title's bevel/border with a padding.width of 0 and a
1553 bevelless/borderless label
1554 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1555 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1556 theme->title_height = theme->label_height +
1557 MAX(MAX(theme->padding * 2, ft + fb),
1558 MAX(theme->padding * 2, ut + ub));
1560 theme->title_height = theme->label_height + theme->paddingy * 2;
1562 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1563 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1564 theme->menu_title_height = theme->menu_title_label_height +
1565 theme->paddingy * 2;
1567 theme->button_size = theme->label_height - 2;
1568 theme->grip_width = 25;
1570 RrAppearanceFree(a_disabled_focused_tmp);
1571 RrAppearanceFree(a_disabled_unfocused_tmp);
1572 RrAppearanceFree(a_hover_focused_tmp);
1573 RrAppearanceFree(a_hover_unfocused_tmp);
1574 RrAppearanceFree(a_focused_unpressed_tmp);
1575 RrAppearanceFree(a_focused_pressed_tmp);
1576 RrAppearanceFree(a_unfocused_unpressed_tmp);
1577 RrAppearanceFree(a_unfocused_pressed_tmp);
1578 RrAppearanceFree(a_toggled_hover_focused_tmp);
1579 RrAppearanceFree(a_toggled_hover_unfocused_tmp);
1580 RrAppearanceFree(a_toggled_focused_unpressed_tmp);
1581 RrAppearanceFree(a_toggled_focused_pressed_tmp);
1582 RrAppearanceFree(a_toggled_unfocused_unpressed_tmp);
1583 RrAppearanceFree(a_toggled_unfocused_pressed_tmp);
1588 void RrThemeFree(RrTheme *theme)
1591 g_free(theme->name);
1593 RrButtonFree(theme->btn_max);
1594 RrButtonFree(theme->btn_close);
1595 RrButtonFree(theme->btn_desk);
1596 RrButtonFree(theme->btn_shade);
1597 RrButtonFree(theme->btn_iconify);
1599 RrColorFree(theme->menu_border_color);
1600 RrColorFree(theme->osd_border_color);
1601 RrColorFree(theme->frame_focused_border_color);
1602 RrColorFree(theme->frame_unfocused_border_color);
1603 RrColorFree(theme->title_separator_focused_color);
1604 RrColorFree(theme->title_separator_unfocused_color);
1605 RrColorFree(theme->cb_unfocused_color);
1606 RrColorFree(theme->cb_focused_color);
1607 RrColorFree(theme->title_focused_color);
1608 RrColorFree(theme->title_unfocused_color);
1609 RrColorFree(theme->titlebut_disabled_focused_color);
1610 RrColorFree(theme->titlebut_disabled_unfocused_color);
1611 RrColorFree(theme->titlebut_hover_focused_color);
1612 RrColorFree(theme->titlebut_hover_unfocused_color);
1613 RrColorFree(theme->titlebut_toggled_hover_focused_color);
1614 RrColorFree(theme->titlebut_toggled_hover_unfocused_color);
1615 RrColorFree(theme->titlebut_toggled_focused_pressed_color);
1616 RrColorFree(theme->titlebut_toggled_unfocused_pressed_color);
1617 RrColorFree(theme->titlebut_toggled_focused_unpressed_color);
1618 RrColorFree(theme->titlebut_toggled_unfocused_unpressed_color);
1619 RrColorFree(theme->titlebut_focused_pressed_color);
1620 RrColorFree(theme->titlebut_unfocused_pressed_color);
1621 RrColorFree(theme->titlebut_focused_unpressed_color);
1622 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1623 RrColorFree(theme->menu_title_color);
1624 RrColorFree(theme->menu_sep_color);
1625 RrColorFree(theme->menu_color);
1626 RrColorFree(theme->menu_bullet_color);
1627 RrColorFree(theme->menu_bullet_selected_color);
1628 RrColorFree(theme->menu_selected_color);
1629 RrColorFree(theme->menu_disabled_color);
1630 RrColorFree(theme->menu_disabled_selected_color);
1631 RrColorFree(theme->title_focused_shadow_color);
1632 RrColorFree(theme->title_unfocused_shadow_color);
1633 RrColorFree(theme->osd_text_active_color);
1634 RrColorFree(theme->osd_text_inactive_color);
1635 RrColorFree(theme->osd_text_active_shadow_color);
1636 RrColorFree(theme->osd_text_inactive_shadow_color);
1637 RrColorFree(theme->osd_pressed_color);
1638 RrColorFree(theme->osd_unpressed_color);
1639 RrColorFree(theme->osd_focused_color);
1640 RrColorFree(theme->osd_pressed_lineart);
1641 RrColorFree(theme->osd_focused_lineart);
1642 RrColorFree(theme->menu_title_shadow_color);
1643 RrColorFree(theme->menu_text_normal_shadow_color);
1644 RrColorFree(theme->menu_text_selected_shadow_color);
1645 RrColorFree(theme->menu_text_disabled_shadow_color);
1646 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1648 g_free(theme->def_win_icon);
1650 RrPixmapMaskFree(theme->menu_bullet_mask);
1651 RrPixmapMaskFree(theme->down_arrow_mask);
1652 RrPixmapMaskFree(theme->up_arrow_mask);
1654 RrFontClose(theme->win_font_focused);
1655 RrFontClose(theme->win_font_unfocused);
1656 RrFontClose(theme->menu_title_font);
1657 RrFontClose(theme->menu_font);
1658 RrFontClose(theme->osd_font_hilite);
1659 RrFontClose(theme->osd_font_unhilite);
1661 RrAppearanceFree(theme->a_focused_grip);
1662 RrAppearanceFree(theme->a_unfocused_grip);
1663 RrAppearanceFree(theme->a_focused_title);
1664 RrAppearanceFree(theme->a_unfocused_title);
1665 RrAppearanceFree(theme->a_focused_label);
1666 RrAppearanceFree(theme->a_unfocused_label);
1667 RrAppearanceFree(theme->a_icon);
1668 RrAppearanceFree(theme->a_focused_handle);
1669 RrAppearanceFree(theme->a_unfocused_handle);
1670 RrAppearanceFree(theme->a_menu);
1671 RrAppearanceFree(theme->a_menu_title);
1672 RrAppearanceFree(theme->a_menu_text_title);
1673 RrAppearanceFree(theme->a_menu_normal);
1674 RrAppearanceFree(theme->a_menu_selected);
1675 RrAppearanceFree(theme->a_menu_disabled);
1676 RrAppearanceFree(theme->a_menu_disabled_selected);
1677 RrAppearanceFree(theme->a_menu_text_normal);
1678 RrAppearanceFree(theme->a_menu_text_selected);
1679 RrAppearanceFree(theme->a_menu_text_disabled);
1680 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1681 RrAppearanceFree(theme->a_menu_bullet_normal);
1682 RrAppearanceFree(theme->a_menu_bullet_selected);
1683 RrAppearanceFree(theme->a_clear);
1684 RrAppearanceFree(theme->a_clear_tex);
1685 RrAppearanceFree(theme->osd_bg);
1686 RrAppearanceFree(theme->osd_hilite_bg);
1687 RrAppearanceFree(theme->osd_hilite_label);
1688 RrAppearanceFree(theme->osd_unhilite_bg);
1689 RrAppearanceFree(theme->osd_unhilite_label);
1690 RrAppearanceFree(theme->osd_pressed_button);
1691 RrAppearanceFree(theme->osd_unpressed_button);
1692 RrAppearanceFree(theme->osd_focused_button);
1694 g_slice_free(RrTheme, theme);
1698 static XrmDatabase loaddb(const gchar *name, gchar **path)
1701 XrmDatabase db = NULL;
1704 if (name[0] == '/') {
1705 s = g_build_filename(name, "openbox-3", "themerc", NULL);
1706 if ((db = XrmGetFileDatabase(s)))
1707 *path = g_path_get_dirname(s);
1712 p = obt_paths_new();
1714 /* XXX backwards compatibility, remove me sometime later */
1715 s = g_build_filename(g_get_home_dir(), ".themes", name,
1716 "openbox-3", "themerc", NULL);
1717 if ((db = XrmGetFileDatabase(s)))
1718 *path = g_path_get_dirname(s);
1721 for (it = obt_paths_data_dirs(p); !db && it; it = g_slist_next(it))
1723 s = g_build_filename(it->data, "themes", name,
1724 "openbox-3", "themerc", NULL);
1725 if ((db = XrmGetFileDatabase(s)))
1726 *path = g_path_get_dirname(s);
1734 s = g_build_filename(name, "themerc", NULL);
1735 if ((db = XrmGetFileDatabase(s)))
1736 *path = g_path_get_dirname(s);
1743 static gchar *create_class_name(const gchar *rname)
1745 gchar *rclass = g_strdup(rname);
1750 p = strchr(p+1, '.');
1751 if (p == NULL) break;
1753 if (*p == '\0') break;
1758 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1760 gboolean ret = FALSE;
1761 gchar *rclass = create_class_name(rname);
1762 gchar *rettype, *end;
1765 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1766 retvalue.addr != NULL) {
1767 *value = (gint)strtol(retvalue.addr, &end, 10);
1768 if (end != retvalue.addr)
1776 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1778 gboolean ret = FALSE;
1779 gchar *rclass = create_class_name(rname);
1783 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1784 retvalue.addr != NULL) {
1785 *value = retvalue.addr;
1793 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1794 const gchar *rname, RrColor **value)
1796 gboolean ret = FALSE;
1797 gchar *rclass = create_class_name(rname);
1801 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1802 retvalue.addr != NULL) {
1803 RrColor *c = RrColorParse(inst, retvalue.addr);
1814 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1815 RrTheme *theme, const gchar *maskname,
1816 RrPixmapMask **value)
1818 gboolean ret = FALSE;
1820 gint hx, hy; /* ignored */
1824 s = g_build_filename(path, maskname, NULL);
1825 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1827 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1835 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1836 RrReliefType *relief, RrBevelType *bevel,
1837 gboolean *interlaced, gboolean *border,
1838 gboolean allow_trans)
1842 /* convert to all lowercase */
1843 for (t = tex; *t != '\0'; ++t)
1844 *t = g_ascii_tolower(*t);
1846 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1847 *grad = RR_SURFACE_PARENTREL;
1849 if (strstr(tex, "gradient") != NULL) {
1850 if (strstr(tex, "crossdiagonal") != NULL)
1851 *grad = RR_SURFACE_CROSS_DIAGONAL;
1852 else if (strstr(tex, "pyramid") != NULL)
1853 *grad = RR_SURFACE_PYRAMID;
1854 else if (strstr(tex, "mirrorhorizontal") != NULL)
1855 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1856 else if (strstr(tex, "horizontal") != NULL)
1857 *grad = RR_SURFACE_HORIZONTAL;
1858 else if (strstr(tex, "splitvertical") != NULL)
1859 *grad = RR_SURFACE_SPLIT_VERTICAL;
1860 else if (strstr(tex, "vertical") != NULL)
1861 *grad = RR_SURFACE_VERTICAL;
1863 *grad = RR_SURFACE_DIAGONAL;
1865 *grad = RR_SURFACE_SOLID;
1869 if (strstr(tex, "sunken") != NULL)
1870 *relief = RR_RELIEF_SUNKEN;
1871 else if (strstr(tex, "flat") != NULL)
1872 *relief = RR_RELIEF_FLAT;
1873 else if (strstr(tex, "raised") != NULL)
1874 *relief = RR_RELIEF_RAISED;
1876 *relief = (*grad == RR_SURFACE_PARENTREL) ?
1877 RR_RELIEF_FLAT : RR_RELIEF_RAISED;
1880 if (*relief == RR_RELIEF_FLAT) {
1881 if (strstr(tex, "border") != NULL)
1884 if (strstr(tex, "bevel2") != NULL)
1885 *bevel = RR_BEVEL_2;
1887 *bevel = RR_BEVEL_1;
1890 if (strstr(tex, "interlaced") != NULL)
1893 *interlaced = FALSE;
1896 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1897 const gchar *rname, RrAppearance *value,
1898 gboolean allow_trans)
1900 gboolean ret = FALSE;
1901 gchar *rclass = create_class_name(rname);
1902 gchar *cname, *ctoname, *bcname, *icname, *hname, *sname;
1903 gchar *csplitname, *ctosplitname;
1908 cname = g_strconcat(rname, ".color", NULL);
1909 ctoname = g_strconcat(rname, ".colorTo", NULL);
1910 bcname = g_strconcat(rname, ".border.color", NULL);
1911 icname = g_strconcat(rname, ".interlace.color", NULL);
1912 hname = g_strconcat(rname, ".highlight", NULL);
1913 sname = g_strconcat(rname, ".shadow", NULL);
1914 csplitname = g_strconcat(rname, ".color.splitTo", NULL);
1915 ctosplitname = g_strconcat(rname, ".colorTo.splitTo", NULL);
1917 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1918 retvalue.addr != NULL) {
1919 parse_appearance(retvalue.addr,
1920 &value->surface.grad,
1921 &value->surface.relief,
1922 &value->surface.bevel,
1923 &value->surface.interlaced,
1924 &value->surface.border,
1926 if (!read_color(db, inst, cname, &value->surface.primary))
1927 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1928 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1929 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1930 if (value->surface.border)
1931 if (!read_color(db, inst, bcname,
1932 &value->surface.border_color))
1933 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1934 if (value->surface.interlaced)
1935 if (!read_color(db, inst, icname,
1936 &value->surface.interlace_color))
1937 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1938 if (read_int(db, hname, &i) && i >= 0)
1939 value->surface.bevel_light_adjust = i;
1940 if (read_int(db, sname, &i) && i >= 0 && i <= 256)
1941 value->surface.bevel_dark_adjust = i;
1943 if (value->surface.grad == RR_SURFACE_SPLIT_VERTICAL) {
1946 if (!read_color(db, inst, csplitname,
1947 &value->surface.split_primary))
1949 r = value->surface.primary->r;
1951 g = value->surface.primary->g;
1953 b = value->surface.primary->b;
1955 if (r > 0xFF) r = 0xFF;
1956 if (g > 0xFF) g = 0xFF;
1957 if (b > 0xFF) b = 0xFF;
1958 value->surface.split_primary = RrColorNew(inst, r, g, b);
1961 if (!read_color(db, inst, ctosplitname,
1962 &value->surface.split_secondary))
1964 r = value->surface.secondary->r;
1966 g = value->surface.secondary->g;
1968 b = value->surface.secondary->b;
1970 if (r > 0xFF) r = 0xFF;
1971 if (g > 0xFF) g = 0xFF;
1972 if (b > 0xFF) b = 0xFF;
1973 value->surface.split_secondary = RrColorNew(inst, r, g, b);
1980 g_free(ctosplitname);
1992 static int parse_inline_number(const char *p)
2000 for (; isdigit(*p); ++p)
2001 res = res * 10 + *p - '0';
2006 static void set_default_appearance(RrAppearance *a)
2008 a->surface.grad = RR_SURFACE_SOLID;
2009 a->surface.relief = RR_RELIEF_FLAT;
2010 a->surface.bevel = RR_BEVEL_1;
2011 a->surface.interlaced = FALSE;
2012 a->surface.border = FALSE;
2013 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
2014 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
2017 /* Reads the output from gimp's C-Source file format into valid RGBA data for
2018 an RrTextureRGBA. */
2019 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
2024 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
2026 for (i = 0; i < width * height; ++i) {
2027 guchar a = ((*p >> 24) & 0xff);
2028 guchar b = ((*p >> 16) & 0xff);
2029 guchar g = ((*p >> 8) & 0xff);
2030 guchar r = ((*p >> 0) & 0xff);
2032 *p = ((r << RrDefaultRedOffset) +
2033 (g << RrDefaultGreenOffset) +
2034 (b << RrDefaultBlueOffset) +
2035 (a << RrDefaultAlphaOffset));
2042 static void read_button_colors(XrmDatabase db, const RrInstance *inst,
2043 const RrTheme *theme, RrButton *btn,
2044 const gchar *btnname)
2048 /* active unpressed */
2049 name = g_strdup_printf("window.active.button.%s.unpressed.image.color",
2051 READ_COLOR(name, btn->focused_unpressed_color,
2052 RrColorCopy(theme->titlebut_focused_unpressed_color));
2055 /* inactive unpressed */
2056 name = g_strdup_printf("window.inactive.button.%s.unpressed.image.color",
2058 READ_COLOR(name, btn->unfocused_unpressed_color,
2059 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
2062 /* active pressed */
2063 name = g_strdup_printf("window.active.button.%s.pressed.image.color",
2065 READ_COLOR(name, btn->focused_pressed_color,
2066 RrColorCopy(theme->titlebut_focused_pressed_color));
2069 /* inactive pressed */
2070 name = g_strdup_printf("window.inactive.button.%s.pressed.image.color",
2072 READ_COLOR(name, btn->unfocused_pressed_color,
2073 RrColorCopy(theme->titlebut_unfocused_pressed_color));
2076 /* active disabled */
2077 name = g_strdup_printf("window.active.button.%s.disabled.image.color",
2079 READ_COLOR(name, btn->disabled_focused_color,
2080 RrColorCopy(theme->titlebut_disabled_focused_color));
2083 /* inactive disabled */
2084 name = g_strdup_printf("window.inactive.button.%s.disabled.image.color",
2086 READ_COLOR(name, btn->disabled_unfocused_color,
2087 RrColorCopy(theme->titlebut_disabled_unfocused_color));
2091 name = g_strdup_printf("window.active.button.%s.hover.image.color",
2093 READ_COLOR(name, btn->hover_focused_color,
2094 RrColorCopy(theme->titlebut_hover_focused_color));
2097 /* inactive hover */
2098 name = g_strdup_printf("window.inactive.button.%s.hover.image.color",
2100 READ_COLOR(name, btn->hover_unfocused_color,
2101 RrColorCopy(theme->titlebut_hover_unfocused_color));
2104 /* active toggled unpressed */
2105 name = g_strdup_printf("window.active.button.%s.toggled."
2106 "unpressed.image.color", btnname);
2107 READ_COLOR(name, btn->toggled_focused_unpressed_color,
2108 RrColorCopy(theme->titlebut_toggled_focused_unpressed_color));
2111 /* inactive toggled unpressed */
2112 name = g_strdup_printf("window.inactive.button.%s.toggled."
2113 "unpressed.image.color", btnname);
2114 READ_COLOR(name, btn->toggled_unfocused_unpressed_color,
2115 RrColorCopy(theme->titlebut_toggled_unfocused_unpressed_color));
2118 /* active toggled hover */
2119 name = g_strdup_printf("window.active.button.%s.toggled.hover.image.color",
2121 READ_COLOR(name, btn->toggled_hover_focused_color,
2122 RrColorCopy(theme->titlebut_toggled_hover_focused_color));
2126 /* inactive toggled hover */
2127 name = g_strdup_printf("window.inactive.button.%s.toggled.hover."
2128 "image.color", btnname);
2129 READ_COLOR(name, btn->toggled_hover_unfocused_color,
2130 RrColorCopy(theme->titlebut_toggled_hover_unfocused_color));
2133 /* active toggled pressed */
2134 name = g_strdup_printf("window.active.button.%s.toggled.pressed."
2135 "image.color", btnname);
2136 READ_COLOR(name, btn->toggled_focused_pressed_color,
2137 RrColorCopy(theme->titlebut_toggled_focused_pressed_color));
2140 /* inactive toggled pressed */
2141 name = g_strdup_printf("window.inactive.button.%s.toggled.pressed."
2142 "image.color", btnname);
2143 READ_COLOR(name, btn->toggled_unfocused_pressed_color,
2144 RrColorCopy(theme->titlebut_toggled_unfocused_pressed_color));