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