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