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);
62 theme
->a_menu_bullet
= RrAppearanceNew(inst
, 1);
63 theme
->a_clear
= RrAppearanceNew(inst
, 0);
65 theme
->app_hilite_bg
= RrAppearanceNew(inst
, 0);
66 theme
->app_unhilite_bg
= RrAppearanceNew(inst
, 0);
67 theme
->app_hilite_label
= RrAppearanceNew(inst
, 1);
68 theme
->app_unhilite_label
= RrAppearanceNew(inst
, 1);
69 theme
->app_icon
= RrAppearanceNew(inst
, 1);
72 db
= loaddb(theme
, name
);
74 g_warning("Failed to load the theme '%s'\n"
75 "Falling back to the default: '%s'",
78 theme
->name
= g_path_get_basename(name
);
81 db
= loaddb(theme
, DEFAULT_THEME
);
83 g_warning("Failed to load the theme '%s'.", DEFAULT_THEME
);
86 theme
->name
= g_path_get_basename(DEFAULT_THEME
);
89 /* load the font stuff */
90 if (!read_string(db
, "window.title.xftfont", &font_str
))
91 font_str
= "arial,sans:bold:pixelsize=10:shadow=y:shadowtint=50";
93 if (!(theme
->winfont
= RrFontOpen(inst
, font_str
))) {
97 theme
->winfont_height
= RrFontHeight(theme
->winfont
);
99 winjust
= RR_JUSTIFY_LEFT
;
100 if (read_string(db
, "window.justify", &str
)) {
101 if (!g_ascii_strcasecmp(str
, "right"))
102 winjust
= RR_JUSTIFY_RIGHT
;
103 else if (!g_ascii_strcasecmp(str
, "center"))
104 winjust
= RR_JUSTIFY_CENTER
;
107 if (!read_string(db
, "menu.title.xftfont", &font_str
))
108 font_str
= "arial,sans:bold:pixelsize=12:shadow=y";
110 if (!(theme
->mtitlefont
= RrFontOpen(inst
, font_str
))) {
114 theme
->mtitlefont_height
= RrFontHeight(theme
->mtitlefont
);
116 mtitlejust
= RR_JUSTIFY_LEFT
;
117 if (read_string(db
, "menu.title.justify", &str
)) {
118 if (!g_ascii_strcasecmp(str
, "right"))
119 mtitlejust
= RR_JUSTIFY_RIGHT
;
120 else if (!g_ascii_strcasecmp(str
, "center"))
121 mtitlejust
= RR_JUSTIFY_CENTER
;
124 if (!read_string(db
, "menu.frame.xftfont", &font_str
))
125 font_str
= "arial,sans:bold:pixelsize=11:shadow=y";
127 if (!(theme
->mfont
= RrFontOpen(inst
, font_str
))) {
131 theme
->mfont_height
= RrFontHeight(theme
->mfont
);
133 mjust
= RR_JUSTIFY_LEFT
;
134 if (read_string(db
, "menu.frame.justify", &str
)) {
135 if (!g_ascii_strcasecmp(str
, "right"))
136 mjust
= RR_JUSTIFY_RIGHT
;
137 else if (!g_ascii_strcasecmp(str
, "center"))
138 mjust
= RR_JUSTIFY_CENTER
;
141 /* load direct dimensions */
142 if (!read_int(db
, "menuOverlap", &theme
->menu_overlap
) ||
143 theme
->menu_overlap
< 0 || theme
->menu_overlap
> 20)
144 theme
->handle_height
= 0;
145 if (!read_int(db
, "handleWidth", &theme
->handle_height
) ||
146 theme
->handle_height
< 0 || theme
->handle_height
> 100)
147 theme
->handle_height
= 6;
148 if (!read_int(db
, "bevelWidth", &theme
->bevel
) ||
149 theme
->bevel
<= 0 || theme
->bevel
> 100) theme
->bevel
= 3;
150 if (!read_int(db
, "borderWidth", &theme
->bwidth
) ||
151 theme
->bwidth
< 0 || theme
->bwidth
> 100) theme
->bwidth
= 1;
152 if (!read_int(db
, "frameWidth", &theme
->cbwidth
) ||
153 theme
->cbwidth
< 0 || theme
->cbwidth
> 100)
154 theme
->cbwidth
= theme
->bevel
;
157 if (!read_color(db
, inst
,
158 "borderColor", &theme
->b_color
))
159 theme
->b_color
= RrColorNew(inst
, 0, 0, 0);
160 if (!read_color(db
, inst
,
161 "window.frame.focusColor", &theme
->cb_focused_color
))
162 theme
->cb_focused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
163 if (!read_color(db
, inst
,
164 "window.frame.unfocusColor",&theme
->cb_unfocused_color
))
165 theme
->cb_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
166 if (!read_color(db
, inst
,
167 "window.label.focus.textColor",
168 &theme
->title_focused_color
))
169 theme
->title_focused_color
= RrColorNew(inst
, 0x0, 0x0, 0x0);
170 if (!read_color(db
, inst
,
171 "window.label.unfocus.textColor",
172 &theme
->title_unfocused_color
))
173 theme
->title_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
174 if (!read_color(db
, inst
,
175 "window.button.focus.picColor",
176 &theme
->titlebut_focused_unpressed_color
))
177 theme
->titlebut_focused_unpressed_color
= RrColorNew(inst
, 0, 0, 0);
178 if (!read_color(db
, inst
,
179 "window.button.unfocus.picColor",
180 &theme
->titlebut_unfocused_unpressed_color
))
181 theme
->titlebut_unfocused_unpressed_color
=
182 RrColorNew(inst
, 0xff, 0xff, 0xff);
183 if (!read_color(db
, inst
,
184 "window.button.pressed.focus.picColor",
185 &theme
->titlebut_focused_pressed_color
))
186 theme
->titlebut_focused_pressed_color
=
188 theme
->titlebut_focused_unpressed_color
->r
,
189 theme
->titlebut_focused_unpressed_color
->g
,
190 theme
->titlebut_focused_unpressed_color
->b
);
191 if (!read_color(db
, inst
,
192 "window.button.pressed.unfocus.picColor",
193 &theme
->titlebut_unfocused_pressed_color
))
194 theme
->titlebut_unfocused_pressed_color
=
196 theme
->titlebut_unfocused_unpressed_color
->r
,
197 theme
->titlebut_unfocused_unpressed_color
->g
,
198 theme
->titlebut_unfocused_unpressed_color
->b
);
199 if (!read_color(db
, inst
,
200 "window.button.disabled.focus.picColor",
201 &theme
->titlebut_disabled_focused_color
))
202 theme
->titlebut_disabled_focused_color
=
203 RrColorNew(inst
, 0xff, 0xff, 0xff);
204 if (!read_color(db
, inst
,
205 "window.button.disabled.unfocus.picColor",
206 &theme
->titlebut_disabled_unfocused_color
))
207 theme
->titlebut_disabled_unfocused_color
= RrColorNew(inst
, 0, 0, 0);
208 if (!read_color(db
, inst
,
209 "window.button.hover.focus.picColor",
210 &theme
->titlebut_hover_focused_color
))
211 theme
->titlebut_hover_focused_color
=
213 theme
->titlebut_focused_unpressed_color
->r
,
214 theme
->titlebut_focused_unpressed_color
->g
,
215 theme
->titlebut_focused_unpressed_color
->b
);
216 if (!read_color(db
, inst
,
217 "window.button.hover.unfocus.picColor",
218 &theme
->titlebut_hover_unfocused_color
))
219 theme
->titlebut_hover_unfocused_color
=
221 theme
->titlebut_unfocused_unpressed_color
->r
,
222 theme
->titlebut_unfocused_unpressed_color
->g
,
223 theme
->titlebut_unfocused_unpressed_color
->b
);
224 if (!read_color(db
, inst
,
225 "window.button.toggled.focus.picColor",
226 &theme
->titlebut_toggled_focused_color
))
227 theme
->titlebut_toggled_focused_color
=
229 theme
->titlebut_focused_pressed_color
->r
,
230 theme
->titlebut_focused_pressed_color
->g
,
231 theme
->titlebut_focused_pressed_color
->b
);
232 if (!read_color(db
, inst
,
233 "window.button.toggled.unfocus.picColor",
234 &theme
->titlebut_toggled_unfocused_color
))
235 theme
->titlebut_toggled_unfocused_color
=
237 theme
->titlebut_unfocused_pressed_color
->r
,
238 theme
->titlebut_unfocused_pressed_color
->g
,
239 theme
->titlebut_unfocused_pressed_color
->b
);
240 if (!read_color(db
, inst
,
241 "menu.title.textColor", &theme
->menu_title_color
))
242 theme
->menu_title_color
= RrColorNew(inst
, 0, 0, 0);
243 if (!read_color(db
, inst
,
244 "menu.frame.textColor", &theme
->menu_color
))
245 theme
->menu_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
246 if (!read_color(db
, inst
,
247 "menu.bullet.picColor", &theme
->menu_color
))
248 theme
->menu_bullet_color
= RrColorNew(inst
, 0, 0, 0);
249 if (!read_color(db
, inst
,
250 "menu.frame.disableColor", &theme
->menu_disabled_color
))
251 theme
->menu_disabled_color
= RrColorNew(inst
, 0, 0, 0);
252 if (!read_color(db
, inst
,
253 "menu.hilite.textColor", &theme
->menu_hilite_color
))
254 theme
->menu_hilite_color
= RrColorNew(inst
, 0, 0, 0);
257 if (read_mask(inst
, "max.xbm", theme
, &theme
->max_mask
)) {
258 if (!read_mask(inst
, "max_pressed.xbm", theme
,
259 &theme
->max_pressed_mask
)) {
260 theme
->max_pressed_mask
= RrPixmapMaskCopy(theme
->max_mask
);
262 if (!read_mask(inst
, "max_toggled.xbm", theme
,
263 &theme
->max_toggled_mask
)) {
264 theme
->max_toggled_mask
=
265 RrPixmapMaskCopy(theme
->max_pressed_mask
);
267 if (!read_mask(inst
, "max_disabled.xbm", theme
,
268 &theme
->max_disabled_mask
)) {
269 theme
->max_disabled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
271 if (!read_mask(inst
, "max_hover.xbm", theme
, &theme
->max_hover_mask
)) {
272 theme
->max_hover_mask
= RrPixmapMaskCopy(theme
->max_mask
);
276 char data
[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
277 theme
->max_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
280 char data
[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
281 theme
->max_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
283 theme
->max_pressed_mask
= RrPixmapMaskCopy(theme
->max_mask
);
284 theme
->max_disabled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
285 theme
->max_hover_mask
= RrPixmapMaskCopy(theme
->max_mask
);
288 if (read_mask(inst
, "iconify.xbm", theme
, &theme
->iconify_mask
)) {
289 if (!read_mask(inst
, "iconify_pressed.xbm", theme
,
290 &theme
->iconify_pressed_mask
)) {
291 theme
->iconify_pressed_mask
=
292 RrPixmapMaskCopy(theme
->iconify_mask
);
294 if (!read_mask(inst
, "iconify_disabled.xbm", theme
,
295 &theme
->iconify_disabled_mask
)) {
296 theme
->iconify_disabled_mask
=
297 RrPixmapMaskCopy(theme
->iconify_mask
);
299 if (!read_mask(inst
, "iconify_hover.xbm", theme
,
300 &theme
->iconify_hover_mask
)) {
301 theme
->iconify_hover_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
305 char data
[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
306 theme
->iconify_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
308 theme
->iconify_pressed_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
309 theme
->iconify_disabled_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
310 theme
->iconify_hover_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
313 if (read_mask(inst
, "desk.xbm", theme
, &theme
->desk_mask
)) {
314 if (!read_mask(inst
, "desk_pressed.xbm", theme
,
315 &theme
->desk_pressed_mask
)) {
316 theme
->desk_pressed_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
318 if (!read_mask(inst
, "desk_toggled.xbm", theme
,
319 &theme
->desk_toggled_mask
)) {
320 theme
->desk_toggled_mask
=
321 RrPixmapMaskCopy(theme
->desk_pressed_mask
);
323 if (!read_mask(inst
, "desk_disabled.xbm", theme
,
324 &theme
->desk_disabled_mask
)) {
325 theme
->desk_disabled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
327 if (!read_mask(inst
, "desk_hover.xbm", theme
,
328 &theme
->desk_hover_mask
)) {
329 theme
->desk_hover_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
333 char data
[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
334 theme
->desk_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
337 char data
[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
338 theme
->desk_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
340 theme
->desk_pressed_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
341 theme
->desk_disabled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
342 theme
->desk_hover_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
345 if (read_mask(inst
, "shade.xbm", theme
, &theme
->shade_mask
)) {
346 if (!read_mask(inst
, "shade_pressed.xbm", theme
,
347 &theme
->shade_pressed_mask
)) {
348 theme
->shade_pressed_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
350 if (!read_mask(inst
, "shade_toggled.xbm", theme
,
351 &theme
->shade_toggled_mask
)) {
352 theme
->shade_toggled_mask
=
353 RrPixmapMaskCopy(theme
->shade_pressed_mask
);
355 if (!read_mask(inst
, "shade_disabled.xbm", theme
,
356 &theme
->shade_disabled_mask
)) {
357 theme
->shade_disabled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
359 if (!read_mask(inst
, "shade_hover.xbm", theme
,
360 &theme
->shade_hover_mask
)) {
361 theme
->shade_hover_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
365 char data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
366 theme
->shade_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
369 char data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
370 theme
->shade_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
372 theme
->shade_pressed_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
373 theme
->shade_disabled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
374 theme
->shade_hover_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
377 if (read_mask(inst
, "close.xbm", theme
, &theme
->close_mask
)) {
378 if (!read_mask(inst
, "close_pressed.xbm", theme
,
379 &theme
->close_pressed_mask
)) {
380 theme
->close_pressed_mask
= RrPixmapMaskCopy(theme
->close_mask
);
382 if (!read_mask(inst
, "close_disabled.xbm", theme
,
383 &theme
->close_disabled_mask
)) {
384 theme
->close_disabled_mask
= RrPixmapMaskCopy(theme
->close_mask
);
386 if (!read_mask(inst
, "close_hover.xbm", theme
,
387 &theme
->close_hover_mask
)) {
388 theme
->close_hover_mask
= RrPixmapMaskCopy(theme
->close_mask
);
392 char data
[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
393 theme
->close_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
395 theme
->close_pressed_mask
= RrPixmapMaskCopy(theme
->close_mask
);
396 theme
->close_disabled_mask
= RrPixmapMaskCopy(theme
->close_mask
);
397 theme
->close_hover_mask
= RrPixmapMaskCopy(theme
->close_mask
);
400 if (!read_mask(inst
, "bullet.xbm", theme
, &theme
->menu_bullet_mask
)) {
401 char data
[] = { 0x18, 0x30, 0x60, 0xfe, 0xfe, 0x60, 0x30, 0x18 };
402 theme
->menu_bullet_mask
= RrPixmapMaskNew(inst
, 8, 8, data
);
405 /* read the decoration textures */
406 if (!read_appearance(db
, inst
,
407 "window.title.focus", theme
->a_focused_title
,
409 set_default_appearance(theme
->a_focused_title
);
410 if (!read_appearance(db
, inst
,
411 "window.title.unfocus", theme
->a_unfocused_title
,
413 set_default_appearance(theme
->a_unfocused_title
);
414 if (!read_appearance(db
, inst
,
415 "window.label.focus", theme
->a_focused_label
,
417 set_default_appearance(theme
->a_focused_label
);
418 if (!read_appearance(db
, inst
,
419 "window.label.unfocus", theme
->a_unfocused_label
,
421 set_default_appearance(theme
->a_unfocused_label
);
422 if (!read_appearance(db
, inst
,
423 "window.handle.focus", theme
->a_focused_handle
,
425 set_default_appearance(theme
->a_focused_handle
);
426 if (!read_appearance(db
, inst
,
427 "window.handle.unfocus",theme
->a_unfocused_handle
,
429 set_default_appearance(theme
->a_unfocused_handle
);
430 if (!read_appearance(db
, inst
,
431 "window.grip.focus", theme
->a_focused_grip
,
433 set_default_appearance(theme
->a_focused_grip
);
434 if (!read_appearance(db
, inst
,
435 "window.grip.unfocus", theme
->a_unfocused_grip
,
437 set_default_appearance(theme
->a_unfocused_grip
);
438 if (!read_appearance(db
, inst
,
439 "menu.frame", theme
->a_menu
,
441 set_default_appearance(theme
->a_menu
);
442 if (!read_appearance(db
, inst
,
443 "menu.title", theme
->a_menu_title
,
445 set_default_appearance(theme
->a_menu_title
);
446 if (!read_appearance(db
, inst
,
447 "menu.hilite", theme
->a_menu_hilite
,
449 set_default_appearance(theme
->a_menu_hilite
);
451 /* read the appearances for rendering non-decorations */
452 if (!read_appearance(db
, inst
,
453 "window.title.focus", theme
->app_hilite_bg
,
455 set_default_appearance(theme
->app_hilite_bg
);
456 if (!read_appearance(db
, inst
,
457 "window.label.focus", theme
->app_hilite_label
,
459 set_default_appearance(theme
->app_hilite_label
);
460 if (!read_appearance(db
, inst
,
461 "window.title.unfocus", theme
->app_unhilite_bg
,
463 set_default_appearance(theme
->app_unhilite_bg
);
464 if (!read_appearance(db
, inst
,
465 "window.label.unfocus", theme
->app_unhilite_label
,
467 set_default_appearance(theme
->app_unhilite_label
);
469 /* read buttons textures */
470 if (!read_appearance(db
, inst
,
471 "window.button.disabled.focus",
472 theme
->a_disabled_focused_max
,
474 set_default_appearance(theme
->a_disabled_focused_max
);
475 if (!read_appearance(db
, inst
,
476 "window.button.disabled.unfocus",
477 theme
->a_disabled_unfocused_max
,
479 set_default_appearance(theme
->a_disabled_unfocused_max
);
480 if (!read_appearance(db
, inst
,
481 "window.button.pressed.focus",
482 theme
->a_focused_pressed_max
,
484 set_default_appearance(theme
->a_focused_pressed_max
);
485 if (!read_appearance(db
, inst
,
486 "window.button.pressed.unfocus",
487 theme
->a_unfocused_pressed_max
,
489 set_default_appearance(theme
->a_unfocused_pressed_max
);
490 if (!read_appearance(db
, inst
,
491 "window.button.toggled.focus",
492 theme
->a_toggled_focused_max
,
494 theme
->a_toggled_focused_max
=
495 RrAppearanceCopy(theme
->a_focused_pressed_max
);
496 if (!read_appearance(db
, inst
,
497 "window.button.toggled.unfocus",
498 theme
->a_toggled_unfocused_max
,
500 theme
->a_toggled_unfocused_max
=
501 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
502 if (!read_appearance(db
, inst
,
503 "window.button.focus",
504 theme
->a_focused_unpressed_max
,
506 set_default_appearance(theme
->a_focused_unpressed_max
);
507 if (!read_appearance(db
, inst
,
508 "window.button.unfocus",
509 theme
->a_unfocused_unpressed_max
,
511 set_default_appearance(theme
->a_unfocused_unpressed_max
);
512 if (!read_appearance(db
, inst
,
513 "window.button.hover.focus",
514 theme
->a_hover_focused_max
,
516 theme
->a_hover_focused_max
=
517 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
518 if (!read_appearance(db
, inst
,
519 "window.button.hover.unfocus",
520 theme
->a_hover_unfocused_max
,
522 theme
->a_hover_unfocused_max
=
523 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
525 theme
->a_disabled_focused_close
=
526 RrAppearanceCopy(theme
->a_disabled_focused_max
);
527 theme
->a_disabled_unfocused_close
=
528 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
529 theme
->a_hover_focused_close
=
530 RrAppearanceCopy(theme
->a_hover_focused_max
);
531 theme
->a_hover_unfocused_close
=
532 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
533 theme
->a_unfocused_unpressed_close
=
534 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
535 theme
->a_unfocused_pressed_close
=
536 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
537 theme
->a_focused_unpressed_close
=
538 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
539 theme
->a_focused_pressed_close
=
540 RrAppearanceCopy(theme
->a_focused_pressed_max
);
541 theme
->a_disabled_focused_desk
=
542 RrAppearanceCopy(theme
->a_disabled_focused_max
);
543 theme
->a_disabled_unfocused_desk
=
544 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
545 theme
->a_hover_focused_desk
=
546 RrAppearanceCopy(theme
->a_hover_focused_max
);
547 theme
->a_hover_unfocused_desk
=
548 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
549 theme
->a_toggled_focused_desk
=
550 RrAppearanceCopy(theme
->a_toggled_focused_max
);
551 theme
->a_toggled_unfocused_desk
=
552 RrAppearanceCopy(theme
->a_toggled_unfocused_max
);
553 theme
->a_unfocused_unpressed_desk
=
554 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
555 theme
->a_unfocused_pressed_desk
=
556 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
557 theme
->a_focused_unpressed_desk
=
558 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
559 theme
->a_focused_pressed_desk
=
560 RrAppearanceCopy(theme
->a_focused_pressed_max
);
561 theme
->a_disabled_focused_shade
=
562 RrAppearanceCopy(theme
->a_disabled_focused_max
);
563 theme
->a_disabled_unfocused_shade
=
564 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
565 theme
->a_hover_focused_shade
=
566 RrAppearanceCopy(theme
->a_hover_focused_max
);
567 theme
->a_hover_unfocused_shade
=
568 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
569 theme
->a_toggled_focused_shade
=
570 RrAppearanceCopy(theme
->a_toggled_focused_max
);
571 theme
->a_toggled_unfocused_shade
=
572 RrAppearanceCopy(theme
->a_toggled_unfocused_max
);
573 theme
->a_unfocused_unpressed_shade
=
574 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
575 theme
->a_unfocused_pressed_shade
=
576 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
577 theme
->a_focused_unpressed_shade
=
578 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
579 theme
->a_focused_pressed_shade
=
580 RrAppearanceCopy(theme
->a_focused_pressed_max
);
581 theme
->a_disabled_focused_iconify
=
582 RrAppearanceCopy(theme
->a_disabled_focused_max
);
583 theme
->a_disabled_unfocused_iconify
=
584 RrAppearanceCopy(theme
->a_disabled_focused_max
);
585 theme
->a_hover_focused_iconify
=
586 RrAppearanceCopy(theme
->a_hover_focused_max
);
587 theme
->a_hover_unfocused_iconify
=
588 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
589 theme
->a_unfocused_unpressed_iconify
=
590 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
591 theme
->a_unfocused_pressed_iconify
=
592 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
593 theme
->a_focused_unpressed_iconify
=
594 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
595 theme
->a_focused_pressed_iconify
=
596 RrAppearanceCopy(theme
->a_focused_pressed_max
);
598 theme
->a_icon
->surface
.grad
= RR_SURFACE_PARENTREL
;
599 theme
->a_clear
->surface
.grad
= RR_SURFACE_PARENTREL
;
601 /* set up the textures */
602 theme
->a_focused_label
->texture
[0].type
=
603 theme
->app_hilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
604 theme
->a_focused_label
->texture
[0].data
.text
.justify
= winjust
;
605 theme
->app_hilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
606 theme
->a_focused_label
->texture
[0].data
.text
.font
=
607 theme
->app_hilite_label
->texture
[0].data
.text
.font
= theme
->winfont
;
608 theme
->a_focused_label
->texture
[0].data
.text
.color
=
609 theme
->app_hilite_label
->texture
[0].data
.text
.color
=
610 theme
->title_focused_color
;
612 theme
->a_unfocused_label
->texture
[0].type
=
613 theme
->app_unhilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
614 theme
->a_unfocused_label
->texture
[0].data
.text
.justify
= winjust
;
615 theme
->app_unhilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
616 theme
->a_unfocused_label
->texture
[0].data
.text
.font
=
617 theme
->app_unhilite_label
->texture
[0].data
.text
.font
= theme
->winfont
;
618 theme
->a_unfocused_label
->texture
[0].data
.text
.color
=
619 theme
->app_unhilite_label
->texture
[0].data
.text
.color
=
620 theme
->title_unfocused_color
;
622 theme
->a_menu_title
->texture
[0].type
= RR_TEXTURE_TEXT
;
623 theme
->a_menu_title
->texture
[0].data
.text
.justify
= mtitlejust
;
624 theme
->a_menu_title
->texture
[0].data
.text
.font
= theme
->mtitlefont
;
625 theme
->a_menu_title
->texture
[0].data
.text
.color
= theme
->menu_title_color
;
627 theme
->a_menu_item
->surface
.grad
=
628 theme
->a_menu_disabled
->surface
.grad
=
629 theme
->a_menu_bullet
->surface
.grad
=
630 theme
->app_icon
->surface
.grad
= RR_SURFACE_PARENTREL
;
632 theme
->a_menu_item
->texture
[0].type
=
633 theme
->a_menu_disabled
->texture
[0].type
=
634 theme
->a_menu_hilite
->texture
[0].type
= RR_TEXTURE_TEXT
;
635 theme
->a_menu_item
->texture
[0].data
.text
.justify
=
636 theme
->a_menu_disabled
->texture
[0].data
.text
.justify
=
637 theme
->a_menu_hilite
->texture
[0].data
.text
.justify
= mjust
;
638 theme
->a_menu_item
->texture
[0].data
.text
.font
=
639 theme
->a_menu_disabled
->texture
[0].data
.text
.font
=
640 theme
->a_menu_hilite
->texture
[0].data
.text
.font
= theme
->mfont
;
641 theme
->a_menu_item
->texture
[0].data
.text
.color
= theme
->menu_color
;
642 theme
->a_menu_disabled
->texture
[0].data
.text
.color
=
643 theme
->menu_disabled_color
;
644 theme
->a_menu_hilite
->texture
[0].data
.text
.color
=
645 theme
->menu_hilite_color
;
646 theme
->a_menu_bullet
->texture
[0].data
.mask
.color
=
647 theme
->menu_bullet_color
;
649 theme
->a_disabled_focused_max
->texture
[0].type
=
650 theme
->a_disabled_unfocused_max
->texture
[0].type
=
651 theme
->a_hover_focused_max
->texture
[0].type
=
652 theme
->a_hover_unfocused_max
->texture
[0].type
=
653 theme
->a_toggled_focused_max
->texture
[0].type
=
654 theme
->a_toggled_unfocused_max
->texture
[0].type
=
655 theme
->a_focused_unpressed_max
->texture
[0].type
=
656 theme
->a_focused_pressed_max
->texture
[0].type
=
657 theme
->a_unfocused_unpressed_max
->texture
[0].type
=
658 theme
->a_unfocused_pressed_max
->texture
[0].type
=
659 theme
->a_disabled_focused_close
->texture
[0].type
=
660 theme
->a_disabled_unfocused_close
->texture
[0].type
=
661 theme
->a_hover_focused_close
->texture
[0].type
=
662 theme
->a_hover_unfocused_close
->texture
[0].type
=
663 theme
->a_focused_unpressed_close
->texture
[0].type
=
664 theme
->a_focused_pressed_close
->texture
[0].type
=
665 theme
->a_unfocused_unpressed_close
->texture
[0].type
=
666 theme
->a_unfocused_pressed_close
->texture
[0].type
=
667 theme
->a_disabled_focused_desk
->texture
[0].type
=
668 theme
->a_disabled_unfocused_desk
->texture
[0].type
=
669 theme
->a_hover_focused_desk
->texture
[0].type
=
670 theme
->a_hover_unfocused_desk
->texture
[0].type
=
671 theme
->a_toggled_focused_desk
->texture
[0].type
=
672 theme
->a_toggled_unfocused_desk
->texture
[0].type
=
673 theme
->a_focused_unpressed_desk
->texture
[0].type
=
674 theme
->a_focused_pressed_desk
->texture
[0].type
=
675 theme
->a_unfocused_unpressed_desk
->texture
[0].type
=
676 theme
->a_unfocused_pressed_desk
->texture
[0].type
=
677 theme
->a_disabled_focused_shade
->texture
[0].type
=
678 theme
->a_disabled_unfocused_shade
->texture
[0].type
=
679 theme
->a_hover_focused_shade
->texture
[0].type
=
680 theme
->a_hover_unfocused_shade
->texture
[0].type
=
681 theme
->a_toggled_focused_shade
->texture
[0].type
=
682 theme
->a_toggled_unfocused_shade
->texture
[0].type
=
683 theme
->a_focused_unpressed_shade
->texture
[0].type
=
684 theme
->a_focused_pressed_shade
->texture
[0].type
=
685 theme
->a_unfocused_unpressed_shade
->texture
[0].type
=
686 theme
->a_unfocused_pressed_shade
->texture
[0].type
=
687 theme
->a_disabled_focused_iconify
->texture
[0].type
=
688 theme
->a_disabled_unfocused_iconify
->texture
[0].type
=
689 theme
->a_hover_focused_iconify
->texture
[0].type
=
690 theme
->a_hover_unfocused_iconify
->texture
[0].type
=
691 theme
->a_focused_unpressed_iconify
->texture
[0].type
=
692 theme
->a_focused_pressed_iconify
->texture
[0].type
=
693 theme
->a_unfocused_unpressed_iconify
->texture
[0].type
=
694 theme
->a_unfocused_pressed_iconify
->texture
[0].type
=
695 theme
->a_menu_bullet
->texture
[0].type
= RR_TEXTURE_MASK
;
697 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.mask
=
698 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.mask
=
699 theme
->max_disabled_mask
;
700 theme
->a_hover_focused_max
->texture
[0].data
.mask
.mask
=
701 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.mask
=
702 theme
->max_hover_mask
;
703 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.mask
=
704 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.mask
=
705 theme
->max_pressed_mask
;
706 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.mask
=
707 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.mask
=
709 theme
->a_toggled_focused_max
->texture
[0].data
.mask
.mask
=
710 theme
->a_toggled_unfocused_max
->texture
[0].data
.mask
.mask
=
711 theme
->max_toggled_mask
;
712 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.mask
=
713 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.mask
=
714 theme
->close_disabled_mask
;
715 theme
->a_hover_focused_close
->texture
[0].data
.mask
.mask
=
716 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.mask
=
717 theme
->close_hover_mask
;
718 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.mask
=
719 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.mask
=
720 theme
->close_pressed_mask
;
721 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.mask
=
722 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.mask
=
724 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.mask
=
725 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.mask
=
726 theme
->desk_disabled_mask
;
727 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.mask
=
728 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.mask
=
729 theme
->desk_hover_mask
;
730 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.mask
=
731 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.mask
=
732 theme
->desk_pressed_mask
;
733 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.mask
=
734 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.mask
=
736 theme
->a_toggled_focused_desk
->texture
[0].data
.mask
.mask
=
737 theme
->a_toggled_unfocused_desk
->texture
[0].data
.mask
.mask
=
738 theme
->desk_toggled_mask
;
739 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.mask
=
740 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.mask
=
741 theme
->shade_disabled_mask
;
742 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.mask
=
743 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.mask
=
744 theme
->shade_hover_mask
;
745 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.mask
=
746 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.mask
=
747 theme
->shade_pressed_mask
;
748 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.mask
=
749 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.mask
=
751 theme
->a_toggled_focused_shade
->texture
[0].data
.mask
.mask
=
752 theme
->a_toggled_unfocused_shade
->texture
[0].data
.mask
.mask
=
753 theme
->shade_toggled_mask
;
754 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.mask
=
755 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.mask
=
756 theme
->iconify_disabled_mask
;
757 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.mask
=
758 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.mask
=
759 theme
->iconify_hover_mask
;
760 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.mask
=
761 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.mask
=
762 theme
->iconify_pressed_mask
;
763 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
764 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
766 theme
->a_menu_bullet
->texture
[0].data
.mask
.mask
=
767 theme
->menu_bullet_mask
;
768 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.color
=
769 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.color
=
770 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.color
=
771 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.color
=
772 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.color
=
773 theme
->titlebut_disabled_focused_color
;
774 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.color
=
775 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.color
=
776 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.color
=
777 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.color
=
778 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.color
=
779 theme
->titlebut_disabled_unfocused_color
;
780 theme
->a_hover_focused_max
->texture
[0].data
.mask
.color
=
781 theme
->a_hover_focused_close
->texture
[0].data
.mask
.color
=
782 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.color
=
783 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.color
=
784 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.color
=
785 theme
->titlebut_hover_focused_color
;
786 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.color
=
787 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.color
=
788 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.color
=
789 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.color
=
790 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.color
=
791 theme
->titlebut_hover_unfocused_color
;
792 theme
->a_toggled_focused_max
->texture
[0].data
.mask
.color
=
793 theme
->a_toggled_focused_desk
->texture
[0].data
.mask
.color
=
794 theme
->a_toggled_focused_shade
->texture
[0].data
.mask
.color
=
795 theme
->titlebut_toggled_focused_color
;
796 theme
->a_toggled_unfocused_max
->texture
[0].data
.mask
.color
=
797 theme
->a_toggled_unfocused_desk
->texture
[0].data
.mask
.color
=
798 theme
->a_toggled_unfocused_shade
->texture
[0].data
.mask
.color
=
799 theme
->titlebut_toggled_unfocused_color
;
800 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.color
=
801 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.color
=
802 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.color
=
803 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.color
=
804 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.color
=
805 theme
->titlebut_focused_unpressed_color
;
806 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.color
=
807 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.color
=
808 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.color
=
809 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.color
=
810 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.color
=
811 theme
->titlebut_focused_pressed_color
;
812 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.color
=
813 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.color
=
814 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.color
=
815 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.color
=
816 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.color
=
817 theme
->titlebut_unfocused_unpressed_color
;
818 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.color
=
819 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.color
=
820 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.color
=
821 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.color
=
822 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.color
=
823 theme
->titlebut_unfocused_pressed_color
;
824 theme
->a_menu_bullet
->texture
[0].data
.mask
.color
=
825 theme
->menu_bullet_color
;
827 XrmDestroyDatabase(db
);
829 theme
->label_height
= theme
->winfont_height
;
830 theme
->title_height
= theme
->label_height
+ theme
->bevel
* 2;
831 theme
->button_size
= theme
->label_height
- 2;
832 theme
->grip_width
= theme
->button_size
* 2;
837 void RrThemeFree(RrTheme
*theme
)
842 RrColorFree(theme
->b_color
);
843 RrColorFree(theme
->cb_unfocused_color
);
844 RrColorFree(theme
->cb_focused_color
);
845 RrColorFree(theme
->title_unfocused_color
);
846 RrColorFree(theme
->title_focused_color
);
847 RrColorFree(theme
->titlebut_disabled_focused_color
);
848 RrColorFree(theme
->titlebut_disabled_unfocused_color
);
849 RrColorFree(theme
->titlebut_hover_focused_color
);
850 RrColorFree(theme
->titlebut_hover_unfocused_color
);
851 RrColorFree(theme
->titlebut_toggled_focused_color
);
852 RrColorFree(theme
->titlebut_toggled_unfocused_color
);
853 RrColorFree(theme
->titlebut_unfocused_pressed_color
);
854 RrColorFree(theme
->titlebut_focused_pressed_color
);
855 RrColorFree(theme
->titlebut_unfocused_unpressed_color
);
856 RrColorFree(theme
->titlebut_focused_unpressed_color
);
857 RrColorFree(theme
->menu_color
);
858 RrColorFree(theme
->menu_title_color
);
859 RrColorFree(theme
->menu_disabled_color
);
860 RrColorFree(theme
->menu_hilite_color
);
862 RrPixmapMaskFree(theme
->max_mask
);
863 RrPixmapMaskFree(theme
->max_toggled_mask
);
864 RrPixmapMaskFree(theme
->max_disabled_mask
);
865 RrPixmapMaskFree(theme
->max_hover_mask
);
866 RrPixmapMaskFree(theme
->max_pressed_mask
);
867 RrPixmapMaskFree(theme
->desk_mask
);
868 RrPixmapMaskFree(theme
->desk_toggled_mask
);
869 RrPixmapMaskFree(theme
->desk_disabled_mask
);
870 RrPixmapMaskFree(theme
->desk_hover_mask
);
871 RrPixmapMaskFree(theme
->desk_pressed_mask
);
872 RrPixmapMaskFree(theme
->shade_mask
);
873 RrPixmapMaskFree(theme
->shade_toggled_mask
);
874 RrPixmapMaskFree(theme
->shade_disabled_mask
);
875 RrPixmapMaskFree(theme
->shade_hover_mask
);
876 RrPixmapMaskFree(theme
->shade_pressed_mask
);
877 RrPixmapMaskFree(theme
->iconify_mask
);
878 RrPixmapMaskFree(theme
->iconify_disabled_mask
);
879 RrPixmapMaskFree(theme
->iconify_hover_mask
);
880 RrPixmapMaskFree(theme
->iconify_pressed_mask
);
881 RrPixmapMaskFree(theme
->close_mask
);
882 RrPixmapMaskFree(theme
->close_disabled_mask
);
883 RrPixmapMaskFree(theme
->close_hover_mask
);
884 RrPixmapMaskFree(theme
->close_pressed_mask
);
885 RrPixmapMaskFree(theme
->menu_bullet_mask
);
887 RrFontClose(theme
->winfont
);
888 RrFontClose(theme
->mtitlefont
);
889 RrFontClose(theme
->mfont
);
891 RrAppearanceFree(theme
->a_disabled_focused_max
);
892 RrAppearanceFree(theme
->a_disabled_unfocused_max
);
893 RrAppearanceFree(theme
->a_hover_focused_max
);
894 RrAppearanceFree(theme
->a_hover_unfocused_max
);
895 RrAppearanceFree(theme
->a_toggled_focused_max
);
896 RrAppearanceFree(theme
->a_toggled_unfocused_max
);
897 RrAppearanceFree(theme
->a_focused_unpressed_max
);
898 RrAppearanceFree(theme
->a_focused_pressed_max
);
899 RrAppearanceFree(theme
->a_unfocused_unpressed_max
);
900 RrAppearanceFree(theme
->a_unfocused_pressed_max
);
901 RrAppearanceFree(theme
->a_disabled_focused_close
);
902 RrAppearanceFree(theme
->a_disabled_unfocused_close
);
903 RrAppearanceFree(theme
->a_hover_focused_close
);
904 RrAppearanceFree(theme
->a_hover_unfocused_close
);
905 RrAppearanceFree(theme
->a_focused_unpressed_close
);
906 RrAppearanceFree(theme
->a_focused_pressed_close
);
907 RrAppearanceFree(theme
->a_unfocused_unpressed_close
);
908 RrAppearanceFree(theme
->a_unfocused_pressed_close
);
909 RrAppearanceFree(theme
->a_disabled_focused_desk
);
910 RrAppearanceFree(theme
->a_disabled_unfocused_desk
);
911 RrAppearanceFree(theme
->a_hover_focused_desk
);
912 RrAppearanceFree(theme
->a_hover_unfocused_desk
);
913 RrAppearanceFree(theme
->a_toggled_focused_desk
);
914 RrAppearanceFree(theme
->a_toggled_unfocused_desk
);
915 RrAppearanceFree(theme
->a_focused_unpressed_desk
);
916 RrAppearanceFree(theme
->a_focused_pressed_desk
);
917 RrAppearanceFree(theme
->a_unfocused_unpressed_desk
);
918 RrAppearanceFree(theme
->a_unfocused_pressed_desk
);
919 RrAppearanceFree(theme
->a_disabled_focused_shade
);
920 RrAppearanceFree(theme
->a_disabled_unfocused_shade
);
921 RrAppearanceFree(theme
->a_hover_focused_shade
);
922 RrAppearanceFree(theme
->a_hover_unfocused_shade
);
923 RrAppearanceFree(theme
->a_toggled_focused_shade
);
924 RrAppearanceFree(theme
->a_toggled_unfocused_shade
);
925 RrAppearanceFree(theme
->a_focused_unpressed_shade
);
926 RrAppearanceFree(theme
->a_focused_pressed_shade
);
927 RrAppearanceFree(theme
->a_unfocused_unpressed_shade
);
928 RrAppearanceFree(theme
->a_unfocused_pressed_shade
);
929 RrAppearanceFree(theme
->a_disabled_focused_iconify
);
930 RrAppearanceFree(theme
->a_disabled_unfocused_iconify
);
931 RrAppearanceFree(theme
->a_hover_focused_iconify
);
932 RrAppearanceFree(theme
->a_hover_unfocused_iconify
);
933 RrAppearanceFree(theme
->a_focused_unpressed_iconify
);
934 RrAppearanceFree(theme
->a_focused_pressed_iconify
);
935 RrAppearanceFree(theme
->a_unfocused_unpressed_iconify
);
936 RrAppearanceFree(theme
->a_unfocused_pressed_iconify
);
937 RrAppearanceFree(theme
->a_focused_grip
);
938 RrAppearanceFree(theme
->a_unfocused_grip
);
939 RrAppearanceFree(theme
->a_focused_title
);
940 RrAppearanceFree(theme
->a_unfocused_title
);
941 RrAppearanceFree(theme
->a_focused_label
);
942 RrAppearanceFree(theme
->a_unfocused_label
);
943 RrAppearanceFree(theme
->a_icon
);
944 RrAppearanceFree(theme
->a_focused_handle
);
945 RrAppearanceFree(theme
->a_unfocused_handle
);
946 RrAppearanceFree(theme
->a_menu
);
947 RrAppearanceFree(theme
->a_menu_title
);
948 RrAppearanceFree(theme
->a_menu_item
);
949 RrAppearanceFree(theme
->a_menu_disabled
);
950 RrAppearanceFree(theme
->a_menu_hilite
);
951 RrAppearanceFree(theme
->a_clear
);
952 RrAppearanceFree(theme
->app_hilite_bg
);
953 RrAppearanceFree(theme
->app_unhilite_bg
);
954 RrAppearanceFree(theme
->app_hilite_label
);
955 RrAppearanceFree(theme
->app_unhilite_label
);
956 RrAppearanceFree(theme
->app_icon
);
960 static XrmDatabase
loaddb(RrTheme
*theme
, char *name
)
964 char *s
= g_build_filename(g_get_home_dir(), ".openbox", "themes",
965 name
, "themerc", NULL
);
966 if ((db
= XrmGetFileDatabase(s
)))
967 theme
->path
= g_path_get_dirname(s
);
970 char *s
= g_build_filename(THEMEDIR
, name
, "themerc", NULL
);
971 if ((db
= XrmGetFileDatabase(s
)))
972 theme
->path
= g_path_get_dirname(s
);
976 char *s
= g_build_filename(name
, "themerc", NULL
);
977 if ((db
= XrmGetFileDatabase(s
)))
978 theme
->path
= g_path_get_dirname(s
);
985 static char *create_class_name(char *rname
)
987 char *rclass
= g_strdup(rname
);
992 p
= strchr(p
+1, '.');
993 if (p
== NULL
) break;
995 if (*p
== '\0') break;
1000 static gboolean
read_int(XrmDatabase db
, char *rname
, int *value
)
1002 gboolean ret
= FALSE
;
1003 char *rclass
= create_class_name(rname
);
1004 char *rettype
, *end
;
1007 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1008 retvalue
.addr
!= NULL
) {
1009 *value
= (int)strtol(retvalue
.addr
, &end
, 10);
1010 if (end
!= retvalue
.addr
)
1018 static gboolean
read_string(XrmDatabase db
, char *rname
, char **value
)
1020 gboolean ret
= FALSE
;
1021 char *rclass
= create_class_name(rname
);
1025 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1026 retvalue
.addr
!= NULL
) {
1027 *value
= retvalue
.addr
;
1035 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
1036 gchar
*rname
, RrColor
**value
)
1038 gboolean ret
= FALSE
;
1039 char *rclass
= create_class_name(rname
);
1043 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1044 retvalue
.addr
!= NULL
) {
1045 RrColor
*c
= RrColorParse(inst
, retvalue
.addr
);
1056 static gboolean
read_mask(const RrInstance
*inst
,
1057 gchar
*maskname
, RrTheme
*theme
,
1058 RrPixmapMask
**value
)
1060 gboolean ret
= FALSE
;
1062 int hx
, hy
; /* ignored */
1066 s
= g_build_filename(theme
->path
, maskname
, NULL
);
1067 if (XReadBitmapFileData(s
, &w
, &h
, &b
, &hx
, &hy
) == BitmapSuccess
) {
1069 *value
= RrPixmapMaskNew(inst
, w
, h
, (char*)b
);
1077 static void parse_appearance(gchar
*tex
, RrSurfaceColorType
*grad
,
1078 RrReliefType
*relief
, RrBevelType
*bevel
,
1079 gboolean
*interlaced
, gboolean
*border
,
1080 gboolean allow_trans
)
1084 /* convert to all lowercase */
1085 for (t
= tex
; *t
!= '\0'; ++t
)
1086 *t
= g_ascii_tolower(*t
);
1088 if (allow_trans
&& strstr(tex
, "parentrelative") != NULL
) {
1089 *grad
= RR_SURFACE_PARENTREL
;
1091 if (strstr(tex
, "gradient") != NULL
) {
1092 if (strstr(tex
, "crossdiagonal") != NULL
)
1093 *grad
= RR_SURFACE_CROSS_DIAGONAL
;
1094 else if (strstr(tex
, "pyramid") != NULL
)
1095 *grad
= RR_SURFACE_PYRAMID
;
1096 else if (strstr(tex
, "horizontal") != NULL
)
1097 *grad
= RR_SURFACE_HORIZONTAL
;
1098 else if (strstr(tex
, "vertical") != NULL
)
1099 *grad
= RR_SURFACE_VERTICAL
;
1101 *grad
= RR_SURFACE_DIAGONAL
;
1103 *grad
= RR_SURFACE_SOLID
;
1106 if (strstr(tex
, "sunken") != NULL
)
1107 *relief
= RR_RELIEF_SUNKEN
;
1108 else if (strstr(tex
, "flat") != NULL
)
1109 *relief
= RR_RELIEF_FLAT
;
1111 *relief
= RR_RELIEF_RAISED
;
1114 if (*relief
== RR_RELIEF_FLAT
) {
1115 if (strstr(tex
, "border") != NULL
)
1118 if (strstr(tex
, "bevel2") != NULL
)
1119 *bevel
= RR_BEVEL_2
;
1121 *bevel
= RR_BEVEL_1
;
1124 if (strstr(tex
, "interlaced") != NULL
)
1127 *interlaced
= FALSE
;
1132 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
1133 gchar
*rname
, RrAppearance
*value
,
1134 gboolean allow_trans
)
1136 gboolean ret
= FALSE
;
1137 char *rclass
= create_class_name(rname
), *cname
, *ctoname
, *bcname
;
1141 cname
= g_strconcat(rname
, ".color", NULL
);
1142 ctoname
= g_strconcat(rname
, ".colorTo", NULL
);
1143 bcname
= g_strconcat(rname
, ".borderColor", NULL
);
1145 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1146 retvalue
.addr
!= NULL
) {
1147 parse_appearance(retvalue
.addr
,
1148 &value
->surface
.grad
,
1149 &value
->surface
.relief
,
1150 &value
->surface
.bevel
,
1151 &value
->surface
.interlaced
,
1152 &value
->surface
.border
,
1154 if (!read_color(db
, inst
, cname
, &value
->surface
.primary
))
1155 value
->surface
.primary
= RrColorNew(inst
, 0, 0, 0);
1156 if (!read_color(db
, inst
, ctoname
, &value
->surface
.secondary
))
1157 value
->surface
.secondary
= RrColorNew(inst
, 0, 0, 0);
1158 if (value
->surface
.border
)
1159 if (!read_color(db
, inst
, bcname
,
1160 &value
->surface
.border_color
))
1161 value
->surface
.border_color
= RrColorNew(inst
, 0, 0, 0);
1172 static void set_default_appearance(RrAppearance
*a
)
1174 a
->surface
.grad
= RR_SURFACE_SOLID
;
1175 a
->surface
.relief
= RR_RELIEF_FLAT
;
1176 a
->surface
.bevel
= RR_BEVEL_1
;
1177 a
->surface
.interlaced
= FALSE
;
1178 a
->surface
.border
= FALSE
;
1179 a
->surface
.primary
= RrColorNew(a
->inst
, 0, 0, 0);
1180 a
->surface
.secondary
= RrColorNew(a
->inst
, 0, 0, 0);