1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 theme.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
26 #include "obt/paths.h"
27 #include "openbox/engine_interface.h"
30 #include <X11/Xresource.h>
35 static XrmDatabase loaddb(const gchar *name, gchar **path);
36 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value);
37 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value);
38 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
39 const gchar *rname, RrColor **value);
40 static gboolean read_mask(const RrInstance *inst, const gchar *path,
41 RrTheme *theme, const gchar *maskname,
42 RrPixmapMask **value);
43 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
44 const gchar *rname, RrAppearance *value,
45 gboolean allow_trans);
46 static int parse_inline_number(const char *p);
47 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data);
48 static void set_default_appearance(RrAppearance *a);
50 gint LoadThemeConfig(ObFramePlugin * p, const RrInstance *inst,
51 const gchar *name, gboolean allow_fallback, RrFont *active_window_font,
52 RrFont *inactive_window_font, RrFont *menu_title_font,
53 RrFont *menu_item_font, RrFont *osd_font)
55 XrmDatabase db = NULL;
60 db = loaddb(name, &path);
63 g_message("Unable to load the theme '%s'", name);
65 g_message("Falling back to the default theme '%s'", DEFAULT_THEME);
66 /* fallback to the default theme */
74 db = loaddb(DEFAULT_THEME, &path);
77 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
85 gint i = (p->load_theme_config)(inst, name, path, db, active_window_font,
86 inactive_window_font, menu_title_font, menu_item_font, osd_font);
89 XrmDestroyDatabase(db);
94 RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
95 gboolean allow_fallback,
96 RrFont *active_window_font, RrFont *inactive_window_font,
97 RrFont *menu_title_font, RrFont *menu_item_font,
100 XrmDatabase db = NULL;
101 RrJustify winjust, mtitlejust;
108 db = loaddb(name, &path);
110 g_message("Unable to load the theme '%s'", name);
112 g_message("Falling back to the default theme '%s'",
114 /* fallback to the default theme */
119 if (allow_fallback) {
120 db = loaddb(DEFAULT_THEME, &path);
122 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
129 theme = g_new0(RrTheme, 1);
132 theme->name = g_strdup(name ? name : DEFAULT_THEME);
134 theme->a_disabled_focused_max = RrAppearanceNew(inst, 1);
135 theme->a_disabled_unfocused_max = RrAppearanceNew(inst, 1);
136 theme->a_hover_focused_max = RrAppearanceNew(inst, 1);
137 theme->a_hover_unfocused_max = RrAppearanceNew(inst, 1);
138 theme->a_toggled_focused_unpressed_max = RrAppearanceNew(inst, 1);
139 theme->a_toggled_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
140 theme->a_toggled_hover_focused_max = RrAppearanceNew(inst, 1);
141 theme->a_toggled_hover_unfocused_max = RrAppearanceNew(inst, 1);
142 theme->a_toggled_focused_pressed_max = RrAppearanceNew(inst, 1);
143 theme->a_toggled_unfocused_pressed_max = RrAppearanceNew(inst, 1);
144 theme->a_focused_unpressed_max = RrAppearanceNew(inst, 1);
145 theme->a_focused_pressed_max = RrAppearanceNew(inst, 1);
146 theme->a_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
147 theme->a_unfocused_pressed_max = RrAppearanceNew(inst, 1);
148 theme->a_focused_grip = RrAppearanceNew(inst, 0);
149 theme->a_unfocused_grip = RrAppearanceNew(inst, 0);
150 theme->a_focused_title = RrAppearanceNew(inst, 0);
151 theme->a_unfocused_title = RrAppearanceNew(inst, 0);
152 theme->a_focused_label = RrAppearanceNew(inst, 1);
153 theme->a_unfocused_label = RrAppearanceNew(inst, 1);
154 theme->a_icon = RrAppearanceNew(inst, 1);
155 theme->a_focused_handle = RrAppearanceNew(inst, 0);
156 theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
157 theme->a_menu = RrAppearanceNew(inst, 0);
158 theme->a_menu_title = RrAppearanceNew(inst, 0);
159 theme->a_menu_text_title = RrAppearanceNew(inst, 1);
160 theme->a_menu_normal = RrAppearanceNew(inst, 0);
161 theme->a_menu_selected = RrAppearanceNew(inst, 0);
162 theme->a_menu_disabled = RrAppearanceNew(inst, 0);
163 /* a_menu_disabled_selected is copied from a_menu_selected */
164 theme->a_menu_text_normal = RrAppearanceNew(inst, 1);
165 theme->a_menu_text_selected = RrAppearanceNew(inst, 1);
166 theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
167 theme->a_menu_text_disabled_selected = RrAppearanceNew(inst, 1);
168 theme->a_menu_bullet_normal = RrAppearanceNew(inst, 1);
169 theme->a_menu_bullet_selected = RrAppearanceNew(inst, 1);
170 theme->a_clear = RrAppearanceNew(inst, 0);
171 theme->a_clear_tex = RrAppearanceNew(inst, 1);
172 theme->osd_hilite_bg = RrAppearanceNew(inst, 0);
173 theme->osd_hilite_label = RrAppearanceNew(inst, 1);
174 theme->osd_hilite_fg = RrAppearanceNew(inst, 0);
175 theme->osd_unhilite_fg = RrAppearanceNew(inst, 0);
177 /* load the font stuff */
178 if (active_window_font) {
179 theme->win_font_focused = active_window_font;
180 RrFontRef(active_window_font);
182 theme->win_font_focused = RrFontOpenDefault(inst);
184 if (inactive_window_font) {
185 theme->win_font_unfocused = inactive_window_font;
186 RrFontRef(inactive_window_font);
188 theme->win_font_unfocused = RrFontOpenDefault(inst);
190 winjust = RR_JUSTIFY_LEFT;
191 if (read_string(db, "window.label.text.justify", &str)) {
192 if (!g_ascii_strcasecmp(str, "right"))
193 winjust = RR_JUSTIFY_RIGHT;
194 else if (!g_ascii_strcasecmp(str, "center"))
195 winjust = RR_JUSTIFY_CENTER;
198 if (menu_title_font) {
199 theme->menu_title_font = menu_title_font;
200 RrFontRef(menu_title_font);
202 theme->menu_title_font = RrFontOpenDefault(inst);
204 mtitlejust = RR_JUSTIFY_LEFT;
205 if (read_string(db, "menu.title.text.justify", &str)) {
206 if (!g_ascii_strcasecmp(str, "right"))
207 mtitlejust = RR_JUSTIFY_RIGHT;
208 else if (!g_ascii_strcasecmp(str, "center"))
209 mtitlejust = RR_JUSTIFY_CENTER;
212 if (menu_item_font) {
213 theme->menu_font = menu_item_font;
214 RrFontRef(menu_item_font);
216 theme->menu_font = RrFontOpenDefault(inst);
219 theme->osd_font = osd_font;
222 theme->osd_font = RrFontOpenDefault(inst);
224 /* load direct dimensions */
225 if (!read_int(db, "menu.overlap", &theme->menu_overlap) ||
226 theme->menu_overlap < -100 || theme->menu_overlap > 100)
227 theme->menu_overlap = 0;
228 if (!read_int(db, "window.handle.width", &theme->handle_height) ||
229 theme->handle_height < 0 || theme->handle_height > 100)
230 theme->handle_height = 6;
231 if (!read_int(db, "padding.width", &theme->paddingx) ||
232 theme->paddingx < 0 || theme->paddingx > 100)
234 if (!read_int(db, "padding.height", &theme->paddingy) ||
235 theme->paddingy < 0 || theme->paddingy > 100)
236 theme->paddingy = theme->paddingx;
237 if (!read_int(db, "border.width", &theme->fbwidth) ||
238 theme->fbwidth < 0 || theme->fbwidth > 100)
240 /* menu border width inherits from the frame border width */
241 if (!read_int(db, "menu.border.width", &theme->mbwidth) ||
242 theme->mbwidth < 0 || theme->mbwidth > 100)
243 theme->mbwidth = theme->fbwidth;
244 /* osd border width inherits from the frame border width */
245 if (!read_int(db, "osd.border.width", &theme->obwidth) ||
246 theme->obwidth < 0 || theme->obwidth > 100)
247 theme->obwidth = theme->fbwidth;
248 if (!read_int(db, "window.client.padding.width", &theme->cbwidthx) ||
249 theme->cbwidthx < 0 || theme->cbwidthx > 100)
250 theme->cbwidthx = theme->paddingx;
251 if (!read_int(db, "window.client.padding.height", &theme->cbwidthy) ||
252 theme->cbwidthy < 0 || theme->cbwidthy > 100)
253 theme->cbwidthy = theme->cbwidthx;
256 if (!read_color(db, inst,
257 "window.active.border.color",
258 &theme->frame_focused_border_color) &&
259 !read_color(db, inst,
261 &theme->frame_focused_border_color))
262 theme->frame_focused_border_color = RrColorNew(inst, 0, 0, 0);
263 /* title separator focused color inherits from focused boder color */
264 if (!read_color(db, inst,
265 "window.active.title.separator.color",
266 &theme->title_separator_focused_color))
267 theme->title_separator_focused_color =
269 theme->frame_focused_border_color->r,
270 theme->frame_focused_border_color->g,
271 theme->frame_focused_border_color->b);
272 /* unfocused border color inherits from frame focused border color */
273 if (!read_color(db, inst,
274 "window.inactive.border.color",
275 &theme->frame_unfocused_border_color))
276 theme->frame_unfocused_border_color =
277 RrColorNew(inst, theme->frame_focused_border_color->r,
278 theme->frame_focused_border_color->g,
279 theme->frame_focused_border_color->b);
280 /* title separator unfocused color inherits from unfocused boder color */
281 if (!read_color(db, inst,
282 "window.inactive.title.separator.color",
283 &theme->title_separator_unfocused_color))
284 theme->title_separator_unfocused_color =
286 theme->frame_unfocused_border_color->r,
287 theme->frame_unfocused_border_color->g,
288 theme->frame_unfocused_border_color->b);
290 /* menu border color inherits from frame focused border color */
291 if (!read_color(db, inst, "menu.border.color", &theme->menu_border_color))
292 theme->menu_border_color =
294 theme->frame_focused_border_color->r,
295 theme->frame_focused_border_color->g,
296 theme->frame_focused_border_color->b);
297 /* osd border color inherits from frame focused border color */
298 if (!read_color(db, inst, "osd.border.color", &theme->osd_border_color))
299 theme->osd_border_color =
301 theme->frame_focused_border_color->r,
302 theme->frame_focused_border_color->g,
303 theme->frame_focused_border_color->b);
304 if (!read_color(db, inst,
305 "window.active.client.color",
306 &theme->cb_focused_color))
307 theme->cb_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
308 if (!read_color(db, inst,
309 "window.inactive.client.color",
310 &theme->cb_unfocused_color))
311 theme->cb_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
312 if (!read_color(db, inst,
313 "window.active.label.text.color",
314 &theme->title_focused_color))
315 theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0);
316 if (!read_color(db, inst, "osd.label.text.color", &theme->osd_color))
317 theme->osd_color = RrColorNew(inst,
318 theme->title_focused_color->r,
319 theme->title_focused_color->g,
320 theme->title_focused_color->b);
321 if (!read_color(db, inst,
322 "window.inactive.label.text.color",
323 &theme->title_unfocused_color))
324 theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
325 if (!read_color(db, inst,
326 "window.active.button.unpressed.image.color",
327 &theme->titlebut_focused_unpressed_color))
328 theme->titlebut_focused_unpressed_color = RrColorNew(inst, 0, 0, 0);
329 if (!read_color(db, inst,
330 "window.inactive.button.unpressed.image.color",
331 &theme->titlebut_unfocused_unpressed_color))
332 theme->titlebut_unfocused_unpressed_color =
333 RrColorNew(inst, 0xff, 0xff, 0xff);
334 if (!read_color(db, inst,
335 "window.active.button.pressed.image.color",
336 &theme->titlebut_focused_pressed_color))
337 theme->titlebut_focused_pressed_color =
339 theme->titlebut_focused_unpressed_color->r,
340 theme->titlebut_focused_unpressed_color->g,
341 theme->titlebut_focused_unpressed_color->b);
342 if (!read_color(db, inst,
343 "window.inactive.button.pressed.image.color",
344 &theme->titlebut_unfocused_pressed_color))
345 theme->titlebut_unfocused_pressed_color =
347 theme->titlebut_unfocused_unpressed_color->r,
348 theme->titlebut_unfocused_unpressed_color->g,
349 theme->titlebut_unfocused_unpressed_color->b);
350 if (!read_color(db, inst,
351 "window.active.button.disabled.image.color",
352 &theme->titlebut_disabled_focused_color))
353 theme->titlebut_disabled_focused_color =
354 RrColorNew(inst, 0xff, 0xff, 0xff);
355 if (!read_color(db, inst,
356 "window.inactive.button.disabled.image.color",
357 &theme->titlebut_disabled_unfocused_color))
358 theme->titlebut_disabled_unfocused_color = RrColorNew(inst, 0, 0, 0);
359 if (!read_color(db, inst,
360 "window.active.button.hover.image.color",
361 &theme->titlebut_hover_focused_color))
362 theme->titlebut_hover_focused_color =
364 theme->titlebut_focused_unpressed_color->r,
365 theme->titlebut_focused_unpressed_color->g,
366 theme->titlebut_focused_unpressed_color->b);
367 if (!read_color(db, inst,
368 "window.inactive.button.hover.image.color",
369 &theme->titlebut_hover_unfocused_color))
370 theme->titlebut_hover_unfocused_color =
372 theme->titlebut_unfocused_unpressed_color->r,
373 theme->titlebut_unfocused_unpressed_color->g,
374 theme->titlebut_unfocused_unpressed_color->b);
375 if (!read_color(db, inst,
376 "window.active.button.toggled.unpressed.image.color",
377 &theme->titlebut_toggled_focused_unpressed_color) &&
378 !read_color(db, inst,
379 "window.active.button.toggled.image.color",
380 &theme->titlebut_toggled_focused_unpressed_color))
381 theme->titlebut_toggled_focused_unpressed_color =
383 theme->titlebut_focused_pressed_color->r,
384 theme->titlebut_focused_pressed_color->g,
385 theme->titlebut_focused_pressed_color->b);
386 if (!read_color(db, inst,
387 "window.inactive.button.toggled.unpressed.image.color",
388 &theme->titlebut_toggled_unfocused_unpressed_color) &&
389 !read_color(db, inst,
390 "window.inactive.button.toggled.image.color",
391 &theme->titlebut_toggled_unfocused_unpressed_color))
392 theme->titlebut_toggled_unfocused_unpressed_color =
394 theme->titlebut_unfocused_pressed_color->r,
395 theme->titlebut_unfocused_pressed_color->g,
396 theme->titlebut_unfocused_pressed_color->b);
397 if (!read_color(db, inst,
398 "window.active.button.toggled.hover.image.color",
399 &theme->titlebut_toggled_hover_focused_color))
400 theme->titlebut_toggled_hover_focused_color =
402 theme->titlebut_toggled_focused_unpressed_color->r,
403 theme->titlebut_toggled_focused_unpressed_color->g,
404 theme->titlebut_toggled_focused_unpressed_color->b);
405 if (!read_color(db, inst,
406 "window.inactive.button.toggled.hover.image.color",
407 &theme->titlebut_toggled_hover_unfocused_color))
408 theme->titlebut_toggled_hover_unfocused_color =
410 theme->titlebut_toggled_unfocused_unpressed_color->r,
411 theme->titlebut_toggled_unfocused_unpressed_color->g,
412 theme->titlebut_toggled_unfocused_unpressed_color->b);
413 if (!read_color(db, inst,
414 "window.active.button.toggled.pressed.image.color",
415 &theme->titlebut_toggled_focused_pressed_color))
416 theme->titlebut_toggled_focused_pressed_color =
418 theme->titlebut_focused_pressed_color->r,
419 theme->titlebut_focused_pressed_color->g,
420 theme->titlebut_focused_pressed_color->b);
421 if (!read_color(db, inst,
422 "window.inactive.button.toggled.pressed.image.color",
423 &theme->titlebut_toggled_unfocused_pressed_color))
424 theme->titlebut_toggled_unfocused_pressed_color =
426 theme->titlebut_unfocused_pressed_color->r,
427 theme->titlebut_unfocused_pressed_color->g,
428 theme->titlebut_unfocused_pressed_color->b);
429 if (!read_color(db, inst,
430 "menu.title.text.color", &theme->menu_title_color))
431 theme->menu_title_color = RrColorNew(inst, 0, 0, 0);
432 if (!read_color(db, inst,
433 "menu.items.text.color", &theme->menu_color))
434 theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff);
435 if (!read_color(db, inst,
436 "menu.items.disabled.text.color",
437 &theme->menu_disabled_color))
438 theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0);
439 if (!read_color(db, inst,
440 "menu.items.active.disabled.text.color",
441 &theme->menu_disabled_selected_color))
442 theme->menu_disabled_selected_color =
444 theme->menu_disabled_color->r,
445 theme->menu_disabled_color->g,
446 theme->menu_disabled_color->b);
447 if (!read_color(db, inst,
448 "menu.items.active.text.color",
449 &theme->menu_selected_color))
450 theme->menu_selected_color = RrColorNew(inst, 0, 0, 0);
452 /* load the image masks */
454 /* maximize button masks */
456 if (!read_mask(inst, path, theme, "max.xbm", &theme->max_mask)) {
457 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
458 theme->max_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
461 if (!read_mask(inst, path, theme, "max_toggled.xbm",
462 &theme->max_toggled_mask))
465 theme->max_toggled_mask = RrPixmapMaskCopy(theme->max_mask);
467 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
468 theme->max_toggled_mask = RrPixmapMaskNew(inst, 6, 6,(gchar*)data);
471 if (!read_mask(inst, path, theme, "max_pressed.xbm",
472 &theme->max_pressed_mask))
473 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
474 if (!read_mask(inst,path,theme,"max_disabled.xbm",
475 &theme->max_disabled_mask))
476 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
477 if (!read_mask(inst, path, theme, "max_hover.xbm", &theme->max_hover_mask))
478 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
479 if (!read_mask(inst, path, theme, "max_toggled_pressed.xbm",
480 &theme->max_toggled_pressed_mask))
481 theme->max_toggled_pressed_mask =
482 RrPixmapMaskCopy(theme->max_toggled_mask);
483 if (!read_mask(inst, path, theme, "max_toggled_hover.xbm",
484 &theme->max_toggled_hover_mask))
485 theme->max_toggled_hover_mask =
486 RrPixmapMaskCopy(theme->max_toggled_mask);
488 /* iconify button masks */
489 if (!read_mask(inst, path, theme, "iconify.xbm", &theme->iconify_mask)) {
490 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
491 theme->iconify_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
493 if (!read_mask(inst, path, theme, "iconify_pressed.xbm",
494 &theme->iconify_pressed_mask))
495 theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
496 if (!read_mask(inst, path, theme, "iconify_disabled.xbm",
497 &theme->iconify_disabled_mask))
498 theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
499 if (!read_mask(inst, path, theme, "iconify_hover.xbm",
500 &theme->iconify_hover_mask))
501 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
503 /* all desktops button masks */
505 if (!read_mask(inst, path, theme, "desk.xbm", &theme->desk_mask)) {
506 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
507 theme->desk_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
510 if (!read_mask(inst, path, theme, "desk_toggled.xbm",
511 &theme->desk_toggled_mask)) {
513 theme->desk_toggled_mask = RrPixmapMaskCopy(theme->desk_mask);
515 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
516 theme->desk_toggled_mask =
517 RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
520 if (!read_mask(inst, path, theme, "desk_pressed.xbm",
521 &theme->desk_pressed_mask))
522 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
523 if (!read_mask(inst, path, theme, "desk_disabled.xbm",
524 &theme->desk_disabled_mask))
525 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
526 if (!read_mask(inst, path, theme, "desk_hover.xbm",
527 &theme->desk_hover_mask))
528 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
529 if (!read_mask(inst, path, theme, "desk_toggled_pressed.xbm",
530 &theme->desk_toggled_pressed_mask))
531 theme->desk_toggled_pressed_mask =
532 RrPixmapMaskCopy(theme->desk_toggled_mask);
533 if (!read_mask(inst, path, theme, "desk_toggled_hover.xbm",
534 &theme->desk_toggled_hover_mask))
535 theme->desk_toggled_hover_mask =
536 RrPixmapMaskCopy(theme->desk_toggled_mask);
538 /* shade button masks */
539 if (!read_mask(inst, path, theme, "shade.xbm", &theme->shade_mask)) {
540 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
541 theme->shade_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
543 if (!read_mask(inst, path, theme, "shade_toggled.xbm",
544 &theme->shade_toggled_mask))
545 theme->shade_toggled_mask = RrPixmapMaskCopy(theme->shade_mask);
546 if (!read_mask(inst, path, theme, "shade_pressed.xbm",
547 &theme->shade_pressed_mask))
548 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
549 if (!read_mask(inst, path, theme, "shade_disabled.xbm",
550 &theme->shade_disabled_mask))
551 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
552 if (!read_mask(inst, path, theme, "shade_hover.xbm",
553 &theme->shade_hover_mask))
554 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
555 if (!read_mask(inst, path, theme, "shade_toggled_pressed.xbm",
556 &theme->shade_toggled_pressed_mask))
557 theme->shade_toggled_pressed_mask =
558 RrPixmapMaskCopy(theme->shade_toggled_mask);
559 if (!read_mask(inst, path, theme, "shade_toggled_hover.xbm",
560 &theme->shade_toggled_hover_mask))
561 theme->shade_toggled_hover_mask =
562 RrPixmapMaskCopy(theme->shade_toggled_mask);
564 /* close button masks */
565 if (!read_mask(inst, path, theme, "close.xbm", &theme->close_mask)) {
566 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
567 theme->close_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
569 if (!read_mask(inst, path, theme, "close_pressed.xbm",
570 &theme->close_pressed_mask))
571 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
572 if (!read_mask(inst, path, theme, "close_disabled.xbm",
573 &theme->close_disabled_mask))
574 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
575 if (!read_mask(inst, path, theme, "close_hover.xbm",
576 &theme->close_hover_mask))
577 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
579 /* submenu bullet mask */
580 if (!read_mask(inst, path, theme, "bullet.xbm", &theme->menu_bullet_mask))
582 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
583 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
586 /* up and down arrows */
588 guchar data[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 };
589 theme->down_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
592 guchar data[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 };
593 theme->up_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
596 /* setup the default window icon */
597 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
598 OB_DEFAULT_ICON_HEIGHT,
599 OB_DEFAULT_ICON_pixel_data);
601 /* read the decoration textures */
602 if (!read_appearance(db, inst,
603 "window.active.title.bg", theme->a_focused_title,
605 set_default_appearance(theme->a_focused_title);
606 if (!read_appearance(db, inst,
607 "window.inactive.title.bg", theme->a_unfocused_title,
609 set_default_appearance(theme->a_unfocused_title);
610 if (!read_appearance(db, inst,
611 "window.active.label.bg", theme->a_focused_label,
613 set_default_appearance(theme->a_focused_label);
614 if (!read_appearance(db, inst,
615 "window.inactive.label.bg", theme->a_unfocused_label,
617 set_default_appearance(theme->a_unfocused_label);
618 if (!read_appearance(db, inst,
619 "window.active.handle.bg", theme->a_focused_handle,
621 set_default_appearance(theme->a_focused_handle);
622 if (!read_appearance(db, inst,
623 "window.inactive.handle.bg",theme->a_unfocused_handle,
625 set_default_appearance(theme->a_unfocused_handle);
626 if (!read_appearance(db, inst,
627 "window.active.grip.bg", theme->a_focused_grip,
629 set_default_appearance(theme->a_focused_grip);
630 if (!read_appearance(db, inst,
631 "window.inactive.grip.bg", theme->a_unfocused_grip,
633 set_default_appearance(theme->a_unfocused_grip);
634 if (!read_appearance(db, inst,
635 "menu.items.bg", theme->a_menu,
637 set_default_appearance(theme->a_menu);
638 if (!read_appearance(db, inst,
639 "menu.title.bg", theme->a_menu_title,
641 set_default_appearance(theme->a_menu_title);
642 if (!read_appearance(db, inst,
643 "menu.items.active.bg", theme->a_menu_selected,
645 set_default_appearance(theme->a_menu_selected);
646 theme->a_menu_disabled_selected =
647 RrAppearanceCopy(theme->a_menu_selected);
649 /* read appearances for non-decorations (on-screen-display) */
650 if (!read_appearance(db, inst, "osd.bg", theme->osd_hilite_bg, FALSE)) {
651 RrAppearanceFree(theme->osd_hilite_bg);
652 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
654 if (!read_appearance(db, inst, "osd.label.bg",
655 theme->osd_hilite_label, TRUE)) {
656 RrAppearanceFree(theme->osd_hilite_label);
657 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
659 /* osd_hilite_fg can't be parentrel */
660 if (!read_appearance(db, inst, "osd.hilight.bg",
661 theme->osd_hilite_fg, FALSE)) {
662 RrAppearanceFree(theme->osd_hilite_fg);
663 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
664 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_label);
666 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_title);
668 /* osd_unhilite_fg can't be parentrel either */
669 if (!read_appearance(db, inst, "osd.unhilight.bg",
670 theme->osd_unhilite_fg, FALSE)) {
671 RrAppearanceFree(theme->osd_unhilite_fg);
672 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
673 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_label);
675 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_title);
678 /* read buttons textures */
679 if (!read_appearance(db, inst,
680 "window.active.button.disabled.bg",
681 theme->a_disabled_focused_max,
683 set_default_appearance(theme->a_disabled_focused_max);
684 if (!read_appearance(db, inst,
685 "window.inactive.button.disabled.bg",
686 theme->a_disabled_unfocused_max,
688 set_default_appearance(theme->a_disabled_unfocused_max);
689 if (!read_appearance(db, inst,
690 "window.active.button.pressed.bg",
691 theme->a_focused_pressed_max,
693 set_default_appearance(theme->a_focused_pressed_max);
694 if (!read_appearance(db, inst,
695 "window.inactive.button.pressed.bg",
696 theme->a_unfocused_pressed_max,
698 set_default_appearance(theme->a_unfocused_pressed_max);
699 if (!read_appearance(db, inst,
700 "window.active.button.toggled.unpressed.bg",
701 theme->a_toggled_focused_unpressed_max,
703 !read_appearance(db, inst,
704 "window.active.button.toggled.bg",
705 theme->a_toggled_focused_unpressed_max,
708 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
709 theme->a_toggled_focused_unpressed_max =
710 RrAppearanceCopy(theme->a_focused_pressed_max);
712 if (!read_appearance(db, inst,
713 "window.inactive.button.toggled.unpressed.bg",
714 theme->a_toggled_unfocused_unpressed_max,
716 !read_appearance(db, inst,
717 "window.inactive.button.toggled.bg",
718 theme->a_toggled_unfocused_unpressed_max,
721 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
722 theme->a_toggled_unfocused_unpressed_max =
723 RrAppearanceCopy(theme->a_unfocused_pressed_max);
725 if (!read_appearance(db, inst,
726 "window.active.button.toggled.hover.bg",
727 theme->a_toggled_hover_focused_max,
730 RrAppearanceFree(theme->a_toggled_hover_focused_max);
731 theme->a_toggled_hover_focused_max =
732 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
734 if (!read_appearance(db, inst,
735 "window.inactive.button.toggled.hover.bg",
736 theme->a_toggled_hover_unfocused_max,
739 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
740 theme->a_toggled_hover_unfocused_max =
741 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
743 if (!read_appearance(db, inst,
744 "window.active.button.toggled.pressed.bg",
745 theme->a_toggled_focused_pressed_max,
748 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
749 theme->a_toggled_focused_pressed_max =
750 RrAppearanceCopy(theme->a_focused_pressed_max);
752 if (!read_appearance(db, inst,
753 "window.inactive.button.toggled.pressed.bg",
754 theme->a_toggled_unfocused_pressed_max,
757 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
758 theme->a_toggled_unfocused_pressed_max =
759 RrAppearanceCopy(theme->a_unfocused_pressed_max);
761 if (!read_appearance(db, inst,
762 "window.active.button.unpressed.bg",
763 theme->a_focused_unpressed_max,
765 set_default_appearance(theme->a_focused_unpressed_max);
766 if (!read_appearance(db, inst,
767 "window.inactive.button.unpressed.bg",
768 theme->a_unfocused_unpressed_max,
770 set_default_appearance(theme->a_unfocused_unpressed_max);
771 if (!read_appearance(db, inst,
772 "window.active.button.hover.bg",
773 theme->a_hover_focused_max,
776 RrAppearanceFree(theme->a_hover_focused_max);
777 theme->a_hover_focused_max =
778 RrAppearanceCopy(theme->a_focused_unpressed_max);
780 if (!read_appearance(db, inst,
781 "window.inactive.button.hover.bg",
782 theme->a_hover_unfocused_max,
785 RrAppearanceFree(theme->a_hover_unfocused_max);
786 theme->a_hover_unfocused_max =
787 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
790 theme->a_disabled_focused_close =
791 RrAppearanceCopy(theme->a_disabled_focused_max);
792 theme->a_disabled_unfocused_close =
793 RrAppearanceCopy(theme->a_disabled_unfocused_max);
794 theme->a_hover_focused_close =
795 RrAppearanceCopy(theme->a_hover_focused_max);
796 theme->a_hover_unfocused_close =
797 RrAppearanceCopy(theme->a_hover_unfocused_max);
798 theme->a_unfocused_unpressed_close =
799 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
800 theme->a_unfocused_pressed_close =
801 RrAppearanceCopy(theme->a_unfocused_pressed_max);
802 theme->a_focused_unpressed_close =
803 RrAppearanceCopy(theme->a_focused_unpressed_max);
804 theme->a_focused_pressed_close =
805 RrAppearanceCopy(theme->a_focused_pressed_max);
806 theme->a_disabled_focused_desk =
807 RrAppearanceCopy(theme->a_disabled_focused_max);
808 theme->a_disabled_unfocused_desk =
809 RrAppearanceCopy(theme->a_disabled_unfocused_max);
810 theme->a_hover_focused_desk =
811 RrAppearanceCopy(theme->a_hover_focused_max);
812 theme->a_hover_unfocused_desk =
813 RrAppearanceCopy(theme->a_hover_unfocused_max);
814 theme->a_toggled_hover_focused_desk =
815 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
816 theme->a_toggled_hover_unfocused_desk =
817 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
818 theme->a_toggled_focused_unpressed_desk =
819 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
820 theme->a_toggled_unfocused_unpressed_desk =
821 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
822 theme->a_toggled_focused_pressed_desk =
823 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
824 theme->a_toggled_unfocused_pressed_desk =
825 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
826 theme->a_unfocused_unpressed_desk =
827 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
828 theme->a_unfocused_pressed_desk =
829 RrAppearanceCopy(theme->a_unfocused_pressed_max);
830 theme->a_focused_unpressed_desk =
831 RrAppearanceCopy(theme->a_focused_unpressed_max);
832 theme->a_focused_pressed_desk =
833 RrAppearanceCopy(theme->a_focused_pressed_max);
834 theme->a_disabled_focused_shade =
835 RrAppearanceCopy(theme->a_disabled_focused_max);
836 theme->a_disabled_unfocused_shade =
837 RrAppearanceCopy(theme->a_disabled_unfocused_max);
838 theme->a_hover_focused_shade =
839 RrAppearanceCopy(theme->a_hover_focused_max);
840 theme->a_hover_unfocused_shade =
841 RrAppearanceCopy(theme->a_hover_unfocused_max);
842 theme->a_toggled_hover_focused_shade =
843 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
844 theme->a_toggled_hover_unfocused_shade =
845 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
846 theme->a_toggled_focused_unpressed_shade =
847 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
848 theme->a_toggled_unfocused_unpressed_shade =
849 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
850 theme->a_toggled_focused_pressed_shade =
851 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
852 theme->a_toggled_unfocused_pressed_shade =
853 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
854 theme->a_unfocused_unpressed_shade =
855 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
856 theme->a_unfocused_pressed_shade =
857 RrAppearanceCopy(theme->a_unfocused_pressed_max);
858 theme->a_focused_unpressed_shade =
859 RrAppearanceCopy(theme->a_focused_unpressed_max);
860 theme->a_focused_pressed_shade =
861 RrAppearanceCopy(theme->a_focused_pressed_max);
862 theme->a_disabled_focused_iconify =
863 RrAppearanceCopy(theme->a_disabled_focused_max);
864 theme->a_disabled_unfocused_iconify =
865 RrAppearanceCopy(theme->a_disabled_focused_max);
866 theme->a_hover_focused_iconify =
867 RrAppearanceCopy(theme->a_hover_focused_max);
868 theme->a_hover_unfocused_iconify =
869 RrAppearanceCopy(theme->a_hover_unfocused_max);
870 theme->a_unfocused_unpressed_iconify =
871 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
872 theme->a_unfocused_pressed_iconify =
873 RrAppearanceCopy(theme->a_unfocused_pressed_max);
874 theme->a_focused_unpressed_iconify =
875 RrAppearanceCopy(theme->a_focused_unpressed_max);
876 theme->a_focused_pressed_iconify =
877 RrAppearanceCopy(theme->a_focused_pressed_max);
879 theme->a_icon->surface.grad =
880 theme->a_clear->surface.grad =
881 theme->a_clear_tex->surface.grad =
882 theme->a_menu_text_title->surface.grad =
883 theme->a_menu_normal->surface.grad =
884 theme->a_menu_disabled->surface.grad =
885 theme->a_menu_text_normal->surface.grad =
886 theme->a_menu_text_selected->surface.grad =
887 theme->a_menu_text_disabled->surface.grad =
888 theme->a_menu_text_disabled_selected->surface.grad =
889 theme->a_menu_bullet_normal->surface.grad =
890 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
892 /* set up the textures */
893 theme->a_focused_label->texture[0].type = RR_TEXTURE_TEXT;
894 theme->a_focused_label->texture[0].data.text.justify = winjust;
895 theme->a_focused_label->texture[0].data.text.font=theme->win_font_focused;
896 theme->a_focused_label->texture[0].data.text.color =
897 theme->title_focused_color;
899 if (read_string(db, "window.active.label.text.font", &str)) {
903 if (strstr(str, "shadow=y")) {
904 if ((p = strstr(str, "shadowoffset=")))
905 i = parse_inline_number(p + strlen("shadowoffset="));
908 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
909 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
911 if ((p = strstr(str, "shadowtint=")))
913 i = parse_inline_number(p + strlen("shadowtint="));
914 j = (i > 0 ? 0 : 255);
917 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
918 theme->title_focused_shadow_alpha = i;
920 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
921 theme->title_focused_shadow_alpha = 50;
925 theme->a_focused_label->texture[0].data.text.shadow_color =
926 theme->title_focused_shadow_color;
927 theme->a_focused_label->texture[0].data.text.shadow_alpha =
928 theme->title_focused_shadow_alpha;
930 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
931 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
932 theme->osd_hilite_label->texture[0].data.text.font = theme->osd_font;
933 theme->osd_hilite_label->texture[0].data.text.color = theme->osd_color;
935 if (read_string(db, "osd.label.text.font", &str)) {
939 if (strstr(str, "shadow=y")) {
940 if ((p = strstr(str, "shadowoffset=")))
941 i = parse_inline_number(p + strlen("shadowoffset="));
944 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
945 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
946 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
947 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
949 if ((p = strstr(str, "shadowtint=")))
951 i = parse_inline_number(p + strlen("shadowtint="));
952 j = (i > 0 ? 0 : 255);
955 theme->osd_shadow_color = RrColorNew(inst, j, j, j);
956 theme->osd_shadow_alpha = i;
958 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
959 theme->osd_shadow_alpha = 50;
962 /* inherit the font settings from the focused label */
963 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x =
964 theme->a_focused_label->texture[0].data.text.shadow_offset_x;
965 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y =
966 theme->a_focused_label->texture[0].data.text.shadow_offset_y;
967 if (theme->title_focused_shadow_color)
968 theme->osd_shadow_color =
970 theme->title_focused_shadow_color->r,
971 theme->title_focused_shadow_color->g,
972 theme->title_focused_shadow_color->b);
974 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
975 theme->osd_shadow_alpha = theme->title_focused_shadow_alpha;
978 theme->osd_hilite_label->texture[0].data.text.shadow_color =
979 theme->osd_shadow_color;
980 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
981 theme->osd_shadow_alpha;
983 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
984 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
985 theme->a_unfocused_label->texture[0].data.text.font =
986 theme->win_font_unfocused;
987 theme->a_unfocused_label->texture[0].data.text.color =
988 theme->title_unfocused_color;
990 if (read_string(db, "window.inactive.label.text.font", &str)) {
994 if (strstr(str, "shadow=y")) {
995 if ((p = strstr(str, "shadowoffset=")))
996 i = parse_inline_number(p + strlen("shadowoffset="));
999 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
1000 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
1002 if ((p = strstr(str, "shadowtint=")))
1004 i = parse_inline_number(p + strlen("shadowtint="));
1005 j = (i > 0 ? 0 : 255);
1008 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
1009 theme->title_unfocused_shadow_alpha = i;
1011 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
1012 theme->title_unfocused_shadow_alpha = 50;
1016 theme->a_unfocused_label->texture[0].data.text.shadow_color =
1017 theme->title_unfocused_shadow_color;
1018 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
1019 theme->title_unfocused_shadow_alpha;
1021 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
1022 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
1023 theme->a_menu_text_title->texture[0].data.text.font =
1024 theme->menu_title_font;
1025 theme->a_menu_text_title->texture[0].data.text.color =
1026 theme->menu_title_color;
1028 if (read_string(db, "menu.title.text.font", &str)) {
1032 if (strstr(str, "shadow=y")) {
1033 if ((p = strstr(str, "shadowoffset=")))
1034 i = parse_inline_number(p + strlen("shadowoffset="));
1037 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
1038 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
1040 if ((p = strstr(str, "shadowtint=")))
1042 i = parse_inline_number(p + strlen("shadowtint="));
1043 j = (i > 0 ? 0 : 255);
1046 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
1047 theme->menu_title_shadow_alpha = i;
1049 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
1050 theme->menu_title_shadow_alpha = 50;
1054 theme->a_menu_text_title->texture[0].data.text.shadow_color =
1055 theme->menu_title_shadow_color;
1056 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
1057 theme->menu_title_shadow_alpha;
1059 theme->a_menu_text_normal->texture[0].type =
1060 theme->a_menu_text_selected->texture[0].type =
1061 theme->a_menu_text_disabled->texture[0].type =
1062 theme->a_menu_text_disabled_selected->texture[0].type =
1064 theme->a_menu_text_normal->texture[0].data.text.justify =
1065 theme->a_menu_text_selected->texture[0].data.text.justify =
1066 theme->a_menu_text_disabled->texture[0].data.text.justify =
1067 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
1069 theme->a_menu_text_normal->texture[0].data.text.font =
1070 theme->a_menu_text_selected->texture[0].data.text.font =
1071 theme->a_menu_text_disabled->texture[0].data.text.font =
1072 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
1074 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
1075 theme->a_menu_text_selected->texture[0].data.text.color =
1076 theme->menu_selected_color;
1077 theme->a_menu_text_disabled->texture[0].data.text.color =
1078 theme->menu_disabled_color;
1079 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
1080 theme->menu_disabled_selected_color;
1082 if (read_string(db, "menu.items.font", &str)) {
1086 if (strstr(str, "shadow=y")) {
1087 if ((p = strstr(str, "shadowoffset=")))
1088 i = parse_inline_number(p + strlen("shadowoffset="));
1091 theme->a_menu_text_normal->
1092 texture[0].data.text.shadow_offset_x = i;
1093 theme->a_menu_text_normal->
1094 texture[0].data.text.shadow_offset_y = i;
1095 theme->a_menu_text_selected->
1096 texture[0].data.text.shadow_offset_x = i;
1097 theme->a_menu_text_selected->
1098 texture[0].data.text.shadow_offset_y = i;
1099 theme->a_menu_text_disabled->
1100 texture[0].data.text.shadow_offset_x = i;
1101 theme->a_menu_text_disabled->
1102 texture[0].data.text.shadow_offset_y = i;
1103 theme->a_menu_text_disabled_selected->
1104 texture[0].data.text.shadow_offset_x = i;
1105 theme->a_menu_text_disabled_selected->
1106 texture[0].data.text.shadow_offset_y = i;
1108 if ((p = strstr(str, "shadowtint=")))
1110 i = parse_inline_number(p + strlen("shadowtint="));
1111 j = (i > 0 ? 0 : 255);
1114 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
1115 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
1116 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
1117 theme->menu_text_normal_shadow_alpha = i;
1118 theme->menu_text_selected_shadow_alpha = i;
1119 theme->menu_text_disabled_shadow_alpha = i;
1120 theme->menu_text_disabled_selected_shadow_alpha = i;
1122 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
1123 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
1124 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
1125 theme->menu_text_normal_shadow_alpha = 50;
1126 theme->menu_text_selected_shadow_alpha = 50;
1127 theme->menu_text_disabled_selected_shadow_alpha = 50;
1131 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
1132 theme->menu_text_normal_shadow_color;
1133 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
1134 theme->menu_text_normal_shadow_alpha;
1135 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
1136 theme->menu_text_selected_shadow_color;
1137 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
1138 theme->menu_text_selected_shadow_alpha;
1139 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
1140 theme->menu_text_disabled_shadow_color;
1141 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
1142 theme->menu_text_disabled_shadow_alpha;
1143 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
1144 theme->menu_text_disabled_shadow_color;
1145 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
1146 theme->menu_text_disabled_shadow_alpha;
1148 theme->a_disabled_focused_max->texture[0].type =
1149 theme->a_disabled_unfocused_max->texture[0].type =
1150 theme->a_hover_focused_max->texture[0].type =
1151 theme->a_hover_unfocused_max->texture[0].type =
1152 theme->a_toggled_hover_focused_max->texture[0].type =
1153 theme->a_toggled_hover_unfocused_max->texture[0].type =
1154 theme->a_toggled_focused_unpressed_max->texture[0].type =
1155 theme->a_toggled_unfocused_unpressed_max->texture[0].type =
1156 theme->a_toggled_focused_pressed_max->texture[0].type =
1157 theme->a_toggled_unfocused_pressed_max->texture[0].type =
1158 theme->a_focused_unpressed_max->texture[0].type =
1159 theme->a_focused_pressed_max->texture[0].type =
1160 theme->a_unfocused_unpressed_max->texture[0].type =
1161 theme->a_unfocused_pressed_max->texture[0].type =
1162 theme->a_disabled_focused_close->texture[0].type =
1163 theme->a_disabled_unfocused_close->texture[0].type =
1164 theme->a_hover_focused_close->texture[0].type =
1165 theme->a_hover_unfocused_close->texture[0].type =
1166 theme->a_focused_unpressed_close->texture[0].type =
1167 theme->a_focused_pressed_close->texture[0].type =
1168 theme->a_unfocused_unpressed_close->texture[0].type =
1169 theme->a_unfocused_pressed_close->texture[0].type =
1170 theme->a_disabled_focused_desk->texture[0].type =
1171 theme->a_disabled_unfocused_desk->texture[0].type =
1172 theme->a_hover_focused_desk->texture[0].type =
1173 theme->a_hover_unfocused_desk->texture[0].type =
1174 theme->a_toggled_hover_focused_desk->texture[0].type =
1175 theme->a_toggled_hover_unfocused_desk->texture[0].type =
1176 theme->a_toggled_focused_unpressed_desk->texture[0].type =
1177 theme->a_toggled_unfocused_unpressed_desk->texture[0].type =
1178 theme->a_toggled_focused_pressed_desk->texture[0].type =
1179 theme->a_toggled_unfocused_pressed_desk->texture[0].type =
1180 theme->a_focused_unpressed_desk->texture[0].type =
1181 theme->a_focused_pressed_desk->texture[0].type =
1182 theme->a_unfocused_unpressed_desk->texture[0].type =
1183 theme->a_unfocused_pressed_desk->texture[0].type =
1184 theme->a_disabled_focused_shade->texture[0].type =
1185 theme->a_disabled_unfocused_shade->texture[0].type =
1186 theme->a_hover_focused_shade->texture[0].type =
1187 theme->a_hover_unfocused_shade->texture[0].type =
1188 theme->a_toggled_hover_focused_shade->texture[0].type =
1189 theme->a_toggled_hover_unfocused_shade->texture[0].type =
1190 theme->a_toggled_focused_unpressed_shade->texture[0].type =
1191 theme->a_toggled_unfocused_unpressed_shade->texture[0].type =
1192 theme->a_toggled_focused_pressed_shade->texture[0].type =
1193 theme->a_toggled_unfocused_pressed_shade->texture[0].type =
1194 theme->a_focused_unpressed_shade->texture[0].type =
1195 theme->a_focused_pressed_shade->texture[0].type =
1196 theme->a_unfocused_unpressed_shade->texture[0].type =
1197 theme->a_unfocused_pressed_shade->texture[0].type =
1198 theme->a_disabled_focused_iconify->texture[0].type =
1199 theme->a_disabled_unfocused_iconify->texture[0].type =
1200 theme->a_hover_focused_iconify->texture[0].type =
1201 theme->a_hover_unfocused_iconify->texture[0].type =
1202 theme->a_focused_unpressed_iconify->texture[0].type =
1203 theme->a_focused_pressed_iconify->texture[0].type =
1204 theme->a_unfocused_unpressed_iconify->texture[0].type =
1205 theme->a_unfocused_pressed_iconify->texture[0].type =
1206 theme->a_menu_bullet_normal->texture[0].type =
1207 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
1209 theme->a_disabled_focused_max->texture[0].data.mask.mask =
1210 theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
1211 theme->max_disabled_mask;
1212 theme->a_hover_focused_max->texture[0].data.mask.mask =
1213 theme->a_hover_unfocused_max->texture[0].data.mask.mask =
1214 theme->max_hover_mask;
1215 theme->a_focused_pressed_max->texture[0].data.mask.mask =
1216 theme->a_unfocused_pressed_max->texture[0].data.mask.mask =
1217 theme->max_pressed_mask;
1218 theme->a_focused_unpressed_max->texture[0].data.mask.mask =
1219 theme->a_unfocused_unpressed_max->texture[0].data.mask.mask =
1221 theme->a_toggled_hover_focused_max->texture[0].data.mask.mask =
1222 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.mask =
1223 theme->max_toggled_hover_mask;
1224 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.mask =
1225 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.mask =
1226 theme->max_toggled_mask;
1227 theme->a_toggled_focused_pressed_max->texture[0].data.mask.mask =
1228 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.mask =
1229 theme->max_toggled_pressed_mask;
1230 theme->a_disabled_focused_close->texture[0].data.mask.mask =
1231 theme->a_disabled_unfocused_close->texture[0].data.mask.mask =
1232 theme->close_disabled_mask;
1233 theme->a_hover_focused_close->texture[0].data.mask.mask =
1234 theme->a_hover_unfocused_close->texture[0].data.mask.mask =
1235 theme->close_hover_mask;
1236 theme->a_focused_pressed_close->texture[0].data.mask.mask =
1237 theme->a_unfocused_pressed_close->texture[0].data.mask.mask =
1238 theme->close_pressed_mask;
1239 theme->a_focused_unpressed_close->texture[0].data.mask.mask =
1240 theme->a_unfocused_unpressed_close->texture[0].data.mask.mask =
1242 theme->a_disabled_focused_desk->texture[0].data.mask.mask =
1243 theme->a_disabled_unfocused_desk->texture[0].data.mask.mask =
1244 theme->desk_disabled_mask;
1245 theme->a_hover_focused_desk->texture[0].data.mask.mask =
1246 theme->a_hover_unfocused_desk->texture[0].data.mask.mask =
1247 theme->desk_hover_mask;
1248 theme->a_focused_pressed_desk->texture[0].data.mask.mask =
1249 theme->a_unfocused_pressed_desk->texture[0].data.mask.mask =
1250 theme->desk_pressed_mask;
1251 theme->a_focused_unpressed_desk->texture[0].data.mask.mask =
1252 theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask =
1254 theme->a_toggled_hover_focused_desk->texture[0].data.mask.mask =
1255 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.mask =
1256 theme->desk_toggled_hover_mask;
1257 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.mask =
1258 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.mask =
1259 theme->desk_toggled_mask;
1260 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.mask =
1261 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.mask =
1262 theme->desk_toggled_pressed_mask;
1263 theme->a_disabled_focused_shade->texture[0].data.mask.mask =
1264 theme->a_disabled_unfocused_shade->texture[0].data.mask.mask =
1265 theme->shade_disabled_mask;
1266 theme->a_hover_focused_shade->texture[0].data.mask.mask =
1267 theme->a_hover_unfocused_shade->texture[0].data.mask.mask =
1268 theme->shade_hover_mask;
1269 theme->a_focused_pressed_shade->texture[0].data.mask.mask =
1270 theme->a_unfocused_pressed_shade->texture[0].data.mask.mask =
1271 theme->shade_pressed_mask;
1272 theme->a_focused_unpressed_shade->texture[0].data.mask.mask =
1273 theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask =
1275 theme->a_toggled_hover_focused_shade->texture[0].data.mask.mask =
1276 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.mask =
1277 theme->shade_toggled_hover_mask;
1278 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.mask =
1279 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.mask =
1280 theme->shade_toggled_mask;
1281 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.mask =
1282 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.mask =
1283 theme->shade_toggled_pressed_mask;
1284 theme->a_disabled_focused_iconify->texture[0].data.mask.mask =
1285 theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask =
1286 theme->iconify_disabled_mask;
1287 theme->a_hover_focused_iconify->texture[0].data.mask.mask =
1288 theme->a_hover_unfocused_iconify->texture[0].data.mask.mask =
1289 theme->iconify_hover_mask;
1290 theme->a_focused_pressed_iconify->texture[0].data.mask.mask =
1291 theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask =
1292 theme->iconify_pressed_mask;
1293 theme->a_focused_unpressed_iconify->texture[0].data.mask.mask =
1294 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask =
1295 theme->iconify_mask;
1296 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1297 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1298 theme->menu_bullet_mask;
1299 theme->a_disabled_focused_max->texture[0].data.mask.color =
1300 theme->a_disabled_focused_close->texture[0].data.mask.color =
1301 theme->a_disabled_focused_desk->texture[0].data.mask.color =
1302 theme->a_disabled_focused_shade->texture[0].data.mask.color =
1303 theme->a_disabled_focused_iconify->texture[0].data.mask.color =
1304 theme->titlebut_disabled_focused_color;
1305 theme->a_disabled_unfocused_max->texture[0].data.mask.color =
1306 theme->a_disabled_unfocused_close->texture[0].data.mask.color =
1307 theme->a_disabled_unfocused_desk->texture[0].data.mask.color =
1308 theme->a_disabled_unfocused_shade->texture[0].data.mask.color =
1309 theme->a_disabled_unfocused_iconify->texture[0].data.mask.color =
1310 theme->titlebut_disabled_unfocused_color;
1311 theme->a_hover_focused_max->texture[0].data.mask.color =
1312 theme->a_hover_focused_close->texture[0].data.mask.color =
1313 theme->a_hover_focused_desk->texture[0].data.mask.color =
1314 theme->a_hover_focused_shade->texture[0].data.mask.color =
1315 theme->a_hover_focused_iconify->texture[0].data.mask.color =
1316 theme->titlebut_hover_focused_color;
1317 theme->a_hover_unfocused_max->texture[0].data.mask.color =
1318 theme->a_hover_unfocused_close->texture[0].data.mask.color =
1319 theme->a_hover_unfocused_desk->texture[0].data.mask.color =
1320 theme->a_hover_unfocused_shade->texture[0].data.mask.color =
1321 theme->a_hover_unfocused_iconify->texture[0].data.mask.color =
1322 theme->titlebut_hover_unfocused_color;
1323 theme->a_toggled_hover_focused_max->texture[0].data.mask.color =
1324 theme->a_toggled_hover_focused_desk->texture[0].data.mask.color =
1325 theme->a_toggled_hover_focused_shade->texture[0].data.mask.color =
1326 theme->titlebut_toggled_hover_focused_color;
1327 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.color =
1328 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.color =
1329 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.color =
1330 theme->titlebut_toggled_hover_unfocused_color;
1331 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.color =
1332 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.color =
1333 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.color =
1334 theme->titlebut_toggled_focused_unpressed_color;
1335 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.color =
1336 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.color =
1337 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.color=
1338 theme->titlebut_toggled_unfocused_unpressed_color;
1339 theme->a_toggled_focused_pressed_max->texture[0].data.mask.color =
1340 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.color =
1341 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.color =
1342 theme->titlebut_toggled_focused_pressed_color;
1343 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.color =
1344 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.color =
1345 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.color =
1346 theme->titlebut_toggled_unfocused_pressed_color;
1347 theme->a_focused_unpressed_max->texture[0].data.mask.color =
1348 theme->a_focused_unpressed_close->texture[0].data.mask.color =
1349 theme->a_focused_unpressed_desk->texture[0].data.mask.color =
1350 theme->a_focused_unpressed_shade->texture[0].data.mask.color =
1351 theme->a_focused_unpressed_iconify->texture[0].data.mask.color =
1352 theme->titlebut_focused_unpressed_color;
1353 theme->a_focused_pressed_max->texture[0].data.mask.color =
1354 theme->a_focused_pressed_close->texture[0].data.mask.color =
1355 theme->a_focused_pressed_desk->texture[0].data.mask.color =
1356 theme->a_focused_pressed_shade->texture[0].data.mask.color =
1357 theme->a_focused_pressed_iconify->texture[0].data.mask.color =
1358 theme->titlebut_focused_pressed_color;
1359 theme->a_unfocused_unpressed_max->texture[0].data.mask.color =
1360 theme->a_unfocused_unpressed_close->texture[0].data.mask.color =
1361 theme->a_unfocused_unpressed_desk->texture[0].data.mask.color =
1362 theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
1363 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
1364 theme->titlebut_unfocused_unpressed_color;
1365 theme->a_unfocused_pressed_max->texture[0].data.mask.color =
1366 theme->a_unfocused_pressed_close->texture[0].data.mask.color =
1367 theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
1368 theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
1369 theme->a_unfocused_pressed_iconify->texture[0].data.mask.color =
1370 theme->titlebut_unfocused_pressed_color;
1371 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1373 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1374 theme->menu_selected_color;
1377 XrmDestroyDatabase(db);
1379 /* set the font heights */
1380 theme->win_font_height = RrFontHeight
1381 (theme->win_font_focused,
1382 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1383 theme->win_font_height =
1384 MAX(theme->win_font_height,
1386 (theme->win_font_focused,
1387 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1388 theme->menu_title_font_height = RrFontHeight
1389 (theme->menu_title_font,
1390 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1391 theme->menu_font_height = RrFontHeight
1393 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1395 /* calculate some last extents */
1397 gint ft, fb, fl, fr, ut, ub, ul, ur;
1399 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1400 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1401 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1402 theme->label_height += theme->label_height % 2;
1404 /* this would be nice I think, since padding.width can now be 0,
1405 but it breaks frame.c horribly and I don't feel like fixing that
1406 right now, so if anyone complains, here is how to keep text from
1407 going over the title's bevel/border with a padding.width of 0 and a
1408 bevelless/borderless label
1409 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1410 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1411 theme->title_height = theme->label_height +
1412 MAX(MAX(theme->padding * 2, ft + fb),
1413 MAX(theme->padding * 2, ut + ub));
1415 theme->title_height = theme->label_height + theme->paddingy * 2;
1417 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1418 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1419 theme->menu_title_height = theme->menu_title_label_height +
1420 theme->paddingy * 2;
1422 theme->button_size = theme->label_height - 2;
1423 theme->grip_width = 25;
1428 void RrThemeFree(RrTheme *theme)
1431 g_free(theme->name);
1433 RrColorFree(theme->menu_border_color);
1434 RrColorFree(theme->osd_border_color);
1435 RrColorFree(theme->frame_focused_border_color);
1436 RrColorFree(theme->frame_unfocused_border_color);
1437 RrColorFree(theme->title_separator_focused_color);
1438 RrColorFree(theme->title_separator_unfocused_color);
1439 RrColorFree(theme->cb_unfocused_color);
1440 RrColorFree(theme->cb_focused_color);
1441 RrColorFree(theme->title_focused_color);
1442 RrColorFree(theme->title_unfocused_color);
1443 RrColorFree(theme->titlebut_disabled_focused_color);
1444 RrColorFree(theme->titlebut_disabled_unfocused_color);
1445 RrColorFree(theme->titlebut_hover_focused_color);
1446 RrColorFree(theme->titlebut_hover_unfocused_color);
1447 RrColorFree(theme->titlebut_toggled_hover_focused_color);
1448 RrColorFree(theme->titlebut_toggled_hover_unfocused_color);
1449 RrColorFree(theme->titlebut_toggled_focused_pressed_color);
1450 RrColorFree(theme->titlebut_toggled_unfocused_pressed_color);
1451 RrColorFree(theme->titlebut_toggled_focused_unpressed_color);
1452 RrColorFree(theme->titlebut_toggled_unfocused_unpressed_color);
1453 RrColorFree(theme->titlebut_focused_pressed_color);
1454 RrColorFree(theme->titlebut_unfocused_pressed_color);
1455 RrColorFree(theme->titlebut_focused_unpressed_color);
1456 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1457 RrColorFree(theme->menu_title_color);
1458 RrColorFree(theme->menu_color);
1459 RrColorFree(theme->menu_selected_color);
1460 RrColorFree(theme->menu_disabled_color);
1461 RrColorFree(theme->menu_disabled_selected_color);
1462 RrColorFree(theme->title_focused_shadow_color);
1463 RrColorFree(theme->title_unfocused_shadow_color);
1464 RrColorFree(theme->osd_color);
1465 RrColorFree(theme->osd_shadow_color);
1466 RrColorFree(theme->menu_title_shadow_color);
1467 RrColorFree(theme->menu_text_normal_shadow_color);
1468 RrColorFree(theme->menu_text_selected_shadow_color);
1469 RrColorFree(theme->menu_text_disabled_shadow_color);
1470 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1472 g_free(theme->def_win_icon);
1474 RrPixmapMaskFree(theme->max_mask);
1475 RrPixmapMaskFree(theme->max_toggled_mask);
1476 RrPixmapMaskFree(theme->max_toggled_hover_mask);
1477 RrPixmapMaskFree(theme->max_toggled_pressed_mask);
1478 RrPixmapMaskFree(theme->max_disabled_mask);
1479 RrPixmapMaskFree(theme->max_hover_mask);
1480 RrPixmapMaskFree(theme->max_pressed_mask);
1481 RrPixmapMaskFree(theme->desk_mask);
1482 RrPixmapMaskFree(theme->desk_toggled_mask);
1483 RrPixmapMaskFree(theme->desk_toggled_hover_mask);
1484 RrPixmapMaskFree(theme->desk_toggled_pressed_mask);
1485 RrPixmapMaskFree(theme->desk_disabled_mask);
1486 RrPixmapMaskFree(theme->desk_hover_mask);
1487 RrPixmapMaskFree(theme->desk_pressed_mask);
1488 RrPixmapMaskFree(theme->shade_mask);
1489 RrPixmapMaskFree(theme->shade_toggled_mask);
1490 RrPixmapMaskFree(theme->shade_toggled_hover_mask);
1491 RrPixmapMaskFree(theme->shade_toggled_pressed_mask);
1492 RrPixmapMaskFree(theme->shade_disabled_mask);
1493 RrPixmapMaskFree(theme->shade_hover_mask);
1494 RrPixmapMaskFree(theme->shade_pressed_mask);
1495 RrPixmapMaskFree(theme->iconify_mask);
1496 RrPixmapMaskFree(theme->iconify_disabled_mask);
1497 RrPixmapMaskFree(theme->iconify_hover_mask);
1498 RrPixmapMaskFree(theme->iconify_pressed_mask);
1499 RrPixmapMaskFree(theme->close_mask);
1500 RrPixmapMaskFree(theme->close_disabled_mask);
1501 RrPixmapMaskFree(theme->close_hover_mask);
1502 RrPixmapMaskFree(theme->close_pressed_mask);
1503 RrPixmapMaskFree(theme->menu_bullet_mask);
1504 RrPixmapMaskFree(theme->down_arrow_mask);
1505 RrPixmapMaskFree(theme->up_arrow_mask);
1507 RrFontClose(theme->win_font_focused);
1508 RrFontClose(theme->win_font_unfocused);
1509 RrFontClose(theme->menu_title_font);
1510 RrFontClose(theme->menu_font);
1511 RrFontClose(theme->osd_font);
1513 RrAppearanceFree(theme->a_disabled_focused_max);
1514 RrAppearanceFree(theme->a_disabled_unfocused_max);
1515 RrAppearanceFree(theme->a_hover_focused_max);
1516 RrAppearanceFree(theme->a_hover_unfocused_max);
1517 RrAppearanceFree(theme->a_toggled_hover_focused_max);
1518 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
1519 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
1520 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
1521 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
1522 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
1523 RrAppearanceFree(theme->a_focused_unpressed_max);
1524 RrAppearanceFree(theme->a_focused_pressed_max);
1525 RrAppearanceFree(theme->a_unfocused_unpressed_max);
1526 RrAppearanceFree(theme->a_unfocused_pressed_max);
1527 RrAppearanceFree(theme->a_disabled_focused_close);
1528 RrAppearanceFree(theme->a_disabled_unfocused_close);
1529 RrAppearanceFree(theme->a_hover_focused_close);
1530 RrAppearanceFree(theme->a_hover_unfocused_close);
1531 RrAppearanceFree(theme->a_focused_unpressed_close);
1532 RrAppearanceFree(theme->a_focused_pressed_close);
1533 RrAppearanceFree(theme->a_unfocused_unpressed_close);
1534 RrAppearanceFree(theme->a_unfocused_pressed_close);
1535 RrAppearanceFree(theme->a_disabled_focused_desk);
1536 RrAppearanceFree(theme->a_disabled_unfocused_desk);
1537 RrAppearanceFree(theme->a_hover_focused_desk);
1538 RrAppearanceFree(theme->a_hover_unfocused_desk);
1539 RrAppearanceFree(theme->a_toggled_hover_focused_desk);
1540 RrAppearanceFree(theme->a_toggled_hover_unfocused_desk);
1541 RrAppearanceFree(theme->a_toggled_focused_unpressed_desk);
1542 RrAppearanceFree(theme->a_toggled_focused_pressed_desk);
1543 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_desk);
1544 RrAppearanceFree(theme->a_toggled_unfocused_pressed_desk);
1545 RrAppearanceFree(theme->a_focused_unpressed_desk);
1546 RrAppearanceFree(theme->a_focused_pressed_desk);
1547 RrAppearanceFree(theme->a_unfocused_unpressed_desk);
1548 RrAppearanceFree(theme->a_unfocused_pressed_desk);
1549 RrAppearanceFree(theme->a_disabled_focused_shade);
1550 RrAppearanceFree(theme->a_disabled_unfocused_shade);
1551 RrAppearanceFree(theme->a_hover_focused_shade);
1552 RrAppearanceFree(theme->a_hover_unfocused_shade);
1553 RrAppearanceFree(theme->a_toggled_hover_focused_shade);
1554 RrAppearanceFree(theme->a_toggled_hover_unfocused_shade);
1555 RrAppearanceFree(theme->a_toggled_focused_unpressed_shade);
1556 RrAppearanceFree(theme->a_toggled_focused_pressed_shade);
1557 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_shade);
1558 RrAppearanceFree(theme->a_toggled_unfocused_pressed_shade);
1559 RrAppearanceFree(theme->a_focused_unpressed_shade);
1560 RrAppearanceFree(theme->a_focused_pressed_shade);
1561 RrAppearanceFree(theme->a_unfocused_unpressed_shade);
1562 RrAppearanceFree(theme->a_unfocused_pressed_shade);
1563 RrAppearanceFree(theme->a_disabled_focused_iconify);
1564 RrAppearanceFree(theme->a_disabled_unfocused_iconify);
1565 RrAppearanceFree(theme->a_hover_focused_iconify);
1566 RrAppearanceFree(theme->a_hover_unfocused_iconify);
1567 RrAppearanceFree(theme->a_focused_unpressed_iconify);
1568 RrAppearanceFree(theme->a_focused_pressed_iconify);
1569 RrAppearanceFree(theme->a_unfocused_unpressed_iconify);
1570 RrAppearanceFree(theme->a_unfocused_pressed_iconify);
1571 RrAppearanceFree(theme->a_focused_grip);
1572 RrAppearanceFree(theme->a_unfocused_grip);
1573 RrAppearanceFree(theme->a_focused_title);
1574 RrAppearanceFree(theme->a_unfocused_title);
1575 RrAppearanceFree(theme->a_focused_label);
1576 RrAppearanceFree(theme->a_unfocused_label);
1577 RrAppearanceFree(theme->a_icon);
1578 RrAppearanceFree(theme->a_focused_handle);
1579 RrAppearanceFree(theme->a_unfocused_handle);
1580 RrAppearanceFree(theme->a_menu);
1581 RrAppearanceFree(theme->a_menu_title);
1582 RrAppearanceFree(theme->a_menu_text_title);
1583 RrAppearanceFree(theme->a_menu_normal);
1584 RrAppearanceFree(theme->a_menu_selected);
1585 RrAppearanceFree(theme->a_menu_disabled);
1586 RrAppearanceFree(theme->a_menu_disabled_selected);
1587 RrAppearanceFree(theme->a_menu_text_normal);
1588 RrAppearanceFree(theme->a_menu_text_selected);
1589 RrAppearanceFree(theme->a_menu_text_disabled);
1590 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1591 RrAppearanceFree(theme->a_menu_bullet_normal);
1592 RrAppearanceFree(theme->a_menu_bullet_selected);
1593 RrAppearanceFree(theme->a_clear);
1594 RrAppearanceFree(theme->a_clear_tex);
1595 RrAppearanceFree(theme->osd_hilite_bg);
1596 RrAppearanceFree(theme->osd_hilite_fg);
1597 RrAppearanceFree(theme->osd_hilite_label);
1598 RrAppearanceFree(theme->osd_unhilite_fg);
1604 static XrmDatabase loaddb(const gchar *name, gchar **path)
1607 XrmDatabase db = NULL;
1610 if (name[0] == '/') {
1611 s = g_build_filename(name, "openbox-3", "themerc", NULL);
1612 if ((db = XrmGetFileDatabase(s)))
1613 *path = g_path_get_dirname(s);
1618 p = obt_paths_new();
1620 /* XXX backwards compatibility, remove me sometime later */
1621 s = g_build_filename(g_get_home_dir(), ".themes", name,
1622 "openbox-3", "themerc", NULL);
1623 if ((db = XrmGetFileDatabase(s)))
1624 *path = g_path_get_dirname(s);
1627 for (it = obt_paths_data_dirs(p); !db && it; it = g_slist_next(it))
1629 s = g_build_filename(it->data, "themes", name,
1630 "openbox-3", "themerc", NULL);
1631 if ((db = XrmGetFileDatabase(s)))
1632 *path = g_path_get_dirname(s);
1640 s = g_build_filename(name, "themerc", NULL);
1641 if ((db = XrmGetFileDatabase(s)))
1642 *path = g_path_get_dirname(s);
1649 static gchar *create_class_name(const gchar *rname)
1651 gchar *rclass = g_strdup(rname);
1656 p = strchr(p+1, '.');
1657 if (p == NULL) break;
1659 if (*p == '\0') break;
1664 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1666 gboolean ret = FALSE;
1667 gchar *rclass = create_class_name(rname);
1668 gchar *rettype, *end;
1671 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1672 retvalue.addr != NULL) {
1673 *value = (gint)strtol(retvalue.addr, &end, 10);
1674 if (end != retvalue.addr)
1682 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1684 gboolean ret = FALSE;
1685 gchar *rclass = create_class_name(rname);
1689 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1690 retvalue.addr != NULL) {
1691 *value = retvalue.addr;
1699 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1700 const gchar *rname, RrColor **value)
1702 gboolean ret = FALSE;
1703 gchar *rclass = create_class_name(rname);
1707 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1708 retvalue.addr != NULL) {
1709 RrColor *c = RrColorParse(inst, retvalue.addr);
1720 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1721 RrTheme *theme, const gchar *maskname,
1722 RrPixmapMask **value)
1724 gboolean ret = FALSE;
1726 gint hx, hy; /* ignored */
1730 s = g_build_filename(path, maskname, NULL);
1731 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1733 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1741 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1742 RrReliefType *relief, RrBevelType *bevel,
1743 gboolean *interlaced, gboolean *border,
1744 gboolean allow_trans)
1748 /* convert to all lowercase */
1749 for (t = tex; *t != '\0'; ++t)
1750 *t = g_ascii_tolower(*t);
1752 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1753 *grad = RR_SURFACE_PARENTREL;
1755 if (strstr(tex, "gradient") != NULL) {
1756 if (strstr(tex, "crossdiagonal") != NULL)
1757 *grad = RR_SURFACE_CROSS_DIAGONAL;
1758 else if (strstr(tex, "pyramid") != NULL)
1759 *grad = RR_SURFACE_PYRAMID;
1760 else if (strstr(tex, "mirrorhorizontal") != NULL)
1761 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1762 else if (strstr(tex, "horizontal") != NULL)
1763 *grad = RR_SURFACE_HORIZONTAL;
1764 else if (strstr(tex, "splitvertical") != NULL)
1765 *grad = RR_SURFACE_SPLIT_VERTICAL;
1766 else if (strstr(tex, "vertical") != NULL)
1767 *grad = RR_SURFACE_VERTICAL;
1769 *grad = RR_SURFACE_DIAGONAL;
1771 *grad = RR_SURFACE_SOLID;
1775 if (strstr(tex, "sunken") != NULL)
1776 *relief = RR_RELIEF_SUNKEN;
1777 else if (strstr(tex, "flat") != NULL)
1778 *relief = RR_RELIEF_FLAT;
1779 else if (strstr(tex, "raised") != NULL)
1780 *relief = RR_RELIEF_RAISED;
1782 *relief = (*grad == RR_SURFACE_PARENTREL) ?
1783 RR_RELIEF_FLAT : RR_RELIEF_RAISED;
1786 if (*relief == RR_RELIEF_FLAT) {
1787 if (strstr(tex, "border") != NULL)
1790 if (strstr(tex, "bevel2") != NULL)
1791 *bevel = RR_BEVEL_2;
1793 *bevel = RR_BEVEL_1;
1796 if (strstr(tex, "interlaced") != NULL)
1799 *interlaced = FALSE;
1803 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1804 const gchar *rname, RrAppearance *value,
1805 gboolean allow_trans)
1807 gboolean ret = FALSE;
1808 gchar *rclass = create_class_name(rname);
1809 gchar *cname, *ctoname, *bcname, *icname, *hname, *sname;
1810 gchar *csplitname, *ctosplitname;
1815 cname = g_strconcat(rname, ".color", NULL);
1816 ctoname = g_strconcat(rname, ".colorTo", NULL);
1817 bcname = g_strconcat(rname, ".border.color", NULL);
1818 icname = g_strconcat(rname, ".interlace.color", NULL);
1819 hname = g_strconcat(rname, ".highlight", NULL);
1820 sname = g_strconcat(rname, ".shadow", NULL);
1821 csplitname = g_strconcat(rname, ".color.splitTo", NULL);
1822 ctosplitname = g_strconcat(rname, ".colorTo.splitTo", NULL);
1824 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1825 retvalue.addr != NULL) {
1826 parse_appearance(retvalue.addr,
1827 &value->surface.grad,
1828 &value->surface.relief,
1829 &value->surface.bevel,
1830 &value->surface.interlaced,
1831 &value->surface.border,
1833 if (!read_color(db, inst, cname, &value->surface.primary))
1834 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1835 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1836 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1837 if (value->surface.border)
1838 if (!read_color(db, inst, bcname,
1839 &value->surface.border_color))
1840 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1841 if (value->surface.interlaced)
1842 if (!read_color(db, inst, icname,
1843 &value->surface.interlace_color))
1844 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1845 if (read_int(db, hname, &i) && i >= 0)
1846 value->surface.bevel_light_adjust = i;
1847 if (read_int(db, sname, &i) && i >= 0 && i <= 256)
1848 value->surface.bevel_dark_adjust = i;
1850 if (value->surface.grad == RR_SURFACE_SPLIT_VERTICAL) {
1853 if (!read_color(db, inst, csplitname,
1854 &value->surface.split_primary))
1856 r = value->surface.primary->r;
1858 g = value->surface.primary->g;
1860 b = value->surface.primary->b;
1862 if (r > 0xFF) r = 0xFF;
1863 if (g > 0xFF) g = 0xFF;
1864 if (b > 0xFF) b = 0xFF;
1865 value->surface.split_primary = RrColorNew(inst, r, g, b);
1868 if (!read_color(db, inst, ctosplitname,
1869 &value->surface.split_secondary))
1871 r = value->surface.secondary->r;
1873 g = value->surface.secondary->g;
1875 b = value->surface.secondary->b;
1877 if (r > 0xFF) r = 0xFF;
1878 if (g > 0xFF) g = 0xFF;
1879 if (b > 0xFF) b = 0xFF;
1880 value->surface.split_secondary = RrColorNew(inst, r, g, b);
1887 g_free(ctosplitname);
1899 static int parse_inline_number(const char *p)
1907 for (; isdigit(*p); ++p)
1908 res = res * 10 + *p - '0';
1913 static void set_default_appearance(RrAppearance *a)
1915 a->surface.grad = RR_SURFACE_SOLID;
1916 a->surface.relief = RR_RELIEF_FLAT;
1917 a->surface.bevel = RR_BEVEL_1;
1918 a->surface.interlaced = FALSE;
1919 a->surface.border = FALSE;
1920 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1921 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
1924 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1925 an RrTextureRGBA. */
1926 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
1931 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
1933 for (i = 0; i < width * height; ++i) {
1934 guchar a = ((*p >> 24) & 0xff);
1935 guchar b = ((*p >> 16) & 0xff);
1936 guchar g = ((*p >> 8) & 0xff);
1937 guchar r = ((*p >> 0) & 0xff);
1939 *p = ((r << RrDefaultRedOffset) +
1940 (g << RrDefaultGreenOffset) +
1941 (b << RrDefaultBlueOffset) +
1942 (a << RrDefaultAlphaOffset));