8 #include <X11/Xresource.h>
13 static XrmDatabase loaddb(RrTheme *theme, char *name);
14 static gboolean read_int(XrmDatabase db, char *rname, int *value);
15 static gboolean read_string(XrmDatabase db, char *rname, char **value);
16 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
17 gchar *rname, RrColor **value);
18 static gboolean read_mask(const RrInstance *inst,
19 gchar *maskname, RrTheme *theme,
20 RrPixmapMask **value);
21 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
22 gchar *rname, RrAppearance *value,
23 gboolean allow_trans);
24 static void set_default_appearance(RrAppearance *a);
26 RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
28 XrmDatabase db = NULL;
29 RrJustify winjust, mtitlejust;
34 theme = g_new0(RrTheme, 1);
38 theme->a_disabled_focused_max = RrAppearanceNew(inst, 1);
39 theme->a_disabled_unfocused_max = RrAppearanceNew(inst, 1);
40 theme->a_hover_focused_max = RrAppearanceNew(inst, 1);
41 theme->a_hover_unfocused_max = RrAppearanceNew(inst, 1);
42 theme->a_toggled_focused_max = RrAppearanceNew(inst, 1);
43 theme->a_toggled_unfocused_max = RrAppearanceNew(inst, 1);
44 theme->a_focused_unpressed_max = RrAppearanceNew(inst, 1);
45 theme->a_focused_pressed_max = RrAppearanceNew(inst, 1);
46 theme->a_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
47 theme->a_unfocused_pressed_max = RrAppearanceNew(inst, 1);
48 theme->a_focused_grip = RrAppearanceNew(inst, 0);
49 theme->a_unfocused_grip = RrAppearanceNew(inst, 0);
50 theme->a_focused_title = RrAppearanceNew(inst, 0);
51 theme->a_unfocused_title = RrAppearanceNew(inst, 0);
52 theme->a_focused_label = RrAppearanceNew(inst, 1);
53 theme->a_unfocused_label = RrAppearanceNew(inst, 1);
54 theme->a_icon = RrAppearanceNew(inst, 1);
55 theme->a_focused_handle = RrAppearanceNew(inst, 0);
56 theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
57 theme->a_menu = RrAppearanceNew(inst, 0);
58 theme->a_menu_title = RrAppearanceNew(inst, 1);
59 theme->a_menu_item = RrAppearanceNew(inst, 0);
60 theme->a_menu_disabled = RrAppearanceNew(inst, 0);
61 theme->a_menu_hilite = RrAppearanceNew(inst, 0);
62 theme->a_menu_text_item = RrAppearanceNew(inst, 1);
63 theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
64 theme->a_menu_text_hilite = RrAppearanceNew(inst, 1);
65 theme->a_menu_bullet = RrAppearanceNew(inst, 1);
66 theme->a_clear = RrAppearanceNew(inst, 0);
67 theme->a_clear_tex = RrAppearanceNew(inst, 1);
69 theme->app_hilite_bg = RrAppearanceNew(inst, 0);
70 theme->app_unhilite_bg = RrAppearanceNew(inst, 0);
71 theme->app_hilite_label = RrAppearanceNew(inst, 1);
72 theme->app_unhilite_label = RrAppearanceNew(inst, 1);
75 db = loaddb(theme, name);
77 g_warning("Failed to load the theme '%s'\n"
78 "Falling back to the default: '%s'",
81 theme->name = g_path_get_basename(name);
84 db = loaddb(theme, DEFAULT_THEME);
86 g_warning("Failed to load the theme '%s'.", DEFAULT_THEME);
89 theme->name = g_path_get_basename(DEFAULT_THEME);
92 /* load the font stuff */
93 if (!read_string(db, "window.focus.font", &font_str))
94 font_str = "arial,sans:bold:pixelsize=10:shadow=y:shadowtint=50";
96 if (!(theme->winfont_focused = RrFontOpen(inst, font_str))) {
100 theme->winfont_height = RrFontHeight(theme->winfont_focused);
102 if (!read_string(db, "window.unfocus.font", &font_str))
103 /* font_str will already be set to the last one */;
105 if (!(theme->winfont_unfocused = RrFontOpen(inst, font_str))) {
109 theme->winfont_height = MAX(theme->winfont_height,
110 RrFontHeight(theme->winfont_unfocused));
112 winjust = RR_JUSTIFY_LEFT;
113 if (read_string(db, "window.justify", &str)) {
114 if (!g_ascii_strcasecmp(str, "right"))
115 winjust = RR_JUSTIFY_RIGHT;
116 else if (!g_ascii_strcasecmp(str, "center"))
117 winjust = RR_JUSTIFY_CENTER;
120 if (!read_string(db, "menu.title.font", &font_str))
121 font_str = "arial,sans:bold:pixelsize=12:shadow=y";
123 if (!(theme->mtitlefont = RrFontOpen(inst, font_str))) {
127 theme->mtitlefont_height = RrFontHeight(theme->mtitlefont);
129 mtitlejust = RR_JUSTIFY_LEFT;
130 if (read_string(db, "menu.title.justify", &str)) {
131 if (!g_ascii_strcasecmp(str, "right"))
132 mtitlejust = RR_JUSTIFY_RIGHT;
133 else if (!g_ascii_strcasecmp(str, "center"))
134 mtitlejust = RR_JUSTIFY_CENTER;
137 if (!read_string(db, "menu.frame.font", &font_str))
138 font_str = "arial,sans:bold:pixelsize=11:shadow=y";
140 if (!(theme->mfont = RrFontOpen(inst, font_str))) {
144 theme->mfont_height = RrFontHeight(theme->mfont);
146 /* load direct dimensions */
147 if (!read_int(db, "menuOverlap", &theme->menu_overlap) ||
148 theme->menu_overlap < 0 || theme->menu_overlap > 20)
149 theme->menu_overlap = 0;
150 if (!read_int(db, "handleWidth", &theme->handle_height) ||
151 theme->handle_height < 0 || theme->handle_height > 100)
152 theme->handle_height = 3;
153 if (!read_int(db, "bevelWidth", &theme->bevel) ||
154 theme->bevel <= 0 || theme->bevel > 100)
156 if (!read_int(db, "borderWidth", &theme->bwidth) ||
157 theme->bwidth < 0 || theme->bwidth > 100)
159 if (!read_int(db, "frameWidth", &theme->cbwidth) ||
160 theme->cbwidth < 0 || theme->cbwidth > 100)
161 theme->cbwidth = theme->bevel;
164 if (!read_color(db, inst,
165 "borderColor", &theme->b_color))
166 theme->b_color = RrColorNew(inst, 0, 0, 0);
167 if (!read_color(db, inst,
168 "window.frame.focusColor", &theme->cb_focused_color))
169 theme->cb_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
170 if (!read_color(db, inst,
171 "window.frame.unfocusColor",&theme->cb_unfocused_color))
172 theme->cb_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
173 if (!read_color(db, inst,
174 "window.label.focus.textColor",
175 &theme->title_focused_color))
176 theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0);
177 if (!read_color(db, inst,
178 "window.label.unfocus.textColor",
179 &theme->title_unfocused_color))
180 theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
181 if (!read_color(db, inst,
182 "window.button.focus.picColor",
183 &theme->titlebut_focused_unpressed_color))
184 theme->titlebut_focused_unpressed_color = RrColorNew(inst, 0, 0, 0);
185 if (!read_color(db, inst,
186 "window.button.unfocus.picColor",
187 &theme->titlebut_unfocused_unpressed_color))
188 theme->titlebut_unfocused_unpressed_color =
189 RrColorNew(inst, 0xff, 0xff, 0xff);
190 if (!read_color(db, inst,
191 "window.button.pressed.focus.picColor",
192 &theme->titlebut_focused_pressed_color))
193 theme->titlebut_focused_pressed_color =
195 theme->titlebut_focused_unpressed_color->r,
196 theme->titlebut_focused_unpressed_color->g,
197 theme->titlebut_focused_unpressed_color->b);
198 if (!read_color(db, inst,
199 "window.button.pressed.unfocus.picColor",
200 &theme->titlebut_unfocused_pressed_color))
201 theme->titlebut_unfocused_pressed_color =
203 theme->titlebut_unfocused_unpressed_color->r,
204 theme->titlebut_unfocused_unpressed_color->g,
205 theme->titlebut_unfocused_unpressed_color->b);
206 if (!read_color(db, inst,
207 "window.button.disabled.focus.picColor",
208 &theme->titlebut_disabled_focused_color))
209 theme->titlebut_disabled_focused_color =
210 RrColorNew(inst, 0xff, 0xff, 0xff);
211 if (!read_color(db, inst,
212 "window.button.disabled.unfocus.picColor",
213 &theme->titlebut_disabled_unfocused_color))
214 theme->titlebut_disabled_unfocused_color = RrColorNew(inst, 0, 0, 0);
215 if (!read_color(db, inst,
216 "window.button.hover.focus.picColor",
217 &theme->titlebut_hover_focused_color))
218 theme->titlebut_hover_focused_color =
220 theme->titlebut_focused_unpressed_color->r,
221 theme->titlebut_focused_unpressed_color->g,
222 theme->titlebut_focused_unpressed_color->b);
223 if (!read_color(db, inst,
224 "window.button.hover.unfocus.picColor",
225 &theme->titlebut_hover_unfocused_color))
226 theme->titlebut_hover_unfocused_color =
228 theme->titlebut_unfocused_unpressed_color->r,
229 theme->titlebut_unfocused_unpressed_color->g,
230 theme->titlebut_unfocused_unpressed_color->b);
231 if (!read_color(db, inst,
232 "window.button.toggled.focus.picColor",
233 &theme->titlebut_toggled_focused_color))
234 theme->titlebut_toggled_focused_color =
236 theme->titlebut_focused_pressed_color->r,
237 theme->titlebut_focused_pressed_color->g,
238 theme->titlebut_focused_pressed_color->b);
239 if (!read_color(db, inst,
240 "window.button.toggled.unfocus.picColor",
241 &theme->titlebut_toggled_unfocused_color))
242 theme->titlebut_toggled_unfocused_color =
244 theme->titlebut_unfocused_pressed_color->r,
245 theme->titlebut_unfocused_pressed_color->g,
246 theme->titlebut_unfocused_pressed_color->b);
247 if (!read_color(db, inst,
248 "menu.title.textColor", &theme->menu_title_color))
249 theme->menu_title_color = RrColorNew(inst, 0, 0, 0);
250 if (!read_color(db, inst,
251 "menu.frame.textColor", &theme->menu_color))
252 theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff);
253 if (!read_color(db, inst,
254 "menu.bullet.picColor", &theme->menu_bullet_color))
255 theme->menu_bullet_color = RrColorNew(inst, 0, 0, 0);
256 if (!read_color(db, inst,
257 "menu.frame.disableColor", &theme->menu_disabled_color))
258 theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0);
259 if (!read_color(db, inst,
260 "menu.hilite.textColor", &theme->menu_hilite_color))
261 theme->menu_hilite_color = RrColorNew(inst, 0, 0, 0);
264 if (read_mask(inst, "max.xbm", theme, &theme->max_mask)) {
265 if (!read_mask(inst, "max_pressed.xbm", theme,
266 &theme->max_pressed_mask)) {
267 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
269 if (!read_mask(inst, "max_toggled.xbm", theme,
270 &theme->max_toggled_mask)) {
271 theme->max_toggled_mask =
272 RrPixmapMaskCopy(theme->max_pressed_mask);
274 if (!read_mask(inst, "max_disabled.xbm", theme,
275 &theme->max_disabled_mask)) {
276 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
278 if (!read_mask(inst, "max_hover.xbm", theme, &theme->max_hover_mask)) {
279 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
283 guchar data[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
284 theme->max_mask = RrPixmapMaskNew(inst, 7, 7, (char*)data);
287 guchar data[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
288 theme->max_toggled_mask = RrPixmapMaskNew(inst, 7, 7, (char*)data);
290 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
291 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
292 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
295 if (read_mask(inst, "iconify.xbm", theme, &theme->iconify_mask)) {
296 if (!read_mask(inst, "iconify_pressed.xbm", theme,
297 &theme->iconify_pressed_mask)) {
298 theme->iconify_pressed_mask =
299 RrPixmapMaskCopy(theme->iconify_mask);
301 if (!read_mask(inst, "iconify_disabled.xbm", theme,
302 &theme->iconify_disabled_mask)) {
303 theme->iconify_disabled_mask =
304 RrPixmapMaskCopy(theme->iconify_mask);
306 if (!read_mask(inst, "iconify_hover.xbm", theme,
307 &theme->iconify_hover_mask)) {
308 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
312 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
313 theme->iconify_mask = RrPixmapMaskNew(inst, 7, 7, (char*)data);
315 theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
316 theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
317 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
320 if (read_mask(inst, "desk.xbm", theme, &theme->desk_mask)) {
321 if (!read_mask(inst, "desk_pressed.xbm", theme,
322 &theme->desk_pressed_mask)) {
323 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
325 if (!read_mask(inst, "desk_toggled.xbm", theme,
326 &theme->desk_toggled_mask)) {
327 theme->desk_toggled_mask =
328 RrPixmapMaskCopy(theme->desk_pressed_mask);
330 if (!read_mask(inst, "desk_disabled.xbm", theme,
331 &theme->desk_disabled_mask)) {
332 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
334 if (!read_mask(inst, "desk_hover.xbm", theme,
335 &theme->desk_hover_mask)) {
336 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
340 guchar data[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
341 theme->desk_mask = RrPixmapMaskNew(inst, 7, 7, (char*)data);
344 guchar data[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
345 theme->desk_toggled_mask = RrPixmapMaskNew(inst, 7, 7,
348 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
349 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
350 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
353 if (read_mask(inst, "shade.xbm", theme, &theme->shade_mask)) {
354 if (!read_mask(inst, "shade_pressed.xbm", theme,
355 &theme->shade_pressed_mask)) {
356 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
358 if (!read_mask(inst, "shade_toggled.xbm", theme,
359 &theme->shade_toggled_mask)) {
360 theme->shade_toggled_mask =
361 RrPixmapMaskCopy(theme->shade_pressed_mask);
363 if (!read_mask(inst, "shade_disabled.xbm", theme,
364 &theme->shade_disabled_mask)) {
365 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
367 if (!read_mask(inst, "shade_hover.xbm", theme,
368 &theme->shade_hover_mask)) {
369 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
373 guchar data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
374 theme->shade_mask = RrPixmapMaskNew(inst, 7, 7, (char*)data);
377 guchar data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
378 theme->shade_toggled_mask = RrPixmapMaskNew(inst, 7, 7,
381 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
382 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
383 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
386 if (read_mask(inst, "close.xbm", theme, &theme->close_mask)) {
387 if (!read_mask(inst, "close_pressed.xbm", theme,
388 &theme->close_pressed_mask)) {
389 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
391 if (!read_mask(inst, "close_disabled.xbm", theme,
392 &theme->close_disabled_mask)) {
393 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
395 if (!read_mask(inst, "close_hover.xbm", theme,
396 &theme->close_hover_mask)) {
397 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
401 guchar data[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
402 theme->close_mask = RrPixmapMaskNew(inst, 7, 7, (char*)data);
404 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
405 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
406 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
409 if (!read_mask(inst, "bullet.xbm", theme, &theme->menu_bullet_mask)) {
410 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
411 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (char*)data);
414 /* read the decoration textures */
415 if (!read_appearance(db, inst,
416 "window.title.focus", theme->a_focused_title,
418 set_default_appearance(theme->a_focused_title);
419 if (!read_appearance(db, inst,
420 "window.title.unfocus", theme->a_unfocused_title,
422 set_default_appearance(theme->a_unfocused_title);
423 if (!read_appearance(db, inst,
424 "window.label.focus", theme->a_focused_label,
426 set_default_appearance(theme->a_focused_label);
427 if (!read_appearance(db, inst,
428 "window.label.unfocus", theme->a_unfocused_label,
430 set_default_appearance(theme->a_unfocused_label);
431 if (!read_appearance(db, inst,
432 "window.handle.focus", theme->a_focused_handle,
434 set_default_appearance(theme->a_focused_handle);
435 if (!read_appearance(db, inst,
436 "window.handle.unfocus",theme->a_unfocused_handle,
438 set_default_appearance(theme->a_unfocused_handle);
439 if (!read_appearance(db, inst,
440 "window.grip.focus", theme->a_focused_grip,
442 set_default_appearance(theme->a_focused_grip);
443 if (!read_appearance(db, inst,
444 "window.grip.unfocus", theme->a_unfocused_grip,
446 set_default_appearance(theme->a_unfocused_grip);
447 if (!read_appearance(db, inst,
448 "menu.frame", theme->a_menu,
450 set_default_appearance(theme->a_menu);
451 if (!read_appearance(db, inst,
452 "menu.title", theme->a_menu_title,
454 set_default_appearance(theme->a_menu_title);
455 if (!read_appearance(db, inst,
456 "menu.hilite", theme->a_menu_hilite,
458 set_default_appearance(theme->a_menu_hilite);
460 /* read the appearances for rendering non-decorations */
461 if (!read_appearance(db, inst,
462 "window.title.focus", theme->app_hilite_bg,
464 set_default_appearance(theme->app_hilite_bg);
465 if (!read_appearance(db, inst,
466 "window.label.focus", theme->app_hilite_label,
468 set_default_appearance(theme->app_hilite_label);
469 if (!read_appearance(db, inst,
470 "window.title.unfocus", theme->app_unhilite_bg,
472 set_default_appearance(theme->app_unhilite_bg);
473 if (!read_appearance(db, inst,
474 "window.label.unfocus", theme->app_unhilite_label,
476 set_default_appearance(theme->app_unhilite_label);
478 /* read buttons textures */
479 if (!read_appearance(db, inst,
480 "window.button.disabled.focus",
481 theme->a_disabled_focused_max,
483 set_default_appearance(theme->a_disabled_focused_max);
484 if (!read_appearance(db, inst,
485 "window.button.disabled.unfocus",
486 theme->a_disabled_unfocused_max,
488 set_default_appearance(theme->a_disabled_unfocused_max);
489 if (!read_appearance(db, inst,
490 "window.button.pressed.focus",
491 theme->a_focused_pressed_max,
493 set_default_appearance(theme->a_focused_pressed_max);
494 if (!read_appearance(db, inst,
495 "window.button.pressed.unfocus",
496 theme->a_unfocused_pressed_max,
498 set_default_appearance(theme->a_unfocused_pressed_max);
499 if (!read_appearance(db, inst,
500 "window.button.toggled.focus",
501 theme->a_toggled_focused_max,
504 RrAppearanceFree(theme->a_toggled_focused_max);
505 theme->a_toggled_focused_max =
506 RrAppearanceCopy(theme->a_focused_pressed_max);
508 if (!read_appearance(db, inst,
509 "window.button.toggled.unfocus",
510 theme->a_toggled_unfocused_max,
513 RrAppearanceFree(theme->a_toggled_unfocused_max);
514 theme->a_toggled_unfocused_max =
515 RrAppearanceCopy(theme->a_unfocused_pressed_max);
517 if (!read_appearance(db, inst,
518 "window.button.focus",
519 theme->a_focused_unpressed_max,
521 set_default_appearance(theme->a_focused_unpressed_max);
522 if (!read_appearance(db, inst,
523 "window.button.unfocus",
524 theme->a_unfocused_unpressed_max,
526 set_default_appearance(theme->a_unfocused_unpressed_max);
527 if (!read_appearance(db, inst,
528 "window.button.hover.focus",
529 theme->a_hover_focused_max,
532 RrAppearanceFree(theme->a_hover_focused_max);
533 theme->a_hover_focused_max =
534 RrAppearanceCopy(theme->a_focused_unpressed_max);
536 if (!read_appearance(db, inst,
537 "window.button.hover.unfocus",
538 theme->a_hover_unfocused_max,
541 RrAppearanceFree(theme->a_hover_unfocused_max);
542 theme->a_hover_unfocused_max =
543 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
546 theme->a_disabled_focused_close =
547 RrAppearanceCopy(theme->a_disabled_focused_max);
548 theme->a_disabled_unfocused_close =
549 RrAppearanceCopy(theme->a_disabled_unfocused_max);
550 theme->a_hover_focused_close =
551 RrAppearanceCopy(theme->a_hover_focused_max);
552 theme->a_hover_unfocused_close =
553 RrAppearanceCopy(theme->a_hover_unfocused_max);
554 theme->a_unfocused_unpressed_close =
555 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
556 theme->a_unfocused_pressed_close =
557 RrAppearanceCopy(theme->a_unfocused_pressed_max);
558 theme->a_focused_unpressed_close =
559 RrAppearanceCopy(theme->a_focused_unpressed_max);
560 theme->a_focused_pressed_close =
561 RrAppearanceCopy(theme->a_focused_pressed_max);
562 theme->a_disabled_focused_desk =
563 RrAppearanceCopy(theme->a_disabled_focused_max);
564 theme->a_disabled_unfocused_desk =
565 RrAppearanceCopy(theme->a_disabled_unfocused_max);
566 theme->a_hover_focused_desk =
567 RrAppearanceCopy(theme->a_hover_focused_max);
568 theme->a_hover_unfocused_desk =
569 RrAppearanceCopy(theme->a_hover_unfocused_max);
570 theme->a_toggled_focused_desk =
571 RrAppearanceCopy(theme->a_toggled_focused_max);
572 theme->a_toggled_unfocused_desk =
573 RrAppearanceCopy(theme->a_toggled_unfocused_max);
574 theme->a_unfocused_unpressed_desk =
575 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
576 theme->a_unfocused_pressed_desk =
577 RrAppearanceCopy(theme->a_unfocused_pressed_max);
578 theme->a_focused_unpressed_desk =
579 RrAppearanceCopy(theme->a_focused_unpressed_max);
580 theme->a_focused_pressed_desk =
581 RrAppearanceCopy(theme->a_focused_pressed_max);
582 theme->a_disabled_focused_shade =
583 RrAppearanceCopy(theme->a_disabled_focused_max);
584 theme->a_disabled_unfocused_shade =
585 RrAppearanceCopy(theme->a_disabled_unfocused_max);
586 theme->a_hover_focused_shade =
587 RrAppearanceCopy(theme->a_hover_focused_max);
588 theme->a_hover_unfocused_shade =
589 RrAppearanceCopy(theme->a_hover_unfocused_max);
590 theme->a_toggled_focused_shade =
591 RrAppearanceCopy(theme->a_toggled_focused_max);
592 theme->a_toggled_unfocused_shade =
593 RrAppearanceCopy(theme->a_toggled_unfocused_max);
594 theme->a_unfocused_unpressed_shade =
595 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
596 theme->a_unfocused_pressed_shade =
597 RrAppearanceCopy(theme->a_unfocused_pressed_max);
598 theme->a_focused_unpressed_shade =
599 RrAppearanceCopy(theme->a_focused_unpressed_max);
600 theme->a_focused_pressed_shade =
601 RrAppearanceCopy(theme->a_focused_pressed_max);
602 theme->a_disabled_focused_iconify =
603 RrAppearanceCopy(theme->a_disabled_focused_max);
604 theme->a_disabled_unfocused_iconify =
605 RrAppearanceCopy(theme->a_disabled_focused_max);
606 theme->a_hover_focused_iconify =
607 RrAppearanceCopy(theme->a_hover_focused_max);
608 theme->a_hover_unfocused_iconify =
609 RrAppearanceCopy(theme->a_hover_unfocused_max);
610 theme->a_unfocused_unpressed_iconify =
611 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
612 theme->a_unfocused_pressed_iconify =
613 RrAppearanceCopy(theme->a_unfocused_pressed_max);
614 theme->a_focused_unpressed_iconify =
615 RrAppearanceCopy(theme->a_focused_unpressed_max);
616 theme->a_focused_pressed_iconify =
617 RrAppearanceCopy(theme->a_focused_pressed_max);
619 theme->a_icon->surface.grad =
620 theme->a_clear->surface.grad =
621 theme->a_clear_tex->surface.grad =
622 theme->a_menu_item->surface.grad =
623 theme->a_menu_disabled->surface.grad =
624 theme->a_menu_text_item->surface.grad =
625 theme->a_menu_text_disabled->surface.grad =
626 theme->a_menu_text_hilite->surface.grad =
627 theme->a_menu_bullet->surface.grad = RR_SURFACE_PARENTREL;
629 /* set up the textures */
630 theme->a_focused_label->texture[0].type =
631 theme->app_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
632 theme->a_focused_label->texture[0].data.text.justify = winjust;
633 theme->app_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
634 theme->a_focused_label->texture[0].data.text.font =
635 theme->app_hilite_label->texture[0].data.text.font =
636 theme->winfont_focused;
637 theme->a_focused_label->texture[0].data.text.color =
638 theme->app_hilite_label->texture[0].data.text.color =
639 theme->title_focused_color;
641 theme->a_unfocused_label->texture[0].type =
642 theme->app_unhilite_label->texture[0].type = RR_TEXTURE_TEXT;
643 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
644 theme->app_unhilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
645 theme->a_unfocused_label->texture[0].data.text.font =
646 theme->app_unhilite_label->texture[0].data.text.font =
647 theme->winfont_unfocused;
648 theme->a_unfocused_label->texture[0].data.text.color =
649 theme->app_unhilite_label->texture[0].data.text.color =
650 theme->title_unfocused_color;
652 theme->a_menu_title->texture[0].type = RR_TEXTURE_TEXT;
653 theme->a_menu_title->texture[0].data.text.justify = mtitlejust;
654 theme->a_menu_title->texture[0].data.text.font = theme->mtitlefont;
655 theme->a_menu_title->texture[0].data.text.color = theme->menu_title_color;
657 theme->a_menu_text_item->texture[0].type =
658 theme->a_menu_text_disabled->texture[0].type =
659 theme->a_menu_text_hilite->texture[0].type = RR_TEXTURE_TEXT;
660 theme->a_menu_text_item->texture[0].data.text.justify =
661 theme->a_menu_text_disabled->texture[0].data.text.justify =
662 theme->a_menu_text_hilite->texture[0].data.text.justify =
664 theme->a_menu_text_item->texture[0].data.text.font =
665 theme->a_menu_text_disabled->texture[0].data.text.font =
666 theme->a_menu_text_hilite->texture[0].data.text.font = theme->mfont;
667 theme->a_menu_text_item->texture[0].data.text.color = theme->menu_color;
668 theme->a_menu_text_disabled->texture[0].data.text.color =
669 theme->menu_disabled_color;
670 theme->a_menu_text_hilite->texture[0].data.text.color =
671 theme->menu_hilite_color;
672 theme->a_menu_bullet->texture[0].data.mask.color =
673 theme->menu_bullet_color;
675 theme->a_disabled_focused_max->texture[0].type =
676 theme->a_disabled_unfocused_max->texture[0].type =
677 theme->a_hover_focused_max->texture[0].type =
678 theme->a_hover_unfocused_max->texture[0].type =
679 theme->a_toggled_focused_max->texture[0].type =
680 theme->a_toggled_unfocused_max->texture[0].type =
681 theme->a_focused_unpressed_max->texture[0].type =
682 theme->a_focused_pressed_max->texture[0].type =
683 theme->a_unfocused_unpressed_max->texture[0].type =
684 theme->a_unfocused_pressed_max->texture[0].type =
685 theme->a_disabled_focused_close->texture[0].type =
686 theme->a_disabled_unfocused_close->texture[0].type =
687 theme->a_hover_focused_close->texture[0].type =
688 theme->a_hover_unfocused_close->texture[0].type =
689 theme->a_focused_unpressed_close->texture[0].type =
690 theme->a_focused_pressed_close->texture[0].type =
691 theme->a_unfocused_unpressed_close->texture[0].type =
692 theme->a_unfocused_pressed_close->texture[0].type =
693 theme->a_disabled_focused_desk->texture[0].type =
694 theme->a_disabled_unfocused_desk->texture[0].type =
695 theme->a_hover_focused_desk->texture[0].type =
696 theme->a_hover_unfocused_desk->texture[0].type =
697 theme->a_toggled_focused_desk->texture[0].type =
698 theme->a_toggled_unfocused_desk->texture[0].type =
699 theme->a_focused_unpressed_desk->texture[0].type =
700 theme->a_focused_pressed_desk->texture[0].type =
701 theme->a_unfocused_unpressed_desk->texture[0].type =
702 theme->a_unfocused_pressed_desk->texture[0].type =
703 theme->a_disabled_focused_shade->texture[0].type =
704 theme->a_disabled_unfocused_shade->texture[0].type =
705 theme->a_hover_focused_shade->texture[0].type =
706 theme->a_hover_unfocused_shade->texture[0].type =
707 theme->a_toggled_focused_shade->texture[0].type =
708 theme->a_toggled_unfocused_shade->texture[0].type =
709 theme->a_focused_unpressed_shade->texture[0].type =
710 theme->a_focused_pressed_shade->texture[0].type =
711 theme->a_unfocused_unpressed_shade->texture[0].type =
712 theme->a_unfocused_pressed_shade->texture[0].type =
713 theme->a_disabled_focused_iconify->texture[0].type =
714 theme->a_disabled_unfocused_iconify->texture[0].type =
715 theme->a_hover_focused_iconify->texture[0].type =
716 theme->a_hover_unfocused_iconify->texture[0].type =
717 theme->a_focused_unpressed_iconify->texture[0].type =
718 theme->a_focused_pressed_iconify->texture[0].type =
719 theme->a_unfocused_unpressed_iconify->texture[0].type =
720 theme->a_unfocused_pressed_iconify->texture[0].type =
721 theme->a_menu_bullet->texture[0].type = RR_TEXTURE_MASK;
723 theme->a_disabled_focused_max->texture[0].data.mask.mask =
724 theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
725 theme->max_disabled_mask;
726 theme->a_hover_focused_max->texture[0].data.mask.mask =
727 theme->a_hover_unfocused_max->texture[0].data.mask.mask =
728 theme->max_hover_mask;
729 theme->a_focused_pressed_max->texture[0].data.mask.mask =
730 theme->a_unfocused_pressed_max->texture[0].data.mask.mask =
731 theme->max_pressed_mask;
732 theme->a_focused_unpressed_max->texture[0].data.mask.mask =
733 theme->a_unfocused_unpressed_max->texture[0].data.mask.mask =
735 theme->a_toggled_focused_max->texture[0].data.mask.mask =
736 theme->a_toggled_unfocused_max->texture[0].data.mask.mask =
737 theme->max_toggled_mask;
738 theme->a_disabled_focused_close->texture[0].data.mask.mask =
739 theme->a_disabled_unfocused_close->texture[0].data.mask.mask =
740 theme->close_disabled_mask;
741 theme->a_hover_focused_close->texture[0].data.mask.mask =
742 theme->a_hover_unfocused_close->texture[0].data.mask.mask =
743 theme->close_hover_mask;
744 theme->a_focused_pressed_close->texture[0].data.mask.mask =
745 theme->a_unfocused_pressed_close->texture[0].data.mask.mask =
746 theme->close_pressed_mask;
747 theme->a_focused_unpressed_close->texture[0].data.mask.mask =
748 theme->a_unfocused_unpressed_close->texture[0].data.mask.mask =
750 theme->a_disabled_focused_desk->texture[0].data.mask.mask =
751 theme->a_disabled_unfocused_desk->texture[0].data.mask.mask =
752 theme->desk_disabled_mask;
753 theme->a_hover_focused_desk->texture[0].data.mask.mask =
754 theme->a_hover_unfocused_desk->texture[0].data.mask.mask =
755 theme->desk_hover_mask;
756 theme->a_focused_pressed_desk->texture[0].data.mask.mask =
757 theme->a_unfocused_pressed_desk->texture[0].data.mask.mask =
758 theme->desk_pressed_mask;
759 theme->a_focused_unpressed_desk->texture[0].data.mask.mask =
760 theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask =
762 theme->a_toggled_focused_desk->texture[0].data.mask.mask =
763 theme->a_toggled_unfocused_desk->texture[0].data.mask.mask =
764 theme->desk_toggled_mask;
765 theme->a_disabled_focused_shade->texture[0].data.mask.mask =
766 theme->a_disabled_unfocused_shade->texture[0].data.mask.mask =
767 theme->shade_disabled_mask;
768 theme->a_hover_focused_shade->texture[0].data.mask.mask =
769 theme->a_hover_unfocused_shade->texture[0].data.mask.mask =
770 theme->shade_hover_mask;
771 theme->a_focused_pressed_shade->texture[0].data.mask.mask =
772 theme->a_unfocused_pressed_shade->texture[0].data.mask.mask =
773 theme->shade_pressed_mask;
774 theme->a_focused_unpressed_shade->texture[0].data.mask.mask =
775 theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask =
777 theme->a_toggled_focused_shade->texture[0].data.mask.mask =
778 theme->a_toggled_unfocused_shade->texture[0].data.mask.mask =
779 theme->shade_toggled_mask;
780 theme->a_disabled_focused_iconify->texture[0].data.mask.mask =
781 theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask =
782 theme->iconify_disabled_mask;
783 theme->a_hover_focused_iconify->texture[0].data.mask.mask =
784 theme->a_hover_unfocused_iconify->texture[0].data.mask.mask =
785 theme->iconify_hover_mask;
786 theme->a_focused_pressed_iconify->texture[0].data.mask.mask =
787 theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask =
788 theme->iconify_pressed_mask;
789 theme->a_focused_unpressed_iconify->texture[0].data.mask.mask =
790 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask =
792 theme->a_menu_bullet->texture[0].data.mask.mask =
793 theme->menu_bullet_mask;
794 theme->a_disabled_focused_max->texture[0].data.mask.color =
795 theme->a_disabled_focused_close->texture[0].data.mask.color =
796 theme->a_disabled_focused_desk->texture[0].data.mask.color =
797 theme->a_disabled_focused_shade->texture[0].data.mask.color =
798 theme->a_disabled_focused_iconify->texture[0].data.mask.color =
799 theme->titlebut_disabled_focused_color;
800 theme->a_disabled_unfocused_max->texture[0].data.mask.color =
801 theme->a_disabled_unfocused_close->texture[0].data.mask.color =
802 theme->a_disabled_unfocused_desk->texture[0].data.mask.color =
803 theme->a_disabled_unfocused_shade->texture[0].data.mask.color =
804 theme->a_disabled_unfocused_iconify->texture[0].data.mask.color =
805 theme->titlebut_disabled_unfocused_color;
806 theme->a_hover_focused_max->texture[0].data.mask.color =
807 theme->a_hover_focused_close->texture[0].data.mask.color =
808 theme->a_hover_focused_desk->texture[0].data.mask.color =
809 theme->a_hover_focused_shade->texture[0].data.mask.color =
810 theme->a_hover_focused_iconify->texture[0].data.mask.color =
811 theme->titlebut_hover_focused_color;
812 theme->a_hover_unfocused_max->texture[0].data.mask.color =
813 theme->a_hover_unfocused_close->texture[0].data.mask.color =
814 theme->a_hover_unfocused_desk->texture[0].data.mask.color =
815 theme->a_hover_unfocused_shade->texture[0].data.mask.color =
816 theme->a_hover_unfocused_iconify->texture[0].data.mask.color =
817 theme->titlebut_hover_unfocused_color;
818 theme->a_toggled_focused_max->texture[0].data.mask.color =
819 theme->a_toggled_focused_desk->texture[0].data.mask.color =
820 theme->a_toggled_focused_shade->texture[0].data.mask.color =
821 theme->titlebut_toggled_focused_color;
822 theme->a_toggled_unfocused_max->texture[0].data.mask.color =
823 theme->a_toggled_unfocused_desk->texture[0].data.mask.color =
824 theme->a_toggled_unfocused_shade->texture[0].data.mask.color =
825 theme->titlebut_toggled_unfocused_color;
826 theme->a_focused_unpressed_max->texture[0].data.mask.color =
827 theme->a_focused_unpressed_close->texture[0].data.mask.color =
828 theme->a_focused_unpressed_desk->texture[0].data.mask.color =
829 theme->a_focused_unpressed_shade->texture[0].data.mask.color =
830 theme->a_focused_unpressed_iconify->texture[0].data.mask.color =
831 theme->titlebut_focused_unpressed_color;
832 theme->a_focused_pressed_max->texture[0].data.mask.color =
833 theme->a_focused_pressed_close->texture[0].data.mask.color =
834 theme->a_focused_pressed_desk->texture[0].data.mask.color =
835 theme->a_focused_pressed_shade->texture[0].data.mask.color =
836 theme->a_focused_pressed_iconify->texture[0].data.mask.color =
837 theme->titlebut_focused_pressed_color;
838 theme->a_unfocused_unpressed_max->texture[0].data.mask.color =
839 theme->a_unfocused_unpressed_close->texture[0].data.mask.color =
840 theme->a_unfocused_unpressed_desk->texture[0].data.mask.color =
841 theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
842 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
843 theme->titlebut_unfocused_unpressed_color;
844 theme->a_unfocused_pressed_max->texture[0].data.mask.color =
845 theme->a_unfocused_pressed_close->texture[0].data.mask.color =
846 theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
847 theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
848 theme->a_unfocused_pressed_iconify->texture[0].data.mask.color =
849 theme->titlebut_unfocused_pressed_color;
850 theme->a_menu_bullet->texture[0].data.mask.color =
851 theme->menu_bullet_color;
853 XrmDestroyDatabase(db);
855 theme->label_height = theme->winfont_height;
856 theme->title_height = theme->label_height + theme->bevel * 2;
857 theme->button_size = theme->label_height - 2;
858 theme->grip_width = theme->title_height * 1.5;
863 void RrThemeFree(RrTheme *theme)
868 RrColorFree(theme->b_color);
869 RrColorFree(theme->cb_unfocused_color);
870 RrColorFree(theme->cb_focused_color);
871 RrColorFree(theme->title_unfocused_color);
872 RrColorFree(theme->title_focused_color);
873 RrColorFree(theme->titlebut_disabled_focused_color);
874 RrColorFree(theme->titlebut_disabled_unfocused_color);
875 RrColorFree(theme->titlebut_hover_focused_color);
876 RrColorFree(theme->titlebut_hover_unfocused_color);
877 RrColorFree(theme->titlebut_toggled_focused_color);
878 RrColorFree(theme->titlebut_toggled_unfocused_color);
879 RrColorFree(theme->titlebut_unfocused_pressed_color);
880 RrColorFree(theme->titlebut_focused_pressed_color);
881 RrColorFree(theme->titlebut_unfocused_unpressed_color);
882 RrColorFree(theme->titlebut_focused_unpressed_color);
883 RrColorFree(theme->menu_color);
884 RrColorFree(theme->menu_title_color);
885 RrColorFree(theme->menu_disabled_color);
886 RrColorFree(theme->menu_hilite_color);
887 RrColorFree(theme->menu_bullet_color);
889 RrPixmapMaskFree(theme->max_mask);
890 RrPixmapMaskFree(theme->max_toggled_mask);
891 RrPixmapMaskFree(theme->max_disabled_mask);
892 RrPixmapMaskFree(theme->max_hover_mask);
893 RrPixmapMaskFree(theme->max_pressed_mask);
894 RrPixmapMaskFree(theme->desk_mask);
895 RrPixmapMaskFree(theme->desk_toggled_mask);
896 RrPixmapMaskFree(theme->desk_disabled_mask);
897 RrPixmapMaskFree(theme->desk_hover_mask);
898 RrPixmapMaskFree(theme->desk_pressed_mask);
899 RrPixmapMaskFree(theme->shade_mask);
900 RrPixmapMaskFree(theme->shade_toggled_mask);
901 RrPixmapMaskFree(theme->shade_disabled_mask);
902 RrPixmapMaskFree(theme->shade_hover_mask);
903 RrPixmapMaskFree(theme->shade_pressed_mask);
904 RrPixmapMaskFree(theme->iconify_mask);
905 RrPixmapMaskFree(theme->iconify_disabled_mask);
906 RrPixmapMaskFree(theme->iconify_hover_mask);
907 RrPixmapMaskFree(theme->iconify_pressed_mask);
908 RrPixmapMaskFree(theme->close_mask);
909 RrPixmapMaskFree(theme->close_disabled_mask);
910 RrPixmapMaskFree(theme->close_hover_mask);
911 RrPixmapMaskFree(theme->close_pressed_mask);
912 RrPixmapMaskFree(theme->menu_bullet_mask);
914 RrFontClose(theme->winfont_focused);
915 RrFontClose(theme->winfont_unfocused);
916 RrFontClose(theme->mtitlefont);
917 RrFontClose(theme->mfont);
919 RrAppearanceFree(theme->a_disabled_focused_max);
920 RrAppearanceFree(theme->a_disabled_unfocused_max);
921 RrAppearanceFree(theme->a_hover_focused_max);
922 RrAppearanceFree(theme->a_hover_unfocused_max);
923 RrAppearanceFree(theme->a_toggled_focused_max);
924 RrAppearanceFree(theme->a_toggled_unfocused_max);
925 RrAppearanceFree(theme->a_focused_unpressed_max);
926 RrAppearanceFree(theme->a_focused_pressed_max);
927 RrAppearanceFree(theme->a_unfocused_unpressed_max);
928 RrAppearanceFree(theme->a_unfocused_pressed_max);
929 RrAppearanceFree(theme->a_disabled_focused_close);
930 RrAppearanceFree(theme->a_disabled_unfocused_close);
931 RrAppearanceFree(theme->a_hover_focused_close);
932 RrAppearanceFree(theme->a_hover_unfocused_close);
933 RrAppearanceFree(theme->a_focused_unpressed_close);
934 RrAppearanceFree(theme->a_focused_pressed_close);
935 RrAppearanceFree(theme->a_unfocused_unpressed_close);
936 RrAppearanceFree(theme->a_unfocused_pressed_close);
937 RrAppearanceFree(theme->a_disabled_focused_desk);
938 RrAppearanceFree(theme->a_disabled_unfocused_desk);
939 RrAppearanceFree(theme->a_hover_focused_desk);
940 RrAppearanceFree(theme->a_hover_unfocused_desk);
941 RrAppearanceFree(theme->a_toggled_focused_desk);
942 RrAppearanceFree(theme->a_toggled_unfocused_desk);
943 RrAppearanceFree(theme->a_focused_unpressed_desk);
944 RrAppearanceFree(theme->a_focused_pressed_desk);
945 RrAppearanceFree(theme->a_unfocused_unpressed_desk);
946 RrAppearanceFree(theme->a_unfocused_pressed_desk);
947 RrAppearanceFree(theme->a_disabled_focused_shade);
948 RrAppearanceFree(theme->a_disabled_unfocused_shade);
949 RrAppearanceFree(theme->a_hover_focused_shade);
950 RrAppearanceFree(theme->a_hover_unfocused_shade);
951 RrAppearanceFree(theme->a_toggled_focused_shade);
952 RrAppearanceFree(theme->a_toggled_unfocused_shade);
953 RrAppearanceFree(theme->a_focused_unpressed_shade);
954 RrAppearanceFree(theme->a_focused_pressed_shade);
955 RrAppearanceFree(theme->a_unfocused_unpressed_shade);
956 RrAppearanceFree(theme->a_unfocused_pressed_shade);
957 RrAppearanceFree(theme->a_disabled_focused_iconify);
958 RrAppearanceFree(theme->a_disabled_unfocused_iconify);
959 RrAppearanceFree(theme->a_hover_focused_iconify);
960 RrAppearanceFree(theme->a_hover_unfocused_iconify);
961 RrAppearanceFree(theme->a_focused_unpressed_iconify);
962 RrAppearanceFree(theme->a_focused_pressed_iconify);
963 RrAppearanceFree(theme->a_unfocused_unpressed_iconify);
964 RrAppearanceFree(theme->a_unfocused_pressed_iconify);
965 RrAppearanceFree(theme->a_focused_grip);
966 RrAppearanceFree(theme->a_unfocused_grip);
967 RrAppearanceFree(theme->a_focused_title);
968 RrAppearanceFree(theme->a_unfocused_title);
969 RrAppearanceFree(theme->a_focused_label);
970 RrAppearanceFree(theme->a_unfocused_label);
971 RrAppearanceFree(theme->a_icon);
972 RrAppearanceFree(theme->a_focused_handle);
973 RrAppearanceFree(theme->a_unfocused_handle);
974 RrAppearanceFree(theme->a_menu);
975 RrAppearanceFree(theme->a_menu_title);
976 RrAppearanceFree(theme->a_menu_item);
977 RrAppearanceFree(theme->a_menu_disabled);
978 RrAppearanceFree(theme->a_menu_hilite);
979 RrAppearanceFree(theme->a_menu_text_item);
980 RrAppearanceFree(theme->a_menu_text_disabled);
981 RrAppearanceFree(theme->a_menu_text_hilite);
982 RrAppearanceFree(theme->a_clear);
983 RrAppearanceFree(theme->a_clear_tex);
984 RrAppearanceFree(theme->app_hilite_bg);
985 RrAppearanceFree(theme->app_unhilite_bg);
986 RrAppearanceFree(theme->app_hilite_label);
987 RrAppearanceFree(theme->app_unhilite_label);
991 static XrmDatabase loaddb(RrTheme *theme, char *name)
995 char *s = g_build_filename(g_get_home_dir(), ".openbox", "themes",
996 name, "themerc", NULL);
997 if ((db = XrmGetFileDatabase(s)))
998 theme->path = g_path_get_dirname(s);
1001 char *s = g_build_filename(THEMEDIR, name, "themerc", NULL);
1002 if ((db = XrmGetFileDatabase(s)))
1003 theme->path = g_path_get_dirname(s);
1007 char *s = g_build_filename(name, "themerc", NULL);
1008 if ((db = XrmGetFileDatabase(s)))
1009 theme->path = g_path_get_dirname(s);
1016 static char *create_class_name(char *rname)
1018 char *rclass = g_strdup(rname);
1023 p = strchr(p+1, '.');
1024 if (p == NULL) break;
1026 if (*p == '\0') break;
1031 static gboolean read_int(XrmDatabase db, char *rname, int *value)
1033 gboolean ret = FALSE;
1034 char *rclass = create_class_name(rname);
1035 char *rettype, *end;
1038 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1039 retvalue.addr != NULL) {
1040 *value = (int)strtol(retvalue.addr, &end, 10);
1041 if (end != retvalue.addr)
1049 static gboolean read_string(XrmDatabase db, char *rname, char **value)
1051 gboolean ret = FALSE;
1052 char *rclass = create_class_name(rname);
1056 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1057 retvalue.addr != NULL) {
1058 *value = retvalue.addr;
1066 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1067 gchar *rname, RrColor **value)
1069 gboolean ret = FALSE;
1070 char *rclass = create_class_name(rname);
1074 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1075 retvalue.addr != NULL) {
1076 RrColor *c = RrColorParse(inst, retvalue.addr);
1087 static gboolean read_mask(const RrInstance *inst,
1088 gchar *maskname, RrTheme *theme,
1089 RrPixmapMask **value)
1091 gboolean ret = FALSE;
1093 int hx, hy; /* ignored */
1097 s = g_build_filename(theme->path, maskname, NULL);
1098 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1100 *value = RrPixmapMaskNew(inst, w, h, (char*)b);
1108 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1109 RrReliefType *relief, RrBevelType *bevel,
1110 gboolean *interlaced, gboolean *border,
1111 gboolean allow_trans)
1115 /* convert to all lowercase */
1116 for (t = tex; *t != '\0'; ++t)
1117 *t = g_ascii_tolower(*t);
1119 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1120 *grad = RR_SURFACE_PARENTREL;
1122 if (strstr(tex, "gradient") != NULL) {
1123 if (strstr(tex, "crossdiagonal") != NULL)
1124 *grad = RR_SURFACE_CROSS_DIAGONAL;
1125 else if (strstr(tex, "pyramid") != NULL)
1126 *grad = RR_SURFACE_PYRAMID;
1127 else if (strstr(tex, "horizontal") != NULL)
1128 *grad = RR_SURFACE_HORIZONTAL;
1129 else if (strstr(tex, "vertical") != NULL)
1130 *grad = RR_SURFACE_VERTICAL;
1132 *grad = RR_SURFACE_DIAGONAL;
1134 *grad = RR_SURFACE_SOLID;
1137 if (strstr(tex, "sunken") != NULL)
1138 *relief = RR_RELIEF_SUNKEN;
1139 else if (strstr(tex, "flat") != NULL)
1140 *relief = RR_RELIEF_FLAT;
1142 *relief = RR_RELIEF_RAISED;
1145 if (*relief == RR_RELIEF_FLAT) {
1146 if (strstr(tex, "border") != NULL)
1149 if (strstr(tex, "bevel2") != NULL)
1150 *bevel = RR_BEVEL_2;
1152 *bevel = RR_BEVEL_1;
1155 if (strstr(tex, "interlaced") != NULL)
1158 *interlaced = FALSE;
1163 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1164 gchar *rname, RrAppearance *value,
1165 gboolean allow_trans)
1167 gboolean ret = FALSE;
1168 char *rclass = create_class_name(rname), *cname, *ctoname, *bcname;
1172 cname = g_strconcat(rname, ".color", NULL);
1173 ctoname = g_strconcat(rname, ".colorTo", NULL);
1174 bcname = g_strconcat(rname, ".borderColor", NULL);
1176 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1177 retvalue.addr != NULL) {
1178 parse_appearance(retvalue.addr,
1179 &value->surface.grad,
1180 &value->surface.relief,
1181 &value->surface.bevel,
1182 &value->surface.interlaced,
1183 &value->surface.border,
1185 if (!read_color(db, inst, cname, &value->surface.primary))
1186 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1187 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1188 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1189 if (value->surface.border)
1190 if (!read_color(db, inst, bcname,
1191 &value->surface.border_color))
1192 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1203 static void set_default_appearance(RrAppearance *a)
1205 a->surface.grad = RR_SURFACE_SOLID;
1206 a->surface.relief = RR_RELIEF_FLAT;
1207 a->surface.bevel = RR_BEVEL_1;
1208 a->surface.interlaced = FALSE;
1209 a->surface.border = FALSE;
1210 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1211 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);