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