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 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
277 theme
->max_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
280 guchar data
[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
281 theme
->max_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)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 guchar data
[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
306 theme
->iconify_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)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 guchar data
[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
334 theme
->desk_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
337 guchar data
[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
338 theme
->desk_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7,
341 theme
->desk_pressed_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
342 theme
->desk_disabled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
343 theme
->desk_hover_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
346 if (read_mask(inst
, "shade.xbm", theme
, &theme
->shade_mask
)) {
347 if (!read_mask(inst
, "shade_pressed.xbm", theme
,
348 &theme
->shade_pressed_mask
)) {
349 theme
->shade_pressed_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
351 if (!read_mask(inst
, "shade_toggled.xbm", theme
,
352 &theme
->shade_toggled_mask
)) {
353 theme
->shade_toggled_mask
=
354 RrPixmapMaskCopy(theme
->shade_pressed_mask
);
356 if (!read_mask(inst
, "shade_disabled.xbm", theme
,
357 &theme
->shade_disabled_mask
)) {
358 theme
->shade_disabled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
360 if (!read_mask(inst
, "shade_hover.xbm", theme
,
361 &theme
->shade_hover_mask
)) {
362 theme
->shade_hover_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
366 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
367 theme
->shade_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
370 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
371 theme
->shade_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7,
374 theme
->shade_pressed_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
375 theme
->shade_disabled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
376 theme
->shade_hover_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
379 if (read_mask(inst
, "close.xbm", theme
, &theme
->close_mask
)) {
380 if (!read_mask(inst
, "close_pressed.xbm", theme
,
381 &theme
->close_pressed_mask
)) {
382 theme
->close_pressed_mask
= RrPixmapMaskCopy(theme
->close_mask
);
384 if (!read_mask(inst
, "close_disabled.xbm", theme
,
385 &theme
->close_disabled_mask
)) {
386 theme
->close_disabled_mask
= RrPixmapMaskCopy(theme
->close_mask
);
388 if (!read_mask(inst
, "close_hover.xbm", theme
,
389 &theme
->close_hover_mask
)) {
390 theme
->close_hover_mask
= RrPixmapMaskCopy(theme
->close_mask
);
394 guchar data
[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
395 theme
->close_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
397 theme
->close_pressed_mask
= RrPixmapMaskCopy(theme
->close_mask
);
398 theme
->close_disabled_mask
= RrPixmapMaskCopy(theme
->close_mask
);
399 theme
->close_hover_mask
= RrPixmapMaskCopy(theme
->close_mask
);
402 if (!read_mask(inst
, "bullet.xbm", theme
, &theme
->menu_bullet_mask
)) {
403 guchar data
[] = { 0x18, 0x30, 0x60, 0xfe, 0xfe, 0x60, 0x30, 0x18 };
404 theme
->menu_bullet_mask
= RrPixmapMaskNew(inst
, 8, 8, (char*)data
);
407 /* read the decoration textures */
408 if (!read_appearance(db
, inst
,
409 "window.title.focus", theme
->a_focused_title
,
411 set_default_appearance(theme
->a_focused_title
);
412 if (!read_appearance(db
, inst
,
413 "window.title.unfocus", theme
->a_unfocused_title
,
415 set_default_appearance(theme
->a_unfocused_title
);
416 if (!read_appearance(db
, inst
,
417 "window.label.focus", theme
->a_focused_label
,
419 set_default_appearance(theme
->a_focused_label
);
420 if (!read_appearance(db
, inst
,
421 "window.label.unfocus", theme
->a_unfocused_label
,
423 set_default_appearance(theme
->a_unfocused_label
);
424 if (!read_appearance(db
, inst
,
425 "window.handle.focus", theme
->a_focused_handle
,
427 set_default_appearance(theme
->a_focused_handle
);
428 if (!read_appearance(db
, inst
,
429 "window.handle.unfocus",theme
->a_unfocused_handle
,
431 set_default_appearance(theme
->a_unfocused_handle
);
432 if (!read_appearance(db
, inst
,
433 "window.grip.focus", theme
->a_focused_grip
,
435 set_default_appearance(theme
->a_focused_grip
);
436 if (!read_appearance(db
, inst
,
437 "window.grip.unfocus", theme
->a_unfocused_grip
,
439 set_default_appearance(theme
->a_unfocused_grip
);
440 if (!read_appearance(db
, inst
,
441 "menu.frame", theme
->a_menu
,
443 set_default_appearance(theme
->a_menu
);
444 if (!read_appearance(db
, inst
,
445 "menu.title", theme
->a_menu_title
,
447 set_default_appearance(theme
->a_menu_title
);
448 if (!read_appearance(db
, inst
,
449 "menu.hilite", theme
->a_menu_hilite
,
451 set_default_appearance(theme
->a_menu_hilite
);
453 /* read the appearances for rendering non-decorations */
454 if (!read_appearance(db
, inst
,
455 "window.title.focus", theme
->app_hilite_bg
,
457 set_default_appearance(theme
->app_hilite_bg
);
458 if (!read_appearance(db
, inst
,
459 "window.label.focus", theme
->app_hilite_label
,
461 set_default_appearance(theme
->app_hilite_label
);
462 if (!read_appearance(db
, inst
,
463 "window.title.unfocus", theme
->app_unhilite_bg
,
465 set_default_appearance(theme
->app_unhilite_bg
);
466 if (!read_appearance(db
, inst
,
467 "window.label.unfocus", theme
->app_unhilite_label
,
469 set_default_appearance(theme
->app_unhilite_label
);
471 /* read buttons textures */
472 if (!read_appearance(db
, inst
,
473 "window.button.disabled.focus",
474 theme
->a_disabled_focused_max
,
476 set_default_appearance(theme
->a_disabled_focused_max
);
477 if (!read_appearance(db
, inst
,
478 "window.button.disabled.unfocus",
479 theme
->a_disabled_unfocused_max
,
481 set_default_appearance(theme
->a_disabled_unfocused_max
);
482 if (!read_appearance(db
, inst
,
483 "window.button.pressed.focus",
484 theme
->a_focused_pressed_max
,
486 set_default_appearance(theme
->a_focused_pressed_max
);
487 if (!read_appearance(db
, inst
,
488 "window.button.pressed.unfocus",
489 theme
->a_unfocused_pressed_max
,
491 set_default_appearance(theme
->a_unfocused_pressed_max
);
492 if (!read_appearance(db
, inst
,
493 "window.button.toggled.focus",
494 theme
->a_toggled_focused_max
,
496 theme
->a_toggled_focused_max
=
497 RrAppearanceCopy(theme
->a_focused_pressed_max
);
498 if (!read_appearance(db
, inst
,
499 "window.button.toggled.unfocus",
500 theme
->a_toggled_unfocused_max
,
502 theme
->a_toggled_unfocused_max
=
503 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
504 if (!read_appearance(db
, inst
,
505 "window.button.focus",
506 theme
->a_focused_unpressed_max
,
508 set_default_appearance(theme
->a_focused_unpressed_max
);
509 if (!read_appearance(db
, inst
,
510 "window.button.unfocus",
511 theme
->a_unfocused_unpressed_max
,
513 set_default_appearance(theme
->a_unfocused_unpressed_max
);
514 if (!read_appearance(db
, inst
,
515 "window.button.hover.focus",
516 theme
->a_hover_focused_max
,
518 theme
->a_hover_focused_max
=
519 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
520 if (!read_appearance(db
, inst
,
521 "window.button.hover.unfocus",
522 theme
->a_hover_unfocused_max
,
524 theme
->a_hover_unfocused_max
=
525 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
527 theme
->a_disabled_focused_close
=
528 RrAppearanceCopy(theme
->a_disabled_focused_max
);
529 theme
->a_disabled_unfocused_close
=
530 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
531 theme
->a_hover_focused_close
=
532 RrAppearanceCopy(theme
->a_hover_focused_max
);
533 theme
->a_hover_unfocused_close
=
534 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
535 theme
->a_unfocused_unpressed_close
=
536 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
537 theme
->a_unfocused_pressed_close
=
538 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
539 theme
->a_focused_unpressed_close
=
540 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
541 theme
->a_focused_pressed_close
=
542 RrAppearanceCopy(theme
->a_focused_pressed_max
);
543 theme
->a_disabled_focused_desk
=
544 RrAppearanceCopy(theme
->a_disabled_focused_max
);
545 theme
->a_disabled_unfocused_desk
=
546 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
547 theme
->a_hover_focused_desk
=
548 RrAppearanceCopy(theme
->a_hover_focused_max
);
549 theme
->a_hover_unfocused_desk
=
550 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
551 theme
->a_toggled_focused_desk
=
552 RrAppearanceCopy(theme
->a_toggled_focused_max
);
553 theme
->a_toggled_unfocused_desk
=
554 RrAppearanceCopy(theme
->a_toggled_unfocused_max
);
555 theme
->a_unfocused_unpressed_desk
=
556 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
557 theme
->a_unfocused_pressed_desk
=
558 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
559 theme
->a_focused_unpressed_desk
=
560 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
561 theme
->a_focused_pressed_desk
=
562 RrAppearanceCopy(theme
->a_focused_pressed_max
);
563 theme
->a_disabled_focused_shade
=
564 RrAppearanceCopy(theme
->a_disabled_focused_max
);
565 theme
->a_disabled_unfocused_shade
=
566 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
567 theme
->a_hover_focused_shade
=
568 RrAppearanceCopy(theme
->a_hover_focused_max
);
569 theme
->a_hover_unfocused_shade
=
570 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
571 theme
->a_toggled_focused_shade
=
572 RrAppearanceCopy(theme
->a_toggled_focused_max
);
573 theme
->a_toggled_unfocused_shade
=
574 RrAppearanceCopy(theme
->a_toggled_unfocused_max
);
575 theme
->a_unfocused_unpressed_shade
=
576 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
577 theme
->a_unfocused_pressed_shade
=
578 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
579 theme
->a_focused_unpressed_shade
=
580 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
581 theme
->a_focused_pressed_shade
=
582 RrAppearanceCopy(theme
->a_focused_pressed_max
);
583 theme
->a_disabled_focused_iconify
=
584 RrAppearanceCopy(theme
->a_disabled_focused_max
);
585 theme
->a_disabled_unfocused_iconify
=
586 RrAppearanceCopy(theme
->a_disabled_focused_max
);
587 theme
->a_hover_focused_iconify
=
588 RrAppearanceCopy(theme
->a_hover_focused_max
);
589 theme
->a_hover_unfocused_iconify
=
590 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
591 theme
->a_unfocused_unpressed_iconify
=
592 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
593 theme
->a_unfocused_pressed_iconify
=
594 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
595 theme
->a_focused_unpressed_iconify
=
596 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
597 theme
->a_focused_pressed_iconify
=
598 RrAppearanceCopy(theme
->a_focused_pressed_max
);
600 theme
->a_icon
->surface
.grad
= RR_SURFACE_PARENTREL
;
601 theme
->a_clear
->surface
.grad
= RR_SURFACE_PARENTREL
;
603 /* set up the textures */
604 theme
->a_focused_label
->texture
[0].type
=
605 theme
->app_hilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
606 theme
->a_focused_label
->texture
[0].data
.text
.justify
= winjust
;
607 theme
->app_hilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
608 theme
->a_focused_label
->texture
[0].data
.text
.font
=
609 theme
->app_hilite_label
->texture
[0].data
.text
.font
= theme
->winfont
;
610 theme
->a_focused_label
->texture
[0].data
.text
.color
=
611 theme
->app_hilite_label
->texture
[0].data
.text
.color
=
612 theme
->title_focused_color
;
614 theme
->a_unfocused_label
->texture
[0].type
=
615 theme
->app_unhilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
616 theme
->a_unfocused_label
->texture
[0].data
.text
.justify
= winjust
;
617 theme
->app_unhilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
618 theme
->a_unfocused_label
->texture
[0].data
.text
.font
=
619 theme
->app_unhilite_label
->texture
[0].data
.text
.font
= theme
->winfont
;
620 theme
->a_unfocused_label
->texture
[0].data
.text
.color
=
621 theme
->app_unhilite_label
->texture
[0].data
.text
.color
=
622 theme
->title_unfocused_color
;
624 theme
->a_menu_title
->texture
[0].type
= RR_TEXTURE_TEXT
;
625 theme
->a_menu_title
->texture
[0].data
.text
.justify
= mtitlejust
;
626 theme
->a_menu_title
->texture
[0].data
.text
.font
= theme
->mtitlefont
;
627 theme
->a_menu_title
->texture
[0].data
.text
.color
= theme
->menu_title_color
;
629 theme
->a_menu_item
->surface
.grad
=
630 theme
->a_menu_disabled
->surface
.grad
=
631 theme
->a_menu_bullet
->surface
.grad
=
632 theme
->app_icon
->surface
.grad
= RR_SURFACE_PARENTREL
;
634 theme
->a_menu_item
->texture
[0].type
=
635 theme
->a_menu_disabled
->texture
[0].type
=
636 theme
->a_menu_hilite
->texture
[0].type
= RR_TEXTURE_TEXT
;
637 theme
->a_menu_item
->texture
[0].data
.text
.justify
=
638 theme
->a_menu_disabled
->texture
[0].data
.text
.justify
=
639 theme
->a_menu_hilite
->texture
[0].data
.text
.justify
= mjust
;
640 theme
->a_menu_item
->texture
[0].data
.text
.font
=
641 theme
->a_menu_disabled
->texture
[0].data
.text
.font
=
642 theme
->a_menu_hilite
->texture
[0].data
.text
.font
= theme
->mfont
;
643 theme
->a_menu_item
->texture
[0].data
.text
.color
= theme
->menu_color
;
644 theme
->a_menu_disabled
->texture
[0].data
.text
.color
=
645 theme
->menu_disabled_color
;
646 theme
->a_menu_hilite
->texture
[0].data
.text
.color
=
647 theme
->menu_hilite_color
;
648 theme
->a_menu_bullet
->texture
[0].data
.mask
.color
=
649 theme
->menu_bullet_color
;
651 theme
->a_disabled_focused_max
->texture
[0].type
=
652 theme
->a_disabled_unfocused_max
->texture
[0].type
=
653 theme
->a_hover_focused_max
->texture
[0].type
=
654 theme
->a_hover_unfocused_max
->texture
[0].type
=
655 theme
->a_toggled_focused_max
->texture
[0].type
=
656 theme
->a_toggled_unfocused_max
->texture
[0].type
=
657 theme
->a_focused_unpressed_max
->texture
[0].type
=
658 theme
->a_focused_pressed_max
->texture
[0].type
=
659 theme
->a_unfocused_unpressed_max
->texture
[0].type
=
660 theme
->a_unfocused_pressed_max
->texture
[0].type
=
661 theme
->a_disabled_focused_close
->texture
[0].type
=
662 theme
->a_disabled_unfocused_close
->texture
[0].type
=
663 theme
->a_hover_focused_close
->texture
[0].type
=
664 theme
->a_hover_unfocused_close
->texture
[0].type
=
665 theme
->a_focused_unpressed_close
->texture
[0].type
=
666 theme
->a_focused_pressed_close
->texture
[0].type
=
667 theme
->a_unfocused_unpressed_close
->texture
[0].type
=
668 theme
->a_unfocused_pressed_close
->texture
[0].type
=
669 theme
->a_disabled_focused_desk
->texture
[0].type
=
670 theme
->a_disabled_unfocused_desk
->texture
[0].type
=
671 theme
->a_hover_focused_desk
->texture
[0].type
=
672 theme
->a_hover_unfocused_desk
->texture
[0].type
=
673 theme
->a_toggled_focused_desk
->texture
[0].type
=
674 theme
->a_toggled_unfocused_desk
->texture
[0].type
=
675 theme
->a_focused_unpressed_desk
->texture
[0].type
=
676 theme
->a_focused_pressed_desk
->texture
[0].type
=
677 theme
->a_unfocused_unpressed_desk
->texture
[0].type
=
678 theme
->a_unfocused_pressed_desk
->texture
[0].type
=
679 theme
->a_disabled_focused_shade
->texture
[0].type
=
680 theme
->a_disabled_unfocused_shade
->texture
[0].type
=
681 theme
->a_hover_focused_shade
->texture
[0].type
=
682 theme
->a_hover_unfocused_shade
->texture
[0].type
=
683 theme
->a_toggled_focused_shade
->texture
[0].type
=
684 theme
->a_toggled_unfocused_shade
->texture
[0].type
=
685 theme
->a_focused_unpressed_shade
->texture
[0].type
=
686 theme
->a_focused_pressed_shade
->texture
[0].type
=
687 theme
->a_unfocused_unpressed_shade
->texture
[0].type
=
688 theme
->a_unfocused_pressed_shade
->texture
[0].type
=
689 theme
->a_disabled_focused_iconify
->texture
[0].type
=
690 theme
->a_disabled_unfocused_iconify
->texture
[0].type
=
691 theme
->a_hover_focused_iconify
->texture
[0].type
=
692 theme
->a_hover_unfocused_iconify
->texture
[0].type
=
693 theme
->a_focused_unpressed_iconify
->texture
[0].type
=
694 theme
->a_focused_pressed_iconify
->texture
[0].type
=
695 theme
->a_unfocused_unpressed_iconify
->texture
[0].type
=
696 theme
->a_unfocused_pressed_iconify
->texture
[0].type
=
697 theme
->a_menu_bullet
->texture
[0].type
= RR_TEXTURE_MASK
;
699 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.mask
=
700 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.mask
=
701 theme
->max_disabled_mask
;
702 theme
->a_hover_focused_max
->texture
[0].data
.mask
.mask
=
703 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.mask
=
704 theme
->max_hover_mask
;
705 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.mask
=
706 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.mask
=
707 theme
->max_pressed_mask
;
708 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.mask
=
709 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.mask
=
711 theme
->a_toggled_focused_max
->texture
[0].data
.mask
.mask
=
712 theme
->a_toggled_unfocused_max
->texture
[0].data
.mask
.mask
=
713 theme
->max_toggled_mask
;
714 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.mask
=
715 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.mask
=
716 theme
->close_disabled_mask
;
717 theme
->a_hover_focused_close
->texture
[0].data
.mask
.mask
=
718 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.mask
=
719 theme
->close_hover_mask
;
720 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.mask
=
721 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.mask
=
722 theme
->close_pressed_mask
;
723 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.mask
=
724 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.mask
=
726 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.mask
=
727 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.mask
=
728 theme
->desk_disabled_mask
;
729 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.mask
=
730 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.mask
=
731 theme
->desk_hover_mask
;
732 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.mask
=
733 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.mask
=
734 theme
->desk_pressed_mask
;
735 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.mask
=
736 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.mask
=
738 theme
->a_toggled_focused_desk
->texture
[0].data
.mask
.mask
=
739 theme
->a_toggled_unfocused_desk
->texture
[0].data
.mask
.mask
=
740 theme
->desk_toggled_mask
;
741 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.mask
=
742 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.mask
=
743 theme
->shade_disabled_mask
;
744 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.mask
=
745 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.mask
=
746 theme
->shade_hover_mask
;
747 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.mask
=
748 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.mask
=
749 theme
->shade_pressed_mask
;
750 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.mask
=
751 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.mask
=
753 theme
->a_toggled_focused_shade
->texture
[0].data
.mask
.mask
=
754 theme
->a_toggled_unfocused_shade
->texture
[0].data
.mask
.mask
=
755 theme
->shade_toggled_mask
;
756 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.mask
=
757 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.mask
=
758 theme
->iconify_disabled_mask
;
759 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.mask
=
760 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.mask
=
761 theme
->iconify_hover_mask
;
762 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.mask
=
763 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.mask
=
764 theme
->iconify_pressed_mask
;
765 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
766 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
768 theme
->a_menu_bullet
->texture
[0].data
.mask
.mask
=
769 theme
->menu_bullet_mask
;
770 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.color
=
771 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.color
=
772 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.color
=
773 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.color
=
774 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.color
=
775 theme
->titlebut_disabled_focused_color
;
776 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.color
=
777 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.color
=
778 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.color
=
779 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.color
=
780 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.color
=
781 theme
->titlebut_disabled_unfocused_color
;
782 theme
->a_hover_focused_max
->texture
[0].data
.mask
.color
=
783 theme
->a_hover_focused_close
->texture
[0].data
.mask
.color
=
784 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.color
=
785 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.color
=
786 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.color
=
787 theme
->titlebut_hover_focused_color
;
788 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.color
=
789 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.color
=
790 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.color
=
791 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.color
=
792 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.color
=
793 theme
->titlebut_hover_unfocused_color
;
794 theme
->a_toggled_focused_max
->texture
[0].data
.mask
.color
=
795 theme
->a_toggled_focused_desk
->texture
[0].data
.mask
.color
=
796 theme
->a_toggled_focused_shade
->texture
[0].data
.mask
.color
=
797 theme
->titlebut_toggled_focused_color
;
798 theme
->a_toggled_unfocused_max
->texture
[0].data
.mask
.color
=
799 theme
->a_toggled_unfocused_desk
->texture
[0].data
.mask
.color
=
800 theme
->a_toggled_unfocused_shade
->texture
[0].data
.mask
.color
=
801 theme
->titlebut_toggled_unfocused_color
;
802 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.color
=
803 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.color
=
804 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.color
=
805 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.color
=
806 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.color
=
807 theme
->titlebut_focused_unpressed_color
;
808 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.color
=
809 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.color
=
810 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.color
=
811 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.color
=
812 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.color
=
813 theme
->titlebut_focused_pressed_color
;
814 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.color
=
815 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.color
=
816 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.color
=
817 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.color
=
818 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.color
=
819 theme
->titlebut_unfocused_unpressed_color
;
820 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.color
=
821 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.color
=
822 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.color
=
823 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.color
=
824 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.color
=
825 theme
->titlebut_unfocused_pressed_color
;
826 theme
->a_menu_bullet
->texture
[0].data
.mask
.color
=
827 theme
->menu_bullet_color
;
829 XrmDestroyDatabase(db
);
831 theme
->label_height
= theme
->winfont_height
;
832 theme
->title_height
= theme
->label_height
+ theme
->bevel
* 2;
833 theme
->button_size
= theme
->label_height
- 2;
834 theme
->grip_width
= theme
->button_size
* 2;
839 void RrThemeFree(RrTheme
*theme
)
844 RrColorFree(theme
->b_color
);
845 RrColorFree(theme
->cb_unfocused_color
);
846 RrColorFree(theme
->cb_focused_color
);
847 RrColorFree(theme
->title_unfocused_color
);
848 RrColorFree(theme
->title_focused_color
);
849 RrColorFree(theme
->titlebut_disabled_focused_color
);
850 RrColorFree(theme
->titlebut_disabled_unfocused_color
);
851 RrColorFree(theme
->titlebut_hover_focused_color
);
852 RrColorFree(theme
->titlebut_hover_unfocused_color
);
853 RrColorFree(theme
->titlebut_toggled_focused_color
);
854 RrColorFree(theme
->titlebut_toggled_unfocused_color
);
855 RrColorFree(theme
->titlebut_unfocused_pressed_color
);
856 RrColorFree(theme
->titlebut_focused_pressed_color
);
857 RrColorFree(theme
->titlebut_unfocused_unpressed_color
);
858 RrColorFree(theme
->titlebut_focused_unpressed_color
);
859 RrColorFree(theme
->menu_color
);
860 RrColorFree(theme
->menu_title_color
);
861 RrColorFree(theme
->menu_disabled_color
);
862 RrColorFree(theme
->menu_hilite_color
);
864 RrPixmapMaskFree(theme
->max_mask
);
865 RrPixmapMaskFree(theme
->max_toggled_mask
);
866 RrPixmapMaskFree(theme
->max_disabled_mask
);
867 RrPixmapMaskFree(theme
->max_hover_mask
);
868 RrPixmapMaskFree(theme
->max_pressed_mask
);
869 RrPixmapMaskFree(theme
->desk_mask
);
870 RrPixmapMaskFree(theme
->desk_toggled_mask
);
871 RrPixmapMaskFree(theme
->desk_disabled_mask
);
872 RrPixmapMaskFree(theme
->desk_hover_mask
);
873 RrPixmapMaskFree(theme
->desk_pressed_mask
);
874 RrPixmapMaskFree(theme
->shade_mask
);
875 RrPixmapMaskFree(theme
->shade_toggled_mask
);
876 RrPixmapMaskFree(theme
->shade_disabled_mask
);
877 RrPixmapMaskFree(theme
->shade_hover_mask
);
878 RrPixmapMaskFree(theme
->shade_pressed_mask
);
879 RrPixmapMaskFree(theme
->iconify_mask
);
880 RrPixmapMaskFree(theme
->iconify_disabled_mask
);
881 RrPixmapMaskFree(theme
->iconify_hover_mask
);
882 RrPixmapMaskFree(theme
->iconify_pressed_mask
);
883 RrPixmapMaskFree(theme
->close_mask
);
884 RrPixmapMaskFree(theme
->close_disabled_mask
);
885 RrPixmapMaskFree(theme
->close_hover_mask
);
886 RrPixmapMaskFree(theme
->close_pressed_mask
);
887 RrPixmapMaskFree(theme
->menu_bullet_mask
);
889 RrFontClose(theme
->winfont
);
890 RrFontClose(theme
->mtitlefont
);
891 RrFontClose(theme
->mfont
);
893 RrAppearanceFree(theme
->a_disabled_focused_max
);
894 RrAppearanceFree(theme
->a_disabled_unfocused_max
);
895 RrAppearanceFree(theme
->a_hover_focused_max
);
896 RrAppearanceFree(theme
->a_hover_unfocused_max
);
897 RrAppearanceFree(theme
->a_toggled_focused_max
);
898 RrAppearanceFree(theme
->a_toggled_unfocused_max
);
899 RrAppearanceFree(theme
->a_focused_unpressed_max
);
900 RrAppearanceFree(theme
->a_focused_pressed_max
);
901 RrAppearanceFree(theme
->a_unfocused_unpressed_max
);
902 RrAppearanceFree(theme
->a_unfocused_pressed_max
);
903 RrAppearanceFree(theme
->a_disabled_focused_close
);
904 RrAppearanceFree(theme
->a_disabled_unfocused_close
);
905 RrAppearanceFree(theme
->a_hover_focused_close
);
906 RrAppearanceFree(theme
->a_hover_unfocused_close
);
907 RrAppearanceFree(theme
->a_focused_unpressed_close
);
908 RrAppearanceFree(theme
->a_focused_pressed_close
);
909 RrAppearanceFree(theme
->a_unfocused_unpressed_close
);
910 RrAppearanceFree(theme
->a_unfocused_pressed_close
);
911 RrAppearanceFree(theme
->a_disabled_focused_desk
);
912 RrAppearanceFree(theme
->a_disabled_unfocused_desk
);
913 RrAppearanceFree(theme
->a_hover_focused_desk
);
914 RrAppearanceFree(theme
->a_hover_unfocused_desk
);
915 RrAppearanceFree(theme
->a_toggled_focused_desk
);
916 RrAppearanceFree(theme
->a_toggled_unfocused_desk
);
917 RrAppearanceFree(theme
->a_focused_unpressed_desk
);
918 RrAppearanceFree(theme
->a_focused_pressed_desk
);
919 RrAppearanceFree(theme
->a_unfocused_unpressed_desk
);
920 RrAppearanceFree(theme
->a_unfocused_pressed_desk
);
921 RrAppearanceFree(theme
->a_disabled_focused_shade
);
922 RrAppearanceFree(theme
->a_disabled_unfocused_shade
);
923 RrAppearanceFree(theme
->a_hover_focused_shade
);
924 RrAppearanceFree(theme
->a_hover_unfocused_shade
);
925 RrAppearanceFree(theme
->a_toggled_focused_shade
);
926 RrAppearanceFree(theme
->a_toggled_unfocused_shade
);
927 RrAppearanceFree(theme
->a_focused_unpressed_shade
);
928 RrAppearanceFree(theme
->a_focused_pressed_shade
);
929 RrAppearanceFree(theme
->a_unfocused_unpressed_shade
);
930 RrAppearanceFree(theme
->a_unfocused_pressed_shade
);
931 RrAppearanceFree(theme
->a_disabled_focused_iconify
);
932 RrAppearanceFree(theme
->a_disabled_unfocused_iconify
);
933 RrAppearanceFree(theme
->a_hover_focused_iconify
);
934 RrAppearanceFree(theme
->a_hover_unfocused_iconify
);
935 RrAppearanceFree(theme
->a_focused_unpressed_iconify
);
936 RrAppearanceFree(theme
->a_focused_pressed_iconify
);
937 RrAppearanceFree(theme
->a_unfocused_unpressed_iconify
);
938 RrAppearanceFree(theme
->a_unfocused_pressed_iconify
);
939 RrAppearanceFree(theme
->a_focused_grip
);
940 RrAppearanceFree(theme
->a_unfocused_grip
);
941 RrAppearanceFree(theme
->a_focused_title
);
942 RrAppearanceFree(theme
->a_unfocused_title
);
943 RrAppearanceFree(theme
->a_focused_label
);
944 RrAppearanceFree(theme
->a_unfocused_label
);
945 RrAppearanceFree(theme
->a_icon
);
946 RrAppearanceFree(theme
->a_focused_handle
);
947 RrAppearanceFree(theme
->a_unfocused_handle
);
948 RrAppearanceFree(theme
->a_menu
);
949 RrAppearanceFree(theme
->a_menu_title
);
950 RrAppearanceFree(theme
->a_menu_item
);
951 RrAppearanceFree(theme
->a_menu_disabled
);
952 RrAppearanceFree(theme
->a_menu_hilite
);
953 RrAppearanceFree(theme
->a_clear
);
954 RrAppearanceFree(theme
->app_hilite_bg
);
955 RrAppearanceFree(theme
->app_unhilite_bg
);
956 RrAppearanceFree(theme
->app_hilite_label
);
957 RrAppearanceFree(theme
->app_unhilite_label
);
958 RrAppearanceFree(theme
->app_icon
);
962 static XrmDatabase
loaddb(RrTheme
*theme
, char *name
)
966 char *s
= g_build_filename(g_get_home_dir(), ".openbox", "themes",
967 name
, "themerc", NULL
);
968 if ((db
= XrmGetFileDatabase(s
)))
969 theme
->path
= g_path_get_dirname(s
);
972 char *s
= g_build_filename(THEMEDIR
, name
, "themerc", NULL
);
973 if ((db
= XrmGetFileDatabase(s
)))
974 theme
->path
= g_path_get_dirname(s
);
978 char *s
= g_build_filename(name
, "themerc", NULL
);
979 if ((db
= XrmGetFileDatabase(s
)))
980 theme
->path
= g_path_get_dirname(s
);
987 static char *create_class_name(char *rname
)
989 char *rclass
= g_strdup(rname
);
994 p
= strchr(p
+1, '.');
995 if (p
== NULL
) break;
997 if (*p
== '\0') break;
1002 static gboolean
read_int(XrmDatabase db
, char *rname
, int *value
)
1004 gboolean ret
= FALSE
;
1005 char *rclass
= create_class_name(rname
);
1006 char *rettype
, *end
;
1009 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1010 retvalue
.addr
!= NULL
) {
1011 *value
= (int)strtol(retvalue
.addr
, &end
, 10);
1012 if (end
!= retvalue
.addr
)
1020 static gboolean
read_string(XrmDatabase db
, char *rname
, char **value
)
1022 gboolean ret
= FALSE
;
1023 char *rclass
= create_class_name(rname
);
1027 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1028 retvalue
.addr
!= NULL
) {
1029 *value
= retvalue
.addr
;
1037 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
1038 gchar
*rname
, RrColor
**value
)
1040 gboolean ret
= FALSE
;
1041 char *rclass
= create_class_name(rname
);
1045 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1046 retvalue
.addr
!= NULL
) {
1047 RrColor
*c
= RrColorParse(inst
, retvalue
.addr
);
1058 static gboolean
read_mask(const RrInstance
*inst
,
1059 gchar
*maskname
, RrTheme
*theme
,
1060 RrPixmapMask
**value
)
1062 gboolean ret
= FALSE
;
1064 int hx
, hy
; /* ignored */
1068 s
= g_build_filename(theme
->path
, maskname
, NULL
);
1069 if (XReadBitmapFileData(s
, &w
, &h
, &b
, &hx
, &hy
) == BitmapSuccess
) {
1071 *value
= RrPixmapMaskNew(inst
, w
, h
, (char*)b
);
1079 static void parse_appearance(gchar
*tex
, RrSurfaceColorType
*grad
,
1080 RrReliefType
*relief
, RrBevelType
*bevel
,
1081 gboolean
*interlaced
, gboolean
*border
,
1082 gboolean allow_trans
)
1086 /* convert to all lowercase */
1087 for (t
= tex
; *t
!= '\0'; ++t
)
1088 *t
= g_ascii_tolower(*t
);
1090 if (allow_trans
&& strstr(tex
, "parentrelative") != NULL
) {
1091 *grad
= RR_SURFACE_PARENTREL
;
1093 if (strstr(tex
, "gradient") != NULL
) {
1094 if (strstr(tex
, "crossdiagonal") != NULL
)
1095 *grad
= RR_SURFACE_CROSS_DIAGONAL
;
1096 else if (strstr(tex
, "pyramid") != NULL
)
1097 *grad
= RR_SURFACE_PYRAMID
;
1098 else if (strstr(tex
, "horizontal") != NULL
)
1099 *grad
= RR_SURFACE_HORIZONTAL
;
1100 else if (strstr(tex
, "vertical") != NULL
)
1101 *grad
= RR_SURFACE_VERTICAL
;
1103 *grad
= RR_SURFACE_DIAGONAL
;
1105 *grad
= RR_SURFACE_SOLID
;
1108 if (strstr(tex
, "sunken") != NULL
)
1109 *relief
= RR_RELIEF_SUNKEN
;
1110 else if (strstr(tex
, "flat") != NULL
)
1111 *relief
= RR_RELIEF_FLAT
;
1113 *relief
= RR_RELIEF_RAISED
;
1116 if (*relief
== RR_RELIEF_FLAT
) {
1117 if (strstr(tex
, "border") != NULL
)
1120 if (strstr(tex
, "bevel2") != NULL
)
1121 *bevel
= RR_BEVEL_2
;
1123 *bevel
= RR_BEVEL_1
;
1126 if (strstr(tex
, "interlaced") != NULL
)
1129 *interlaced
= FALSE
;
1134 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
1135 gchar
*rname
, RrAppearance
*value
,
1136 gboolean allow_trans
)
1138 gboolean ret
= FALSE
;
1139 char *rclass
= create_class_name(rname
), *cname
, *ctoname
, *bcname
;
1143 cname
= g_strconcat(rname
, ".color", NULL
);
1144 ctoname
= g_strconcat(rname
, ".colorTo", NULL
);
1145 bcname
= g_strconcat(rname
, ".borderColor", NULL
);
1147 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1148 retvalue
.addr
!= NULL
) {
1149 parse_appearance(retvalue
.addr
,
1150 &value
->surface
.grad
,
1151 &value
->surface
.relief
,
1152 &value
->surface
.bevel
,
1153 &value
->surface
.interlaced
,
1154 &value
->surface
.border
,
1156 if (!read_color(db
, inst
, cname
, &value
->surface
.primary
))
1157 value
->surface
.primary
= RrColorNew(inst
, 0, 0, 0);
1158 if (!read_color(db
, inst
, ctoname
, &value
->surface
.secondary
))
1159 value
->surface
.secondary
= RrColorNew(inst
, 0, 0, 0);
1160 if (value
->surface
.border
)
1161 if (!read_color(db
, inst
, bcname
,
1162 &value
->surface
.border_color
))
1163 value
->surface
.border_color
= RrColorNew(inst
, 0, 0, 0);
1174 static void set_default_appearance(RrAppearance
*a
)
1176 a
->surface
.grad
= RR_SURFACE_SOLID
;
1177 a
->surface
.relief
= RR_RELIEF_FLAT
;
1178 a
->surface
.bevel
= RR_BEVEL_1
;
1179 a
->surface
.interlaced
= FALSE
;
1180 a
->surface
.border
= FALSE
;
1181 a
->surface
.primary
= RrColorNew(a
->inst
, 0, 0, 0);
1182 a
->surface
.secondary
= RrColorNew(a
->inst
, 0, 0, 0);