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 "parser/parse.h"
29 #include <X11/Xresource.h>
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);
49 static RrFont *get_font(RrFont *target, RrFont **default_font,
50 const RrInstance *inst)
56 /* Only load the default font once */
58 RrFontRef(*default_font);
60 *default_font = RrFontOpenDefault(inst);
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,
72 XrmDatabase db = NULL;
73 RrJustify winjust, mtitlejust;
76 RrFont *default_font = NULL;
81 db = loaddb(name, &path);
83 g_message("Unable to load the theme '%s'", name);
85 g_message("Falling back to the default theme '%s'",
87 /* fallback to the default theme */
93 db = loaddb(DEFAULT_THEME, &path);
95 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
102 theme = g_new0(RrTheme, 1);
105 theme->name = g_strdup(name ? name : DEFAULT_THEME);
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_hilite_bg = RrAppearanceNew(inst, 0);
146 theme->osd_hilite_label = RrAppearanceNew(inst, 1);
147 theme->osd_hilite_fg = RrAppearanceNew(inst, 0);
148 theme->osd_unhilite_fg = RrAppearanceNew(inst, 0);
150 /* load the font stuff */
151 theme->win_font_focused = get_font(active_window_font,
152 &default_font, inst);
153 theme->win_font_unfocused = get_font(inactive_window_font,
154 &default_font, inst);
156 winjust = RR_JUSTIFY_LEFT;
157 if (read_string(db, "window.label.text.justify", &str)) {
158 if (!g_ascii_strcasecmp(str, "right"))
159 winjust = RR_JUSTIFY_RIGHT;
160 else if (!g_ascii_strcasecmp(str, "center"))
161 winjust = RR_JUSTIFY_CENTER;
164 theme->menu_title_font = get_font(menu_title_font, &default_font, inst);
166 mtitlejust = RR_JUSTIFY_LEFT;
167 if (read_string(db, "menu.title.text.justify", &str)) {
168 if (!g_ascii_strcasecmp(str, "right"))
169 mtitlejust = RR_JUSTIFY_RIGHT;
170 else if (!g_ascii_strcasecmp(str, "center"))
171 mtitlejust = RR_JUSTIFY_CENTER;
174 theme->menu_font = get_font(menu_item_font, &default_font, inst);
176 theme->osd_font = get_font(osd_font, &default_font, inst);
178 /* load direct dimensions */
179 if ((!read_int(db, "menu.overlap.x", &theme->menu_overlap_x) &&
180 !read_int(db, "menu.overlap", &theme->menu_overlap_x)) ||
181 theme->menu_overlap_x < -100 || theme->menu_overlap_x > 100)
182 theme->menu_overlap_x = 0;
183 if ((!read_int(db, "menu.overlap.y", &theme->menu_overlap_y) &&
184 !read_int(db, "menu.overlap", &theme->menu_overlap_y)) ||
185 theme->menu_overlap_y < -100 || theme->menu_overlap_y > 100)
186 theme->menu_overlap_y = 0;
187 if (!read_int(db, "window.handle.width", &theme->handle_height) ||
188 theme->handle_height < 0 || theme->handle_height > 100)
189 theme->handle_height = 6;
190 if (!read_int(db, "padding.width", &theme->paddingx) ||
191 theme->paddingx < 0 || theme->paddingx > 100)
193 if (!read_int(db, "padding.height", &theme->paddingy) ||
194 theme->paddingy < 0 || theme->paddingy > 100)
195 theme->paddingy = theme->paddingx;
196 if (!read_int(db, "border.width", &theme->fbwidth) ||
197 theme->fbwidth < 0 || theme->fbwidth > 100)
199 /* menu border width inherits from the frame border width */
200 if (!read_int(db, "menu.border.width", &theme->mbwidth) ||
201 theme->mbwidth < 0 || theme->mbwidth > 100)
202 theme->mbwidth = theme->fbwidth;
203 /* osd border width inherits from the frame border width */
204 if (!read_int(db, "osd.border.width", &theme->obwidth) ||
205 theme->obwidth < 0 || theme->obwidth > 100)
206 theme->obwidth = theme->fbwidth;
207 if (!read_int(db, "window.client.padding.width", &theme->cbwidthx) ||
208 theme->cbwidthx < 0 || theme->cbwidthx > 100)
209 theme->cbwidthx = theme->paddingx;
210 if (!read_int(db, "window.client.padding.height", &theme->cbwidthy) ||
211 theme->cbwidthy < 0 || theme->cbwidthy > 100)
212 theme->cbwidthy = theme->cbwidthx;
213 if (!read_int(db, "menu.separator.width", &theme->menu_sep_width) ||
214 theme->menu_sep_width < 1 || theme->menu_sep_width > 100)
215 theme->menu_sep_width = 1;
216 if (!read_int(db, "menu.separator.padding.width",
217 &theme->menu_sep_paddingx) ||
218 theme->menu_sep_paddingx < 0 || theme->menu_sep_paddingx > 100)
219 theme->menu_sep_paddingx = 6;
220 if (!read_int(db, "menu.separator.padding.height",
221 &theme->menu_sep_paddingy) ||
222 theme->menu_sep_paddingy < 0 || theme->menu_sep_paddingy > 100)
223 theme->menu_sep_paddingy = 3;
226 if (!read_color(db, inst,
227 "window.active.border.color",
228 &theme->frame_focused_border_color) &&
229 !read_color(db, inst,
231 &theme->frame_focused_border_color))
232 theme->frame_focused_border_color = RrColorNew(inst, 0, 0, 0);
233 /* title separator focused color inherits from focused border color */
234 if (!read_color(db, inst,
235 "window.active.title.separator.color",
236 &theme->title_separator_focused_color))
237 theme->title_separator_focused_color =
239 theme->frame_focused_border_color->r,
240 theme->frame_focused_border_color->g,
241 theme->frame_focused_border_color->b);
242 /* unfocused border color inherits from frame focused border color */
243 if (!read_color(db, inst,
244 "window.inactive.border.color",
245 &theme->frame_unfocused_border_color))
246 theme->frame_unfocused_border_color =
247 RrColorNew(inst, theme->frame_focused_border_color->r,
248 theme->frame_focused_border_color->g,
249 theme->frame_focused_border_color->b);
250 /* title separator unfocused color inherits from unfocused border color */
251 if (!read_color(db, inst,
252 "window.inactive.title.separator.color",
253 &theme->title_separator_unfocused_color))
254 theme->title_separator_unfocused_color =
256 theme->frame_unfocused_border_color->r,
257 theme->frame_unfocused_border_color->g,
258 theme->frame_unfocused_border_color->b);
260 /* menu border color inherits from frame focused border color */
261 if (!read_color(db, inst, "menu.border.color", &theme->menu_border_color))
262 theme->menu_border_color =
264 theme->frame_focused_border_color->r,
265 theme->frame_focused_border_color->g,
266 theme->frame_focused_border_color->b);
267 /* osd border color inherits from frame focused border color */
268 if (!read_color(db, inst, "osd.border.color", &theme->osd_border_color))
269 theme->osd_border_color =
271 theme->frame_focused_border_color->r,
272 theme->frame_focused_border_color->g,
273 theme->frame_focused_border_color->b);
274 if (!read_color(db, inst,
275 "window.active.client.color",
276 &theme->cb_focused_color))
277 theme->cb_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
278 if (!read_color(db, inst,
279 "window.inactive.client.color",
280 &theme->cb_unfocused_color))
281 theme->cb_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
282 if (!read_color(db, inst,
283 "window.active.label.text.color",
284 &theme->title_focused_color))
285 theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0);
286 if (!read_color(db, inst, "osd.label.text.color", &theme->osd_color))
287 theme->osd_color = RrColorNew(inst,
288 theme->title_focused_color->r,
289 theme->title_focused_color->g,
290 theme->title_focused_color->b);
291 if (!read_color(db, inst,
292 "window.inactive.label.text.color",
293 &theme->title_unfocused_color))
294 theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
295 if (!read_color(db, inst,
296 "window.active.button.unpressed.image.color",
297 &theme->titlebut_focused_unpressed_color))
298 theme->titlebut_focused_unpressed_color = RrColorNew(inst, 0, 0, 0);
299 if (!read_color(db, inst,
300 "window.inactive.button.unpressed.image.color",
301 &theme->titlebut_unfocused_unpressed_color))
302 theme->titlebut_unfocused_unpressed_color =
303 RrColorNew(inst, 0xff, 0xff, 0xff);
304 if (!read_color(db, inst,
305 "window.active.button.pressed.image.color",
306 &theme->titlebut_focused_pressed_color))
307 theme->titlebut_focused_pressed_color =
309 theme->titlebut_focused_unpressed_color->r,
310 theme->titlebut_focused_unpressed_color->g,
311 theme->titlebut_focused_unpressed_color->b);
312 if (!read_color(db, inst,
313 "window.inactive.button.pressed.image.color",
314 &theme->titlebut_unfocused_pressed_color))
315 theme->titlebut_unfocused_pressed_color =
317 theme->titlebut_unfocused_unpressed_color->r,
318 theme->titlebut_unfocused_unpressed_color->g,
319 theme->titlebut_unfocused_unpressed_color->b);
320 if (!read_color(db, inst,
321 "window.active.button.disabled.image.color",
322 &theme->titlebut_disabled_focused_color))
323 theme->titlebut_disabled_focused_color =
324 RrColorNew(inst, 0xff, 0xff, 0xff);
325 if (!read_color(db, inst,
326 "window.inactive.button.disabled.image.color",
327 &theme->titlebut_disabled_unfocused_color))
328 theme->titlebut_disabled_unfocused_color = RrColorNew(inst, 0, 0, 0);
329 if (!read_color(db, inst,
330 "window.active.button.hover.image.color",
331 &theme->titlebut_hover_focused_color))
332 theme->titlebut_hover_focused_color =
334 theme->titlebut_focused_unpressed_color->r,
335 theme->titlebut_focused_unpressed_color->g,
336 theme->titlebut_focused_unpressed_color->b);
337 if (!read_color(db, inst,
338 "window.inactive.button.hover.image.color",
339 &theme->titlebut_hover_unfocused_color))
340 theme->titlebut_hover_unfocused_color =
342 theme->titlebut_unfocused_unpressed_color->r,
343 theme->titlebut_unfocused_unpressed_color->g,
344 theme->titlebut_unfocused_unpressed_color->b);
345 if (!read_color(db, inst,
346 "window.active.button.toggled.unpressed.image.color",
347 &theme->titlebut_toggled_focused_unpressed_color) &&
348 !read_color(db, inst,
349 "window.active.button.toggled.image.color",
350 &theme->titlebut_toggled_focused_unpressed_color))
351 theme->titlebut_toggled_focused_unpressed_color =
353 theme->titlebut_focused_pressed_color->r,
354 theme->titlebut_focused_pressed_color->g,
355 theme->titlebut_focused_pressed_color->b);
356 if (!read_color(db, inst,
357 "window.inactive.button.toggled.unpressed.image.color",
358 &theme->titlebut_toggled_unfocused_unpressed_color) &&
359 !read_color(db, inst,
360 "window.inactive.button.toggled.image.color",
361 &theme->titlebut_toggled_unfocused_unpressed_color))
362 theme->titlebut_toggled_unfocused_unpressed_color =
364 theme->titlebut_unfocused_pressed_color->r,
365 theme->titlebut_unfocused_pressed_color->g,
366 theme->titlebut_unfocused_pressed_color->b);
367 if (!read_color(db, inst,
368 "window.active.button.toggled.hover.image.color",
369 &theme->titlebut_toggled_hover_focused_color))
370 theme->titlebut_toggled_hover_focused_color =
372 theme->titlebut_toggled_focused_unpressed_color->r,
373 theme->titlebut_toggled_focused_unpressed_color->g,
374 theme->titlebut_toggled_focused_unpressed_color->b);
375 if (!read_color(db, inst,
376 "window.inactive.button.toggled.hover.image.color",
377 &theme->titlebut_toggled_hover_unfocused_color))
378 theme->titlebut_toggled_hover_unfocused_color =
380 theme->titlebut_toggled_unfocused_unpressed_color->r,
381 theme->titlebut_toggled_unfocused_unpressed_color->g,
382 theme->titlebut_toggled_unfocused_unpressed_color->b);
383 if (!read_color(db, inst,
384 "window.active.button.toggled.pressed.image.color",
385 &theme->titlebut_toggled_focused_pressed_color))
386 theme->titlebut_toggled_focused_pressed_color =
388 theme->titlebut_focused_pressed_color->r,
389 theme->titlebut_focused_pressed_color->g,
390 theme->titlebut_focused_pressed_color->b);
391 if (!read_color(db, inst,
392 "window.inactive.button.toggled.pressed.image.color",
393 &theme->titlebut_toggled_unfocused_pressed_color))
394 theme->titlebut_toggled_unfocused_pressed_color =
396 theme->titlebut_unfocused_pressed_color->r,
397 theme->titlebut_unfocused_pressed_color->g,
398 theme->titlebut_unfocused_pressed_color->b);
399 if (!read_color(db, inst,
400 "menu.title.text.color", &theme->menu_title_color))
401 theme->menu_title_color = RrColorNew(inst, 0, 0, 0);
402 if (!read_color(db, inst,
403 "menu.items.text.color", &theme->menu_color))
404 theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff);
405 if (!read_color(db, inst,
406 "menu.items.disabled.text.color",
407 &theme->menu_disabled_color))
408 theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0);
409 if (!read_color(db, inst,
410 "menu.items.active.disabled.text.color",
411 &theme->menu_disabled_selected_color))
412 theme->menu_disabled_selected_color =
414 theme->menu_disabled_color->r,
415 theme->menu_disabled_color->g,
416 theme->menu_disabled_color->b);
417 if (!read_color(db, inst,
418 "menu.items.active.text.color",
419 &theme->menu_selected_color))
420 theme->menu_selected_color = RrColorNew(inst, 0, 0, 0);
421 if (!read_color(db, inst,
422 "menu.separator.color", &theme->menu_sep_color))
423 theme->menu_sep_color = RrColorNew(inst,
424 theme->menu_color->r,
425 theme->menu_color->g,
426 theme->menu_color->b);
428 /* load the image masks */
430 /* maximize button masks */
432 if (!read_mask(inst, path, theme, "max.xbm", &theme->max_mask)) {
433 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
434 theme->max_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
437 if (!read_mask(inst, path, theme, "max_toggled.xbm",
438 &theme->max_toggled_mask))
441 theme->max_toggled_mask = RrPixmapMaskCopy(theme->max_mask);
443 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
444 theme->max_toggled_mask = RrPixmapMaskNew(inst, 6, 6,(gchar*)data);
447 if (!read_mask(inst, path, theme, "max_pressed.xbm",
448 &theme->max_pressed_mask))
449 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
450 if (!read_mask(inst,path,theme,"max_disabled.xbm",
451 &theme->max_disabled_mask))
452 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
453 if (!read_mask(inst, path, theme, "max_hover.xbm", &theme->max_hover_mask))
454 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
455 if (!read_mask(inst, path, theme, "max_toggled_pressed.xbm",
456 &theme->max_toggled_pressed_mask))
457 theme->max_toggled_pressed_mask =
458 RrPixmapMaskCopy(theme->max_toggled_mask);
459 if (!read_mask(inst, path, theme, "max_toggled_hover.xbm",
460 &theme->max_toggled_hover_mask))
461 theme->max_toggled_hover_mask =
462 RrPixmapMaskCopy(theme->max_toggled_mask);
464 /* iconify button masks */
465 if (!read_mask(inst, path, theme, "iconify.xbm", &theme->iconify_mask)) {
466 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
467 theme->iconify_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
469 if (!read_mask(inst, path, theme, "iconify_pressed.xbm",
470 &theme->iconify_pressed_mask))
471 theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
472 if (!read_mask(inst, path, theme, "iconify_disabled.xbm",
473 &theme->iconify_disabled_mask))
474 theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
475 if (!read_mask(inst, path, theme, "iconify_hover.xbm",
476 &theme->iconify_hover_mask))
477 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
479 /* all desktops button masks */
481 if (!read_mask(inst, path, theme, "desk.xbm", &theme->desk_mask)) {
482 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
483 theme->desk_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
486 if (!read_mask(inst, path, theme, "desk_toggled.xbm",
487 &theme->desk_toggled_mask)) {
489 theme->desk_toggled_mask = RrPixmapMaskCopy(theme->desk_mask);
491 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
492 theme->desk_toggled_mask =
493 RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
496 if (!read_mask(inst, path, theme, "desk_pressed.xbm",
497 &theme->desk_pressed_mask))
498 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
499 if (!read_mask(inst, path, theme, "desk_disabled.xbm",
500 &theme->desk_disabled_mask))
501 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
502 if (!read_mask(inst, path, theme, "desk_hover.xbm",
503 &theme->desk_hover_mask))
504 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
505 if (!read_mask(inst, path, theme, "desk_toggled_pressed.xbm",
506 &theme->desk_toggled_pressed_mask))
507 theme->desk_toggled_pressed_mask =
508 RrPixmapMaskCopy(theme->desk_toggled_mask);
509 if (!read_mask(inst, path, theme, "desk_toggled_hover.xbm",
510 &theme->desk_toggled_hover_mask))
511 theme->desk_toggled_hover_mask =
512 RrPixmapMaskCopy(theme->desk_toggled_mask);
514 /* shade button masks */
515 if (!read_mask(inst, path, theme, "shade.xbm", &theme->shade_mask)) {
516 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
517 theme->shade_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
519 if (!read_mask(inst, path, theme, "shade_toggled.xbm",
520 &theme->shade_toggled_mask))
521 theme->shade_toggled_mask = RrPixmapMaskCopy(theme->shade_mask);
522 if (!read_mask(inst, path, theme, "shade_pressed.xbm",
523 &theme->shade_pressed_mask))
524 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
525 if (!read_mask(inst, path, theme, "shade_disabled.xbm",
526 &theme->shade_disabled_mask))
527 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
528 if (!read_mask(inst, path, theme, "shade_hover.xbm",
529 &theme->shade_hover_mask))
530 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
531 if (!read_mask(inst, path, theme, "shade_toggled_pressed.xbm",
532 &theme->shade_toggled_pressed_mask))
533 theme->shade_toggled_pressed_mask =
534 RrPixmapMaskCopy(theme->shade_toggled_mask);
535 if (!read_mask(inst, path, theme, "shade_toggled_hover.xbm",
536 &theme->shade_toggled_hover_mask))
537 theme->shade_toggled_hover_mask =
538 RrPixmapMaskCopy(theme->shade_toggled_mask);
540 /* close button masks */
541 if (!read_mask(inst, path, theme, "close.xbm", &theme->close_mask)) {
542 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
543 theme->close_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
545 if (!read_mask(inst, path, theme, "close_pressed.xbm",
546 &theme->close_pressed_mask))
547 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
548 if (!read_mask(inst, path, theme, "close_disabled.xbm",
549 &theme->close_disabled_mask))
550 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
551 if (!read_mask(inst, path, theme, "close_hover.xbm",
552 &theme->close_hover_mask))
553 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
555 /* submenu bullet mask */
556 if (!read_mask(inst, path, theme, "bullet.xbm", &theme->menu_bullet_mask))
558 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
559 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
562 /* setup the default window icon */
563 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
564 OB_DEFAULT_ICON_HEIGHT,
565 OB_DEFAULT_ICON_pixel_data);
566 theme->def_win_icon_w = OB_DEFAULT_ICON_WIDTH;
567 theme->def_win_icon_h = OB_DEFAULT_ICON_HEIGHT;
569 /* read the decoration textures */
570 if (!read_appearance(db, inst,
571 "window.active.title.bg", theme->a_focused_title,
573 set_default_appearance(theme->a_focused_title);
574 if (!read_appearance(db, inst,
575 "window.inactive.title.bg", theme->a_unfocused_title,
577 set_default_appearance(theme->a_unfocused_title);
578 if (!read_appearance(db, inst,
579 "window.active.label.bg", theme->a_focused_label,
581 set_default_appearance(theme->a_focused_label);
582 if (!read_appearance(db, inst,
583 "window.inactive.label.bg", theme->a_unfocused_label,
585 set_default_appearance(theme->a_unfocused_label);
586 if (!read_appearance(db, inst,
587 "window.active.handle.bg", theme->a_focused_handle,
589 set_default_appearance(theme->a_focused_handle);
590 if (!read_appearance(db, inst,
591 "window.inactive.handle.bg",theme->a_unfocused_handle,
593 set_default_appearance(theme->a_unfocused_handle);
594 if (!read_appearance(db, inst,
595 "window.active.grip.bg", theme->a_focused_grip,
597 set_default_appearance(theme->a_focused_grip);
598 if (!read_appearance(db, inst,
599 "window.inactive.grip.bg", theme->a_unfocused_grip,
601 set_default_appearance(theme->a_unfocused_grip);
602 if (!read_appearance(db, inst,
603 "menu.items.bg", theme->a_menu,
605 set_default_appearance(theme->a_menu);
606 if (!read_appearance(db, inst,
607 "menu.title.bg", theme->a_menu_title,
609 set_default_appearance(theme->a_menu_title);
610 if (!read_appearance(db, inst,
611 "menu.items.active.bg", theme->a_menu_selected,
613 set_default_appearance(theme->a_menu_selected);
614 theme->a_menu_disabled_selected =
615 RrAppearanceCopy(theme->a_menu_selected);
617 /* read appearances for non-decorations (on-screen-display) */
618 if (!read_appearance(db, inst, "osd.bg", theme->osd_hilite_bg, FALSE)) {
619 RrAppearanceFree(theme->osd_hilite_bg);
620 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
622 if (!read_appearance(db, inst, "osd.label.bg",
623 theme->osd_hilite_label, TRUE)) {
624 RrAppearanceFree(theme->osd_hilite_label);
625 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
627 /* osd_hilite_fg can't be parentrel */
628 if (!read_appearance(db, inst, "osd.hilight.bg",
629 theme->osd_hilite_fg, FALSE)) {
630 RrAppearanceFree(theme->osd_hilite_fg);
631 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
632 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_label);
634 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_title);
636 /* osd_unhilite_fg can't be parentrel either */
637 if (!read_appearance(db, inst, "osd.unhilight.bg",
638 theme->osd_unhilite_fg, FALSE)) {
639 RrAppearanceFree(theme->osd_unhilite_fg);
640 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
641 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_label);
643 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_title);
646 /* read buttons textures */
647 if (!read_appearance(db, inst,
648 "window.active.button.disabled.bg",
649 theme->a_disabled_focused_max,
651 set_default_appearance(theme->a_disabled_focused_max);
652 if (!read_appearance(db, inst,
653 "window.inactive.button.disabled.bg",
654 theme->a_disabled_unfocused_max,
656 set_default_appearance(theme->a_disabled_unfocused_max);
657 if (!read_appearance(db, inst,
658 "window.active.button.pressed.bg",
659 theme->a_focused_pressed_max,
661 set_default_appearance(theme->a_focused_pressed_max);
662 if (!read_appearance(db, inst,
663 "window.inactive.button.pressed.bg",
664 theme->a_unfocused_pressed_max,
666 set_default_appearance(theme->a_unfocused_pressed_max);
667 if (!read_appearance(db, inst,
668 "window.active.button.toggled.unpressed.bg",
669 theme->a_toggled_focused_unpressed_max,
671 !read_appearance(db, inst,
672 "window.active.button.toggled.bg",
673 theme->a_toggled_focused_unpressed_max,
676 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
677 theme->a_toggled_focused_unpressed_max =
678 RrAppearanceCopy(theme->a_focused_pressed_max);
680 if (!read_appearance(db, inst,
681 "window.inactive.button.toggled.unpressed.bg",
682 theme->a_toggled_unfocused_unpressed_max,
684 !read_appearance(db, inst,
685 "window.inactive.button.toggled.bg",
686 theme->a_toggled_unfocused_unpressed_max,
689 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
690 theme->a_toggled_unfocused_unpressed_max =
691 RrAppearanceCopy(theme->a_unfocused_pressed_max);
693 if (!read_appearance(db, inst,
694 "window.active.button.toggled.hover.bg",
695 theme->a_toggled_hover_focused_max,
698 RrAppearanceFree(theme->a_toggled_hover_focused_max);
699 theme->a_toggled_hover_focused_max =
700 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
702 if (!read_appearance(db, inst,
703 "window.inactive.button.toggled.hover.bg",
704 theme->a_toggled_hover_unfocused_max,
707 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
708 theme->a_toggled_hover_unfocused_max =
709 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
711 if (!read_appearance(db, inst,
712 "window.active.button.toggled.pressed.bg",
713 theme->a_toggled_focused_pressed_max,
716 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
717 theme->a_toggled_focused_pressed_max =
718 RrAppearanceCopy(theme->a_focused_pressed_max);
720 if (!read_appearance(db, inst,
721 "window.inactive.button.toggled.pressed.bg",
722 theme->a_toggled_unfocused_pressed_max,
725 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
726 theme->a_toggled_unfocused_pressed_max =
727 RrAppearanceCopy(theme->a_unfocused_pressed_max);
729 if (!read_appearance(db, inst,
730 "window.active.button.unpressed.bg",
731 theme->a_focused_unpressed_max,
733 set_default_appearance(theme->a_focused_unpressed_max);
734 if (!read_appearance(db, inst,
735 "window.inactive.button.unpressed.bg",
736 theme->a_unfocused_unpressed_max,
738 set_default_appearance(theme->a_unfocused_unpressed_max);
739 if (!read_appearance(db, inst,
740 "window.active.button.hover.bg",
741 theme->a_hover_focused_max,
744 RrAppearanceFree(theme->a_hover_focused_max);
745 theme->a_hover_focused_max =
746 RrAppearanceCopy(theme->a_focused_unpressed_max);
748 if (!read_appearance(db, inst,
749 "window.inactive.button.hover.bg",
750 theme->a_hover_unfocused_max,
753 RrAppearanceFree(theme->a_hover_unfocused_max);
754 theme->a_hover_unfocused_max =
755 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
758 theme->a_disabled_focused_close =
759 RrAppearanceCopy(theme->a_disabled_focused_max);
760 theme->a_disabled_unfocused_close =
761 RrAppearanceCopy(theme->a_disabled_unfocused_max);
762 theme->a_hover_focused_close =
763 RrAppearanceCopy(theme->a_hover_focused_max);
764 theme->a_hover_unfocused_close =
765 RrAppearanceCopy(theme->a_hover_unfocused_max);
766 theme->a_unfocused_unpressed_close =
767 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
768 theme->a_unfocused_pressed_close =
769 RrAppearanceCopy(theme->a_unfocused_pressed_max);
770 theme->a_focused_unpressed_close =
771 RrAppearanceCopy(theme->a_focused_unpressed_max);
772 theme->a_focused_pressed_close =
773 RrAppearanceCopy(theme->a_focused_pressed_max);
774 theme->a_disabled_focused_desk =
775 RrAppearanceCopy(theme->a_disabled_focused_max);
776 theme->a_disabled_unfocused_desk =
777 RrAppearanceCopy(theme->a_disabled_unfocused_max);
778 theme->a_hover_focused_desk =
779 RrAppearanceCopy(theme->a_hover_focused_max);
780 theme->a_hover_unfocused_desk =
781 RrAppearanceCopy(theme->a_hover_unfocused_max);
782 theme->a_toggled_hover_focused_desk =
783 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
784 theme->a_toggled_hover_unfocused_desk =
785 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
786 theme->a_toggled_focused_unpressed_desk =
787 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
788 theme->a_toggled_unfocused_unpressed_desk =
789 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
790 theme->a_toggled_focused_pressed_desk =
791 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
792 theme->a_toggled_unfocused_pressed_desk =
793 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
794 theme->a_unfocused_unpressed_desk =
795 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
796 theme->a_unfocused_pressed_desk =
797 RrAppearanceCopy(theme->a_unfocused_pressed_max);
798 theme->a_focused_unpressed_desk =
799 RrAppearanceCopy(theme->a_focused_unpressed_max);
800 theme->a_focused_pressed_desk =
801 RrAppearanceCopy(theme->a_focused_pressed_max);
802 theme->a_disabled_focused_shade =
803 RrAppearanceCopy(theme->a_disabled_focused_max);
804 theme->a_disabled_unfocused_shade =
805 RrAppearanceCopy(theme->a_disabled_unfocused_max);
806 theme->a_hover_focused_shade =
807 RrAppearanceCopy(theme->a_hover_focused_max);
808 theme->a_hover_unfocused_shade =
809 RrAppearanceCopy(theme->a_hover_unfocused_max);
810 theme->a_toggled_hover_focused_shade =
811 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
812 theme->a_toggled_hover_unfocused_shade =
813 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
814 theme->a_toggled_focused_unpressed_shade =
815 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
816 theme->a_toggled_unfocused_unpressed_shade =
817 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
818 theme->a_toggled_focused_pressed_shade =
819 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
820 theme->a_toggled_unfocused_pressed_shade =
821 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
822 theme->a_unfocused_unpressed_shade =
823 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
824 theme->a_unfocused_pressed_shade =
825 RrAppearanceCopy(theme->a_unfocused_pressed_max);
826 theme->a_focused_unpressed_shade =
827 RrAppearanceCopy(theme->a_focused_unpressed_max);
828 theme->a_focused_pressed_shade =
829 RrAppearanceCopy(theme->a_focused_pressed_max);
830 theme->a_disabled_focused_iconify =
831 RrAppearanceCopy(theme->a_disabled_focused_max);
832 theme->a_disabled_unfocused_iconify =
833 RrAppearanceCopy(theme->a_disabled_focused_max);
834 theme->a_hover_focused_iconify =
835 RrAppearanceCopy(theme->a_hover_focused_max);
836 theme->a_hover_unfocused_iconify =
837 RrAppearanceCopy(theme->a_hover_unfocused_max);
838 theme->a_unfocused_unpressed_iconify =
839 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
840 theme->a_unfocused_pressed_iconify =
841 RrAppearanceCopy(theme->a_unfocused_pressed_max);
842 theme->a_focused_unpressed_iconify =
843 RrAppearanceCopy(theme->a_focused_unpressed_max);
844 theme->a_focused_pressed_iconify =
845 RrAppearanceCopy(theme->a_focused_pressed_max);
847 theme->a_icon->surface.grad =
848 theme->a_clear->surface.grad =
849 theme->a_clear_tex->surface.grad =
850 theme->a_menu_text_title->surface.grad =
851 theme->a_menu_normal->surface.grad =
852 theme->a_menu_disabled->surface.grad =
853 theme->a_menu_text_normal->surface.grad =
854 theme->a_menu_text_selected->surface.grad =
855 theme->a_menu_text_disabled->surface.grad =
856 theme->a_menu_text_disabled_selected->surface.grad =
857 theme->a_menu_bullet_normal->surface.grad =
858 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
860 /* set up the textures */
861 theme->a_focused_label->texture[0].type = RR_TEXTURE_TEXT;
862 theme->a_focused_label->texture[0].data.text.justify = winjust;
863 theme->a_focused_label->texture[0].data.text.font=theme->win_font_focused;
864 theme->a_focused_label->texture[0].data.text.color =
865 theme->title_focused_color;
867 if (read_string(db, "window.active.label.text.font", &str)) {
871 if (strstr(str, "shadow=y")) {
872 if ((p = strstr(str, "shadowoffset=")))
873 i = parse_inline_number(p + strlen("shadowoffset="));
876 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
877 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
879 if ((p = strstr(str, "shadowtint=")))
881 i = parse_inline_number(p + strlen("shadowtint="));
882 j = (i > 0 ? 0 : 255);
885 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
886 theme->title_focused_shadow_alpha = i;
888 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
889 theme->title_focused_shadow_alpha = 50;
893 theme->a_focused_label->texture[0].data.text.shadow_color =
894 theme->title_focused_shadow_color;
895 theme->a_focused_label->texture[0].data.text.shadow_alpha =
896 theme->title_focused_shadow_alpha;
898 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
899 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
900 theme->osd_hilite_label->texture[0].data.text.font = theme->osd_font;
901 theme->osd_hilite_label->texture[0].data.text.color = theme->osd_color;
903 if (read_string(db, "osd.label.text.font", &str)) {
907 if (strstr(str, "shadow=y")) {
908 if ((p = strstr(str, "shadowoffset=")))
909 i = parse_inline_number(p + strlen("shadowoffset="));
912 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
913 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
914 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
915 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
917 if ((p = strstr(str, "shadowtint=")))
919 i = parse_inline_number(p + strlen("shadowtint="));
920 j = (i > 0 ? 0 : 255);
923 theme->osd_shadow_color = RrColorNew(inst, j, j, j);
924 theme->osd_shadow_alpha = i;
926 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
927 theme->osd_shadow_alpha = 50;
930 /* inherit the font settings from the focused label */
931 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x =
932 theme->a_focused_label->texture[0].data.text.shadow_offset_x;
933 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y =
934 theme->a_focused_label->texture[0].data.text.shadow_offset_y;
935 if (theme->title_focused_shadow_color)
936 theme->osd_shadow_color =
938 theme->title_focused_shadow_color->r,
939 theme->title_focused_shadow_color->g,
940 theme->title_focused_shadow_color->b);
942 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
943 theme->osd_shadow_alpha = theme->title_focused_shadow_alpha;
946 theme->osd_hilite_label->texture[0].data.text.shadow_color =
947 theme->osd_shadow_color;
948 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
949 theme->osd_shadow_alpha;
951 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
952 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
953 theme->a_unfocused_label->texture[0].data.text.font =
954 theme->win_font_unfocused;
955 theme->a_unfocused_label->texture[0].data.text.color =
956 theme->title_unfocused_color;
958 if (read_string(db, "window.inactive.label.text.font", &str)) {
962 if (strstr(str, "shadow=y")) {
963 if ((p = strstr(str, "shadowoffset=")))
964 i = parse_inline_number(p + strlen("shadowoffset="));
967 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
968 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
970 if ((p = strstr(str, "shadowtint=")))
972 i = parse_inline_number(p + strlen("shadowtint="));
973 j = (i > 0 ? 0 : 255);
976 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
977 theme->title_unfocused_shadow_alpha = i;
979 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
980 theme->title_unfocused_shadow_alpha = 50;
984 theme->a_unfocused_label->texture[0].data.text.shadow_color =
985 theme->title_unfocused_shadow_color;
986 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
987 theme->title_unfocused_shadow_alpha;
989 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
990 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
991 theme->a_menu_text_title->texture[0].data.text.font =
992 theme->menu_title_font;
993 theme->a_menu_text_title->texture[0].data.text.color =
994 theme->menu_title_color;
996 if (read_string(db, "menu.title.text.font", &str)) {
1000 if (strstr(str, "shadow=y")) {
1001 if ((p = strstr(str, "shadowoffset=")))
1002 i = parse_inline_number(p + strlen("shadowoffset="));
1005 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
1006 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
1008 if ((p = strstr(str, "shadowtint=")))
1010 i = parse_inline_number(p + strlen("shadowtint="));
1011 j = (i > 0 ? 0 : 255);
1014 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
1015 theme->menu_title_shadow_alpha = i;
1017 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
1018 theme->menu_title_shadow_alpha = 50;
1022 theme->a_menu_text_title->texture[0].data.text.shadow_color =
1023 theme->menu_title_shadow_color;
1024 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
1025 theme->menu_title_shadow_alpha;
1027 theme->a_menu_text_normal->texture[0].type =
1028 theme->a_menu_text_selected->texture[0].type =
1029 theme->a_menu_text_disabled->texture[0].type =
1030 theme->a_menu_text_disabled_selected->texture[0].type =
1032 theme->a_menu_text_normal->texture[0].data.text.justify =
1033 theme->a_menu_text_selected->texture[0].data.text.justify =
1034 theme->a_menu_text_disabled->texture[0].data.text.justify =
1035 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
1037 theme->a_menu_text_normal->texture[0].data.text.font =
1038 theme->a_menu_text_selected->texture[0].data.text.font =
1039 theme->a_menu_text_disabled->texture[0].data.text.font =
1040 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
1042 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
1043 theme->a_menu_text_selected->texture[0].data.text.color =
1044 theme->menu_selected_color;
1045 theme->a_menu_text_disabled->texture[0].data.text.color =
1046 theme->menu_disabled_color;
1047 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
1048 theme->menu_disabled_selected_color;
1050 if (read_string(db, "menu.items.font", &str)) {
1054 if (strstr(str, "shadow=y")) {
1055 if ((p = strstr(str, "shadowoffset=")))
1056 i = parse_inline_number(p + strlen("shadowoffset="));
1059 theme->a_menu_text_normal->
1060 texture[0].data.text.shadow_offset_x = i;
1061 theme->a_menu_text_normal->
1062 texture[0].data.text.shadow_offset_y = i;
1063 theme->a_menu_text_selected->
1064 texture[0].data.text.shadow_offset_x = i;
1065 theme->a_menu_text_selected->
1066 texture[0].data.text.shadow_offset_y = i;
1067 theme->a_menu_text_disabled->
1068 texture[0].data.text.shadow_offset_x = i;
1069 theme->a_menu_text_disabled->
1070 texture[0].data.text.shadow_offset_y = i;
1071 theme->a_menu_text_disabled_selected->
1072 texture[0].data.text.shadow_offset_x = i;
1073 theme->a_menu_text_disabled_selected->
1074 texture[0].data.text.shadow_offset_y = i;
1076 if ((p = strstr(str, "shadowtint=")))
1078 i = parse_inline_number(p + strlen("shadowtint="));
1079 j = (i > 0 ? 0 : 255);
1082 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
1083 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
1084 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
1085 theme->menu_text_normal_shadow_alpha = i;
1086 theme->menu_text_selected_shadow_alpha = i;
1087 theme->menu_text_disabled_shadow_alpha = i;
1088 theme->menu_text_disabled_selected_shadow_alpha = i;
1090 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
1091 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
1092 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
1093 theme->menu_text_normal_shadow_alpha = 50;
1094 theme->menu_text_selected_shadow_alpha = 50;
1095 theme->menu_text_disabled_selected_shadow_alpha = 50;
1099 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
1100 theme->menu_text_normal_shadow_color;
1101 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
1102 theme->menu_text_normal_shadow_alpha;
1103 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
1104 theme->menu_text_selected_shadow_color;
1105 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
1106 theme->menu_text_selected_shadow_alpha;
1107 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
1108 theme->menu_text_disabled_shadow_color;
1109 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
1110 theme->menu_text_disabled_shadow_alpha;
1111 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
1112 theme->menu_text_disabled_shadow_color;
1113 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
1114 theme->menu_text_disabled_shadow_alpha;
1116 theme->a_disabled_focused_max->texture[0].type =
1117 theme->a_disabled_unfocused_max->texture[0].type =
1118 theme->a_hover_focused_max->texture[0].type =
1119 theme->a_hover_unfocused_max->texture[0].type =
1120 theme->a_toggled_hover_focused_max->texture[0].type =
1121 theme->a_toggled_hover_unfocused_max->texture[0].type =
1122 theme->a_toggled_focused_unpressed_max->texture[0].type =
1123 theme->a_toggled_unfocused_unpressed_max->texture[0].type =
1124 theme->a_toggled_focused_pressed_max->texture[0].type =
1125 theme->a_toggled_unfocused_pressed_max->texture[0].type =
1126 theme->a_focused_unpressed_max->texture[0].type =
1127 theme->a_focused_pressed_max->texture[0].type =
1128 theme->a_unfocused_unpressed_max->texture[0].type =
1129 theme->a_unfocused_pressed_max->texture[0].type =
1130 theme->a_disabled_focused_close->texture[0].type =
1131 theme->a_disabled_unfocused_close->texture[0].type =
1132 theme->a_hover_focused_close->texture[0].type =
1133 theme->a_hover_unfocused_close->texture[0].type =
1134 theme->a_focused_unpressed_close->texture[0].type =
1135 theme->a_focused_pressed_close->texture[0].type =
1136 theme->a_unfocused_unpressed_close->texture[0].type =
1137 theme->a_unfocused_pressed_close->texture[0].type =
1138 theme->a_disabled_focused_desk->texture[0].type =
1139 theme->a_disabled_unfocused_desk->texture[0].type =
1140 theme->a_hover_focused_desk->texture[0].type =
1141 theme->a_hover_unfocused_desk->texture[0].type =
1142 theme->a_toggled_hover_focused_desk->texture[0].type =
1143 theme->a_toggled_hover_unfocused_desk->texture[0].type =
1144 theme->a_toggled_focused_unpressed_desk->texture[0].type =
1145 theme->a_toggled_unfocused_unpressed_desk->texture[0].type =
1146 theme->a_toggled_focused_pressed_desk->texture[0].type =
1147 theme->a_toggled_unfocused_pressed_desk->texture[0].type =
1148 theme->a_focused_unpressed_desk->texture[0].type =
1149 theme->a_focused_pressed_desk->texture[0].type =
1150 theme->a_unfocused_unpressed_desk->texture[0].type =
1151 theme->a_unfocused_pressed_desk->texture[0].type =
1152 theme->a_disabled_focused_shade->texture[0].type =
1153 theme->a_disabled_unfocused_shade->texture[0].type =
1154 theme->a_hover_focused_shade->texture[0].type =
1155 theme->a_hover_unfocused_shade->texture[0].type =
1156 theme->a_toggled_hover_focused_shade->texture[0].type =
1157 theme->a_toggled_hover_unfocused_shade->texture[0].type =
1158 theme->a_toggled_focused_unpressed_shade->texture[0].type =
1159 theme->a_toggled_unfocused_unpressed_shade->texture[0].type =
1160 theme->a_toggled_focused_pressed_shade->texture[0].type =
1161 theme->a_toggled_unfocused_pressed_shade->texture[0].type =
1162 theme->a_focused_unpressed_shade->texture[0].type =
1163 theme->a_focused_pressed_shade->texture[0].type =
1164 theme->a_unfocused_unpressed_shade->texture[0].type =
1165 theme->a_unfocused_pressed_shade->texture[0].type =
1166 theme->a_disabled_focused_iconify->texture[0].type =
1167 theme->a_disabled_unfocused_iconify->texture[0].type =
1168 theme->a_hover_focused_iconify->texture[0].type =
1169 theme->a_hover_unfocused_iconify->texture[0].type =
1170 theme->a_focused_unpressed_iconify->texture[0].type =
1171 theme->a_focused_pressed_iconify->texture[0].type =
1172 theme->a_unfocused_unpressed_iconify->texture[0].type =
1173 theme->a_unfocused_pressed_iconify->texture[0].type =
1174 theme->a_menu_bullet_normal->texture[0].type =
1175 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
1177 theme->a_disabled_focused_max->texture[0].data.mask.mask =
1178 theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
1179 theme->max_disabled_mask;
1180 theme->a_hover_focused_max->texture[0].data.mask.mask =
1181 theme->a_hover_unfocused_max->texture[0].data.mask.mask =
1182 theme->max_hover_mask;
1183 theme->a_focused_pressed_max->texture[0].data.mask.mask =
1184 theme->a_unfocused_pressed_max->texture[0].data.mask.mask =
1185 theme->max_pressed_mask;
1186 theme->a_focused_unpressed_max->texture[0].data.mask.mask =
1187 theme->a_unfocused_unpressed_max->texture[0].data.mask.mask =
1189 theme->a_toggled_hover_focused_max->texture[0].data.mask.mask =
1190 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.mask =
1191 theme->max_toggled_hover_mask;
1192 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.mask =
1193 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.mask =
1194 theme->max_toggled_mask;
1195 theme->a_toggled_focused_pressed_max->texture[0].data.mask.mask =
1196 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.mask =
1197 theme->max_toggled_pressed_mask;
1198 theme->a_disabled_focused_close->texture[0].data.mask.mask =
1199 theme->a_disabled_unfocused_close->texture[0].data.mask.mask =
1200 theme->close_disabled_mask;
1201 theme->a_hover_focused_close->texture[0].data.mask.mask =
1202 theme->a_hover_unfocused_close->texture[0].data.mask.mask =
1203 theme->close_hover_mask;
1204 theme->a_focused_pressed_close->texture[0].data.mask.mask =
1205 theme->a_unfocused_pressed_close->texture[0].data.mask.mask =
1206 theme->close_pressed_mask;
1207 theme->a_focused_unpressed_close->texture[0].data.mask.mask =
1208 theme->a_unfocused_unpressed_close->texture[0].data.mask.mask =
1210 theme->a_disabled_focused_desk->texture[0].data.mask.mask =
1211 theme->a_disabled_unfocused_desk->texture[0].data.mask.mask =
1212 theme->desk_disabled_mask;
1213 theme->a_hover_focused_desk->texture[0].data.mask.mask =
1214 theme->a_hover_unfocused_desk->texture[0].data.mask.mask =
1215 theme->desk_hover_mask;
1216 theme->a_focused_pressed_desk->texture[0].data.mask.mask =
1217 theme->a_unfocused_pressed_desk->texture[0].data.mask.mask =
1218 theme->desk_pressed_mask;
1219 theme->a_focused_unpressed_desk->texture[0].data.mask.mask =
1220 theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask =
1222 theme->a_toggled_hover_focused_desk->texture[0].data.mask.mask =
1223 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.mask =
1224 theme->desk_toggled_hover_mask;
1225 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.mask =
1226 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.mask =
1227 theme->desk_toggled_mask;
1228 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.mask =
1229 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.mask =
1230 theme->desk_toggled_pressed_mask;
1231 theme->a_disabled_focused_shade->texture[0].data.mask.mask =
1232 theme->a_disabled_unfocused_shade->texture[0].data.mask.mask =
1233 theme->shade_disabled_mask;
1234 theme->a_hover_focused_shade->texture[0].data.mask.mask =
1235 theme->a_hover_unfocused_shade->texture[0].data.mask.mask =
1236 theme->shade_hover_mask;
1237 theme->a_focused_pressed_shade->texture[0].data.mask.mask =
1238 theme->a_unfocused_pressed_shade->texture[0].data.mask.mask =
1239 theme->shade_pressed_mask;
1240 theme->a_focused_unpressed_shade->texture[0].data.mask.mask =
1241 theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask =
1243 theme->a_toggled_hover_focused_shade->texture[0].data.mask.mask =
1244 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.mask =
1245 theme->shade_toggled_hover_mask;
1246 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.mask =
1247 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.mask =
1248 theme->shade_toggled_mask;
1249 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.mask =
1250 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.mask =
1251 theme->shade_toggled_pressed_mask;
1252 theme->a_disabled_focused_iconify->texture[0].data.mask.mask =
1253 theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask =
1254 theme->iconify_disabled_mask;
1255 theme->a_hover_focused_iconify->texture[0].data.mask.mask =
1256 theme->a_hover_unfocused_iconify->texture[0].data.mask.mask =
1257 theme->iconify_hover_mask;
1258 theme->a_focused_pressed_iconify->texture[0].data.mask.mask =
1259 theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask =
1260 theme->iconify_pressed_mask;
1261 theme->a_focused_unpressed_iconify->texture[0].data.mask.mask =
1262 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask =
1263 theme->iconify_mask;
1264 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1265 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1266 theme->menu_bullet_mask;
1267 theme->a_disabled_focused_max->texture[0].data.mask.color =
1268 theme->a_disabled_focused_close->texture[0].data.mask.color =
1269 theme->a_disabled_focused_desk->texture[0].data.mask.color =
1270 theme->a_disabled_focused_shade->texture[0].data.mask.color =
1271 theme->a_disabled_focused_iconify->texture[0].data.mask.color =
1272 theme->titlebut_disabled_focused_color;
1273 theme->a_disabled_unfocused_max->texture[0].data.mask.color =
1274 theme->a_disabled_unfocused_close->texture[0].data.mask.color =
1275 theme->a_disabled_unfocused_desk->texture[0].data.mask.color =
1276 theme->a_disabled_unfocused_shade->texture[0].data.mask.color =
1277 theme->a_disabled_unfocused_iconify->texture[0].data.mask.color =
1278 theme->titlebut_disabled_unfocused_color;
1279 theme->a_hover_focused_max->texture[0].data.mask.color =
1280 theme->a_hover_focused_close->texture[0].data.mask.color =
1281 theme->a_hover_focused_desk->texture[0].data.mask.color =
1282 theme->a_hover_focused_shade->texture[0].data.mask.color =
1283 theme->a_hover_focused_iconify->texture[0].data.mask.color =
1284 theme->titlebut_hover_focused_color;
1285 theme->a_hover_unfocused_max->texture[0].data.mask.color =
1286 theme->a_hover_unfocused_close->texture[0].data.mask.color =
1287 theme->a_hover_unfocused_desk->texture[0].data.mask.color =
1288 theme->a_hover_unfocused_shade->texture[0].data.mask.color =
1289 theme->a_hover_unfocused_iconify->texture[0].data.mask.color =
1290 theme->titlebut_hover_unfocused_color;
1291 theme->a_toggled_hover_focused_max->texture[0].data.mask.color =
1292 theme->a_toggled_hover_focused_desk->texture[0].data.mask.color =
1293 theme->a_toggled_hover_focused_shade->texture[0].data.mask.color =
1294 theme->titlebut_toggled_hover_focused_color;
1295 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.color =
1296 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.color =
1297 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.color =
1298 theme->titlebut_toggled_hover_unfocused_color;
1299 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.color =
1300 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.color =
1301 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.color =
1302 theme->titlebut_toggled_focused_unpressed_color;
1303 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.color =
1304 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.color =
1305 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.color=
1306 theme->titlebut_toggled_unfocused_unpressed_color;
1307 theme->a_toggled_focused_pressed_max->texture[0].data.mask.color =
1308 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.color =
1309 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.color =
1310 theme->titlebut_toggled_focused_pressed_color;
1311 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.color =
1312 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.color =
1313 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.color =
1314 theme->titlebut_toggled_unfocused_pressed_color;
1315 theme->a_focused_unpressed_max->texture[0].data.mask.color =
1316 theme->a_focused_unpressed_close->texture[0].data.mask.color =
1317 theme->a_focused_unpressed_desk->texture[0].data.mask.color =
1318 theme->a_focused_unpressed_shade->texture[0].data.mask.color =
1319 theme->a_focused_unpressed_iconify->texture[0].data.mask.color =
1320 theme->titlebut_focused_unpressed_color;
1321 theme->a_focused_pressed_max->texture[0].data.mask.color =
1322 theme->a_focused_pressed_close->texture[0].data.mask.color =
1323 theme->a_focused_pressed_desk->texture[0].data.mask.color =
1324 theme->a_focused_pressed_shade->texture[0].data.mask.color =
1325 theme->a_focused_pressed_iconify->texture[0].data.mask.color =
1326 theme->titlebut_focused_pressed_color;
1327 theme->a_unfocused_unpressed_max->texture[0].data.mask.color =
1328 theme->a_unfocused_unpressed_close->texture[0].data.mask.color =
1329 theme->a_unfocused_unpressed_desk->texture[0].data.mask.color =
1330 theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
1331 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
1332 theme->titlebut_unfocused_unpressed_color;
1333 theme->a_unfocused_pressed_max->texture[0].data.mask.color =
1334 theme->a_unfocused_pressed_close->texture[0].data.mask.color =
1335 theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
1336 theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
1337 theme->a_unfocused_pressed_iconify->texture[0].data.mask.color =
1338 theme->titlebut_unfocused_pressed_color;
1339 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1341 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1342 theme->menu_selected_color;
1345 XrmDestroyDatabase(db);
1347 /* set the font heights */
1348 theme->win_font_height = RrFontHeight
1349 (theme->win_font_focused,
1350 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1351 theme->win_font_height =
1352 MAX(theme->win_font_height,
1354 (theme->win_font_focused,
1355 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1356 theme->menu_title_font_height = RrFontHeight
1357 (theme->menu_title_font,
1358 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1359 theme->menu_font_height = RrFontHeight
1361 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1363 /* calculate some last extents */
1365 gint ft, fb, fl, fr, ut, ub, ul, ur;
1367 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1368 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1369 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1370 theme->label_height += theme->label_height % 2;
1372 /* this would be nice I think, since padding.width can now be 0,
1373 but it breaks frame.c horribly and I don't feel like fixing that
1374 right now, so if anyone complains, here is how to keep text from
1375 going over the title's bevel/border with a padding.width of 0 and a
1376 bevelless/borderless label
1377 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1378 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1379 theme->title_height = theme->label_height +
1380 MAX(MAX(theme->padding * 2, ft + fb),
1381 MAX(theme->padding * 2, ut + ub));
1383 theme->title_height = theme->label_height + theme->paddingy * 2;
1385 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1386 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1387 theme->menu_title_height = theme->menu_title_label_height +
1388 theme->paddingy * 2;
1390 theme->button_size = theme->label_height - 2;
1391 theme->grip_width = 25;
1396 void RrThemeFree(RrTheme *theme)
1399 g_free(theme->name);
1401 RrColorFree(theme->menu_border_color);
1402 RrColorFree(theme->osd_border_color);
1403 RrColorFree(theme->frame_focused_border_color);
1404 RrColorFree(theme->frame_unfocused_border_color);
1405 RrColorFree(theme->title_separator_focused_color);
1406 RrColorFree(theme->title_separator_unfocused_color);
1407 RrColorFree(theme->cb_unfocused_color);
1408 RrColorFree(theme->cb_focused_color);
1409 RrColorFree(theme->title_focused_color);
1410 RrColorFree(theme->title_unfocused_color);
1411 RrColorFree(theme->titlebut_disabled_focused_color);
1412 RrColorFree(theme->titlebut_disabled_unfocused_color);
1413 RrColorFree(theme->titlebut_hover_focused_color);
1414 RrColorFree(theme->titlebut_hover_unfocused_color);
1415 RrColorFree(theme->titlebut_toggled_hover_focused_color);
1416 RrColorFree(theme->titlebut_toggled_hover_unfocused_color);
1417 RrColorFree(theme->titlebut_toggled_focused_pressed_color);
1418 RrColorFree(theme->titlebut_toggled_unfocused_pressed_color);
1419 RrColorFree(theme->titlebut_toggled_focused_unpressed_color);
1420 RrColorFree(theme->titlebut_toggled_unfocused_unpressed_color);
1421 RrColorFree(theme->titlebut_focused_pressed_color);
1422 RrColorFree(theme->titlebut_unfocused_pressed_color);
1423 RrColorFree(theme->titlebut_focused_unpressed_color);
1424 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1425 RrColorFree(theme->menu_title_color);
1426 RrColorFree(theme->menu_sep_color);
1427 RrColorFree(theme->menu_color);
1428 RrColorFree(theme->menu_selected_color);
1429 RrColorFree(theme->menu_disabled_color);
1430 RrColorFree(theme->menu_disabled_selected_color);
1431 RrColorFree(theme->title_focused_shadow_color);
1432 RrColorFree(theme->title_unfocused_shadow_color);
1433 RrColorFree(theme->osd_color);
1434 RrColorFree(theme->osd_shadow_color);
1435 RrColorFree(theme->menu_title_shadow_color);
1436 RrColorFree(theme->menu_text_normal_shadow_color);
1437 RrColorFree(theme->menu_text_selected_shadow_color);
1438 RrColorFree(theme->menu_text_disabled_shadow_color);
1439 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1441 g_free(theme->def_win_icon);
1443 RrPixmapMaskFree(theme->max_mask);
1444 RrPixmapMaskFree(theme->max_toggled_mask);
1445 RrPixmapMaskFree(theme->max_toggled_hover_mask);
1446 RrPixmapMaskFree(theme->max_toggled_pressed_mask);
1447 RrPixmapMaskFree(theme->max_disabled_mask);
1448 RrPixmapMaskFree(theme->max_hover_mask);
1449 RrPixmapMaskFree(theme->max_pressed_mask);
1450 RrPixmapMaskFree(theme->desk_mask);
1451 RrPixmapMaskFree(theme->desk_toggled_mask);
1452 RrPixmapMaskFree(theme->desk_toggled_hover_mask);
1453 RrPixmapMaskFree(theme->desk_toggled_pressed_mask);
1454 RrPixmapMaskFree(theme->desk_disabled_mask);
1455 RrPixmapMaskFree(theme->desk_hover_mask);
1456 RrPixmapMaskFree(theme->desk_pressed_mask);
1457 RrPixmapMaskFree(theme->shade_mask);
1458 RrPixmapMaskFree(theme->shade_toggled_mask);
1459 RrPixmapMaskFree(theme->shade_toggled_hover_mask);
1460 RrPixmapMaskFree(theme->shade_toggled_pressed_mask);
1461 RrPixmapMaskFree(theme->shade_disabled_mask);
1462 RrPixmapMaskFree(theme->shade_hover_mask);
1463 RrPixmapMaskFree(theme->shade_pressed_mask);
1464 RrPixmapMaskFree(theme->iconify_mask);
1465 RrPixmapMaskFree(theme->iconify_disabled_mask);
1466 RrPixmapMaskFree(theme->iconify_hover_mask);
1467 RrPixmapMaskFree(theme->iconify_pressed_mask);
1468 RrPixmapMaskFree(theme->close_mask);
1469 RrPixmapMaskFree(theme->close_disabled_mask);
1470 RrPixmapMaskFree(theme->close_hover_mask);
1471 RrPixmapMaskFree(theme->close_pressed_mask);
1472 RrPixmapMaskFree(theme->menu_bullet_mask);
1474 RrFontClose(theme->win_font_focused);
1475 RrFontClose(theme->win_font_unfocused);
1476 RrFontClose(theme->menu_title_font);
1477 RrFontClose(theme->menu_font);
1478 RrFontClose(theme->osd_font);
1480 RrAppearanceFree(theme->a_disabled_focused_max);
1481 RrAppearanceFree(theme->a_disabled_unfocused_max);
1482 RrAppearanceFree(theme->a_hover_focused_max);
1483 RrAppearanceFree(theme->a_hover_unfocused_max);
1484 RrAppearanceFree(theme->a_toggled_hover_focused_max);
1485 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
1486 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
1487 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
1488 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
1489 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
1490 RrAppearanceFree(theme->a_focused_unpressed_max);
1491 RrAppearanceFree(theme->a_focused_pressed_max);
1492 RrAppearanceFree(theme->a_unfocused_unpressed_max);
1493 RrAppearanceFree(theme->a_unfocused_pressed_max);
1494 RrAppearanceFree(theme->a_disabled_focused_close);
1495 RrAppearanceFree(theme->a_disabled_unfocused_close);
1496 RrAppearanceFree(theme->a_hover_focused_close);
1497 RrAppearanceFree(theme->a_hover_unfocused_close);
1498 RrAppearanceFree(theme->a_focused_unpressed_close);
1499 RrAppearanceFree(theme->a_focused_pressed_close);
1500 RrAppearanceFree(theme->a_unfocused_unpressed_close);
1501 RrAppearanceFree(theme->a_unfocused_pressed_close);
1502 RrAppearanceFree(theme->a_disabled_focused_desk);
1503 RrAppearanceFree(theme->a_disabled_unfocused_desk);
1504 RrAppearanceFree(theme->a_hover_focused_desk);
1505 RrAppearanceFree(theme->a_hover_unfocused_desk);
1506 RrAppearanceFree(theme->a_toggled_hover_focused_desk);
1507 RrAppearanceFree(theme->a_toggled_hover_unfocused_desk);
1508 RrAppearanceFree(theme->a_toggled_focused_unpressed_desk);
1509 RrAppearanceFree(theme->a_toggled_focused_pressed_desk);
1510 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_desk);
1511 RrAppearanceFree(theme->a_toggled_unfocused_pressed_desk);
1512 RrAppearanceFree(theme->a_focused_unpressed_desk);
1513 RrAppearanceFree(theme->a_focused_pressed_desk);
1514 RrAppearanceFree(theme->a_unfocused_unpressed_desk);
1515 RrAppearanceFree(theme->a_unfocused_pressed_desk);
1516 RrAppearanceFree(theme->a_disabled_focused_shade);
1517 RrAppearanceFree(theme->a_disabled_unfocused_shade);
1518 RrAppearanceFree(theme->a_hover_focused_shade);
1519 RrAppearanceFree(theme->a_hover_unfocused_shade);
1520 RrAppearanceFree(theme->a_toggled_hover_focused_shade);
1521 RrAppearanceFree(theme->a_toggled_hover_unfocused_shade);
1522 RrAppearanceFree(theme->a_toggled_focused_unpressed_shade);
1523 RrAppearanceFree(theme->a_toggled_focused_pressed_shade);
1524 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_shade);
1525 RrAppearanceFree(theme->a_toggled_unfocused_pressed_shade);
1526 RrAppearanceFree(theme->a_focused_unpressed_shade);
1527 RrAppearanceFree(theme->a_focused_pressed_shade);
1528 RrAppearanceFree(theme->a_unfocused_unpressed_shade);
1529 RrAppearanceFree(theme->a_unfocused_pressed_shade);
1530 RrAppearanceFree(theme->a_disabled_focused_iconify);
1531 RrAppearanceFree(theme->a_disabled_unfocused_iconify);
1532 RrAppearanceFree(theme->a_hover_focused_iconify);
1533 RrAppearanceFree(theme->a_hover_unfocused_iconify);
1534 RrAppearanceFree(theme->a_focused_unpressed_iconify);
1535 RrAppearanceFree(theme->a_focused_pressed_iconify);
1536 RrAppearanceFree(theme->a_unfocused_unpressed_iconify);
1537 RrAppearanceFree(theme->a_unfocused_pressed_iconify);
1538 RrAppearanceFree(theme->a_focused_grip);
1539 RrAppearanceFree(theme->a_unfocused_grip);
1540 RrAppearanceFree(theme->a_focused_title);
1541 RrAppearanceFree(theme->a_unfocused_title);
1542 RrAppearanceFree(theme->a_focused_label);
1543 RrAppearanceFree(theme->a_unfocused_label);
1544 RrAppearanceFree(theme->a_icon);
1545 RrAppearanceFree(theme->a_focused_handle);
1546 RrAppearanceFree(theme->a_unfocused_handle);
1547 RrAppearanceFree(theme->a_menu);
1548 RrAppearanceFree(theme->a_menu_title);
1549 RrAppearanceFree(theme->a_menu_text_title);
1550 RrAppearanceFree(theme->a_menu_normal);
1551 RrAppearanceFree(theme->a_menu_selected);
1552 RrAppearanceFree(theme->a_menu_disabled);
1553 RrAppearanceFree(theme->a_menu_disabled_selected);
1554 RrAppearanceFree(theme->a_menu_text_normal);
1555 RrAppearanceFree(theme->a_menu_text_selected);
1556 RrAppearanceFree(theme->a_menu_text_disabled);
1557 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1558 RrAppearanceFree(theme->a_menu_bullet_normal);
1559 RrAppearanceFree(theme->a_menu_bullet_selected);
1560 RrAppearanceFree(theme->a_clear);
1561 RrAppearanceFree(theme->a_clear_tex);
1562 RrAppearanceFree(theme->osd_hilite_bg);
1563 RrAppearanceFree(theme->osd_hilite_fg);
1564 RrAppearanceFree(theme->osd_hilite_label);
1565 RrAppearanceFree(theme->osd_unhilite_fg);
1571 static XrmDatabase loaddb(const gchar *name, gchar **path)
1574 XrmDatabase db = NULL;
1577 if (name[0] == '/') {
1578 s = g_build_filename(name, "openbox-3", "themerc", NULL);
1579 if ((db = XrmGetFileDatabase(s)))
1580 *path = g_path_get_dirname(s);
1583 /* XXX backwards compatibility, remove me sometime later */
1584 s = g_build_filename(g_get_home_dir(), ".themes", name,
1585 "openbox-3", "themerc", NULL);
1586 if ((db = XrmGetFileDatabase(s)))
1587 *path = g_path_get_dirname(s);
1590 for (it = parse_xdg_data_dir_paths(); !db && it;
1591 it = g_slist_next(it))
1593 s = g_build_filename(it->data, "themes", name,
1594 "openbox-3", "themerc", NULL);
1595 if ((db = XrmGetFileDatabase(s)))
1596 *path = g_path_get_dirname(s);
1602 s = g_build_filename(name, "themerc", NULL);
1603 if ((db = XrmGetFileDatabase(s)))
1604 *path = g_path_get_dirname(s);
1611 static gchar *create_class_name(const gchar *rname)
1613 gchar *rclass = g_strdup(rname);
1618 p = strchr(p+1, '.');
1619 if (p == NULL) break;
1621 if (*p == '\0') break;
1626 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1628 gboolean ret = FALSE;
1629 gchar *rclass = create_class_name(rname);
1630 gchar *rettype, *end;
1633 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1634 retvalue.addr != NULL) {
1635 *value = (gint)strtol(retvalue.addr, &end, 10);
1636 if (end != retvalue.addr)
1644 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1646 gboolean ret = FALSE;
1647 gchar *rclass = create_class_name(rname);
1651 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1652 retvalue.addr != NULL) {
1653 *value = retvalue.addr;
1661 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1662 const gchar *rname, RrColor **value)
1664 gboolean ret = FALSE;
1665 gchar *rclass = create_class_name(rname);
1669 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1670 retvalue.addr != NULL) {
1671 RrColor *c = RrColorParse(inst, retvalue.addr);
1682 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1683 RrTheme *theme, const gchar *maskname,
1684 RrPixmapMask **value)
1686 gboolean ret = FALSE;
1688 gint hx, hy; /* ignored */
1692 s = g_build_filename(path, maskname, NULL);
1693 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1695 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1703 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1704 RrReliefType *relief, RrBevelType *bevel,
1705 gboolean *interlaced, gboolean *border,
1706 gboolean allow_trans)
1710 /* convert to all lowercase */
1711 for (t = tex; *t != '\0'; ++t)
1712 *t = g_ascii_tolower(*t);
1714 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1715 *grad = RR_SURFACE_PARENTREL;
1717 if (strstr(tex, "gradient") != NULL) {
1718 if (strstr(tex, "crossdiagonal") != NULL)
1719 *grad = RR_SURFACE_CROSS_DIAGONAL;
1720 else if (strstr(tex, "pyramid") != NULL)
1721 *grad = RR_SURFACE_PYRAMID;
1722 else if (strstr(tex, "mirrorhorizontal") != NULL)
1723 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1724 else if (strstr(tex, "horizontal") != NULL)
1725 *grad = RR_SURFACE_HORIZONTAL;
1726 else if (strstr(tex, "splitvertical") != NULL)
1727 *grad = RR_SURFACE_SPLIT_VERTICAL;
1728 else if (strstr(tex, "vertical") != NULL)
1729 *grad = RR_SURFACE_VERTICAL;
1731 *grad = RR_SURFACE_DIAGONAL;
1733 *grad = RR_SURFACE_SOLID;
1737 if (strstr(tex, "sunken") != NULL)
1738 *relief = RR_RELIEF_SUNKEN;
1739 else if (strstr(tex, "flat") != NULL)
1740 *relief = RR_RELIEF_FLAT;
1741 else if (strstr(tex, "raised") != NULL)
1742 *relief = RR_RELIEF_RAISED;
1744 *relief = (*grad == RR_SURFACE_PARENTREL) ?
1745 RR_RELIEF_FLAT : RR_RELIEF_RAISED;
1748 if (*relief == RR_RELIEF_FLAT) {
1749 if (strstr(tex, "border") != NULL)
1752 if (strstr(tex, "bevel2") != NULL)
1753 *bevel = RR_BEVEL_2;
1755 *bevel = RR_BEVEL_1;
1758 if (strstr(tex, "interlaced") != NULL)
1761 *interlaced = FALSE;
1764 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1765 const gchar *rname, RrAppearance *value,
1766 gboolean allow_trans)
1768 gboolean ret = FALSE;
1769 gchar *rclass = create_class_name(rname);
1770 gchar *cname, *ctoname, *bcname, *icname, *hname, *sname;
1771 gchar *csplitname, *ctosplitname;
1776 cname = g_strconcat(rname, ".color", NULL);
1777 ctoname = g_strconcat(rname, ".colorTo", NULL);
1778 bcname = g_strconcat(rname, ".border.color", NULL);
1779 icname = g_strconcat(rname, ".interlace.color", NULL);
1780 hname = g_strconcat(rname, ".highlight", NULL);
1781 sname = g_strconcat(rname, ".shadow", NULL);
1782 csplitname = g_strconcat(rname, ".color.splitTo", NULL);
1783 ctosplitname = g_strconcat(rname, ".colorTo.splitTo", NULL);
1785 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1786 retvalue.addr != NULL) {
1787 parse_appearance(retvalue.addr,
1788 &value->surface.grad,
1789 &value->surface.relief,
1790 &value->surface.bevel,
1791 &value->surface.interlaced,
1792 &value->surface.border,
1794 if (!read_color(db, inst, cname, &value->surface.primary))
1795 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1796 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1797 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1798 if (value->surface.border)
1799 if (!read_color(db, inst, bcname,
1800 &value->surface.border_color))
1801 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1802 if (value->surface.interlaced)
1803 if (!read_color(db, inst, icname,
1804 &value->surface.interlace_color))
1805 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1806 if (read_int(db, hname, &i) && i >= 0)
1807 value->surface.bevel_light_adjust = i;
1808 if (read_int(db, sname, &i) && i >= 0 && i <= 256)
1809 value->surface.bevel_dark_adjust = i;
1811 if (value->surface.grad == RR_SURFACE_SPLIT_VERTICAL) {
1814 if (!read_color(db, inst, csplitname,
1815 &value->surface.split_primary))
1817 r = value->surface.primary->r;
1819 g = value->surface.primary->g;
1821 b = value->surface.primary->b;
1823 if (r > 0xFF) r = 0xFF;
1824 if (g > 0xFF) g = 0xFF;
1825 if (b > 0xFF) b = 0xFF;
1826 value->surface.split_primary = RrColorNew(inst, r, g, b);
1829 if (!read_color(db, inst, ctosplitname,
1830 &value->surface.split_secondary))
1832 r = value->surface.secondary->r;
1834 g = value->surface.secondary->g;
1836 b = value->surface.secondary->b;
1838 if (r > 0xFF) r = 0xFF;
1839 if (g > 0xFF) g = 0xFF;
1840 if (b > 0xFF) b = 0xFF;
1841 value->surface.split_secondary = RrColorNew(inst, r, g, b);
1848 g_free(ctosplitname);
1860 static int parse_inline_number(const char *p)
1868 for (; isdigit(*p); ++p)
1869 res = res * 10 + *p - '0';
1874 static void set_default_appearance(RrAppearance *a)
1876 a->surface.grad = RR_SURFACE_SOLID;
1877 a->surface.relief = RR_RELIEF_FLAT;
1878 a->surface.bevel = RR_BEVEL_1;
1879 a->surface.interlaced = FALSE;
1880 a->surface.border = FALSE;
1881 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1882 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
1885 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1886 an RrTextureRGBA. */
1887 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
1892 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
1894 for (i = 0; i < width * height; ++i) {
1895 guchar a = ((*p >> 24) & 0xff);
1896 guchar b = ((*p >> 16) & 0xff);
1897 guchar g = ((*p >> 8) & 0xff);
1898 guchar r = ((*p >> 0) & 0xff);
1900 *p = ((r << RrDefaultRedOffset) +
1901 (g << RrDefaultGreenOffset) +
1902 (b << RrDefaultBlueOffset) +
1903 (a << RrDefaultAlphaOffset));