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, mjust;
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, 1);
60 theme->a_menu_disabled = RrAppearanceNew(inst, 1);
61 theme->a_menu_hilite = RrAppearanceNew(inst, 1);
63 theme->app_hilite_bg = RrAppearanceNew(inst, 0);
64 theme->app_unhilite_bg = RrAppearanceNew(inst, 0);
65 theme->app_hilite_label = RrAppearanceNew(inst, 1);
66 theme->app_unhilite_label = RrAppearanceNew(inst, 1);
67 theme->app_icon = RrAppearanceNew(inst, 1);
70 db = loaddb(theme, name);
72 g_warning("Failed to load the theme '%s'\n"
73 "Falling back to the default: '%s'",
76 theme->name = g_path_get_basename(name);
79 db = loaddb(theme, DEFAULT_THEME);
81 g_warning("Failed to load the theme '%s'.", DEFAULT_THEME);
84 theme->name = g_path_get_basename(DEFAULT_THEME);
87 /* load the font stuff */
88 if (!read_string(db, "window.title.xftfont", &font_str))
89 font_str = "arial,sans:bold:pixelsize=10:shadow=y:shadowtint=50";
91 if (!(theme->winfont = RrFontOpen(inst, font_str))) {
95 theme->winfont_height = RrFontHeight(theme->winfont);
97 winjust = RR_JUSTIFY_LEFT;
98 if (read_string(db, "window.justify", &str)) {
99 if (!g_ascii_strcasecmp(str, "right"))
100 winjust = RR_JUSTIFY_RIGHT;
101 else if (!g_ascii_strcasecmp(str, "center"))
102 winjust = RR_JUSTIFY_CENTER;
105 if (!read_string(db, "menu.title.xftfont", &font_str))
106 font_str = "arial,sans:bold:pixelsize=12:shadow=y";
108 if (!(theme->mtitlefont = RrFontOpen(inst, font_str))) {
112 theme->mtitlefont_height = RrFontHeight(theme->mtitlefont);
114 mtitlejust = RR_JUSTIFY_LEFT;
115 if (read_string(db, "menu.title.justify", &str)) {
116 if (!g_ascii_strcasecmp(str, "right"))
117 mtitlejust = RR_JUSTIFY_RIGHT;
118 else if (!g_ascii_strcasecmp(str, "center"))
119 mtitlejust = RR_JUSTIFY_CENTER;
122 if (!read_string(db, "menu.frame.xftfont", &font_str))
123 font_str = "arial,sans:bold:pixelsize=11:shadow=y";
125 if (!(theme->mfont = RrFontOpen(inst, font_str))) {
129 theme->mfont_height = RrFontHeight(theme->mfont);
131 mjust = RR_JUSTIFY_LEFT;
132 if (read_string(db, "menu.frame.justify", &str)) {
133 if (!g_ascii_strcasecmp(str, "right"))
134 mjust = RR_JUSTIFY_RIGHT;
135 else if (!g_ascii_strcasecmp(str, "center"))
136 mjust = RR_JUSTIFY_CENTER;
139 /* load direct dimensions */
140 if (!read_int(db, "menuOverlap", &theme->menu_overlap) ||
141 theme->menu_overlap < 0 || theme->menu_overlap > 20)
142 theme->handle_height = 0;
143 if (!read_int(db, "handleWidth", &theme->handle_height) ||
144 theme->handle_height < 0 || theme->handle_height > 100)
145 theme->handle_height = 6;
146 if (!read_int(db, "bevelWidth", &theme->bevel) ||
147 theme->bevel <= 0 || theme->bevel > 100) theme->bevel = 3;
148 if (!read_int(db, "borderWidth", &theme->bwidth) ||
149 theme->bwidth < 0 || theme->bwidth > 100) theme->bwidth = 1;
150 if (!read_int(db, "frameWidth", &theme->cbwidth) ||
151 theme->cbwidth < 0 || theme->cbwidth > 100)
152 theme->cbwidth = theme->bevel;
155 if (!read_color(db, inst,
156 "borderColor", &theme->b_color))
157 theme->b_color = RrColorNew(inst, 0, 0, 0);
158 if (!read_color(db, inst,
159 "window.frame.focusColor", &theme->cb_focused_color))
160 theme->cb_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
161 if (!read_color(db, inst,
162 "window.frame.unfocusColor",&theme->cb_unfocused_color))
163 theme->cb_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
164 if (!read_color(db, inst,
165 "window.label.focus.textColor",
166 &theme->title_focused_color))
167 theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0);
168 if (!read_color(db, inst,
169 "window.label.unfocus.textColor",
170 &theme->title_unfocused_color))
171 theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
172 if (!read_color(db, inst,
173 "window.button.focus.picColor",
174 &theme->titlebut_focused_unpressed_color))
175 theme->titlebut_focused_unpressed_color = RrColorNew(inst, 0, 0, 0);
176 if (!read_color(db, inst,
177 "window.button.unfocus.picColor",
178 &theme->titlebut_unfocused_unpressed_color))
179 theme->titlebut_unfocused_unpressed_color =
180 RrColorNew(inst, 0xff, 0xff, 0xff);
181 if (!read_color(db, inst,
182 "window.button.pressed.focus.picColor",
183 &theme->titlebut_focused_pressed_color))
184 theme->titlebut_focused_pressed_color =
186 theme->titlebut_focused_unpressed_color->r,
187 theme->titlebut_focused_unpressed_color->g,
188 theme->titlebut_focused_unpressed_color->b);
189 if (!read_color(db, inst,
190 "window.button.pressed.unfocus.picColor",
191 &theme->titlebut_unfocused_pressed_color))
192 theme->titlebut_unfocused_pressed_color =
194 theme->titlebut_unfocused_unpressed_color->r,
195 theme->titlebut_unfocused_unpressed_color->g,
196 theme->titlebut_unfocused_unpressed_color->b);
197 if (!read_color(db, inst,
198 "window.button.disabled.focus.picColor",
199 &theme->titlebut_disabled_focused_color))
200 theme->titlebut_disabled_focused_color =
201 RrColorNew(inst, 0xff, 0xff, 0xff);
202 if (!read_color(db, inst,
203 "window.button.disabled.unfocus.picColor",
204 &theme->titlebut_disabled_unfocused_color))
205 theme->titlebut_disabled_unfocused_color = RrColorNew(inst, 0, 0, 0);
206 if (!read_color(db, inst,
207 "window.button.hover.focus.picColor",
208 &theme->titlebut_hover_focused_color))
209 theme->titlebut_hover_focused_color =
211 theme->titlebut_focused_unpressed_color->r,
212 theme->titlebut_focused_unpressed_color->g,
213 theme->titlebut_focused_unpressed_color->b);
214 if (!read_color(db, inst,
215 "window.button.hover.unfocus.picColor",
216 &theme->titlebut_hover_unfocused_color))
217 theme->titlebut_hover_unfocused_color =
219 theme->titlebut_unfocused_unpressed_color->r,
220 theme->titlebut_unfocused_unpressed_color->g,
221 theme->titlebut_unfocused_unpressed_color->b);
222 if (!read_color(db, inst,
223 "window.button.toggled.focus.picColor",
224 &theme->titlebut_toggled_focused_color))
225 theme->titlebut_toggled_focused_color =
227 theme->titlebut_focused_pressed_color->r,
228 theme->titlebut_focused_pressed_color->g,
229 theme->titlebut_focused_pressed_color->b);
230 if (!read_color(db, inst,
231 "window.button.toggled.unfocus.picColor",
232 &theme->titlebut_toggled_unfocused_color))
233 theme->titlebut_toggled_unfocused_color =
235 theme->titlebut_unfocused_pressed_color->r,
236 theme->titlebut_unfocused_pressed_color->g,
237 theme->titlebut_unfocused_pressed_color->b);
238 if (!read_color(db, inst,
239 "menu.title.textColor", &theme->menu_title_color))
240 theme->menu_title_color = RrColorNew(inst, 0, 0, 0);
241 if (!read_color(db, inst,
242 "menu.frame.textColor", &theme->menu_color))
243 theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff);
244 if (!read_color(db, inst,
245 "menu.frame.disableColor", &theme->menu_disabled_color))
246 theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0);
247 if (!read_color(db, inst,
248 "menu.hilite.textColor", &theme->menu_hilite_color))
249 theme->menu_hilite_color = RrColorNew(inst, 0, 0, 0);
251 if (read_mask(inst, "max.xbm", theme, &theme->max_mask)) {
252 if (!read_mask(inst, "max_pressed.xbm", theme,
253 &theme->max_pressed_mask)) {
254 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
256 if (!read_mask(inst, "max_toggled.xbm", theme,
257 &theme->max_toggled_mask)) {
258 theme->max_toggled_mask =
259 RrPixmapMaskCopy(theme->max_pressed_mask);
261 if (!read_mask(inst, "max_disabled.xbm", theme,
262 &theme->max_disabled_mask)) {
263 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
265 if (!read_mask(inst, "max_hover.xbm", theme, &theme->max_hover_mask)) {
266 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
270 char data[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
271 theme->max_mask = RrPixmapMaskNew(inst, 7, 7, data);
274 char data[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
275 theme->max_toggled_mask = RrPixmapMaskNew(inst, 7, 7, data);
277 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
278 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
279 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
282 if (read_mask(inst, "iconify.xbm", theme, &theme->iconify_mask)) {
283 if (!read_mask(inst, "iconify_pressed.xbm", theme,
284 &theme->iconify_pressed_mask)) {
285 theme->iconify_pressed_mask =
286 RrPixmapMaskCopy(theme->iconify_mask);
288 if (!read_mask(inst, "iconify_disabled.xbm", theme,
289 &theme->iconify_disabled_mask)) {
290 theme->iconify_disabled_mask =
291 RrPixmapMaskCopy(theme->iconify_mask);
293 if (!read_mask(inst, "iconify_hover.xbm", theme,
294 &theme->iconify_hover_mask)) {
295 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
299 char data[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
300 theme->iconify_mask = RrPixmapMaskNew(inst, 7, 7, data);
302 theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
303 theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
304 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
307 if (read_mask(inst, "desk.xbm", theme, &theme->desk_mask)) {
308 if (!read_mask(inst, "desk_pressed.xbm", theme,
309 &theme->desk_pressed_mask)) {
310 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
312 if (!read_mask(inst, "desk_toggled.xbm", theme,
313 &theme->desk_toggled_mask)) {
314 theme->desk_toggled_mask =
315 RrPixmapMaskCopy(theme->desk_pressed_mask);
317 if (!read_mask(inst, "desk_disabled.xbm", theme,
318 &theme->desk_disabled_mask)) {
319 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
321 if (!read_mask(inst, "desk_hover.xbm", theme,
322 &theme->desk_hover_mask)) {
323 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
327 char data[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
328 theme->desk_mask = RrPixmapMaskNew(inst, 7, 7, data);
331 char data[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
332 theme->desk_toggled_mask = RrPixmapMaskNew(inst, 7, 7, data);
334 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
335 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
336 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
339 if (read_mask(inst, "shade.xbm", theme, &theme->shade_mask)) {
340 if (!read_mask(inst, "shade_pressed.xbm", theme,
341 &theme->shade_pressed_mask)) {
342 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
344 if (!read_mask(inst, "shade_toggled.xbm", theme,
345 &theme->shade_toggled_mask)) {
346 theme->shade_toggled_mask =
347 RrPixmapMaskCopy(theme->shade_pressed_mask);
349 if (!read_mask(inst, "shade_disabled.xbm", theme,
350 &theme->shade_disabled_mask)) {
351 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
353 if (!read_mask(inst, "shade_hover.xbm", theme,
354 &theme->shade_hover_mask)) {
355 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
359 char data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
360 theme->shade_mask = RrPixmapMaskNew(inst, 7, 7, data);
363 char data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
364 theme->shade_toggled_mask = RrPixmapMaskNew(inst, 7, 7, data);
366 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
367 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
368 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
371 if (read_mask(inst, "close.xbm", theme, &theme->close_mask)) {
372 if (!read_mask(inst, "close_pressed.xbm", theme,
373 &theme->close_pressed_mask)) {
374 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
376 if (!read_mask(inst, "close_disabled.xbm", theme,
377 &theme->close_disabled_mask)) {
378 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
380 if (!read_mask(inst, "close_hover.xbm", theme,
381 &theme->close_hover_mask)) {
382 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
386 char data[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
387 theme->close_mask = RrPixmapMaskNew(inst, 7, 7, data);
389 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
390 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
391 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
394 /* read the decoration textures */
395 if (!read_appearance(db, inst,
396 "window.title.focus", theme->a_focused_title,
398 set_default_appearance(theme->a_focused_title);
399 if (!read_appearance(db, inst,
400 "window.title.unfocus", theme->a_unfocused_title,
402 set_default_appearance(theme->a_unfocused_title);
403 if (!read_appearance(db, inst,
404 "window.label.focus", theme->a_focused_label,
406 set_default_appearance(theme->a_focused_label);
407 if (!read_appearance(db, inst,
408 "window.label.unfocus", theme->a_unfocused_label,
410 set_default_appearance(theme->a_unfocused_label);
411 if (!read_appearance(db, inst,
412 "window.handle.focus", theme->a_focused_handle,
414 set_default_appearance(theme->a_focused_handle);
415 if (!read_appearance(db, inst,
416 "window.handle.unfocus",theme->a_unfocused_handle,
418 set_default_appearance(theme->a_unfocused_handle);
419 if (!read_appearance(db, inst,
420 "window.grip.focus", theme->a_focused_grip,
422 set_default_appearance(theme->a_focused_grip);
423 if (!read_appearance(db, inst,
424 "window.grip.unfocus", theme->a_unfocused_grip,
426 set_default_appearance(theme->a_unfocused_grip);
427 if (!read_appearance(db, inst,
428 "menu.frame", theme->a_menu,
430 set_default_appearance(theme->a_menu);
431 if (!read_appearance(db, inst,
432 "menu.title", theme->a_menu_title,
434 set_default_appearance(theme->a_menu_title);
435 if (!read_appearance(db, inst,
436 "menu.hilite", theme->a_menu_hilite,
438 set_default_appearance(theme->a_menu_hilite);
440 /* read the appearances for rendering non-decorations */
441 if (!read_appearance(db, inst,
442 "window.title.focus", theme->app_hilite_bg,
444 set_default_appearance(theme->app_hilite_bg);
445 if (!read_appearance(db, inst,
446 "window.label.focus", theme->app_hilite_label,
448 set_default_appearance(theme->app_hilite_label);
449 if (!read_appearance(db, inst,
450 "window.title.unfocus", theme->app_unhilite_bg,
452 set_default_appearance(theme->app_unhilite_bg);
453 if (!read_appearance(db, inst,
454 "window.label.unfocus", theme->app_unhilite_label,
456 set_default_appearance(theme->app_unhilite_label);
458 /* read buttons textures */
459 if (!read_appearance(db, inst,
460 "window.button.disabled.focus",
461 theme->a_disabled_focused_max,
463 set_default_appearance(theme->a_disabled_focused_max);
464 if (!read_appearance(db, inst,
465 "window.button.disabled.unfocus",
466 theme->a_disabled_unfocused_max,
468 set_default_appearance(theme->a_disabled_unfocused_max);
469 if (!read_appearance(db, inst,
470 "window.button.pressed.focus",
471 theme->a_focused_pressed_max,
473 set_default_appearance(theme->a_focused_pressed_max);
474 if (!read_appearance(db, inst,
475 "window.button.pressed.unfocus",
476 theme->a_unfocused_pressed_max,
478 set_default_appearance(theme->a_unfocused_pressed_max);
479 if (!read_appearance(db, inst,
480 "window.button.toggled.focus",
481 theme->a_toggled_focused_max,
483 theme->a_toggled_focused_max =
484 RrAppearanceCopy(theme->a_focused_pressed_max);
485 if (!read_appearance(db, inst,
486 "window.button.toggled.unfocus",
487 theme->a_toggled_unfocused_max,
489 theme->a_toggled_unfocused_max =
490 RrAppearanceCopy(theme->a_unfocused_pressed_max);
491 if (!read_appearance(db, inst,
492 "window.button.focus",
493 theme->a_focused_unpressed_max,
495 set_default_appearance(theme->a_focused_unpressed_max);
496 if (!read_appearance(db, inst,
497 "window.button.unfocus",
498 theme->a_unfocused_unpressed_max,
500 set_default_appearance(theme->a_unfocused_unpressed_max);
501 if (!read_appearance(db, inst,
502 "window.button.hover.focus",
503 theme->a_hover_focused_max,
505 theme->a_hover_focused_max =
506 RrAppearanceCopy(theme->a_focused_unpressed_max);
507 if (!read_appearance(db, inst,
508 "window.button.hover.unfocus",
509 theme->a_hover_unfocused_max,
511 theme->a_hover_unfocused_max =
512 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
514 theme->a_disabled_focused_close =
515 RrAppearanceCopy(theme->a_disabled_focused_max);
516 theme->a_disabled_unfocused_close =
517 RrAppearanceCopy(theme->a_disabled_unfocused_max);
518 theme->a_hover_focused_close =
519 RrAppearanceCopy(theme->a_hover_focused_max);
520 theme->a_hover_unfocused_close =
521 RrAppearanceCopy(theme->a_hover_unfocused_max);
522 theme->a_unfocused_unpressed_close =
523 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
524 theme->a_unfocused_pressed_close =
525 RrAppearanceCopy(theme->a_unfocused_pressed_max);
526 theme->a_focused_unpressed_close =
527 RrAppearanceCopy(theme->a_focused_unpressed_max);
528 theme->a_focused_pressed_close =
529 RrAppearanceCopy(theme->a_focused_pressed_max);
530 theme->a_disabled_focused_desk =
531 RrAppearanceCopy(theme->a_disabled_focused_max);
532 theme->a_disabled_unfocused_desk =
533 RrAppearanceCopy(theme->a_disabled_unfocused_max);
534 theme->a_hover_focused_desk =
535 RrAppearanceCopy(theme->a_hover_focused_max);
536 theme->a_hover_unfocused_desk =
537 RrAppearanceCopy(theme->a_hover_unfocused_max);
538 theme->a_toggled_focused_desk =
539 RrAppearanceCopy(theme->a_toggled_focused_max);
540 theme->a_toggled_unfocused_desk =
541 RrAppearanceCopy(theme->a_toggled_unfocused_max);
542 theme->a_unfocused_unpressed_desk =
543 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
544 theme->a_unfocused_pressed_desk =
545 RrAppearanceCopy(theme->a_unfocused_pressed_max);
546 theme->a_focused_unpressed_desk =
547 RrAppearanceCopy(theme->a_focused_unpressed_max);
548 theme->a_focused_pressed_desk =
549 RrAppearanceCopy(theme->a_focused_pressed_max);
550 theme->a_disabled_focused_shade =
551 RrAppearanceCopy(theme->a_disabled_focused_max);
552 theme->a_disabled_unfocused_shade =
553 RrAppearanceCopy(theme->a_disabled_unfocused_max);
554 theme->a_hover_focused_shade =
555 RrAppearanceCopy(theme->a_hover_focused_max);
556 theme->a_hover_unfocused_shade =
557 RrAppearanceCopy(theme->a_hover_unfocused_max);
558 theme->a_toggled_focused_shade =
559 RrAppearanceCopy(theme->a_toggled_focused_max);
560 theme->a_toggled_unfocused_shade =
561 RrAppearanceCopy(theme->a_toggled_unfocused_max);
562 theme->a_unfocused_unpressed_shade =
563 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
564 theme->a_unfocused_pressed_shade =
565 RrAppearanceCopy(theme->a_unfocused_pressed_max);
566 theme->a_focused_unpressed_shade =
567 RrAppearanceCopy(theme->a_focused_unpressed_max);
568 theme->a_focused_pressed_shade =
569 RrAppearanceCopy(theme->a_focused_pressed_max);
570 theme->a_disabled_focused_iconify =
571 RrAppearanceCopy(theme->a_disabled_focused_max);
572 theme->a_disabled_unfocused_iconify =
573 RrAppearanceCopy(theme->a_disabled_focused_max);
574 theme->a_hover_focused_iconify =
575 RrAppearanceCopy(theme->a_hover_focused_max);
576 theme->a_hover_unfocused_iconify =
577 RrAppearanceCopy(theme->a_hover_unfocused_max);
578 theme->a_unfocused_unpressed_iconify =
579 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
580 theme->a_unfocused_pressed_iconify =
581 RrAppearanceCopy(theme->a_unfocused_pressed_max);
582 theme->a_focused_unpressed_iconify =
583 RrAppearanceCopy(theme->a_focused_unpressed_max);
584 theme->a_focused_pressed_iconify =
585 RrAppearanceCopy(theme->a_focused_pressed_max);
587 theme->a_icon->surface.grad = RR_SURFACE_PARENTREL;
589 /* set up the textures */
590 theme->a_focused_label->texture[0].type =
591 theme->app_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
592 theme->a_focused_label->texture[0].data.text.justify = winjust;
593 theme->app_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
594 theme->a_focused_label->texture[0].data.text.font =
595 theme->app_hilite_label->texture[0].data.text.font = theme->winfont;
596 theme->a_focused_label->texture[0].data.text.color =
597 theme->app_hilite_label->texture[0].data.text.color =
598 theme->title_focused_color;
600 theme->a_unfocused_label->texture[0].type =
601 theme->app_unhilite_label->texture[0].type = RR_TEXTURE_TEXT;
602 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
603 theme->app_unhilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
604 theme->a_unfocused_label->texture[0].data.text.font =
605 theme->app_unhilite_label->texture[0].data.text.font = theme->winfont;
606 theme->a_unfocused_label->texture[0].data.text.color =
607 theme->app_unhilite_label->texture[0].data.text.color =
608 theme->title_unfocused_color;
610 theme->a_menu_title->texture[0].type = RR_TEXTURE_TEXT;
611 theme->a_menu_title->texture[0].data.text.justify = mtitlejust;
612 theme->a_menu_title->texture[0].data.text.font = theme->mtitlefont;
613 theme->a_menu_title->texture[0].data.text.color = theme->menu_title_color;
615 theme->a_menu_item->surface.grad =
616 theme->a_menu_disabled->surface.grad =
617 theme->app_icon->surface.grad = RR_SURFACE_PARENTREL;
619 theme->a_menu_item->texture[0].type =
620 theme->a_menu_disabled->texture[0].type =
621 theme->a_menu_hilite->texture[0].type = RR_TEXTURE_TEXT;
622 theme->a_menu_item->texture[0].data.text.justify =
623 theme->a_menu_disabled->texture[0].data.text.justify =
624 theme->a_menu_hilite->texture[0].data.text.justify = mjust;
625 theme->a_menu_item->texture[0].data.text.font =
626 theme->a_menu_disabled->texture[0].data.text.font =
627 theme->a_menu_hilite->texture[0].data.text.font = theme->mfont;
628 theme->a_menu_item->texture[0].data.text.color = theme->menu_color;
629 theme->a_menu_disabled->texture[0].data.text.color =
630 theme->menu_disabled_color;
631 theme->a_menu_hilite->texture[0].data.text.color =
632 theme->menu_hilite_color;
634 theme->a_disabled_focused_max->texture[0].type =
635 theme->a_disabled_unfocused_max->texture[0].type =
636 theme->a_hover_focused_max->texture[0].type =
637 theme->a_hover_unfocused_max->texture[0].type =
638 theme->a_toggled_focused_max->texture[0].type =
639 theme->a_toggled_unfocused_max->texture[0].type =
640 theme->a_focused_unpressed_max->texture[0].type =
641 theme->a_focused_pressed_max->texture[0].type =
642 theme->a_unfocused_unpressed_max->texture[0].type =
643 theme->a_unfocused_pressed_max->texture[0].type =
644 theme->a_disabled_focused_close->texture[0].type =
645 theme->a_disabled_unfocused_close->texture[0].type =
646 theme->a_hover_focused_close->texture[0].type =
647 theme->a_hover_unfocused_close->texture[0].type =
648 theme->a_focused_unpressed_close->texture[0].type =
649 theme->a_focused_pressed_close->texture[0].type =
650 theme->a_unfocused_unpressed_close->texture[0].type =
651 theme->a_unfocused_pressed_close->texture[0].type =
652 theme->a_disabled_focused_desk->texture[0].type =
653 theme->a_disabled_unfocused_desk->texture[0].type =
654 theme->a_hover_focused_desk->texture[0].type =
655 theme->a_hover_unfocused_desk->texture[0].type =
656 theme->a_toggled_focused_desk->texture[0].type =
657 theme->a_toggled_unfocused_desk->texture[0].type =
658 theme->a_focused_unpressed_desk->texture[0].type =
659 theme->a_focused_pressed_desk->texture[0].type =
660 theme->a_unfocused_unpressed_desk->texture[0].type =
661 theme->a_unfocused_pressed_desk->texture[0].type =
662 theme->a_disabled_focused_shade->texture[0].type =
663 theme->a_disabled_unfocused_shade->texture[0].type =
664 theme->a_hover_focused_shade->texture[0].type =
665 theme->a_hover_unfocused_shade->texture[0].type =
666 theme->a_toggled_focused_shade->texture[0].type =
667 theme->a_toggled_unfocused_shade->texture[0].type =
668 theme->a_focused_unpressed_shade->texture[0].type =
669 theme->a_focused_pressed_shade->texture[0].type =
670 theme->a_unfocused_unpressed_shade->texture[0].type =
671 theme->a_unfocused_pressed_shade->texture[0].type =
672 theme->a_disabled_focused_iconify->texture[0].type =
673 theme->a_disabled_unfocused_iconify->texture[0].type =
674 theme->a_hover_focused_iconify->texture[0].type =
675 theme->a_hover_unfocused_iconify->texture[0].type =
676 theme->a_focused_unpressed_iconify->texture[0].type =
677 theme->a_focused_pressed_iconify->texture[0].type =
678 theme->a_unfocused_unpressed_iconify->texture[0].type =
679 theme->a_unfocused_pressed_iconify->texture[0].type = RR_TEXTURE_MASK;
680 theme->a_disabled_focused_max->texture[0].data.mask.mask =
681 theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
682 theme->max_disabled_mask;
683 theme->a_hover_focused_max->texture[0].data.mask.mask =
684 theme->a_hover_unfocused_max->texture[0].data.mask.mask =
685 theme->max_hover_mask;
686 theme->a_focused_pressed_max->texture[0].data.mask.mask =
687 theme->a_unfocused_pressed_max->texture[0].data.mask.mask =
688 theme->max_pressed_mask;
689 theme->a_focused_unpressed_max->texture[0].data.mask.mask =
690 theme->a_unfocused_unpressed_max->texture[0].data.mask.mask =
692 theme->a_toggled_focused_max->texture[0].data.mask.mask =
693 theme->a_toggled_unfocused_max->texture[0].data.mask.mask =
694 theme->max_toggled_mask;
695 theme->a_disabled_focused_close->texture[0].data.mask.mask =
696 theme->a_disabled_unfocused_close->texture[0].data.mask.mask =
697 theme->close_disabled_mask;
698 theme->a_hover_focused_close->texture[0].data.mask.mask =
699 theme->a_hover_unfocused_close->texture[0].data.mask.mask =
700 theme->close_hover_mask;
701 theme->a_focused_pressed_close->texture[0].data.mask.mask =
702 theme->a_unfocused_pressed_close->texture[0].data.mask.mask =
703 theme->close_pressed_mask;
704 theme->a_focused_unpressed_close->texture[0].data.mask.mask =
705 theme->a_unfocused_unpressed_close->texture[0].data.mask.mask =
707 theme->a_disabled_focused_desk->texture[0].data.mask.mask =
708 theme->a_disabled_unfocused_desk->texture[0].data.mask.mask =
709 theme->desk_disabled_mask;
710 theme->a_hover_focused_desk->texture[0].data.mask.mask =
711 theme->a_hover_unfocused_desk->texture[0].data.mask.mask =
712 theme->desk_hover_mask;
713 theme->a_focused_pressed_desk->texture[0].data.mask.mask =
714 theme->a_unfocused_pressed_desk->texture[0].data.mask.mask =
715 theme->desk_pressed_mask;
716 theme->a_focused_unpressed_desk->texture[0].data.mask.mask =
717 theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask =
719 theme->a_toggled_focused_desk->texture[0].data.mask.mask =
720 theme->a_toggled_unfocused_desk->texture[0].data.mask.mask =
722 theme->a_disabled_focused_shade->texture[0].data.mask.mask =
723 theme->a_disabled_unfocused_shade->texture[0].data.mask.mask =
724 theme->shade_disabled_mask;
725 theme->a_hover_focused_shade->texture[0].data.mask.mask =
726 theme->a_hover_unfocused_shade->texture[0].data.mask.mask =
727 theme->shade_hover_mask;
728 theme->a_focused_pressed_shade->texture[0].data.mask.mask =
729 theme->a_unfocused_pressed_shade->texture[0].data.mask.mask =
730 theme->shade_pressed_mask;
731 theme->a_focused_unpressed_shade->texture[0].data.mask.mask =
732 theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask =
734 theme->a_toggled_focused_shade->texture[0].data.mask.mask =
735 theme->a_toggled_unfocused_shade->texture[0].data.mask.mask =
737 theme->a_disabled_focused_iconify->texture[0].data.mask.mask =
738 theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask =
739 theme->iconify_disabled_mask;
740 theme->a_hover_focused_iconify->texture[0].data.mask.mask =
741 theme->a_hover_unfocused_iconify->texture[0].data.mask.mask =
742 theme->iconify_hover_mask;
743 theme->a_focused_pressed_iconify->texture[0].data.mask.mask =
744 theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask =
745 theme->iconify_pressed_mask;
746 theme->a_focused_unpressed_iconify->texture[0].data.mask.mask =
747 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask =
749 theme->a_disabled_focused_max->texture[0].data.mask.color =
750 theme->a_disabled_focused_close->texture[0].data.mask.color =
751 theme->a_disabled_focused_desk->texture[0].data.mask.color =
752 theme->a_disabled_focused_shade->texture[0].data.mask.color =
753 theme->a_disabled_focused_iconify->texture[0].data.mask.color =
754 theme->titlebut_disabled_focused_color;
755 theme->a_disabled_unfocused_max->texture[0].data.mask.color =
756 theme->a_disabled_unfocused_close->texture[0].data.mask.color =
757 theme->a_disabled_unfocused_desk->texture[0].data.mask.color =
758 theme->a_disabled_unfocused_shade->texture[0].data.mask.color =
759 theme->a_disabled_unfocused_iconify->texture[0].data.mask.color =
760 theme->titlebut_disabled_unfocused_color;
761 theme->a_hover_focused_max->texture[0].data.mask.color =
762 theme->a_hover_focused_close->texture[0].data.mask.color =
763 theme->a_hover_focused_desk->texture[0].data.mask.color =
764 theme->a_hover_focused_shade->texture[0].data.mask.color =
765 theme->a_hover_focused_iconify->texture[0].data.mask.color =
766 theme->titlebut_hover_focused_color;
767 theme->a_hover_unfocused_max->texture[0].data.mask.color =
768 theme->a_hover_unfocused_close->texture[0].data.mask.color =
769 theme->a_hover_unfocused_desk->texture[0].data.mask.color =
770 theme->a_hover_unfocused_shade->texture[0].data.mask.color =
771 theme->a_hover_unfocused_iconify->texture[0].data.mask.color =
772 theme->titlebut_hover_unfocused_color;
773 theme->a_toggled_focused_max->texture[0].data.mask.color =
774 theme->a_toggled_focused_desk->texture[0].data.mask.color =
775 theme->a_toggled_focused_shade->texture[0].data.mask.color =
776 theme->titlebut_toggled_focused_color;
777 theme->a_toggled_unfocused_max->texture[0].data.mask.color =
778 theme->a_toggled_unfocused_desk->texture[0].data.mask.color =
779 theme->a_toggled_unfocused_shade->texture[0].data.mask.color =
780 theme->titlebut_toggled_unfocused_color;
781 theme->a_focused_unpressed_max->texture[0].data.mask.color =
782 theme->a_focused_unpressed_close->texture[0].data.mask.color =
783 theme->a_focused_unpressed_desk->texture[0].data.mask.color =
784 theme->a_focused_unpressed_shade->texture[0].data.mask.color =
785 theme->a_focused_unpressed_iconify->texture[0].data.mask.color =
786 theme->titlebut_focused_unpressed_color;
787 theme->a_focused_pressed_max->texture[0].data.mask.color =
788 theme->a_focused_pressed_close->texture[0].data.mask.color =
789 theme->a_focused_pressed_desk->texture[0].data.mask.color =
790 theme->a_focused_pressed_shade->texture[0].data.mask.color =
791 theme->a_focused_pressed_iconify->texture[0].data.mask.color =
792 theme->titlebut_focused_pressed_color;
793 theme->a_unfocused_unpressed_max->texture[0].data.mask.color =
794 theme->a_unfocused_unpressed_close->texture[0].data.mask.color =
795 theme->a_unfocused_unpressed_desk->texture[0].data.mask.color =
796 theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
797 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
798 theme->titlebut_unfocused_unpressed_color;
799 theme->a_unfocused_pressed_max->texture[0].data.mask.color =
800 theme->a_unfocused_pressed_close->texture[0].data.mask.color =
801 theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
802 theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
803 theme->a_unfocused_pressed_iconify->texture[0].data.mask.color =
804 theme->titlebut_unfocused_pressed_color;
806 XrmDestroyDatabase(db);
808 theme->label_height = theme->winfont_height;
809 theme->title_height = theme->label_height + theme->bevel * 2;
810 theme->button_size = theme->label_height - 2;
811 theme->grip_width = theme->button_size * 2;
816 void RrThemeFree(RrTheme *theme)
821 RrColorFree(theme->b_color);
822 RrColorFree(theme->cb_unfocused_color);
823 RrColorFree(theme->cb_focused_color);
824 RrColorFree(theme->title_unfocused_color);
825 RrColorFree(theme->title_focused_color);
826 RrColorFree(theme->titlebut_disabled_focused_color);
827 RrColorFree(theme->titlebut_disabled_unfocused_color);
828 RrColorFree(theme->titlebut_hover_focused_color);
829 RrColorFree(theme->titlebut_hover_unfocused_color);
830 RrColorFree(theme->titlebut_toggled_focused_color);
831 RrColorFree(theme->titlebut_toggled_unfocused_color);
832 RrColorFree(theme->titlebut_unfocused_pressed_color);
833 RrColorFree(theme->titlebut_focused_pressed_color);
834 RrColorFree(theme->titlebut_unfocused_unpressed_color);
835 RrColorFree(theme->titlebut_focused_unpressed_color);
836 RrColorFree(theme->menu_color);
837 RrColorFree(theme->menu_title_color);
838 RrColorFree(theme->menu_disabled_color);
839 RrColorFree(theme->menu_hilite_color);
841 RrPixmapMaskFree(theme->max_mask);
842 RrPixmapMaskFree(theme->max_toggled_mask);
843 RrPixmapMaskFree(theme->max_disabled_mask);
844 RrPixmapMaskFree(theme->max_hover_mask);
845 RrPixmapMaskFree(theme->max_pressed_mask);
846 RrPixmapMaskFree(theme->desk_mask);
847 RrPixmapMaskFree(theme->desk_toggled_mask);
848 RrPixmapMaskFree(theme->desk_disabled_mask);
849 RrPixmapMaskFree(theme->desk_hover_mask);
850 RrPixmapMaskFree(theme->desk_pressed_mask);
851 RrPixmapMaskFree(theme->shade_mask);
852 RrPixmapMaskFree(theme->shade_toggled_mask);
853 RrPixmapMaskFree(theme->shade_disabled_mask);
854 RrPixmapMaskFree(theme->shade_hover_mask);
855 RrPixmapMaskFree(theme->shade_pressed_mask);
856 RrPixmapMaskFree(theme->iconify_mask);
857 RrPixmapMaskFree(theme->iconify_disabled_mask);
858 RrPixmapMaskFree(theme->iconify_hover_mask);
859 RrPixmapMaskFree(theme->iconify_pressed_mask);
860 RrPixmapMaskFree(theme->close_mask);
861 RrPixmapMaskFree(theme->close_disabled_mask);
862 RrPixmapMaskFree(theme->close_hover_mask);
863 RrPixmapMaskFree(theme->close_pressed_mask);
865 RrFontClose(theme->winfont);
866 RrFontClose(theme->mtitlefont);
867 RrFontClose(theme->mfont);
869 RrAppearanceFree(theme->a_disabled_focused_max);
870 RrAppearanceFree(theme->a_disabled_unfocused_max);
871 RrAppearanceFree(theme->a_hover_focused_max);
872 RrAppearanceFree(theme->a_hover_unfocused_max);
873 RrAppearanceFree(theme->a_toggled_focused_max);
874 RrAppearanceFree(theme->a_toggled_unfocused_max);
875 RrAppearanceFree(theme->a_focused_unpressed_max);
876 RrAppearanceFree(theme->a_focused_pressed_max);
877 RrAppearanceFree(theme->a_unfocused_unpressed_max);
878 RrAppearanceFree(theme->a_unfocused_pressed_max);
879 RrAppearanceFree(theme->a_disabled_focused_close);
880 RrAppearanceFree(theme->a_disabled_unfocused_close);
881 RrAppearanceFree(theme->a_hover_focused_close);
882 RrAppearanceFree(theme->a_hover_unfocused_close);
883 RrAppearanceFree(theme->a_focused_unpressed_close);
884 RrAppearanceFree(theme->a_focused_pressed_close);
885 RrAppearanceFree(theme->a_unfocused_unpressed_close);
886 RrAppearanceFree(theme->a_unfocused_pressed_close);
887 RrAppearanceFree(theme->a_disabled_focused_desk);
888 RrAppearanceFree(theme->a_disabled_unfocused_desk);
889 RrAppearanceFree(theme->a_hover_focused_desk);
890 RrAppearanceFree(theme->a_hover_unfocused_desk);
891 RrAppearanceFree(theme->a_toggled_focused_desk);
892 RrAppearanceFree(theme->a_toggled_unfocused_desk);
893 RrAppearanceFree(theme->a_focused_unpressed_desk);
894 RrAppearanceFree(theme->a_focused_pressed_desk);
895 RrAppearanceFree(theme->a_unfocused_unpressed_desk);
896 RrAppearanceFree(theme->a_unfocused_pressed_desk);
897 RrAppearanceFree(theme->a_disabled_focused_shade);
898 RrAppearanceFree(theme->a_disabled_unfocused_shade);
899 RrAppearanceFree(theme->a_hover_focused_shade);
900 RrAppearanceFree(theme->a_hover_unfocused_shade);
901 RrAppearanceFree(theme->a_toggled_focused_shade);
902 RrAppearanceFree(theme->a_toggled_unfocused_shade);
903 RrAppearanceFree(theme->a_focused_unpressed_shade);
904 RrAppearanceFree(theme->a_focused_pressed_shade);
905 RrAppearanceFree(theme->a_unfocused_unpressed_shade);
906 RrAppearanceFree(theme->a_unfocused_pressed_shade);
907 RrAppearanceFree(theme->a_disabled_focused_iconify);
908 RrAppearanceFree(theme->a_disabled_unfocused_iconify);
909 RrAppearanceFree(theme->a_hover_focused_iconify);
910 RrAppearanceFree(theme->a_hover_unfocused_iconify);
911 RrAppearanceFree(theme->a_focused_unpressed_iconify);
912 RrAppearanceFree(theme->a_focused_pressed_iconify);
913 RrAppearanceFree(theme->a_unfocused_unpressed_iconify);
914 RrAppearanceFree(theme->a_unfocused_pressed_iconify);
915 RrAppearanceFree(theme->a_focused_grip);
916 RrAppearanceFree(theme->a_unfocused_grip);
917 RrAppearanceFree(theme->a_focused_title);
918 RrAppearanceFree(theme->a_unfocused_title);
919 RrAppearanceFree(theme->a_focused_label);
920 RrAppearanceFree(theme->a_unfocused_label);
921 RrAppearanceFree(theme->a_icon);
922 RrAppearanceFree(theme->a_focused_handle);
923 RrAppearanceFree(theme->a_unfocused_handle);
924 RrAppearanceFree(theme->a_menu);
925 RrAppearanceFree(theme->a_menu_title);
926 RrAppearanceFree(theme->a_menu_item);
927 RrAppearanceFree(theme->a_menu_disabled);
928 RrAppearanceFree(theme->a_menu_hilite);
929 RrAppearanceFree(theme->app_hilite_bg);
930 RrAppearanceFree(theme->app_unhilite_bg);
931 RrAppearanceFree(theme->app_hilite_label);
932 RrAppearanceFree(theme->app_unhilite_label);
933 RrAppearanceFree(theme->app_icon);
937 static XrmDatabase loaddb(RrTheme *theme, char *name)
941 char *s = g_build_filename(name, "themerc", NULL);
942 if ((db = XrmGetFileDatabase(s)))
943 theme->path = g_path_get_dirname(s);
946 char *s = g_build_filename(g_get_home_dir(), ".openbox", "themes",
947 name, "themerc", NULL);
948 if ((db = XrmGetFileDatabase(s)))
949 theme->path = g_path_get_dirname(s);
953 char *s = g_build_filename(THEMEDIR, name, "themerc", NULL);
954 if ((db = XrmGetFileDatabase(s)))
955 theme->path = g_path_get_dirname(s);
962 static char *create_class_name(char *rname)
964 char *rclass = g_strdup(rname);
969 p = strchr(p+1, '.');
970 if (p == NULL) break;
972 if (*p == '\0') break;
977 static gboolean read_int(XrmDatabase db, char *rname, int *value)
979 gboolean ret = FALSE;
980 char *rclass = create_class_name(rname);
984 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
985 retvalue.addr != NULL) {
986 *value = (int)strtol(retvalue.addr, &end, 10);
987 if (end != retvalue.addr)
995 static gboolean read_string(XrmDatabase db, char *rname, char **value)
997 gboolean ret = FALSE;
998 char *rclass = create_class_name(rname);
1002 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1003 retvalue.addr != NULL) {
1004 *value = retvalue.addr;
1012 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1013 gchar *rname, RrColor **value)
1015 gboolean ret = FALSE;
1016 char *rclass = create_class_name(rname);
1020 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1021 retvalue.addr != NULL) {
1022 RrColor *c = RrColorParse(inst, retvalue.addr);
1033 static gboolean read_mask(const RrInstance *inst,
1034 gchar *maskname, RrTheme *theme,
1035 RrPixmapMask **value)
1037 gboolean ret = FALSE;
1039 int hx, hy; /* ignored */
1043 s = g_build_filename(theme->path, maskname, NULL);
1044 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1046 *value = RrPixmapMaskNew(inst, w, h, (char*)b);
1054 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1055 RrReliefType *relief, RrBevelType *bevel,
1056 gboolean *interlaced, gboolean *border,
1057 gboolean allow_trans)
1061 /* convert to all lowercase */
1062 for (t = tex; *t != '\0'; ++t)
1063 *t = g_ascii_tolower(*t);
1065 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1066 *grad = RR_SURFACE_PARENTREL;
1068 if (strstr(tex, "gradient") != NULL) {
1069 if (strstr(tex, "crossdiagonal") != NULL)
1070 *grad = RR_SURFACE_CROSS_DIAGONAL;
1071 else if (strstr(tex, "pyramid") != NULL)
1072 *grad = RR_SURFACE_PYRAMID;
1073 else if (strstr(tex, "horizontal") != NULL)
1074 *grad = RR_SURFACE_HORIZONTAL;
1075 else if (strstr(tex, "vertical") != NULL)
1076 *grad = RR_SURFACE_VERTICAL;
1078 *grad = RR_SURFACE_DIAGONAL;
1080 *grad = RR_SURFACE_SOLID;
1083 if (strstr(tex, "sunken") != NULL)
1084 *relief = RR_RELIEF_SUNKEN;
1085 else if (strstr(tex, "flat") != NULL)
1086 *relief = RR_RELIEF_FLAT;
1088 *relief = RR_RELIEF_RAISED;
1091 if (*relief == RR_RELIEF_FLAT) {
1092 if (strstr(tex, "border") != NULL)
1095 if (strstr(tex, "bevel2") != NULL)
1096 *bevel = RR_BEVEL_2;
1098 *bevel = RR_BEVEL_1;
1101 if (strstr(tex, "interlaced") != NULL)
1104 *interlaced = FALSE;
1109 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1110 gchar *rname, RrAppearance *value,
1111 gboolean allow_trans)
1113 gboolean ret = FALSE;
1114 char *rclass = create_class_name(rname), *cname, *ctoname, *bcname;
1118 cname = g_strconcat(rname, ".color", NULL);
1119 ctoname = g_strconcat(rname, ".colorTo", NULL);
1120 bcname = g_strconcat(rname, ".borderColor", NULL);
1122 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1123 retvalue.addr != NULL) {
1124 parse_appearance(retvalue.addr,
1125 &value->surface.grad,
1126 &value->surface.relief,
1127 &value->surface.bevel,
1128 &value->surface.interlaced,
1129 &value->surface.border,
1131 if (!read_color(db, inst, cname, &value->surface.primary))
1132 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1133 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1134 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1135 if (value->surface.border)
1136 if (!read_color(db, inst, bcname,
1137 &value->surface.border_color))
1138 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1149 static void set_default_appearance(RrAppearance *a)
1151 a->surface.grad = RR_SURFACE_SOLID;
1152 a->surface.relief = RR_RELIEF_FLAT;
1153 a->surface.bevel = RR_BEVEL_1;
1154 a->surface.interlaced = FALSE;
1155 a->surface.border = FALSE;
1156 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1157 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);