]> Dogcows Code - chaz/openbox/blob - obrender/theme.c
Merge branch 'master' into chaz
[chaz/openbox] / obrender / theme.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 theme.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #include "render.h"
21 #include "color.h"
22 #include "font.h"
23 #include "mask.h"
24 #include "theme.h"
25 #include "icon.h"
26 #include "obt/paths.h"
27
28 #include <X11/Xlib.h>
29 #include <X11/Xresource.h>
30 #include <ctype.h>
31 #include <stdlib.h>
32 #include <string.h>
33
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);
51
52 static RrFont *get_font(RrFont *target, RrFont **default_font,
53 const RrInstance *inst)
54 {
55 if (target) {
56 RrFontRef(target);
57 return target;
58 } else {
59 /* Only load the default font once */
60 if (*default_font) {
61 RrFontRef(*default_font);
62 } else {
63 *default_font = RrFontOpenDefault(inst);
64 }
65 return *default_font;
66 }
67 }
68
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) \
72 x_var = x_def;
73
74 #define READ_COLOR(x_resstr, x_var, x_def) \
75 if (!read_color(db, inst, x_resstr, & x_var)) \
76 x_var = x_def;
77
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)) \
81 x_var = x_def;
82
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);
86
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);
90
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); }
95
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); }
102
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); }
108
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)
114 {
115 XrmDatabase db = NULL;
116 RrJustify winjust, mtitlejust;
117 gchar *str;
118 RrTheme *theme;
119 RrFont *default_font = NULL;
120 gchar *path;
121 gboolean userdef;
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;
137
138 if (name) {
139 db = loaddb(name, &path);
140 if (db == NULL) {
141 g_message("Unable to load the theme '%s'", name);
142 if (allow_fallback)
143 g_message("Falling back to the default theme '%s'",
144 DEFAULT_THEME);
145 /* fallback to the default theme */
146 name = NULL;
147 }
148 }
149 if (name == NULL) {
150 if (allow_fallback) {
151 db = loaddb(DEFAULT_THEME, &path);
152 if (db == NULL) {
153 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
154 return NULL;
155 }
156 } else
157 return NULL;
158 }
159
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);
175
176 /* initialize theme */
177 theme = g_slice_new0(RrTheme);
178
179 theme->inst = inst;
180 theme->name = g_strdup(name ? name : DEFAULT_THEME);
181
182 /* init buttons */
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);
188
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);
222
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);
228
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;
235 }
236
237 theme->menu_title_font = get_font(menu_title_font, &default_font, inst);
238
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;
245 }
246
247 theme->menu_font = get_font(menu_item_font, &default_font, inst);
248
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);
251
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("undecorated.border.width", theme->ubwidth, 0, 100,
263 theme->fbwidth);
264 READ_INT("menu.separator.width", theme->menu_sep_width, 1, 100, 1);
265 READ_INT("menu.separator.padding.width", theme->menu_sep_paddingx,
266 0, 100, 6);
267 READ_INT("menu.separator.padding.height", theme->menu_sep_paddingy,
268 0, 100, 3);
269 READ_INT("window.client.padding.width", theme->cbwidthx, 0, 100,
270 theme->paddingx);
271 READ_INT("window.client.padding.height", theme->cbwidthy, 0, 100,
272 theme->cbwidthx);
273
274 /* load colors */
275 READ_COLOR_("window.active.border.color", "border.color",
276 theme->frame_focused_border_color, RrColorNew(inst, 0, 0, 0));
277 /* undecorated focused border color inherits from frame focused border
278 color */
279 READ_COLOR("window.undecorated.active.border.color",
280 theme->frame_undecorated_focused_border_color,
281 RrColorCopy(theme->frame_focused_border_color));
282 /* title separator focused color inherits from focused border color */
283 READ_COLOR("window.active.title.separator.color",
284 theme->title_separator_focused_color,
285 RrColorCopy(theme->frame_focused_border_color));
286
287 /* unfocused border color inherits from frame focused border color */
288 READ_COLOR("window.inactive.border.color",
289 theme->frame_unfocused_border_color,
290 RrColorCopy(theme->frame_focused_border_color));
291
292 /* undecorated unfocused border color inherits from frame unfocused border
293 color */
294 READ_COLOR("window.undecorated.inactive.border.color",
295 theme->frame_undecorated_unfocused_border_color,
296 RrColorCopy(theme->frame_unfocused_border_color));
297
298 /* title separator unfocused color inherits from unfocused border color */
299 READ_COLOR("window.inactive.title.separator.color",
300 theme->title_separator_unfocused_color,
301 RrColorCopy(theme->frame_unfocused_border_color));
302
303 /* menu border color inherits from frame focused border color */
304 READ_COLOR("menu.border.color", theme->menu_border_color,
305 RrColorCopy(theme->frame_focused_border_color));
306
307 /* osd border color inherits from frame focused border color */
308 READ_COLOR("osd.border.color", theme->osd_border_color,
309 RrColorCopy(theme->frame_focused_border_color));
310
311 READ_COLOR("window.active.client.color", theme->cb_focused_color,
312 RrColorNew(inst, 0xff, 0xff, 0xff));
313
314 READ_COLOR("window.inactive.client.color", theme->cb_unfocused_color,
315 RrColorNew(inst, 0xff, 0xff, 0xff));
316
317 READ_COLOR("window.active.label.text.color", theme->title_focused_color,
318 RrColorNew(inst, 0x0, 0x0, 0x0));
319
320 READ_COLOR("window.inactive.label.text.color", theme->title_unfocused_color,
321 RrColorNew(inst, 0xff, 0xff, 0xff));
322
323 READ_COLOR_("osd.active.label.text.color",
324 "osd.label.text.color",
325 theme->osd_text_active_color, RrColorCopy(theme->title_focused_color));
326
327 READ_COLOR_("osd.inactive.label.text.color",
328 "osd.label.text.color",
329 theme->osd_text_inactive_color, RrColorCopy(theme->title_unfocused_color));
330
331 READ_COLOR("window.active.button.unpressed.image.color",
332 theme->titlebut_focused_unpressed_color,
333 RrColorNew(inst, 0, 0, 0));
334
335 READ_COLOR("window.inactive.button.unpressed.image.color",
336 theme->titlebut_unfocused_unpressed_color,
337 RrColorNew(inst, 0xff, 0xff, 0xff));
338
339 READ_COLOR("window.active.button.pressed.image.color",
340 theme->titlebut_focused_pressed_color,
341 RrColorCopy(theme->titlebut_focused_unpressed_color));
342
343 READ_COLOR("window.inactive.button.pressed.image.color",
344 theme->titlebut_unfocused_pressed_color,
345 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
346
347 READ_COLOR("window.active.button.disabled.image.color",
348 theme->titlebut_disabled_focused_color,
349 RrColorNew(inst, 0xff, 0xff, 0xff));
350
351 READ_COLOR("window.inactive.button.disabled.image.color",
352 theme->titlebut_disabled_unfocused_color,
353 RrColorNew(inst, 0, 0, 0));
354
355 READ_COLOR("window.active.button.hover.image.color",
356 theme->titlebut_hover_focused_color,
357 RrColorCopy(theme->titlebut_focused_unpressed_color));
358
359 READ_COLOR("window.inactive.button.hover.image.color",
360 theme->titlebut_hover_unfocused_color,
361 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
362
363 READ_COLOR_("window.active.button.toggled.unpressed.image.color",
364 "window.active.button.toggled.image.color",
365 theme->titlebut_toggled_focused_unpressed_color,
366 RrColorCopy(theme->titlebut_focused_pressed_color));
367
368 READ_COLOR_("window.inactive.button.toggled.unpressed.image.color",
369 "window.inactive.button.toggled.image.color",
370 theme->titlebut_toggled_unfocused_unpressed_color,
371 RrColorCopy(theme->titlebut_unfocused_pressed_color));
372
373 READ_COLOR("window.active.button.toggled.hover.image.color",
374 theme->titlebut_toggled_hover_focused_color,
375 RrColorCopy(theme->titlebut_toggled_focused_unpressed_color));
376
377 READ_COLOR("window.inactive.button.toggled.hover.image.color",
378 theme->titlebut_toggled_hover_unfocused_color,
379 RrColorCopy(theme->titlebut_toggled_unfocused_unpressed_color));
380
381 READ_COLOR("window.active.button.toggled.pressed.image.color",
382 theme->titlebut_toggled_focused_pressed_color,
383 RrColorCopy(theme->titlebut_focused_pressed_color));
384
385 READ_COLOR("window.inactive.button.toggled.pressed.image.color",
386 theme->titlebut_toggled_unfocused_pressed_color,
387 RrColorCopy(theme->titlebut_unfocused_pressed_color));
388
389 READ_COLOR("menu.title.text.color", theme->menu_title_color,
390 RrColorNew(inst, 0, 0, 0));
391
392 READ_COLOR("menu.items.text.color", theme->menu_color,
393 RrColorNew(inst, 0xff, 0xff, 0xff));
394
395 READ_COLOR("menu.bullet.image.color", theme->menu_bullet_color,
396 RrColorCopy(theme->menu_color));
397
398 READ_COLOR("menu.items.disabled.text.color", theme->menu_disabled_color,
399 RrColorNew(inst, 0, 0, 0));
400
401 READ_COLOR("menu.items.active.disabled.text.color",
402 theme->menu_disabled_selected_color,
403 RrColorCopy(theme->menu_disabled_color));
404
405 READ_COLOR("menu.items.active.text.color", theme->menu_selected_color,
406 RrColorNew(inst, 0, 0, 0));
407
408 READ_COLOR("menu.separator.color", theme->menu_sep_color,
409 RrColorCopy(theme->menu_color));
410
411 READ_COLOR("menu.bullet.selected.image.color",
412 theme->menu_bullet_selected_color,
413 RrColorCopy(theme->menu_selected_color));
414
415 READ_COLOR("osd.button.unpressed.text.color", theme->osd_unpressed_color,
416 RrColorCopy(theme->osd_text_active_color));
417 READ_COLOR("osd.button.pressed.text.color", theme->osd_pressed_color,
418 RrColorCopy(theme->osd_text_active_color));
419 READ_COLOR("osd.button.focused.text.color", theme->osd_focused_color,
420 RrColorCopy(theme->osd_text_active_color));
421 READ_COLOR("osd.button.pressed.box.color", theme->osd_pressed_lineart,
422 RrColorCopy(theme->titlebut_focused_pressed_color));
423 READ_COLOR("osd.button.focused.box.color", theme->osd_focused_lineart,
424 RrColorCopy(theme->titlebut_hover_focused_color));
425
426 /* load the image masks */
427
428 /* maximize button masks */
429 userdef = TRUE;
430 if (!read_mask(inst, path, theme, "max.xbm", &theme->btn_max->mask)) {
431 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
432 theme->btn_max->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
433 userdef = FALSE;
434 }
435 if (!read_mask(inst, path, theme, "max_toggled.xbm",
436 &theme->btn_max->toggled_mask))
437 {
438 if (userdef)
439 theme->btn_max->toggled_mask = RrPixmapMaskCopy(theme->btn_max->mask);
440 else {
441 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
442 theme->btn_max->toggled_mask = RrPixmapMaskNew(inst, 6, 6,(gchar*)data);
443 }
444 }
445 READ_MASK_COPY("max_pressed.xbm", theme->btn_max->pressed_mask,
446 theme->btn_max->mask);
447 READ_MASK_COPY("max_disabled.xbm", theme->btn_max->disabled_mask,
448 theme->btn_max->mask);
449 READ_MASK_COPY("max_hover.xbm", theme->btn_max->hover_mask,
450 theme->btn_max->mask);
451 READ_MASK_COPY("max_toggled_pressed.xbm",
452 theme->btn_max->toggled_pressed_mask,
453 theme->btn_max->toggled_mask);
454 READ_MASK_COPY("max_toggled_hover.xbm",
455 theme->btn_max->toggled_hover_mask,
456 theme->btn_max->toggled_mask);
457
458 /* iconify button masks */
459 if (!read_mask(inst, path, theme, "iconify.xbm", &theme->btn_iconify->mask)) {
460 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
461 theme->btn_iconify->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
462 }
463 READ_MASK_COPY("iconify_pressed.xbm", theme->btn_iconify->pressed_mask,
464 theme->btn_iconify->mask);
465 READ_MASK_COPY("iconify_disabled.xbm", theme->btn_iconify->disabled_mask,
466 theme->btn_iconify->mask);
467 READ_MASK_COPY("iconify_hover.xbm", theme->btn_iconify->hover_mask,
468 theme->btn_iconify->mask);
469
470 /* all desktops button masks */
471 userdef = TRUE;
472 if (!read_mask(inst, path, theme, "desk.xbm", &theme->btn_desk->mask)) {
473 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
474 theme->btn_desk->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
475 userdef = FALSE;
476 }
477 if (!read_mask(inst, path, theme, "desk_toggled.xbm",
478 &theme->btn_desk->toggled_mask)) {
479 if (userdef)
480 theme->btn_desk->toggled_mask = RrPixmapMaskCopy(theme->btn_desk->mask);
481 else {
482 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
483 theme->btn_desk->toggled_mask =
484 RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
485 }
486 }
487 READ_MASK_COPY("desk_pressed.xbm", theme->btn_desk->pressed_mask,
488 theme->btn_desk->mask);
489 READ_MASK_COPY("desk_disabled.xbm", theme->btn_desk->disabled_mask,
490 theme->btn_desk->mask);
491 READ_MASK_COPY("desk_hover.xbm", theme->btn_desk->hover_mask, theme->btn_desk->mask);
492 READ_MASK_COPY("desk_toggled_pressed.xbm",
493 theme->btn_desk->toggled_pressed_mask, theme->btn_desk->toggled_mask);
494 READ_MASK_COPY("desk_toggled_hover.xbm", theme->btn_desk->toggled_hover_mask,
495 theme->btn_desk->toggled_mask);
496
497 /* shade button masks */
498 if (!read_mask(inst, path, theme, "shade.xbm", &theme->btn_shade->mask)) {
499 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
500 theme->btn_shade->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
501 }
502 READ_MASK_COPY("shade_toggled.xbm", theme->btn_shade->toggled_mask,
503 theme->btn_shade->mask);
504 READ_MASK_COPY("shade_pressed.xbm", theme->btn_shade->pressed_mask,
505 theme->btn_shade->mask);
506 READ_MASK_COPY("shade_disabled.xbm", theme->btn_shade->disabled_mask,
507 theme->btn_shade->mask);
508 READ_MASK_COPY("shade_hover.xbm", theme->btn_shade->hover_mask,
509 theme->btn_shade->mask);
510 READ_MASK_COPY("shade_toggled_pressed.xbm",
511 theme->btn_shade->toggled_pressed_mask,
512 theme->btn_shade->toggled_mask);
513 READ_MASK_COPY("shade_toggled_hover.xbm",
514 theme->btn_shade->toggled_hover_mask,
515 theme->btn_shade->toggled_mask);
516
517 /* close button masks */
518 if (!read_mask(inst, path, theme, "close.xbm", &theme->btn_close->mask)) {
519 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
520 theme->btn_close->mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
521 }
522 READ_MASK_COPY("close_pressed.xbm", theme->btn_close->pressed_mask,
523 theme->btn_close->mask);
524 READ_MASK_COPY("close_disabled.xbm", theme->btn_close->disabled_mask,
525 theme->btn_close->mask);
526 READ_MASK_COPY("close_hover.xbm", theme->btn_close->hover_mask,
527 theme->btn_close->mask);
528
529 /* submenu bullet mask */
530 if (!read_mask(inst, path, theme, "bullet.xbm", &theme->menu_bullet_mask))
531 {
532 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
533 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
534 }
535
536 /* up and down arrows */
537 {
538 guchar data[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 };
539 theme->down_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
540 }
541 {
542 guchar data[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 };
543 theme->up_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
544 }
545
546 /* setup the default window icon */
547 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
548 OB_DEFAULT_ICON_HEIGHT,
549 OB_DEFAULT_ICON_pixel_data);
550 theme->def_win_icon_w = OB_DEFAULT_ICON_WIDTH;
551 theme->def_win_icon_h = OB_DEFAULT_ICON_HEIGHT;
552
553 /* the toggled hover mask = the toggled unpressed mask (i.e. no change) */
554 theme->btn_max->toggled_hover_mask =
555 RrPixmapMaskCopy(theme->btn_max->toggled_mask);
556 theme->btn_desk->toggled_hover_mask =
557 RrPixmapMaskCopy(theme->btn_desk->toggled_mask);
558 theme->btn_shade->toggled_hover_mask =
559 RrPixmapMaskCopy(theme->btn_shade->toggled_mask);
560 /* the toggled pressed mask = the toggled unpressed mask (i.e. no change)*/
561 theme->btn_max->toggled_pressed_mask =
562 RrPixmapMaskCopy(theme->btn_max->toggled_mask);
563 theme->btn_desk->toggled_pressed_mask =
564 RrPixmapMaskCopy(theme->btn_desk->toggled_mask);
565 theme->btn_shade->toggled_pressed_mask =
566 RrPixmapMaskCopy(theme->btn_shade->toggled_mask);
567
568 /* read the decoration textures */
569 READ_APPEARANCE("window.active.title.bg", theme->a_focused_title, FALSE);
570 READ_APPEARANCE("window.inactive.title.bg", theme->a_unfocused_title,
571 FALSE);
572 READ_APPEARANCE("window.active.label.bg", theme->a_focused_label, TRUE);
573 READ_APPEARANCE("window.inactive.label.bg", theme->a_unfocused_label,
574 TRUE);
575 READ_APPEARANCE("window.active.handle.bg", theme->a_focused_handle, FALSE);
576 READ_APPEARANCE("window.inactive.handle.bg",theme->a_unfocused_handle,
577 FALSE);
578 READ_APPEARANCE("window.active.grip.bg", theme->a_focused_grip, TRUE);
579 READ_APPEARANCE("window.inactive.grip.bg", theme->a_unfocused_grip, TRUE);
580 READ_APPEARANCE("menu.items.bg", theme->a_menu, FALSE);
581 READ_APPEARANCE("menu.title.bg", theme->a_menu_title, TRUE);
582 READ_APPEARANCE("menu.items.active.bg", theme->a_menu_selected, TRUE);
583
584 theme->a_menu_disabled_selected =
585 RrAppearanceCopy(theme->a_menu_selected);
586
587 /* read appearances for non-decorations (on-screen-display) */
588 if (!read_appearance(db, inst, "osd.bg", theme->osd_bg, FALSE)) {
589 RrAppearanceFree(theme->osd_bg);
590 theme->osd_bg = RrAppearanceCopy(theme->a_focused_title);
591 }
592 if (!read_appearance(db, inst, "osd.active.label.bg",
593 theme->osd_hilite_label, TRUE) &&
594 !read_appearance(db, inst, "osd.label.bg",
595 theme->osd_hilite_label, TRUE)) {
596 RrAppearanceFree(theme->osd_hilite_label);
597 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
598 }
599 if (!read_appearance(db, inst, "osd.inactive.label.bg",
600 theme->osd_unhilite_label, TRUE)) {
601 RrAppearanceFree(theme->osd_unhilite_label);
602 theme->osd_unhilite_label = RrAppearanceCopy(theme->a_unfocused_label);
603 }
604 /* osd_hilite_fg can't be parentrel */
605 if (!read_appearance(db, inst, "osd.hilight.bg",
606 theme->osd_hilite_bg, FALSE)) {
607 RrAppearanceFree(theme->osd_hilite_bg);
608 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
609 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_label);
610 else
611 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
612 }
613 /* osd_unhilite_fg can't be parentrel either */
614 if (!read_appearance(db, inst, "osd.unhilight.bg",
615 theme->osd_unhilite_bg, FALSE)) {
616 RrAppearanceFree(theme->osd_unhilite_bg);
617 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
618 theme->osd_unhilite_bg=RrAppearanceCopy(theme->a_unfocused_label);
619 else
620 theme->osd_unhilite_bg=RrAppearanceCopy(theme->a_unfocused_title);
621 }
622
623 /* read buttons textures */
624
625 /* bases: unpressed, pressed, disabled */
626 READ_APPEARANCE("window.active.button.unpressed.bg",
627 a_focused_unpressed_tmp, TRUE);
628 READ_APPEARANCE("window.inactive.button.unpressed.bg",
629 a_unfocused_unpressed_tmp, TRUE);
630 READ_APPEARANCE("window.active.button.pressed.bg",
631 a_focused_pressed_tmp, TRUE);
632 READ_APPEARANCE("window.inactive.button.pressed.bg",
633 a_unfocused_pressed_tmp, TRUE);
634 READ_APPEARANCE("window.active.button.disabled.bg",
635 a_disabled_focused_tmp, TRUE);
636 READ_APPEARANCE("window.inactive.button.disabled.bg",
637 a_disabled_unfocused_tmp, TRUE);
638
639 /* hover */
640 READ_APPEARANCE_COPY("window.active.button.hover.bg",
641 a_hover_focused_tmp, TRUE,
642 a_focused_unpressed_tmp);
643 READ_APPEARANCE_COPY("window.inactive.button.hover.bg",
644 a_hover_unfocused_tmp, TRUE,
645 a_unfocused_unpressed_tmp);
646
647 /* toggled unpressed */
648 READ_APPEARANCE_("window.active.button.toggled.unpressed.bg",
649 "window.active.button.toggled.bg",
650 a_toggled_focused_unpressed_tmp, TRUE,
651 a_focused_pressed_tmp);
652 READ_APPEARANCE_("window.inactive.button.toggled.unpressed.bg",
653 "window.inactive.button.toggled.bg",
654 a_toggled_unfocused_unpressed_tmp, TRUE,
655 a_unfocused_pressed_tmp);
656
657 /* toggled pressed */
658 READ_APPEARANCE_COPY("window.active.button.toggled.pressed.bg",
659 a_toggled_focused_pressed_tmp, TRUE,
660 a_focused_pressed_tmp);
661 READ_APPEARANCE_COPY("window.inactive.button.toggled.pressed.bg",
662 a_toggled_unfocused_pressed_tmp, TRUE,
663 a_unfocused_pressed_tmp);
664
665 /* toggled hover */
666 READ_APPEARANCE_COPY("window.active.button.toggled.hover.bg",
667 a_toggled_hover_focused_tmp, TRUE,
668 a_toggled_focused_unpressed_tmp);
669 READ_APPEARANCE_COPY("window.inactive.button.toggled.hover.bg",
670 a_toggled_hover_unfocused_tmp, TRUE,
671 a_toggled_unfocused_unpressed_tmp);
672
673
674 /* now do individual buttons, if specified */
675
676 /* max button */
677 read_button_colors(db, inst, theme, theme->btn_max, "max");
678
679 /* bases: unpressed, pressed, disabled */
680 READ_APPEARANCE_COPY("window.active.button.max.unpressed.bg",
681 theme->btn_max->a_focused_unpressed, TRUE,
682 a_focused_unpressed_tmp);
683 READ_APPEARANCE_COPY("window.inactive.button.max.unpressed.bg",
684 theme->btn_max->a_unfocused_unpressed, TRUE,
685 a_unfocused_unpressed_tmp);
686 READ_APPEARANCE_COPY("window.active.button.max.pressed.bg",
687 theme->btn_max->a_focused_pressed, TRUE,
688 a_focused_pressed_tmp);
689 READ_APPEARANCE_COPY("window.inactive.button.max.pressed.bg",
690 theme->btn_max->a_unfocused_pressed, TRUE,
691 a_unfocused_pressed_tmp);
692 READ_APPEARANCE_COPY("window.active.button.max.disabled.bg",
693 theme->btn_max->a_disabled_focused, TRUE,
694 a_disabled_focused_tmp);
695 READ_APPEARANCE_COPY("window.inactive.button.max.disabled.bg",
696 theme->btn_max->a_disabled_unfocused, TRUE,
697 a_disabled_unfocused_tmp);
698
699 /* hover */
700 READ_APPEARANCE_COPY("window.active.button.max.hover.bg",
701 theme->btn_max->a_hover_focused, TRUE,
702 a_hover_focused_tmp);
703 READ_APPEARANCE_COPY("window.inactive.button.max.hover.bg",
704 theme->btn_max->a_hover_unfocused, TRUE,
705 a_hover_unfocused_tmp);
706
707 /* toggled unpressed */
708 READ_APPEARANCE_("window.active.button.max.toggled.unpressed.bg",
709 "window.active.button.max.toggled.bg",
710 theme->btn_max->a_toggled_focused_unpressed, TRUE,
711 a_toggled_focused_unpressed_tmp);
712 READ_APPEARANCE_("window.inactive.button.max.toggled.unpressed.bg",
713 "window.inactive.button.max.toggled.bg",
714 theme->btn_max->a_toggled_unfocused_unpressed, TRUE,
715 a_toggled_unfocused_unpressed_tmp);
716
717 /* toggled pressed */
718 READ_APPEARANCE_COPY("window.active.button.max.toggled.pressed.bg",
719 theme->btn_max->a_toggled_focused_pressed, TRUE,
720 a_toggled_focused_pressed_tmp);
721 READ_APPEARANCE_COPY("window.inactive.button.max.toggled.pressed.bg",
722 theme->btn_max->a_toggled_unfocused_pressed, TRUE,
723 a_toggled_unfocused_pressed_tmp);
724
725 /* toggled hover */
726 READ_APPEARANCE_COPY("window.active.button.max.toggled.hover.bg",
727 theme->btn_max->a_toggled_hover_focused, TRUE,
728 a_toggled_hover_focused_tmp);
729 READ_APPEARANCE_COPY("window.inactive.button.max.toggled.hover.bg",
730 theme->btn_max->a_toggled_hover_unfocused, TRUE,
731 a_toggled_hover_unfocused_tmp);
732
733 /* close button */
734 read_button_colors(db, inst, theme, theme->btn_close, "close");
735
736 READ_APPEARANCE_COPY("window.active.button.close.unpressed.bg",
737 theme->btn_close->a_focused_unpressed, TRUE,
738 a_focused_unpressed_tmp);
739 READ_APPEARANCE_COPY("window.inactive.button.close.unpressed.bg",
740 theme->btn_close->a_unfocused_unpressed, TRUE,
741 a_unfocused_unpressed_tmp);
742 READ_APPEARANCE_COPY("window.active.button.close.pressed.bg",
743 theme->btn_close->a_focused_pressed, TRUE,
744 a_focused_pressed_tmp);
745 READ_APPEARANCE_COPY("window.inactive.button.close.pressed.bg",
746 theme->btn_close->a_unfocused_pressed, TRUE,
747 a_unfocused_pressed_tmp);
748 READ_APPEARANCE_COPY("window.active.button.close.disabled.bg",
749 theme->btn_close->a_disabled_focused, TRUE,
750 a_disabled_focused_tmp);
751 READ_APPEARANCE_COPY("window.inactive.button.close.disabled.bg",
752 theme->btn_close->a_disabled_unfocused, TRUE,
753 a_disabled_unfocused_tmp);
754 READ_APPEARANCE_COPY("window.active.button.close.hover.bg",
755 theme->btn_close->a_hover_focused, TRUE,
756 a_hover_focused_tmp);
757 READ_APPEARANCE_COPY("window.inactive.button.close.hover.bg",
758 theme->btn_close->a_hover_unfocused, TRUE,
759 a_hover_unfocused_tmp);
760
761 /* desk button */
762 read_button_colors(db, inst, theme, theme->btn_desk, "desk");
763
764 /* bases: unpressed, pressed, disabled */
765 READ_APPEARANCE_COPY("window.active.button.desk.unpressed.bg",
766 theme->btn_desk->a_focused_unpressed, TRUE,
767 a_focused_unpressed_tmp);
768 READ_APPEARANCE_COPY("window.inactive.button.desk.unpressed.bg",
769 theme->btn_desk->a_unfocused_unpressed, TRUE,
770 a_unfocused_unpressed_tmp);
771 READ_APPEARANCE_COPY("window.active.button.desk.pressed.bg",
772 theme->btn_desk->a_focused_pressed, TRUE,
773 a_focused_pressed_tmp);
774 READ_APPEARANCE_COPY("window.inactive.button.desk.pressed.bg",
775 theme->btn_desk->a_unfocused_pressed, TRUE,
776 a_unfocused_pressed_tmp);
777 READ_APPEARANCE_COPY("window.active.button.desk.disabled.bg",
778 theme->btn_desk->a_disabled_focused, TRUE,
779 a_disabled_focused_tmp);
780 READ_APPEARANCE_COPY("window.inactive.button.desk.disabled.bg",
781 theme->btn_desk->a_disabled_unfocused, TRUE,
782 a_disabled_unfocused_tmp);
783
784 /* hover */
785 READ_APPEARANCE_COPY("window.active.button.desk.hover.bg",
786 theme->btn_desk->a_hover_focused, TRUE,
787 a_hover_focused_tmp);
788 READ_APPEARANCE_COPY("window.inactive.button.desk.hover.bg",
789 theme->btn_desk->a_hover_unfocused, TRUE,
790 a_hover_unfocused_tmp);
791
792 /* toggled unpressed */
793 READ_APPEARANCE_("window.active.button.desk.toggled.unpressed.bg",
794 "window.active.button.desk.toggled.bg",
795 theme->btn_desk->a_toggled_focused_unpressed, TRUE,
796 a_toggled_focused_unpressed_tmp);
797 READ_APPEARANCE_("window.inactive.button.desk.toggled.unpressed.bg",
798 "window.inactive.button.desk.toggled.bg",
799 theme->btn_desk->a_toggled_unfocused_unpressed, TRUE,
800 a_toggled_unfocused_unpressed_tmp);
801
802 /* toggled pressed */
803 READ_APPEARANCE_COPY("window.active.button.desk.toggled.pressed.bg",
804 theme->btn_desk->a_toggled_focused_pressed, TRUE,
805 a_toggled_focused_pressed_tmp);
806 READ_APPEARANCE_COPY("window.inactive.button.desk.toggled.pressed.bg",
807 theme->btn_desk->a_toggled_unfocused_pressed, TRUE,
808 a_toggled_unfocused_pressed_tmp);
809
810 /* toggled hover */
811 READ_APPEARANCE_COPY("window.active.button.desk.toggled.hover.bg",
812 theme->btn_desk->a_toggled_hover_focused, TRUE,
813 a_toggled_hover_focused_tmp);
814 READ_APPEARANCE_COPY("window.inactive.button.desk.toggled.hover.bg",
815 theme->btn_desk->a_toggled_hover_unfocused, TRUE,
816 a_toggled_hover_unfocused_tmp);
817
818 /* shade button */
819 read_button_colors(db, inst, theme, theme->btn_shade, "shade");
820
821 /* bases: unpressed, pressed, disabled */
822 READ_APPEARANCE_COPY("window.active.button.shade.unpressed.bg",
823 theme->btn_shade->a_focused_unpressed, TRUE,
824 a_focused_unpressed_tmp);
825 READ_APPEARANCE_COPY("window.inactive.button.shade.unpressed.bg",
826 theme->btn_shade->a_unfocused_unpressed, TRUE,
827 a_unfocused_unpressed_tmp);
828 READ_APPEARANCE_COPY("window.active.button.shade.pressed.bg",
829 theme->btn_shade->a_focused_pressed, TRUE,
830 a_focused_pressed_tmp);
831 READ_APPEARANCE_COPY("window.inactive.button.shade.pressed.bg",
832 theme->btn_shade->a_unfocused_pressed, TRUE,
833 a_unfocused_pressed_tmp);
834 READ_APPEARANCE_COPY("window.active.button.shade.disabled.bg",
835 theme->btn_shade->a_disabled_focused, TRUE,
836 a_disabled_focused_tmp);
837 READ_APPEARANCE_COPY("window.inactive.button.shade.disabled.bg",
838 theme->btn_shade->a_disabled_unfocused, TRUE,
839 a_disabled_unfocused_tmp);
840
841 /* hover */
842 READ_APPEARANCE_COPY("window.active.button.shade.hover.bg",
843 theme->btn_shade->a_hover_focused, TRUE,
844 a_hover_focused_tmp);
845 READ_APPEARANCE_COPY("window.inactive.button.shade.hover.bg",
846 theme->btn_shade->a_hover_unfocused, TRUE,
847 a_hover_unfocused_tmp);
848
849 /* toggled unpressed */
850 READ_APPEARANCE_("window.active.button.shade.toggled.unpressed.bg",
851 "window.active.button.shade.toggled.bg",
852 theme->btn_shade->a_toggled_focused_unpressed, TRUE,
853 a_toggled_focused_unpressed_tmp);
854 READ_APPEARANCE_("window.inactive.button.shade.toggled.unpressed.bg",
855 "window.inactive.button.shade.toggled.bg",
856 theme->btn_shade->a_toggled_unfocused_unpressed, TRUE,
857 a_toggled_unfocused_unpressed_tmp);
858
859 /* toggled pressed */
860 READ_APPEARANCE_COPY("window.active.button.shade.toggled.pressed.bg",
861 theme->btn_shade->a_toggled_focused_pressed, TRUE,
862 a_toggled_focused_pressed_tmp);
863 READ_APPEARANCE_COPY("window.inactive.button.shade.toggled.pressed.bg",
864 theme->btn_shade->a_toggled_unfocused_pressed, TRUE,
865 a_toggled_unfocused_pressed_tmp);
866
867 /* toggled hover */
868 READ_APPEARANCE_COPY("window.active.button.shade.toggled.hover.bg",
869 theme->btn_shade->a_toggled_hover_focused, TRUE,
870 a_toggled_hover_focused_tmp);
871 READ_APPEARANCE_COPY("window.inactive.button.shade.toggled.hover.bg",
872 theme->btn_shade->a_toggled_hover_unfocused, TRUE,
873 a_toggled_hover_unfocused_tmp);
874
875 /* iconify button */
876 read_button_colors(db, inst, theme, theme->btn_iconify, "iconify");
877
878 READ_APPEARANCE_COPY("window.active.button.iconify.unpressed.bg",
879 theme->btn_iconify->a_focused_unpressed, TRUE,
880 a_focused_unpressed_tmp);
881 READ_APPEARANCE_COPY("window.inactive.button.iconify.unpressed.bg",
882 theme->btn_iconify->a_unfocused_unpressed, TRUE,
883 a_unfocused_unpressed_tmp);
884 READ_APPEARANCE_COPY("window.active.button.iconify.pressed.bg",
885 theme->btn_iconify->a_focused_pressed, TRUE,
886 a_focused_pressed_tmp);
887 READ_APPEARANCE_COPY("window.inactive.button.iconify.pressed.bg",
888 theme->btn_iconify->a_unfocused_pressed, TRUE,
889 a_unfocused_pressed_tmp);
890 READ_APPEARANCE_COPY("window.active.button.iconify.disabled.bg",
891 theme->btn_iconify->a_disabled_focused, TRUE,
892 a_disabled_focused_tmp);
893 READ_APPEARANCE_COPY("window.inactive.button.iconify.disabled.bg",
894 theme->btn_iconify->a_disabled_unfocused, TRUE,
895 a_disabled_unfocused_tmp);
896 READ_APPEARANCE_COPY("window.active.button.iconify.hover.bg",
897 theme->btn_iconify->a_hover_focused, TRUE,
898 a_hover_focused_tmp);
899 READ_APPEARANCE_COPY("window.inactive.button.iconify.hover.bg",
900 theme->btn_iconify->a_hover_unfocused, TRUE,
901 a_hover_unfocused_tmp);
902
903 /* osd buttons */
904 READ_APPEARANCE_COPY("osd.button.unpressed.bg", theme->osd_unpressed_button, TRUE, a_focused_unpressed_tmp);
905 READ_APPEARANCE_COPY_TEXTURES("osd.button.pressed.bg", theme->osd_pressed_button, TRUE, a_focused_pressed_tmp, 5);
906 READ_APPEARANCE_COPY_TEXTURES("osd.button.focused.bg", theme->osd_focused_button, TRUE, a_focused_unpressed_tmp, 5);
907
908 theme->a_icon->surface.grad =
909 theme->a_clear->surface.grad =
910 theme->a_clear_tex->surface.grad =
911 theme->a_menu_text_title->surface.grad =
912 theme->a_menu_normal->surface.grad =
913 theme->a_menu_disabled->surface.grad =
914 theme->a_menu_text_normal->surface.grad =
915 theme->a_menu_text_selected->surface.grad =
916 theme->a_menu_text_disabled->surface.grad =
917 theme->a_menu_text_disabled_selected->surface.grad =
918 theme->a_menu_bullet_normal->surface.grad =
919 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
920
921 /* set up the textures */
922 theme->a_focused_label->texture[0].type = RR_TEXTURE_TEXT;
923 theme->a_focused_label->texture[0].data.text.justify = winjust;
924 theme->a_focused_label->texture[0].data.text.font=theme->win_font_focused;
925 theme->a_focused_label->texture[0].data.text.color =
926 theme->title_focused_color;
927
928 if (read_string(db, "window.active.label.text.font", &str)) {
929 char *p;
930 gint i = 0;
931 gint j;
932 if (strstr(str, "shadow=y")) {
933 if ((p = strstr(str, "shadowoffset=")))
934 i = parse_inline_number(p + strlen("shadowoffset="));
935 else
936 i = 1;
937 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
938 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
939 }
940 if ((p = strstr(str, "shadowtint=")))
941 {
942 i = parse_inline_number(p + strlen("shadowtint="));
943 j = (i > 0 ? 0 : 255);
944 i = ABS(i*255/100);
945
946 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
947 theme->title_focused_shadow_alpha = i;
948 } else {
949 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
950 theme->title_focused_shadow_alpha = 50;
951 }
952 }
953
954 theme->a_focused_label->texture[0].data.text.shadow_color =
955 theme->title_focused_shadow_color;
956 theme->a_focused_label->texture[0].data.text.shadow_alpha =
957 theme->title_focused_shadow_alpha;
958
959 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
960 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
961 theme->osd_hilite_label->texture[0].data.text.font =
962 theme->osd_font_hilite;
963 theme->osd_hilite_label->texture[0].data.text.color =
964 theme->osd_text_active_color;
965
966 if (read_string(db, "osd.active.label.text.font", &str) ||
967 read_string(db, "osd.label.text.font", &str))
968 {
969 char *p;
970 gint i = 0;
971 gint j;
972 if (strstr(str, "shadow=y")) {
973 if ((p = strstr(str, "shadowoffset=")))
974 i = parse_inline_number(p + strlen("shadowoffset="));
975 else
976 i = 1;
977 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
978 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
979 }
980 if ((p = strstr(str, "shadowtint=")))
981 {
982 i = parse_inline_number(p + strlen("shadowtint="));
983 j = (i > 0 ? 0 : 255);
984 i = ABS(i*255/100);
985
986 theme->osd_text_active_shadow_color = RrColorNew(inst, j, j, j);
987 theme->osd_text_active_shadow_alpha = i;
988 } else {
989 theme->osd_text_active_shadow_color = RrColorNew(inst, 0, 0, 0);
990 theme->osd_text_active_shadow_alpha = 50;
991 }
992 } else {
993 /* inherit the font settings from the focused label */
994 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x =
995 theme->a_focused_label->texture[0].data.text.shadow_offset_x;
996 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y =
997 theme->a_focused_label->texture[0].data.text.shadow_offset_y;
998 if (theme->title_focused_shadow_color)
999 theme->osd_text_active_shadow_color =
1000 RrColorCopy(theme->title_focused_shadow_color);
1001 else
1002 theme->osd_text_active_shadow_color = RrColorNew(inst, 0, 0, 0);
1003 theme->osd_text_active_shadow_alpha =
1004 theme->title_focused_shadow_alpha;
1005 }
1006
1007 theme->osd_hilite_label->texture[0].data.text.shadow_color =
1008 theme->osd_text_active_shadow_color;
1009 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
1010 theme->osd_text_active_shadow_alpha;
1011
1012 theme->osd_unpressed_button->texture[0].type =
1013 theme->osd_pressed_button->texture[0].type =
1014 theme->osd_focused_button->texture[0].type =
1015 RR_TEXTURE_TEXT;
1016
1017 theme->osd_unpressed_button->texture[0].data.text.justify =
1018 theme->osd_pressed_button->texture[0].data.text.justify =
1019 theme->osd_focused_button->texture[0].data.text.justify =
1020 RR_JUSTIFY_CENTER;
1021
1022 theme->osd_unpressed_button->texture[0].data.text.font =
1023 theme->osd_pressed_button->texture[0].data.text.font =
1024 theme->osd_focused_button->texture[0].data.text.font =
1025 theme->osd_font_hilite;
1026
1027 theme->osd_unpressed_button->texture[0].data.text.color =
1028 theme->osd_unpressed_color;
1029 theme->osd_pressed_button->texture[0].data.text.color =
1030 theme->osd_pressed_color;
1031 theme->osd_focused_button->texture[0].data.text.color =
1032 theme->osd_focused_color;
1033
1034 theme->osd_pressed_button->texture[1].data.lineart.color =
1035 theme->osd_pressed_button->texture[2].data.lineart.color =
1036 theme->osd_pressed_button->texture[3].data.lineart.color =
1037 theme->osd_pressed_button->texture[4].data.lineart.color =
1038 theme->osd_pressed_lineart;
1039
1040 theme->osd_focused_button->texture[1].data.lineart.color =
1041 theme->osd_focused_button->texture[2].data.lineart.color =
1042 theme->osd_focused_button->texture[3].data.lineart.color =
1043 theme->osd_focused_button->texture[4].data.lineart.color =
1044 theme->osd_focused_lineart;
1045
1046 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
1047 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
1048 theme->a_unfocused_label->texture[0].data.text.font =
1049 theme->win_font_unfocused;
1050 theme->a_unfocused_label->texture[0].data.text.color =
1051 theme->title_unfocused_color;
1052
1053 if (read_string(db, "window.inactive.label.text.font", &str)) {
1054 char *p;
1055 gint i = 0;
1056 gint j;
1057 if (strstr(str, "shadow=y")) {
1058 if ((p = strstr(str, "shadowoffset=")))
1059 i = parse_inline_number(p + strlen("shadowoffset="));
1060 else
1061 i = 1;
1062 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
1063 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
1064 }
1065 if ((p = strstr(str, "shadowtint=")))
1066 {
1067 i = parse_inline_number(p + strlen("shadowtint="));
1068 j = (i > 0 ? 0 : 255);
1069 i = ABS(i*255/100);
1070
1071 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
1072 theme->title_unfocused_shadow_alpha = i;
1073 } else {
1074 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
1075 theme->title_unfocused_shadow_alpha = 50;
1076 }
1077 }
1078
1079 theme->a_unfocused_label->texture[0].data.text.shadow_color =
1080 theme->title_unfocused_shadow_color;
1081 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
1082 theme->title_unfocused_shadow_alpha;
1083
1084 theme->osd_unhilite_label->texture[0].type = RR_TEXTURE_TEXT;
1085 theme->osd_unhilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
1086 theme->osd_unhilite_label->texture[0].data.text.font =
1087 theme->osd_font_unhilite;
1088 theme->osd_unhilite_label->texture[0].data.text.color =
1089 theme->osd_text_inactive_color;
1090
1091 if (read_string(db, "osd.inactive.label.text.font", &str))
1092 {
1093 char *p;
1094 gint i = 0;
1095 gint j;
1096 if (strstr(str, "shadow=y")) {
1097 if ((p = strstr(str, "shadowoffset=")))
1098 i = parse_inline_number(p + strlen("shadowoffset="));
1099 else
1100 i = 1;
1101 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_x=i;
1102 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_y=i;
1103 }
1104 if ((p = strstr(str, "shadowtint=")))
1105 {
1106 i = parse_inline_number(p + strlen("shadowtint="));
1107 j = (i > 0 ? 0 : 255);
1108 i = ABS(i*255/100);
1109
1110 theme->osd_text_inactive_shadow_color = RrColorNew(inst, j, j, j);
1111 theme->osd_text_inactive_shadow_alpha = i;
1112 } else {
1113 theme->osd_text_inactive_shadow_color = RrColorNew(inst, 0, 0, 0);
1114 theme->osd_text_inactive_shadow_alpha = 50;
1115 }
1116 } else {
1117 /* inherit the font settings from the unfocused label */
1118 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_x =
1119 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x;
1120 theme->osd_unhilite_label->texture[0].data.text.shadow_offset_y =
1121 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y;
1122 if (theme->title_unfocused_shadow_color)
1123 theme->osd_text_inactive_shadow_color =
1124 RrColorCopy(theme->title_unfocused_shadow_color);
1125 else
1126 theme->osd_text_inactive_shadow_color = RrColorNew(inst, 0, 0, 0);
1127 theme->osd_text_inactive_shadow_alpha =
1128 theme->title_unfocused_shadow_alpha;
1129 }
1130
1131 theme->osd_unhilite_label->texture[0].data.text.shadow_color =
1132 theme->osd_text_inactive_shadow_color;
1133 theme->osd_unhilite_label->texture[0].data.text.shadow_alpha =
1134 theme->osd_text_inactive_shadow_alpha;
1135
1136 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
1137 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
1138 theme->a_menu_text_title->texture[0].data.text.font =
1139 theme->menu_title_font;
1140 theme->a_menu_text_title->texture[0].data.text.color =
1141 theme->menu_title_color;
1142
1143 if (read_string(db, "menu.title.text.font", &str)) {
1144 char *p;
1145 gint i = 0;
1146 gint j;
1147 if (strstr(str, "shadow=y")) {
1148 if ((p = strstr(str, "shadowoffset=")))
1149 i = parse_inline_number(p + strlen("shadowoffset="));
1150 else
1151 i = 1;
1152 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
1153 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
1154 }
1155 if ((p = strstr(str, "shadowtint=")))
1156 {
1157 i = parse_inline_number(p + strlen("shadowtint="));
1158 j = (i > 0 ? 0 : 255);
1159 i = ABS(i*255/100);
1160
1161 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
1162 theme->menu_title_shadow_alpha = i;
1163 } else {
1164 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
1165 theme->menu_title_shadow_alpha = 50;
1166 }
1167 }
1168
1169 theme->a_menu_text_title->texture[0].data.text.shadow_color =
1170 theme->menu_title_shadow_color;
1171 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
1172 theme->menu_title_shadow_alpha;
1173
1174 theme->a_menu_text_normal->texture[0].type =
1175 theme->a_menu_text_selected->texture[0].type =
1176 theme->a_menu_text_disabled->texture[0].type =
1177 theme->a_menu_text_disabled_selected->texture[0].type =
1178 RR_TEXTURE_TEXT;
1179 theme->a_menu_text_normal->texture[0].data.text.justify =
1180 theme->a_menu_text_selected->texture[0].data.text.justify =
1181 theme->a_menu_text_disabled->texture[0].data.text.justify =
1182 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
1183 RR_JUSTIFY_LEFT;
1184 theme->a_menu_text_normal->texture[0].data.text.font =
1185 theme->a_menu_text_selected->texture[0].data.text.font =
1186 theme->a_menu_text_disabled->texture[0].data.text.font =
1187 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
1188 theme->menu_font;
1189 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
1190 theme->a_menu_text_selected->texture[0].data.text.color =
1191 theme->menu_selected_color;
1192 theme->a_menu_text_disabled->texture[0].data.text.color =
1193 theme->menu_disabled_color;
1194 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
1195 theme->menu_disabled_selected_color;
1196
1197 if (read_string(db, "menu.items.font", &str)) {
1198 char *p;
1199 gint i = 0;
1200 gint j;
1201 if (strstr(str, "shadow=y")) {
1202 if ((p = strstr(str, "shadowoffset=")))
1203 i = parse_inline_number(p + strlen("shadowoffset="));
1204 else
1205 i = 1;
1206 theme->a_menu_text_normal->
1207 texture[0].data.text.shadow_offset_x = i;
1208 theme->a_menu_text_normal->
1209 texture[0].data.text.shadow_offset_y = i;
1210 theme->a_menu_text_selected->
1211 texture[0].data.text.shadow_offset_x = i;
1212 theme->a_menu_text_selected->
1213 texture[0].data.text.shadow_offset_y = i;
1214 theme->a_menu_text_disabled->
1215 texture[0].data.text.shadow_offset_x = i;
1216 theme->a_menu_text_disabled->
1217 texture[0].data.text.shadow_offset_y = i;
1218 theme->a_menu_text_disabled_selected->
1219 texture[0].data.text.shadow_offset_x = i;
1220 theme->a_menu_text_disabled_selected->
1221 texture[0].data.text.shadow_offset_y = i;
1222 }
1223 if ((p = strstr(str, "shadowtint=")))
1224 {
1225 i = parse_inline_number(p + strlen("shadowtint="));
1226 j = (i > 0 ? 0 : 255);
1227 i = ABS(i*255/100);
1228
1229 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
1230 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
1231 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
1232 theme->menu_text_normal_shadow_alpha = i;
1233 theme->menu_text_selected_shadow_alpha = i;
1234 theme->menu_text_disabled_shadow_alpha = i;
1235 theme->menu_text_disabled_selected_shadow_alpha = i;
1236 } else {
1237 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
1238 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
1239 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
1240 theme->menu_text_normal_shadow_alpha = 50;
1241 theme->menu_text_selected_shadow_alpha = 50;
1242 theme->menu_text_disabled_selected_shadow_alpha = 50;
1243 }
1244 }
1245
1246 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
1247 theme->menu_text_normal_shadow_color;
1248 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
1249 theme->menu_text_normal_shadow_alpha;
1250 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
1251 theme->menu_text_selected_shadow_color;
1252 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
1253 theme->menu_text_selected_shadow_alpha;
1254 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
1255 theme->menu_text_disabled_shadow_color;
1256 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
1257 theme->menu_text_disabled_shadow_alpha;
1258 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
1259 theme->menu_text_disabled_shadow_color;
1260 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
1261 theme->menu_text_disabled_shadow_alpha;
1262
1263 theme->btn_max->a_disabled_focused->texture[0].type =
1264 theme->btn_max->a_disabled_unfocused->texture[0].type =
1265 theme->btn_max->a_hover_focused->texture[0].type =
1266 theme->btn_max->a_hover_unfocused->texture[0].type =
1267 theme->btn_max->a_toggled_hover_focused->texture[0].type =
1268 theme->btn_max->a_toggled_hover_unfocused->texture[0].type =
1269 theme->btn_max->a_toggled_focused_unpressed->texture[0].type =
1270 theme->btn_max->a_toggled_unfocused_unpressed->texture[0].type =
1271 theme->btn_max->a_toggled_focused_pressed->texture[0].type =
1272 theme->btn_max->a_toggled_unfocused_pressed->texture[0].type =
1273 theme->btn_max->a_focused_unpressed->texture[0].type =
1274 theme->btn_max->a_focused_pressed->texture[0].type =
1275 theme->btn_max->a_unfocused_unpressed->texture[0].type =
1276 theme->btn_max->a_unfocused_pressed->texture[0].type =
1277 theme->btn_close->a_disabled_focused->texture[0].type =
1278 theme->btn_close->a_disabled_unfocused->texture[0].type =
1279 theme->btn_close->a_hover_focused->texture[0].type =
1280 theme->btn_close->a_hover_unfocused->texture[0].type =
1281 theme->btn_close->a_focused_unpressed->texture[0].type =
1282 theme->btn_close->a_focused_pressed->texture[0].type =
1283 theme->btn_close->a_unfocused_unpressed->texture[0].type =
1284 theme->btn_close->a_unfocused_pressed->texture[0].type =
1285 theme->btn_desk->a_disabled_focused->texture[0].type =
1286 theme->btn_desk->a_disabled_unfocused->texture[0].type =
1287 theme->btn_desk->a_hover_focused->texture[0].type =
1288 theme->btn_desk->a_hover_unfocused->texture[0].type =
1289 theme->btn_desk->a_toggled_hover_focused->texture[0].type =
1290 theme->btn_desk->a_toggled_hover_unfocused->texture[0].type =
1291 theme->btn_desk->a_toggled_focused_unpressed->texture[0].type =
1292 theme->btn_desk->a_toggled_unfocused_unpressed->texture[0].type =
1293 theme->btn_desk->a_toggled_focused_pressed->texture[0].type =
1294 theme->btn_desk->a_toggled_unfocused_pressed->texture[0].type =
1295 theme->btn_desk->a_focused_unpressed->texture[0].type =
1296 theme->btn_desk->a_focused_pressed->texture[0].type =
1297 theme->btn_desk->a_unfocused_unpressed->texture[0].type =
1298 theme->btn_desk->a_unfocused_pressed->texture[0].type =
1299 theme->btn_shade->a_disabled_focused->texture[0].type =
1300 theme->btn_shade->a_disabled_unfocused->texture[0].type =
1301 theme->btn_shade->a_hover_focused->texture[0].type =
1302 theme->btn_shade->a_hover_unfocused->texture[0].type =
1303 theme->btn_shade->a_toggled_hover_focused->texture[0].type =
1304 theme->btn_shade->a_toggled_hover_unfocused->texture[0].type =
1305 theme->btn_shade->a_toggled_focused_unpressed->texture[0].type =
1306 theme->btn_shade->a_toggled_unfocused_unpressed->texture[0].type =
1307 theme->btn_shade->a_toggled_focused_pressed->texture[0].type =
1308 theme->btn_shade->a_toggled_unfocused_pressed->texture[0].type =
1309 theme->btn_shade->a_focused_unpressed->texture[0].type =
1310 theme->btn_shade->a_focused_pressed->texture[0].type =
1311 theme->btn_shade->a_unfocused_unpressed->texture[0].type =
1312 theme->btn_shade->a_unfocused_pressed->texture[0].type =
1313 theme->btn_iconify->a_disabled_focused->texture[0].type =
1314 theme->btn_iconify->a_disabled_unfocused->texture[0].type =
1315 theme->btn_iconify->a_hover_focused->texture[0].type =
1316 theme->btn_iconify->a_hover_unfocused->texture[0].type =
1317 theme->btn_iconify->a_focused_unpressed->texture[0].type =
1318 theme->btn_iconify->a_focused_pressed->texture[0].type =
1319 theme->btn_iconify->a_unfocused_unpressed->texture[0].type =
1320 theme->btn_iconify->a_unfocused_pressed->texture[0].type =
1321 theme->a_menu_bullet_normal->texture[0].type =
1322 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
1323
1324 theme->btn_max->a_disabled_focused->texture[0].data.mask.mask =
1325 theme->btn_max->a_disabled_unfocused->texture[0].data.mask.mask =
1326 theme->btn_max->disabled_mask;
1327 theme->btn_max->a_hover_focused->texture[0].data.mask.mask =
1328 theme->btn_max->a_hover_unfocused->texture[0].data.mask.mask =
1329 theme->btn_max->hover_mask;
1330 theme->btn_max->a_focused_pressed->texture[0].data.mask.mask =
1331 theme->btn_max->a_unfocused_pressed->texture[0].data.mask.mask =
1332 theme->btn_max->pressed_mask;
1333 theme->btn_max->a_focused_unpressed->texture[0].data.mask.mask =
1334 theme->btn_max->a_unfocused_unpressed->texture[0].data.mask.mask =
1335 theme->btn_max->mask;
1336 theme->btn_max->a_toggled_hover_focused->texture[0].data.mask.mask =
1337 theme->btn_max->a_toggled_hover_unfocused->texture[0].data.mask.mask =
1338 theme->btn_max->toggled_hover_mask;
1339 theme->btn_max->a_toggled_focused_unpressed->texture[0].data.mask.mask =
1340 theme->btn_max->a_toggled_unfocused_unpressed->
1341 texture[0].data.mask.mask = theme->btn_max->toggled_mask;
1342 theme->btn_max->a_toggled_focused_pressed->texture[0].data.mask.mask =
1343 theme->btn_max->a_toggled_unfocused_pressed->texture[0].data.mask.mask
1344 = theme->btn_max->toggled_pressed_mask;
1345 theme->btn_close->a_disabled_focused->texture[0].data.mask.mask =
1346 theme->btn_close->a_disabled_unfocused->texture[0].data.mask.mask =
1347 theme->btn_close->disabled_mask;
1348 theme->btn_close->a_hover_focused->texture[0].data.mask.mask =
1349 theme->btn_close->a_hover_unfocused->texture[0].data.mask.mask =
1350 theme->btn_close->hover_mask;
1351 theme->btn_close->a_focused_pressed->texture[0].data.mask.mask =
1352 theme->btn_close->a_unfocused_pressed->texture[0].data.mask.mask =
1353 theme->btn_close->pressed_mask;
1354 theme->btn_close->a_focused_unpressed->texture[0].data.mask.mask =
1355 theme->btn_close->a_unfocused_unpressed->texture[0].data.mask.mask =
1356 theme->btn_close->mask;
1357 theme->btn_desk->a_disabled_focused->texture[0].data.mask.mask =
1358 theme->btn_desk->a_disabled_unfocused->texture[0].data.mask.mask =
1359 theme->btn_desk->disabled_mask;
1360 theme->btn_desk->a_hover_focused->texture[0].data.mask.mask =
1361 theme->btn_desk->a_hover_unfocused->texture[0].data.mask.mask =
1362 theme->btn_desk->hover_mask;
1363 theme->btn_desk->a_focused_pressed->texture[0].data.mask.mask =
1364 theme->btn_desk->a_unfocused_pressed->texture[0].data.mask.mask =
1365 theme->btn_desk->pressed_mask;
1366 theme->btn_desk->a_focused_unpressed->texture[0].data.mask.mask =
1367 theme->btn_desk->a_unfocused_unpressed->texture[0].data.mask.mask =
1368 theme->btn_desk->mask;
1369 theme->btn_desk->a_toggled_hover_focused->texture[0].data.mask.mask =
1370 theme->btn_desk->a_toggled_hover_unfocused->texture[0].data.mask.mask =
1371 theme->btn_desk->toggled_hover_mask;
1372 theme->btn_desk->a_toggled_focused_unpressed->texture[0].data.mask.mask =
1373 theme->btn_desk->a_toggled_unfocused_unpressed->
1374 texture[0].data.mask.mask = theme->btn_desk->toggled_mask;
1375 theme->btn_desk->a_toggled_focused_pressed->texture[0].data.mask.mask =
1376 theme->btn_desk->a_toggled_unfocused_pressed->texture[0].data.mask.mask
1377 = theme->btn_desk->toggled_pressed_mask;
1378 theme->btn_shade->a_disabled_focused->texture[0].data.mask.mask =
1379 theme->btn_shade->a_disabled_unfocused->texture[0].data.mask.mask =
1380 theme->btn_shade->disabled_mask;
1381 theme->btn_shade->a_hover_focused->texture[0].data.mask.mask =
1382 theme->btn_shade->a_hover_unfocused->texture[0].data.mask.mask =
1383 theme->btn_shade->hover_mask;
1384 theme->btn_shade->a_focused_pressed->texture[0].data.mask.mask =
1385 theme->btn_shade->a_unfocused_pressed->texture[0].data.mask.mask =
1386 theme->btn_shade->pressed_mask;
1387 theme->btn_shade->a_focused_unpressed->texture[0].data.mask.mask =
1388 theme->btn_shade->a_unfocused_unpressed->texture[0].data.mask.mask =
1389 theme->btn_shade->mask;
1390 theme->btn_shade->a_toggled_hover_focused->texture[0].data.mask.mask =
1391 theme->btn_shade->a_toggled_hover_unfocused->texture[0].data.mask.mask
1392 = theme->btn_shade->toggled_hover_mask;
1393 theme->btn_shade->a_toggled_focused_unpressed->texture[0].data.mask.mask =
1394 theme->btn_shade->a_toggled_unfocused_unpressed->
1395 texture[0].data.mask.mask = theme->btn_shade->toggled_mask;
1396 theme->btn_shade->a_toggled_focused_pressed->texture[0].data.mask.mask =
1397 theme->btn_shade->a_toggled_unfocused_pressed->
1398 texture[0].data.mask.mask = theme->btn_shade->toggled_pressed_mask;
1399 theme->btn_iconify->a_disabled_focused->texture[0].data.mask.mask =
1400 theme->btn_iconify->a_disabled_unfocused->texture[0].data.mask.mask =
1401 theme->btn_iconify->disabled_mask;
1402 theme->btn_iconify->a_hover_focused->texture[0].data.mask.mask =
1403 theme->btn_iconify->a_hover_unfocused->texture[0].data.mask.mask =
1404 theme->btn_iconify->hover_mask;
1405 theme->btn_iconify->a_focused_pressed->texture[0].data.mask.mask =
1406 theme->btn_iconify->a_unfocused_pressed->texture[0].data.mask.mask =
1407 theme->btn_iconify->pressed_mask;
1408 theme->btn_iconify->a_focused_unpressed->texture[0].data.mask.mask =
1409 theme->btn_iconify->a_unfocused_unpressed->texture[0].data.mask.mask =
1410 theme->btn_iconify->mask;
1411 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1412 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1413 theme->menu_bullet_mask;
1414 theme->btn_max->a_disabled_focused->texture[0].data.mask.color =
1415 theme->btn_max->disabled_focused_color;
1416 theme->btn_close->a_disabled_focused->texture[0].data.mask.color =
1417 theme->btn_close->disabled_focused_color;
1418 theme->btn_desk->a_disabled_focused->texture[0].data.mask.color =
1419 theme->btn_desk->disabled_focused_color;
1420 theme->btn_shade->a_disabled_focused->texture[0].data.mask.color =
1421 theme->btn_shade->disabled_focused_color;
1422 theme->btn_iconify->a_disabled_focused->texture[0].data.mask.color =
1423 theme->btn_iconify->disabled_focused_color;
1424 theme->btn_max->a_disabled_unfocused->texture[0].data.mask.color =
1425 theme->btn_max->disabled_unfocused_color;
1426 theme->btn_close->a_disabled_unfocused->texture[0].data.mask.color =
1427 theme->btn_close->disabled_unfocused_color;
1428 theme->btn_desk->a_disabled_unfocused->texture[0].data.mask.color =
1429 theme->btn_desk->disabled_unfocused_color;
1430 theme->btn_shade->a_disabled_unfocused->texture[0].data.mask.color =
1431 theme->btn_shade->disabled_unfocused_color;
1432 theme->btn_iconify->a_disabled_unfocused->texture[0].data.mask.color =
1433 theme->btn_iconify->disabled_unfocused_color;
1434 theme->btn_max->a_hover_focused->texture[0].data.mask.color =
1435 theme->btn_max->hover_focused_color;
1436 theme->btn_close->a_hover_focused->texture[0].data.mask.color =
1437 theme->btn_close->hover_focused_color;
1438 theme->btn_desk->a_hover_focused->texture[0].data.mask.color =
1439 theme->btn_desk->hover_focused_color;
1440 theme->btn_shade->a_hover_focused->texture[0].data.mask.color =
1441 theme->btn_shade->hover_focused_color;
1442 theme->btn_iconify->a_hover_focused->texture[0].data.mask.color =
1443 theme->btn_iconify->hover_focused_color;
1444 theme->btn_max->a_hover_unfocused->texture[0].data.mask.color =
1445 theme->btn_max->hover_unfocused_color;
1446 theme->btn_close->a_hover_unfocused->texture[0].data.mask.color =
1447 theme->btn_close->hover_unfocused_color;
1448 theme->btn_desk->a_hover_unfocused->texture[0].data.mask.color =
1449 theme->btn_desk->hover_unfocused_color;
1450 theme->btn_shade->a_hover_unfocused->texture[0].data.mask.color =
1451 theme->btn_shade->hover_unfocused_color;
1452 theme->btn_iconify->a_hover_unfocused->texture[0].data.mask.color =
1453 theme->btn_iconify->hover_unfocused_color;
1454 theme->btn_max->a_toggled_hover_focused->texture[0].data.mask.color =
1455 theme->btn_max->toggled_hover_focused_color;
1456 theme->btn_desk->a_toggled_hover_focused->texture[0].data.mask.color =
1457 theme->btn_desk->toggled_hover_focused_color;
1458 theme->btn_shade->a_toggled_hover_focused->texture[0].data.mask.color =
1459 theme->btn_shade->toggled_hover_focused_color;
1460 theme->btn_max->a_toggled_hover_unfocused->texture[0].data.mask.color =
1461 theme->btn_max->toggled_hover_unfocused_color;
1462 theme->btn_desk->a_toggled_hover_unfocused->texture[0].data.mask.color =
1463 theme->btn_desk->toggled_hover_unfocused_color;
1464 theme->btn_shade->a_toggled_hover_unfocused->texture[0].data.mask.color =
1465 theme->btn_shade->toggled_hover_unfocused_color;
1466 theme->btn_max->a_toggled_focused_unpressed->texture[0].data.mask.color =
1467 theme->btn_max->toggled_focused_unpressed_color;
1468 theme->btn_desk->a_toggled_focused_unpressed->texture[0].data.mask.color =
1469 theme->btn_desk->toggled_focused_unpressed_color;
1470 theme->btn_shade->a_toggled_focused_unpressed->texture[0].data.mask.color =
1471 theme->btn_shade->toggled_focused_unpressed_color;
1472 theme->btn_max->a_toggled_unfocused_unpressed->texture[0].data.mask.color =
1473 theme->btn_max->toggled_unfocused_unpressed_color;
1474 theme->btn_desk->a_toggled_unfocused_unpressed->texture[0].data.mask.color
1475 = theme->btn_desk->toggled_unfocused_unpressed_color;
1476 theme->btn_shade->a_toggled_unfocused_unpressed->texture[0].data.mask.color
1477 = theme->btn_shade->toggled_unfocused_unpressed_color;
1478 theme->btn_max->a_toggled_focused_pressed->texture[0].data.mask.color =
1479 theme->btn_max->toggled_focused_pressed_color;
1480 theme->btn_desk->a_toggled_focused_pressed->texture[0].data.mask.color =
1481 theme->btn_desk->toggled_focused_pressed_color;
1482 theme->btn_shade->a_toggled_focused_pressed->texture[0].data.mask.color =
1483 theme->btn_shade->toggled_focused_pressed_color;
1484 theme->btn_max->a_toggled_unfocused_pressed->texture[0].data.mask.color =
1485 theme->btn_max->toggled_unfocused_pressed_color;
1486 theme->btn_desk->a_toggled_unfocused_pressed->texture[0].data.mask.color =
1487 theme->btn_desk->toggled_unfocused_pressed_color;
1488 theme->btn_shade->a_toggled_unfocused_pressed->texture[0].data.mask.color =
1489 theme->btn_shade->toggled_unfocused_pressed_color;
1490 theme->btn_max->a_focused_unpressed->texture[0].data.mask.color =
1491 theme->btn_max->focused_unpressed_color;
1492 theme->btn_close->a_focused_unpressed->texture[0].data.mask.color =
1493 theme->btn_close->focused_unpressed_color;
1494 theme->btn_desk->a_focused_unpressed->texture[0].data.mask.color =
1495 theme->btn_desk->focused_unpressed_color;
1496 theme->btn_shade->a_focused_unpressed->texture[0].data.mask.color =
1497 theme->btn_shade->focused_unpressed_color;
1498 theme->btn_iconify->a_focused_unpressed->texture[0].data.mask.color =
1499 theme->btn_iconify->focused_unpressed_color;
1500 theme->btn_max->a_focused_pressed->texture[0].data.mask.color =
1501 theme->btn_max->focused_pressed_color;
1502 theme->btn_close->a_focused_pressed->texture[0].data.mask.color =
1503 theme->btn_close->focused_pressed_color;
1504 theme->btn_desk->a_focused_pressed->texture[0].data.mask.color =
1505 theme->btn_desk->focused_pressed_color;
1506 theme->btn_shade->a_focused_pressed->texture[0].data.mask.color =
1507 theme->btn_shade->focused_pressed_color;
1508 theme->btn_iconify->a_focused_pressed->texture[0].data.mask.color =
1509 theme->btn_iconify->focused_pressed_color;
1510 theme->btn_max->a_unfocused_unpressed->texture[0].data.mask.color =
1511 theme->btn_max->unfocused_unpressed_color;
1512 theme->btn_close->a_unfocused_unpressed->texture[0].data.mask.color =
1513 theme->btn_close->unfocused_unpressed_color;
1514 theme->btn_desk->a_unfocused_unpressed->texture[0].data.mask.color =
1515 theme->btn_desk->unfocused_unpressed_color;
1516 theme->btn_shade->a_unfocused_unpressed->texture[0].data.mask.color =
1517 theme->btn_shade->unfocused_unpressed_color;
1518 theme->btn_iconify->a_unfocused_unpressed->texture[0].data.mask.color =
1519 theme->btn_iconify->unfocused_unpressed_color;
1520 theme->btn_max->a_unfocused_pressed->texture[0].data.mask.color =
1521 theme->btn_max->unfocused_pressed_color;
1522 theme->btn_close->a_unfocused_pressed->texture[0].data.mask.color =
1523 theme->btn_close->unfocused_pressed_color;
1524 theme->btn_desk->a_unfocused_pressed->texture[0].data.mask.color =
1525 theme->btn_desk->unfocused_pressed_color;
1526 theme->btn_shade->a_unfocused_pressed->texture[0].data.mask.color =
1527 theme->btn_shade->unfocused_pressed_color;
1528 theme->btn_iconify->a_unfocused_pressed->texture[0].data.mask.color =
1529 theme->btn_iconify->unfocused_pressed_color;
1530 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1531 theme->menu_bullet_color;
1532 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1533 theme->menu_bullet_selected_color;
1534
1535 g_free(path);
1536 XrmDestroyDatabase(db);
1537
1538 /* set the font heights */
1539 theme->win_font_height = RrFontHeight
1540 (theme->win_font_focused,
1541 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1542 theme->win_font_height =
1543 MAX(theme->win_font_height,
1544 RrFontHeight
1545 (theme->win_font_focused,
1546 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1547 theme->menu_title_font_height = RrFontHeight
1548 (theme->menu_title_font,
1549 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1550 theme->menu_font_height = RrFontHeight
1551 (theme->menu_font,
1552 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1553
1554 /* calculate some last extents */
1555 {
1556 gint ft, fb, fl, fr, ut, ub, ul, ur;
1557
1558 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1559 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1560 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1561 theme->label_height += theme->label_height % 2;
1562
1563 /* this would be nice I think, since padding.width can now be 0,
1564 but it breaks frame.c horribly and I don't feel like fixing that
1565 right now, so if anyone complains, here is how to keep text from
1566 going over the title's bevel/border with a padding.width of 0 and a
1567 bevelless/borderless label
1568 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1569 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1570 theme->title_height = theme->label_height +
1571 MAX(MAX(theme->padding * 2, ft + fb),
1572 MAX(theme->padding * 2, ut + ub));
1573 */
1574 theme->title_height = theme->label_height + theme->paddingy * 2;
1575
1576 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1577 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1578 theme->menu_title_height = theme->menu_title_label_height +
1579 theme->paddingy * 2;
1580 }
1581 theme->button_size = theme->label_height - 2;
1582 theme->grip_width = 25;
1583
1584 RrAppearanceFree(a_disabled_focused_tmp);
1585 RrAppearanceFree(a_disabled_unfocused_tmp);
1586 RrAppearanceFree(a_hover_focused_tmp);
1587 RrAppearanceFree(a_hover_unfocused_tmp);
1588 RrAppearanceFree(a_focused_unpressed_tmp);
1589 RrAppearanceFree(a_focused_pressed_tmp);
1590 RrAppearanceFree(a_unfocused_unpressed_tmp);
1591 RrAppearanceFree(a_unfocused_pressed_tmp);
1592 RrAppearanceFree(a_toggled_hover_focused_tmp);
1593 RrAppearanceFree(a_toggled_hover_unfocused_tmp);
1594 RrAppearanceFree(a_toggled_focused_unpressed_tmp);
1595 RrAppearanceFree(a_toggled_focused_pressed_tmp);
1596 RrAppearanceFree(a_toggled_unfocused_unpressed_tmp);
1597 RrAppearanceFree(a_toggled_unfocused_pressed_tmp);
1598
1599 return theme;
1600 }
1601
1602 void RrThemeFree(RrTheme *theme)
1603 {
1604 if (theme) {
1605 g_free(theme->name);
1606
1607 RrButtonFree(theme->btn_max);
1608 RrButtonFree(theme->btn_close);
1609 RrButtonFree(theme->btn_desk);
1610 RrButtonFree(theme->btn_shade);
1611 RrButtonFree(theme->btn_iconify);
1612
1613 RrColorFree(theme->menu_border_color);
1614 RrColorFree(theme->osd_border_color);
1615 RrColorFree(theme->frame_focused_border_color);
1616 RrColorFree(theme->frame_undecorated_focused_border_color);
1617 RrColorFree(theme->frame_unfocused_border_color);
1618 RrColorFree(theme->frame_undecorated_unfocused_border_color);
1619 RrColorFree(theme->title_separator_focused_color);
1620 RrColorFree(theme->title_separator_unfocused_color);
1621 RrColorFree(theme->cb_unfocused_color);
1622 RrColorFree(theme->cb_focused_color);
1623 RrColorFree(theme->title_focused_color);
1624 RrColorFree(theme->title_unfocused_color);
1625 RrColorFree(theme->titlebut_disabled_focused_color);
1626 RrColorFree(theme->titlebut_disabled_unfocused_color);
1627 RrColorFree(theme->titlebut_hover_focused_color);
1628 RrColorFree(theme->titlebut_hover_unfocused_color);
1629 RrColorFree(theme->titlebut_toggled_hover_focused_color);
1630 RrColorFree(theme->titlebut_toggled_hover_unfocused_color);
1631 RrColorFree(theme->titlebut_toggled_focused_pressed_color);
1632 RrColorFree(theme->titlebut_toggled_unfocused_pressed_color);
1633 RrColorFree(theme->titlebut_toggled_focused_unpressed_color);
1634 RrColorFree(theme->titlebut_toggled_unfocused_unpressed_color);
1635 RrColorFree(theme->titlebut_focused_pressed_color);
1636 RrColorFree(theme->titlebut_unfocused_pressed_color);
1637 RrColorFree(theme->titlebut_focused_unpressed_color);
1638 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1639 RrColorFree(theme->menu_title_color);
1640 RrColorFree(theme->menu_sep_color);
1641 RrColorFree(theme->menu_color);
1642 RrColorFree(theme->menu_bullet_color);
1643 RrColorFree(theme->menu_bullet_selected_color);
1644 RrColorFree(theme->menu_selected_color);
1645 RrColorFree(theme->menu_disabled_color);
1646 RrColorFree(theme->menu_disabled_selected_color);
1647 RrColorFree(theme->title_focused_shadow_color);
1648 RrColorFree(theme->title_unfocused_shadow_color);
1649 RrColorFree(theme->osd_text_active_color);
1650 RrColorFree(theme->osd_text_inactive_color);
1651 RrColorFree(theme->osd_text_active_shadow_color);
1652 RrColorFree(theme->osd_text_inactive_shadow_color);
1653 RrColorFree(theme->osd_pressed_color);
1654 RrColorFree(theme->osd_unpressed_color);
1655 RrColorFree(theme->osd_focused_color);
1656 RrColorFree(theme->osd_pressed_lineart);
1657 RrColorFree(theme->osd_focused_lineart);
1658 RrColorFree(theme->menu_title_shadow_color);
1659 RrColorFree(theme->menu_text_normal_shadow_color);
1660 RrColorFree(theme->menu_text_selected_shadow_color);
1661 RrColorFree(theme->menu_text_disabled_shadow_color);
1662 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1663
1664 g_free(theme->def_win_icon);
1665
1666 RrPixmapMaskFree(theme->menu_bullet_mask);
1667 RrPixmapMaskFree(theme->down_arrow_mask);
1668 RrPixmapMaskFree(theme->up_arrow_mask);
1669
1670 RrFontClose(theme->win_font_focused);
1671 RrFontClose(theme->win_font_unfocused);
1672 RrFontClose(theme->menu_title_font);
1673 RrFontClose(theme->menu_font);
1674 RrFontClose(theme->osd_font_hilite);
1675 RrFontClose(theme->osd_font_unhilite);
1676
1677 RrAppearanceFree(theme->a_focused_grip);
1678 RrAppearanceFree(theme->a_unfocused_grip);
1679 RrAppearanceFree(theme->a_focused_title);
1680 RrAppearanceFree(theme->a_unfocused_title);
1681 RrAppearanceFree(theme->a_focused_label);
1682 RrAppearanceFree(theme->a_unfocused_label);
1683 RrAppearanceFree(theme->a_icon);
1684 RrAppearanceFree(theme->a_focused_handle);
1685 RrAppearanceFree(theme->a_unfocused_handle);
1686 RrAppearanceFree(theme->a_menu);
1687 RrAppearanceFree(theme->a_menu_title);
1688 RrAppearanceFree(theme->a_menu_text_title);
1689 RrAppearanceFree(theme->a_menu_normal);
1690 RrAppearanceFree(theme->a_menu_selected);
1691 RrAppearanceFree(theme->a_menu_disabled);
1692 RrAppearanceFree(theme->a_menu_disabled_selected);
1693 RrAppearanceFree(theme->a_menu_text_normal);
1694 RrAppearanceFree(theme->a_menu_text_selected);
1695 RrAppearanceFree(theme->a_menu_text_disabled);
1696 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1697 RrAppearanceFree(theme->a_menu_bullet_normal);
1698 RrAppearanceFree(theme->a_menu_bullet_selected);
1699 RrAppearanceFree(theme->a_clear);
1700 RrAppearanceFree(theme->a_clear_tex);
1701 RrAppearanceFree(theme->osd_bg);
1702 RrAppearanceFree(theme->osd_hilite_bg);
1703 RrAppearanceFree(theme->osd_hilite_label);
1704 RrAppearanceFree(theme->osd_unhilite_bg);
1705 RrAppearanceFree(theme->osd_unhilite_label);
1706 RrAppearanceFree(theme->osd_pressed_button);
1707 RrAppearanceFree(theme->osd_unpressed_button);
1708 RrAppearanceFree(theme->osd_focused_button);
1709
1710 g_slice_free(RrTheme, theme);
1711 }
1712 }
1713
1714 static XrmDatabase loaddb(const gchar *name, gchar **path)
1715 {
1716 GSList *it;
1717 XrmDatabase db = NULL;
1718 gchar *s;
1719
1720 if (name[0] == '/') {
1721 s = g_build_filename(name, "openbox-3", "themerc", NULL);
1722 if ((db = XrmGetFileDatabase(s)))
1723 *path = g_path_get_dirname(s);
1724 g_free(s);
1725 } else {
1726 ObtPaths *p;
1727
1728 p = obt_paths_new();
1729
1730 /* XXX backwards compatibility, remove me sometime later */
1731 s = g_build_filename(g_get_home_dir(), ".themes", name,
1732 "openbox-3", "themerc", NULL);
1733 if ((db = XrmGetFileDatabase(s)))
1734 *path = g_path_get_dirname(s);
1735 g_free(s);
1736
1737 for (it = obt_paths_data_dirs(p); !db && it; it = g_slist_next(it))
1738 {
1739 s = g_build_filename(it->data, "themes", name,
1740 "openbox-3", "themerc", NULL);
1741 if ((db = XrmGetFileDatabase(s)))
1742 *path = g_path_get_dirname(s);
1743 g_free(s);
1744 }
1745
1746 obt_paths_unref(p);
1747 }
1748
1749 if (db == NULL) {
1750 s = g_build_filename(name, "themerc", NULL);
1751 if ((db = XrmGetFileDatabase(s)))
1752 *path = g_path_get_dirname(s);
1753 g_free(s);
1754 }
1755
1756 return db;
1757 }
1758
1759 static gchar *create_class_name(const gchar *rname)
1760 {
1761 gchar *rclass = g_strdup(rname);
1762 gchar *p = rclass;
1763
1764 while (TRUE) {
1765 *p = toupper(*p);
1766 p = strchr(p+1, '.');
1767 if (p == NULL) break;
1768 ++p;
1769 if (*p == '\0') break;
1770 }
1771 return rclass;
1772 }
1773
1774 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1775 {
1776 gboolean ret = FALSE;
1777 gchar *rclass = create_class_name(rname);
1778 gchar *rettype, *end;
1779 XrmValue retvalue;
1780
1781 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1782 retvalue.addr != NULL) {
1783 *value = (gint)strtol(retvalue.addr, &end, 10);
1784 if (end != retvalue.addr)
1785 ret = TRUE;
1786 }
1787
1788 g_free(rclass);
1789 return ret;
1790 }
1791
1792 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1793 {
1794 gboolean ret = FALSE;
1795 gchar *rclass = create_class_name(rname);
1796 gchar *rettype;
1797 XrmValue retvalue;
1798
1799 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1800 retvalue.addr != NULL) {
1801 g_strstrip(retvalue.addr);
1802 *value = retvalue.addr;
1803 ret = TRUE;
1804 }
1805
1806 g_free(rclass);
1807 return ret;
1808 }
1809
1810 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1811 const gchar *rname, RrColor **value)
1812 {
1813 gboolean ret = FALSE;
1814 gchar *rclass = create_class_name(rname);
1815 gchar *rettype;
1816 XrmValue retvalue;
1817
1818 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1819 retvalue.addr != NULL) {
1820 RrColor *c;
1821
1822 /* retvalue.addr is inside the xrdb database so we can't destroy it
1823 but we can edit it in place, as g_strstrip does. */
1824 g_strstrip(retvalue.addr);
1825 c = RrColorParse(inst, retvalue.addr);
1826 if (c != NULL) {
1827 *value = c;
1828 ret = TRUE;
1829 }
1830 }
1831
1832 g_free(rclass);
1833 return ret;
1834 }
1835
1836 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1837 RrTheme *theme, const gchar *maskname,
1838 RrPixmapMask **value)
1839 {
1840 gboolean ret = FALSE;
1841 gchar *s;
1842 gint hx, hy; /* ignored */
1843 guint w, h;
1844 guchar *b;
1845
1846 s = g_build_filename(path, maskname, NULL);
1847 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1848 ret = TRUE;
1849 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1850 XFree(b);
1851 }
1852 g_free(s);
1853
1854 return ret;
1855 }
1856
1857 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1858 RrReliefType *relief, RrBevelType *bevel,
1859 gboolean *interlaced, gboolean *border,
1860 gboolean allow_trans)
1861 {
1862 gchar *t;
1863
1864 /* convert to all lowercase */
1865 for (t = tex; *t != '\0'; ++t)
1866 *t = g_ascii_tolower(*t);
1867
1868 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1869 *grad = RR_SURFACE_PARENTREL;
1870 } else {
1871 if (strstr(tex, "gradient") != NULL) {
1872 if (strstr(tex, "crossdiagonal") != NULL)
1873 *grad = RR_SURFACE_CROSS_DIAGONAL;
1874 else if (strstr(tex, "pyramid") != NULL)
1875 *grad = RR_SURFACE_PYRAMID;
1876 else if (strstr(tex, "mirrorhorizontal") != NULL)
1877 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1878 else if (strstr(tex, "horizontal") != NULL)
1879 *grad = RR_SURFACE_HORIZONTAL;
1880 else if (strstr(tex, "splitvertical") != NULL)
1881 *grad = RR_SURFACE_SPLIT_VERTICAL;
1882 else if (strstr(tex, "vertical") != NULL)
1883 *grad = RR_SURFACE_VERTICAL;
1884 else
1885 *grad = RR_SURFACE_DIAGONAL;
1886 } else {
1887 *grad = RR_SURFACE_SOLID;
1888 }
1889 }
1890
1891 if (strstr(tex, "sunken") != NULL)
1892 *relief = RR_RELIEF_SUNKEN;
1893 else if (strstr(tex, "flat") != NULL)
1894 *relief = RR_RELIEF_FLAT;
1895 else if (strstr(tex, "raised") != NULL)
1896 *relief = RR_RELIEF_RAISED;
1897 else
1898 *relief = (*grad == RR_SURFACE_PARENTREL) ?
1899 RR_RELIEF_FLAT : RR_RELIEF_RAISED;
1900
1901 *border = FALSE;
1902 if (*relief == RR_RELIEF_FLAT) {
1903 if (strstr(tex, "border") != NULL)
1904 *border = TRUE;
1905 } else {
1906 if (strstr(tex, "bevel2") != NULL)
1907 *bevel = RR_BEVEL_2;
1908 else
1909 *bevel = RR_BEVEL_1;
1910 }
1911
1912 if (strstr(tex, "interlaced") != NULL)
1913 *interlaced = TRUE;
1914 else
1915 *interlaced = FALSE;
1916 }
1917
1918 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1919 const gchar *rname, RrAppearance *value,
1920 gboolean allow_trans)
1921 {
1922 gboolean ret = FALSE;
1923 gchar *rclass = create_class_name(rname);
1924 gchar *cname, *ctoname, *bcname, *icname, *hname, *sname;
1925 gchar *csplitname, *ctosplitname;
1926 gchar *rettype;
1927 XrmValue retvalue;
1928 gint i;
1929
1930 cname = g_strconcat(rname, ".color", NULL);
1931 ctoname = g_strconcat(rname, ".colorTo", NULL);
1932 bcname = g_strconcat(rname, ".border.color", NULL);
1933 icname = g_strconcat(rname, ".interlace.color", NULL);
1934 hname = g_strconcat(rname, ".highlight", NULL);
1935 sname = g_strconcat(rname, ".shadow", NULL);
1936 csplitname = g_strconcat(rname, ".color.splitTo", NULL);
1937 ctosplitname = g_strconcat(rname, ".colorTo.splitTo", NULL);
1938
1939 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1940 retvalue.addr != NULL) {
1941 parse_appearance(retvalue.addr,
1942 &value->surface.grad,
1943 &value->surface.relief,
1944 &value->surface.bevel,
1945 &value->surface.interlaced,
1946 &value->surface.border,
1947 allow_trans);
1948 if (!read_color(db, inst, cname, &value->surface.primary))
1949 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1950 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1951 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1952 if (value->surface.border)
1953 if (!read_color(db, inst, bcname,
1954 &value->surface.border_color))
1955 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1956 if (value->surface.interlaced)
1957 if (!read_color(db, inst, icname,
1958 &value->surface.interlace_color))
1959 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1960 if (read_int(db, hname, &i) && i >= 0)
1961 value->surface.bevel_light_adjust = i;
1962 if (read_int(db, sname, &i) && i >= 0 && i <= 256)
1963 value->surface.bevel_dark_adjust = i;
1964
1965 if (value->surface.grad == RR_SURFACE_SPLIT_VERTICAL) {
1966 gint r, g, b;
1967
1968 if (!read_color(db, inst, csplitname,
1969 &value->surface.split_primary))
1970 {
1971 r = value->surface.primary->r;
1972 r += r >> 2;
1973 g = value->surface.primary->g;
1974 g += g >> 2;
1975 b = value->surface.primary->b;
1976 b += b >> 2;
1977 if (r > 0xFF) r = 0xFF;
1978 if (g > 0xFF) g = 0xFF;
1979 if (b > 0xFF) b = 0xFF;
1980 value->surface.split_primary = RrColorNew(inst, r, g, b);
1981 }
1982
1983 if (!read_color(db, inst, ctosplitname,
1984 &value->surface.split_secondary))
1985 {
1986 r = value->surface.secondary->r;
1987 r += r >> 4;
1988 g = value->surface.secondary->g;
1989 g += g >> 4;
1990 b = value->surface.secondary->b;
1991 b += b >> 4;
1992 if (r > 0xFF) r = 0xFF;
1993 if (g > 0xFF) g = 0xFF;
1994 if (b > 0xFF) b = 0xFF;
1995 value->surface.split_secondary = RrColorNew(inst, r, g, b);
1996 }
1997 }
1998
1999 ret = TRUE;
2000 }
2001
2002 g_free(ctosplitname);
2003 g_free(csplitname);
2004 g_free(sname);
2005 g_free(hname);
2006 g_free(icname);
2007 g_free(bcname);
2008 g_free(ctoname);
2009 g_free(cname);
2010 g_free(rclass);
2011 return ret;
2012 }
2013
2014 static int parse_inline_number(const char *p)
2015 {
2016 int neg = 1;
2017 int res = 0;
2018 if (*p == '-') {
2019 neg = -1;
2020 ++p;
2021 }
2022 for (; isdigit(*p); ++p)
2023 res = res * 10 + *p - '0';
2024 res *= neg;
2025 return res;
2026 }
2027
2028 static void set_default_appearance(RrAppearance *a)
2029 {
2030 a->surface.grad = RR_SURFACE_SOLID;
2031 a->surface.relief = RR_RELIEF_FLAT;
2032 a->surface.bevel = RR_BEVEL_1;
2033 a->surface.interlaced = FALSE;
2034 a->surface.border = FALSE;
2035 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
2036 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
2037 }
2038
2039 /* Reads the output from gimp's C-Source file format into valid RGBA data for
2040 an RrTextureRGBA. */
2041 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
2042 {
2043 RrPixel32 *im, *p;
2044 gint i;
2045
2046 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
2047
2048 for (i = 0; i < width * height; ++i) {
2049 guchar a = ((*p >> 24) & 0xff);
2050 guchar b = ((*p >> 16) & 0xff);
2051 guchar g = ((*p >> 8) & 0xff);
2052 guchar r = ((*p >> 0) & 0xff);
2053
2054 *p = ((r << RrDefaultRedOffset) +
2055 (g << RrDefaultGreenOffset) +
2056 (b << RrDefaultBlueOffset) +
2057 (a << RrDefaultAlphaOffset));
2058 p++;
2059 }
2060
2061 return im;
2062 }
2063
2064 static void read_button_colors(XrmDatabase db, const RrInstance *inst,
2065 const RrTheme *theme, RrButton *btn,
2066 const gchar *btnname)
2067 {
2068 gchar *name;
2069
2070 /* active unpressed */
2071 name = g_strdup_printf("window.active.button.%s.unpressed.image.color",
2072 btnname);
2073 READ_COLOR(name, btn->focused_unpressed_color,
2074 RrColorCopy(theme->titlebut_focused_unpressed_color));
2075 g_free(name);
2076
2077 /* inactive unpressed */
2078 name = g_strdup_printf("window.inactive.button.%s.unpressed.image.color",
2079 btnname);
2080 READ_COLOR(name, btn->unfocused_unpressed_color,
2081 RrColorCopy(theme->titlebut_unfocused_unpressed_color));
2082 g_free(name);
2083
2084 /* active pressed */
2085 name = g_strdup_printf("window.active.button.%s.pressed.image.color",
2086 btnname);
2087 READ_COLOR(name, btn->focused_pressed_color,
2088 RrColorCopy(theme->titlebut_focused_pressed_color));
2089 g_free(name);
2090
2091 /* inactive pressed */
2092 name = g_strdup_printf("window.inactive.button.%s.pressed.image.color",
2093 btnname);
2094 READ_COLOR(name, btn->unfocused_pressed_color,
2095 RrColorCopy(theme->titlebut_unfocused_pressed_color));
2096 g_free(name);
2097
2098 /* active disabled */
2099 name = g_strdup_printf("window.active.button.%s.disabled.image.color",
2100 btnname);
2101 READ_COLOR(name, btn->disabled_focused_color,
2102 RrColorCopy(theme->titlebut_disabled_focused_color));
2103 g_free(name);
2104
2105 /* inactive disabled */
2106 name = g_strdup_printf("window.inactive.button.%s.disabled.image.color",
2107 btnname);
2108 READ_COLOR(name, btn->disabled_unfocused_color,
2109 RrColorCopy(theme->titlebut_disabled_unfocused_color));
2110 g_free(name);
2111
2112 /* active hover */
2113 name = g_strdup_printf("window.active.button.%s.hover.image.color",
2114 btnname);
2115 READ_COLOR(name, btn->hover_focused_color,
2116 RrColorCopy(theme->titlebut_hover_focused_color));
2117 g_free(name);
2118
2119 /* inactive hover */
2120 name = g_strdup_printf("window.inactive.button.%s.hover.image.color",
2121 btnname);
2122 READ_COLOR(name, btn->hover_unfocused_color,
2123 RrColorCopy(theme->titlebut_hover_unfocused_color));
2124 g_free(name);
2125
2126 /* active toggled unpressed */
2127 name = g_strdup_printf("window.active.button.%s.toggled."
2128 "unpressed.image.color", btnname);
2129 READ_COLOR(name, btn->toggled_focused_unpressed_color,
2130 RrColorCopy(theme->titlebut_toggled_focused_unpressed_color));
2131 g_free(name);
2132
2133 /* inactive toggled unpressed */
2134 name = g_strdup_printf("window.inactive.button.%s.toggled."
2135 "unpressed.image.color", btnname);
2136 READ_COLOR(name, btn->toggled_unfocused_unpressed_color,
2137 RrColorCopy(theme->titlebut_toggled_unfocused_unpressed_color));
2138 g_free(name);
2139
2140 /* active toggled hover */
2141 name = g_strdup_printf("window.active.button.%s.toggled.hover.image.color",
2142 btnname);
2143 READ_COLOR(name, btn->toggled_hover_focused_color,
2144 RrColorCopy(theme->titlebut_toggled_hover_focused_color));
2145
2146 g_free(name);
2147
2148 /* inactive toggled hover */
2149 name = g_strdup_printf("window.inactive.button.%s.toggled.hover."
2150 "image.color", btnname);
2151 READ_COLOR(name, btn->toggled_hover_unfocused_color,
2152 RrColorCopy(theme->titlebut_toggled_hover_unfocused_color));
2153 g_free(name);
2154
2155 /* active toggled pressed */
2156 name = g_strdup_printf("window.active.button.%s.toggled.pressed."
2157 "image.color", btnname);
2158 READ_COLOR(name, btn->toggled_focused_pressed_color,
2159 RrColorCopy(theme->titlebut_toggled_focused_pressed_color));
2160 g_free(name);
2161
2162 /* inactive toggled pressed */
2163 name = g_strdup_printf("window.inactive.button.%s.toggled.pressed."
2164 "image.color", btnname);
2165 READ_COLOR(name, btn->toggled_unfocused_pressed_color,
2166 RrColorCopy(theme->titlebut_toggled_unfocused_pressed_color));
2167 g_free(name);
2168 }
2169
2170
This page took 0.14114 seconds and 4 git commands to generate.