8 #include <X11/Xresource.h>
13 static XrmDatabase
loaddb(RrTheme
*theme
, char *name
);
14 static gboolean
read_int(XrmDatabase db
, char *rname
, int *value
);
15 static gboolean
read_string(XrmDatabase db
, char *rname
, char **value
);
16 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
17 gchar
*rname
, RrColor
**value
);
18 static gboolean
read_mask(const RrInstance
*inst
,
19 gchar
*maskname
, RrTheme
*theme
,
20 RrPixmapMask
**value
);
21 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
22 gchar
*rname
, RrAppearance
*value
,
23 gboolean allow_trans
);
24 static void set_default_appearance(RrAppearance
*a
);
26 RrTheme
* RrThemeNew(const RrInstance
*inst
, gchar
*name
)
28 XrmDatabase db
= NULL
;
29 RrJustify winjust
, mtitlejust
;
34 theme
= g_new0(RrTheme
, 1);
38 theme
->a_disabled_focused_max
= RrAppearanceNew(inst
, 1);
39 theme
->a_disabled_unfocused_max
= RrAppearanceNew(inst
, 1);
40 theme
->a_hover_focused_max
= RrAppearanceNew(inst
, 1);
41 theme
->a_hover_unfocused_max
= RrAppearanceNew(inst
, 1);
42 theme
->a_toggled_focused_max
= RrAppearanceNew(inst
, 1);
43 theme
->a_toggled_unfocused_max
= RrAppearanceNew(inst
, 1);
44 theme
->a_focused_unpressed_max
= RrAppearanceNew(inst
, 1);
45 theme
->a_focused_pressed_max
= RrAppearanceNew(inst
, 1);
46 theme
->a_unfocused_unpressed_max
= RrAppearanceNew(inst
, 1);
47 theme
->a_unfocused_pressed_max
= RrAppearanceNew(inst
, 1);
48 theme
->a_focused_grip
= RrAppearanceNew(inst
, 0);
49 theme
->a_unfocused_grip
= RrAppearanceNew(inst
, 0);
50 theme
->a_focused_title
= RrAppearanceNew(inst
, 0);
51 theme
->a_unfocused_title
= RrAppearanceNew(inst
, 0);
52 theme
->a_focused_label
= RrAppearanceNew(inst
, 1);
53 theme
->a_unfocused_label
= RrAppearanceNew(inst
, 1);
54 theme
->a_icon
= RrAppearanceNew(inst
, 1);
55 theme
->a_focused_handle
= RrAppearanceNew(inst
, 0);
56 theme
->a_unfocused_handle
= RrAppearanceNew(inst
, 0);
57 theme
->a_menu
= RrAppearanceNew(inst
, 0);
58 theme
->a_menu_title
= RrAppearanceNew(inst
, 1);
59 theme
->a_menu_item
= RrAppearanceNew(inst
, 0);
60 theme
->a_menu_disabled
= RrAppearanceNew(inst
, 0);
61 theme
->a_menu_hilite
= RrAppearanceNew(inst
, 0);
62 theme
->a_menu_text_item
= RrAppearanceNew(inst
, 1);
63 theme
->a_menu_text_disabled
= RrAppearanceNew(inst
, 1);
64 theme
->a_menu_text_hilite
= RrAppearanceNew(inst
, 1);
65 theme
->a_menu_bullet
= RrAppearanceNew(inst
, 1);
66 theme
->a_clear
= RrAppearanceNew(inst
, 0);
67 theme
->a_clear_tex
= RrAppearanceNew(inst
, 1);
69 theme
->app_hilite_bg
= RrAppearanceNew(inst
, 0);
70 theme
->app_unhilite_bg
= RrAppearanceNew(inst
, 0);
71 theme
->app_hilite_label
= RrAppearanceNew(inst
, 1);
72 theme
->app_unhilite_label
= RrAppearanceNew(inst
, 1);
75 db
= loaddb(theme
, name
);
77 g_warning("Failed to load the theme '%s'\n"
78 "Falling back to the default: '%s'",
81 theme
->name
= g_path_get_basename(name
);
84 db
= loaddb(theme
, DEFAULT_THEME
);
86 g_warning("Failed to load the theme '%s'.", DEFAULT_THEME
);
89 theme
->name
= g_path_get_basename(DEFAULT_THEME
);
92 /* load the font stuff */
93 if (!read_string(db
, "window.focus.font", &font_str
))
94 font_str
= "arial,sans:bold:pixelsize=10:shadow=y:shadowtint=50";
96 if (!(theme
->winfont_focused
= RrFontOpen(inst
, font_str
))) {
100 theme
->winfont_height
= RrFontHeight(theme
->winfont_focused
);
102 if (!read_string(db
, "window.unfocus.font", &font_str
))
103 /* font_str will already be set to the last one */;
105 if (!(theme
->winfont_unfocused
= RrFontOpen(inst
, font_str
))) {
109 theme
->winfont_height
= MAX(theme
->winfont_height
,
110 RrFontHeight(theme
->winfont_unfocused
));
112 winjust
= RR_JUSTIFY_LEFT
;
113 if (read_string(db
, "window.justify", &str
)) {
114 if (!g_ascii_strcasecmp(str
, "right"))
115 winjust
= RR_JUSTIFY_RIGHT
;
116 else if (!g_ascii_strcasecmp(str
, "center"))
117 winjust
= RR_JUSTIFY_CENTER
;
120 if (!read_string(db
, "menu.title.font", &font_str
))
121 font_str
= "arial,sans:bold:pixelsize=12:shadow=y";
123 if (!(theme
->mtitlefont
= RrFontOpen(inst
, font_str
))) {
127 theme
->mtitlefont_height
= RrFontHeight(theme
->mtitlefont
);
129 mtitlejust
= RR_JUSTIFY_LEFT
;
130 if (read_string(db
, "menu.title.justify", &str
)) {
131 if (!g_ascii_strcasecmp(str
, "right"))
132 mtitlejust
= RR_JUSTIFY_RIGHT
;
133 else if (!g_ascii_strcasecmp(str
, "center"))
134 mtitlejust
= RR_JUSTIFY_CENTER
;
137 if (!read_string(db
, "menu.frame.font", &font_str
))
138 font_str
= "arial,sans:bold:pixelsize=11:shadow=y";
140 if (!(theme
->mfont
= RrFontOpen(inst
, font_str
))) {
144 theme
->mfont_height
= RrFontHeight(theme
->mfont
);
146 /* load direct dimensions */
147 if (!read_int(db
, "menuOverlap", &theme
->menu_overlap
) ||
148 theme
->menu_overlap
< 0 || theme
->menu_overlap
> 20)
149 theme
->handle_height
= 0;
150 if (!read_int(db
, "handleWidth", &theme
->handle_height
) ||
151 theme
->handle_height
< 0 || theme
->handle_height
> 100)
152 theme
->handle_height
= 6;
153 if (!read_int(db
, "bevelWidth", &theme
->bevel
) ||
154 theme
->bevel
<= 0 || theme
->bevel
> 100) theme
->bevel
= 3;
155 if (!read_int(db
, "borderWidth", &theme
->bwidth
) ||
156 theme
->bwidth
< 0 || theme
->bwidth
> 100) theme
->bwidth
= 1;
157 if (!read_int(db
, "frameWidth", &theme
->cbwidth
) ||
158 theme
->cbwidth
< 0 || theme
->cbwidth
> 100)
159 theme
->cbwidth
= theme
->bevel
;
162 if (!read_color(db
, inst
,
163 "borderColor", &theme
->b_color
))
164 theme
->b_color
= RrColorNew(inst
, 0, 0, 0);
165 if (!read_color(db
, inst
,
166 "window.frame.focusColor", &theme
->cb_focused_color
))
167 theme
->cb_focused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
168 if (!read_color(db
, inst
,
169 "window.frame.unfocusColor",&theme
->cb_unfocused_color
))
170 theme
->cb_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
171 if (!read_color(db
, inst
,
172 "window.label.focus.textColor",
173 &theme
->title_focused_color
))
174 theme
->title_focused_color
= RrColorNew(inst
, 0x0, 0x0, 0x0);
175 if (!read_color(db
, inst
,
176 "window.label.unfocus.textColor",
177 &theme
->title_unfocused_color
))
178 theme
->title_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
179 if (!read_color(db
, inst
,
180 "window.button.focus.picColor",
181 &theme
->titlebut_focused_unpressed_color
))
182 theme
->titlebut_focused_unpressed_color
= RrColorNew(inst
, 0, 0, 0);
183 if (!read_color(db
, inst
,
184 "window.button.unfocus.picColor",
185 &theme
->titlebut_unfocused_unpressed_color
))
186 theme
->titlebut_unfocused_unpressed_color
=
187 RrColorNew(inst
, 0xff, 0xff, 0xff);
188 if (!read_color(db
, inst
,
189 "window.button.pressed.focus.picColor",
190 &theme
->titlebut_focused_pressed_color
))
191 theme
->titlebut_focused_pressed_color
=
193 theme
->titlebut_focused_unpressed_color
->r
,
194 theme
->titlebut_focused_unpressed_color
->g
,
195 theme
->titlebut_focused_unpressed_color
->b
);
196 if (!read_color(db
, inst
,
197 "window.button.pressed.unfocus.picColor",
198 &theme
->titlebut_unfocused_pressed_color
))
199 theme
->titlebut_unfocused_pressed_color
=
201 theme
->titlebut_unfocused_unpressed_color
->r
,
202 theme
->titlebut_unfocused_unpressed_color
->g
,
203 theme
->titlebut_unfocused_unpressed_color
->b
);
204 if (!read_color(db
, inst
,
205 "window.button.disabled.focus.picColor",
206 &theme
->titlebut_disabled_focused_color
))
207 theme
->titlebut_disabled_focused_color
=
208 RrColorNew(inst
, 0xff, 0xff, 0xff);
209 if (!read_color(db
, inst
,
210 "window.button.disabled.unfocus.picColor",
211 &theme
->titlebut_disabled_unfocused_color
))
212 theme
->titlebut_disabled_unfocused_color
= RrColorNew(inst
, 0, 0, 0);
213 if (!read_color(db
, inst
,
214 "window.button.hover.focus.picColor",
215 &theme
->titlebut_hover_focused_color
))
216 theme
->titlebut_hover_focused_color
=
218 theme
->titlebut_focused_unpressed_color
->r
,
219 theme
->titlebut_focused_unpressed_color
->g
,
220 theme
->titlebut_focused_unpressed_color
->b
);
221 if (!read_color(db
, inst
,
222 "window.button.hover.unfocus.picColor",
223 &theme
->titlebut_hover_unfocused_color
))
224 theme
->titlebut_hover_unfocused_color
=
226 theme
->titlebut_unfocused_unpressed_color
->r
,
227 theme
->titlebut_unfocused_unpressed_color
->g
,
228 theme
->titlebut_unfocused_unpressed_color
->b
);
229 if (!read_color(db
, inst
,
230 "window.button.toggled.focus.picColor",
231 &theme
->titlebut_toggled_focused_color
))
232 theme
->titlebut_toggled_focused_color
=
234 theme
->titlebut_focused_pressed_color
->r
,
235 theme
->titlebut_focused_pressed_color
->g
,
236 theme
->titlebut_focused_pressed_color
->b
);
237 if (!read_color(db
, inst
,
238 "window.button.toggled.unfocus.picColor",
239 &theme
->titlebut_toggled_unfocused_color
))
240 theme
->titlebut_toggled_unfocused_color
=
242 theme
->titlebut_unfocused_pressed_color
->r
,
243 theme
->titlebut_unfocused_pressed_color
->g
,
244 theme
->titlebut_unfocused_pressed_color
->b
);
245 if (!read_color(db
, inst
,
246 "menu.title.textColor", &theme
->menu_title_color
))
247 theme
->menu_title_color
= RrColorNew(inst
, 0, 0, 0);
248 if (!read_color(db
, inst
,
249 "menu.frame.textColor", &theme
->menu_color
))
250 theme
->menu_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
251 if (!read_color(db
, inst
,
252 "menu.bullet.picColor", &theme
->menu_bullet_color
))
253 theme
->menu_bullet_color
= RrColorNew(inst
, 0, 0, 0);
254 if (!read_color(db
, inst
,
255 "menu.frame.disableColor", &theme
->menu_disabled_color
))
256 theme
->menu_disabled_color
= RrColorNew(inst
, 0, 0, 0);
257 if (!read_color(db
, inst
,
258 "menu.hilite.textColor", &theme
->menu_hilite_color
))
259 theme
->menu_hilite_color
= RrColorNew(inst
, 0, 0, 0);
262 if (read_mask(inst
, "max.xbm", theme
, &theme
->max_mask
)) {
263 if (!read_mask(inst
, "max_pressed.xbm", theme
,
264 &theme
->max_pressed_mask
)) {
265 theme
->max_pressed_mask
= RrPixmapMaskCopy(theme
->max_mask
);
267 if (!read_mask(inst
, "max_toggled.xbm", theme
,
268 &theme
->max_toggled_mask
)) {
269 theme
->max_toggled_mask
=
270 RrPixmapMaskCopy(theme
->max_pressed_mask
);
272 if (!read_mask(inst
, "max_disabled.xbm", theme
,
273 &theme
->max_disabled_mask
)) {
274 theme
->max_disabled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
276 if (!read_mask(inst
, "max_hover.xbm", theme
, &theme
->max_hover_mask
)) {
277 theme
->max_hover_mask
= RrPixmapMaskCopy(theme
->max_mask
);
281 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
282 theme
->max_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
285 guchar data
[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
286 theme
->max_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
288 theme
->max_pressed_mask
= RrPixmapMaskCopy(theme
->max_mask
);
289 theme
->max_disabled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
290 theme
->max_hover_mask
= RrPixmapMaskCopy(theme
->max_mask
);
293 if (read_mask(inst
, "iconify.xbm", theme
, &theme
->iconify_mask
)) {
294 if (!read_mask(inst
, "iconify_pressed.xbm", theme
,
295 &theme
->iconify_pressed_mask
)) {
296 theme
->iconify_pressed_mask
=
297 RrPixmapMaskCopy(theme
->iconify_mask
);
299 if (!read_mask(inst
, "iconify_disabled.xbm", theme
,
300 &theme
->iconify_disabled_mask
)) {
301 theme
->iconify_disabled_mask
=
302 RrPixmapMaskCopy(theme
->iconify_mask
);
304 if (!read_mask(inst
, "iconify_hover.xbm", theme
,
305 &theme
->iconify_hover_mask
)) {
306 theme
->iconify_hover_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
310 guchar data
[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
311 theme
->iconify_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
313 theme
->iconify_pressed_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
314 theme
->iconify_disabled_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
315 theme
->iconify_hover_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
318 if (read_mask(inst
, "desk.xbm", theme
, &theme
->desk_mask
)) {
319 if (!read_mask(inst
, "desk_pressed.xbm", theme
,
320 &theme
->desk_pressed_mask
)) {
321 theme
->desk_pressed_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
323 if (!read_mask(inst
, "desk_toggled.xbm", theme
,
324 &theme
->desk_toggled_mask
)) {
325 theme
->desk_toggled_mask
=
326 RrPixmapMaskCopy(theme
->desk_pressed_mask
);
328 if (!read_mask(inst
, "desk_disabled.xbm", theme
,
329 &theme
->desk_disabled_mask
)) {
330 theme
->desk_disabled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
332 if (!read_mask(inst
, "desk_hover.xbm", theme
,
333 &theme
->desk_hover_mask
)) {
334 theme
->desk_hover_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
338 guchar data
[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
339 theme
->desk_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
342 guchar data
[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
343 theme
->desk_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7,
346 theme
->desk_pressed_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
347 theme
->desk_disabled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
348 theme
->desk_hover_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
351 if (read_mask(inst
, "shade.xbm", theme
, &theme
->shade_mask
)) {
352 if (!read_mask(inst
, "shade_pressed.xbm", theme
,
353 &theme
->shade_pressed_mask
)) {
354 theme
->shade_pressed_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
356 if (!read_mask(inst
, "shade_toggled.xbm", theme
,
357 &theme
->shade_toggled_mask
)) {
358 theme
->shade_toggled_mask
=
359 RrPixmapMaskCopy(theme
->shade_pressed_mask
);
361 if (!read_mask(inst
, "shade_disabled.xbm", theme
,
362 &theme
->shade_disabled_mask
)) {
363 theme
->shade_disabled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
365 if (!read_mask(inst
, "shade_hover.xbm", theme
,
366 &theme
->shade_hover_mask
)) {
367 theme
->shade_hover_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
371 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
372 theme
->shade_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
375 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
376 theme
->shade_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7,
379 theme
->shade_pressed_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
380 theme
->shade_disabled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
381 theme
->shade_hover_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
384 if (read_mask(inst
, "close.xbm", theme
, &theme
->close_mask
)) {
385 if (!read_mask(inst
, "close_pressed.xbm", theme
,
386 &theme
->close_pressed_mask
)) {
387 theme
->close_pressed_mask
= RrPixmapMaskCopy(theme
->close_mask
);
389 if (!read_mask(inst
, "close_disabled.xbm", theme
,
390 &theme
->close_disabled_mask
)) {
391 theme
->close_disabled_mask
= RrPixmapMaskCopy(theme
->close_mask
);
393 if (!read_mask(inst
, "close_hover.xbm", theme
,
394 &theme
->close_hover_mask
)) {
395 theme
->close_hover_mask
= RrPixmapMaskCopy(theme
->close_mask
);
399 guchar data
[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
400 theme
->close_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
402 theme
->close_pressed_mask
= RrPixmapMaskCopy(theme
->close_mask
);
403 theme
->close_disabled_mask
= RrPixmapMaskCopy(theme
->close_mask
);
404 theme
->close_hover_mask
= RrPixmapMaskCopy(theme
->close_mask
);
407 if (!read_mask(inst
, "bullet.xbm", theme
, &theme
->menu_bullet_mask
)) {
408 guchar data
[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
409 theme
->menu_bullet_mask
= RrPixmapMaskNew(inst
, 4, 7, (char*)data
);
412 /* read the decoration textures */
413 if (!read_appearance(db
, inst
,
414 "window.title.focus", theme
->a_focused_title
,
416 set_default_appearance(theme
->a_focused_title
);
417 if (!read_appearance(db
, inst
,
418 "window.title.unfocus", theme
->a_unfocused_title
,
420 set_default_appearance(theme
->a_unfocused_title
);
421 if (!read_appearance(db
, inst
,
422 "window.label.focus", theme
->a_focused_label
,
424 set_default_appearance(theme
->a_focused_label
);
425 if (!read_appearance(db
, inst
,
426 "window.label.unfocus", theme
->a_unfocused_label
,
428 set_default_appearance(theme
->a_unfocused_label
);
429 if (!read_appearance(db
, inst
,
430 "window.handle.focus", theme
->a_focused_handle
,
432 set_default_appearance(theme
->a_focused_handle
);
433 if (!read_appearance(db
, inst
,
434 "window.handle.unfocus",theme
->a_unfocused_handle
,
436 set_default_appearance(theme
->a_unfocused_handle
);
437 if (!read_appearance(db
, inst
,
438 "window.grip.focus", theme
->a_focused_grip
,
440 set_default_appearance(theme
->a_focused_grip
);
441 if (!read_appearance(db
, inst
,
442 "window.grip.unfocus", theme
->a_unfocused_grip
,
444 set_default_appearance(theme
->a_unfocused_grip
);
445 if (!read_appearance(db
, inst
,
446 "menu.frame", theme
->a_menu
,
448 set_default_appearance(theme
->a_menu
);
449 if (!read_appearance(db
, inst
,
450 "menu.title", theme
->a_menu_title
,
452 set_default_appearance(theme
->a_menu_title
);
453 if (!read_appearance(db
, inst
,
454 "menu.hilite", theme
->a_menu_hilite
,
456 set_default_appearance(theme
->a_menu_hilite
);
458 /* read the appearances for rendering non-decorations */
459 if (!read_appearance(db
, inst
,
460 "window.title.focus", theme
->app_hilite_bg
,
462 set_default_appearance(theme
->app_hilite_bg
);
463 if (!read_appearance(db
, inst
,
464 "window.label.focus", theme
->app_hilite_label
,
466 set_default_appearance(theme
->app_hilite_label
);
467 if (!read_appearance(db
, inst
,
468 "window.title.unfocus", theme
->app_unhilite_bg
,
470 set_default_appearance(theme
->app_unhilite_bg
);
471 if (!read_appearance(db
, inst
,
472 "window.label.unfocus", theme
->app_unhilite_label
,
474 set_default_appearance(theme
->app_unhilite_label
);
476 /* read buttons textures */
477 if (!read_appearance(db
, inst
,
478 "window.button.disabled.focus",
479 theme
->a_disabled_focused_max
,
481 set_default_appearance(theme
->a_disabled_focused_max
);
482 if (!read_appearance(db
, inst
,
483 "window.button.disabled.unfocus",
484 theme
->a_disabled_unfocused_max
,
486 set_default_appearance(theme
->a_disabled_unfocused_max
);
487 if (!read_appearance(db
, inst
,
488 "window.button.pressed.focus",
489 theme
->a_focused_pressed_max
,
491 set_default_appearance(theme
->a_focused_pressed_max
);
492 if (!read_appearance(db
, inst
,
493 "window.button.pressed.unfocus",
494 theme
->a_unfocused_pressed_max
,
496 set_default_appearance(theme
->a_unfocused_pressed_max
);
497 if (!read_appearance(db
, inst
,
498 "window.button.toggled.focus",
499 theme
->a_toggled_focused_max
,
502 RrAppearanceFree(theme
->a_toggled_focused_max
);
503 theme
->a_toggled_focused_max
=
504 RrAppearanceCopy(theme
->a_focused_pressed_max
);
506 if (!read_appearance(db
, inst
,
507 "window.button.toggled.unfocus",
508 theme
->a_toggled_unfocused_max
,
511 RrAppearanceFree(theme
->a_toggled_unfocused_max
);
512 theme
->a_toggled_unfocused_max
=
513 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
515 if (!read_appearance(db
, inst
,
516 "window.button.focus",
517 theme
->a_focused_unpressed_max
,
519 set_default_appearance(theme
->a_focused_unpressed_max
);
520 if (!read_appearance(db
, inst
,
521 "window.button.unfocus",
522 theme
->a_unfocused_unpressed_max
,
524 set_default_appearance(theme
->a_unfocused_unpressed_max
);
525 if (!read_appearance(db
, inst
,
526 "window.button.hover.focus",
527 theme
->a_hover_focused_max
,
530 RrAppearanceFree(theme
->a_hover_focused_max
);
531 theme
->a_hover_focused_max
=
532 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
534 if (!read_appearance(db
, inst
,
535 "window.button.hover.unfocus",
536 theme
->a_hover_unfocused_max
,
539 RrAppearanceFree(theme
->a_hover_unfocused_max
);
540 theme
->a_hover_unfocused_max
=
541 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
544 theme
->a_disabled_focused_close
=
545 RrAppearanceCopy(theme
->a_disabled_focused_max
);
546 theme
->a_disabled_unfocused_close
=
547 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
548 theme
->a_hover_focused_close
=
549 RrAppearanceCopy(theme
->a_hover_focused_max
);
550 theme
->a_hover_unfocused_close
=
551 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
552 theme
->a_unfocused_unpressed_close
=
553 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
554 theme
->a_unfocused_pressed_close
=
555 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
556 theme
->a_focused_unpressed_close
=
557 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
558 theme
->a_focused_pressed_close
=
559 RrAppearanceCopy(theme
->a_focused_pressed_max
);
560 theme
->a_disabled_focused_desk
=
561 RrAppearanceCopy(theme
->a_disabled_focused_max
);
562 theme
->a_disabled_unfocused_desk
=
563 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
564 theme
->a_hover_focused_desk
=
565 RrAppearanceCopy(theme
->a_hover_focused_max
);
566 theme
->a_hover_unfocused_desk
=
567 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
568 theme
->a_toggled_focused_desk
=
569 RrAppearanceCopy(theme
->a_toggled_focused_max
);
570 theme
->a_toggled_unfocused_desk
=
571 RrAppearanceCopy(theme
->a_toggled_unfocused_max
);
572 theme
->a_unfocused_unpressed_desk
=
573 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
574 theme
->a_unfocused_pressed_desk
=
575 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
576 theme
->a_focused_unpressed_desk
=
577 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
578 theme
->a_focused_pressed_desk
=
579 RrAppearanceCopy(theme
->a_focused_pressed_max
);
580 theme
->a_disabled_focused_shade
=
581 RrAppearanceCopy(theme
->a_disabled_focused_max
);
582 theme
->a_disabled_unfocused_shade
=
583 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
584 theme
->a_hover_focused_shade
=
585 RrAppearanceCopy(theme
->a_hover_focused_max
);
586 theme
->a_hover_unfocused_shade
=
587 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
588 theme
->a_toggled_focused_shade
=
589 RrAppearanceCopy(theme
->a_toggled_focused_max
);
590 theme
->a_toggled_unfocused_shade
=
591 RrAppearanceCopy(theme
->a_toggled_unfocused_max
);
592 theme
->a_unfocused_unpressed_shade
=
593 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
594 theme
->a_unfocused_pressed_shade
=
595 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
596 theme
->a_focused_unpressed_shade
=
597 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
598 theme
->a_focused_pressed_shade
=
599 RrAppearanceCopy(theme
->a_focused_pressed_max
);
600 theme
->a_disabled_focused_iconify
=
601 RrAppearanceCopy(theme
->a_disabled_focused_max
);
602 theme
->a_disabled_unfocused_iconify
=
603 RrAppearanceCopy(theme
->a_disabled_focused_max
);
604 theme
->a_hover_focused_iconify
=
605 RrAppearanceCopy(theme
->a_hover_focused_max
);
606 theme
->a_hover_unfocused_iconify
=
607 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
608 theme
->a_unfocused_unpressed_iconify
=
609 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
610 theme
->a_unfocused_pressed_iconify
=
611 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
612 theme
->a_focused_unpressed_iconify
=
613 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
614 theme
->a_focused_pressed_iconify
=
615 RrAppearanceCopy(theme
->a_focused_pressed_max
);
617 theme
->a_icon
->surface
.grad
=
618 theme
->a_clear
->surface
.grad
=
619 theme
->a_clear_tex
->surface
.grad
=
620 theme
->a_menu_item
->surface
.grad
=
621 theme
->a_menu_disabled
->surface
.grad
=
622 theme
->a_menu_text_item
->surface
.grad
=
623 theme
->a_menu_text_disabled
->surface
.grad
=
624 theme
->a_menu_text_hilite
->surface
.grad
=
625 theme
->a_menu_bullet
->surface
.grad
= RR_SURFACE_PARENTREL
;
627 /* set up the textures */
628 theme
->a_focused_label
->texture
[0].type
=
629 theme
->app_hilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
630 theme
->a_focused_label
->texture
[0].data
.text
.justify
= winjust
;
631 theme
->app_hilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
632 theme
->a_focused_label
->texture
[0].data
.text
.font
=
633 theme
->app_hilite_label
->texture
[0].data
.text
.font
=
634 theme
->winfont_focused
;
635 theme
->a_focused_label
->texture
[0].data
.text
.color
=
636 theme
->app_hilite_label
->texture
[0].data
.text
.color
=
637 theme
->title_focused_color
;
639 theme
->a_unfocused_label
->texture
[0].type
=
640 theme
->app_unhilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
641 theme
->a_unfocused_label
->texture
[0].data
.text
.justify
= winjust
;
642 theme
->app_unhilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
643 theme
->a_unfocused_label
->texture
[0].data
.text
.font
=
644 theme
->app_unhilite_label
->texture
[0].data
.text
.font
=
645 theme
->winfont_unfocused
;
646 theme
->a_unfocused_label
->texture
[0].data
.text
.color
=
647 theme
->app_unhilite_label
->texture
[0].data
.text
.color
=
648 theme
->title_unfocused_color
;
650 theme
->a_menu_title
->texture
[0].type
= RR_TEXTURE_TEXT
;
651 theme
->a_menu_title
->texture
[0].data
.text
.justify
= mtitlejust
;
652 theme
->a_menu_title
->texture
[0].data
.text
.font
= theme
->mtitlefont
;
653 theme
->a_menu_title
->texture
[0].data
.text
.color
= theme
->menu_title_color
;
655 theme
->a_menu_text_item
->texture
[0].type
=
656 theme
->a_menu_text_disabled
->texture
[0].type
=
657 theme
->a_menu_text_hilite
->texture
[0].type
= RR_TEXTURE_TEXT
;
658 theme
->a_menu_text_item
->texture
[0].data
.text
.justify
=
659 theme
->a_menu_text_disabled
->texture
[0].data
.text
.justify
=
660 theme
->a_menu_text_hilite
->texture
[0].data
.text
.justify
=
662 theme
->a_menu_text_item
->texture
[0].data
.text
.font
=
663 theme
->a_menu_text_disabled
->texture
[0].data
.text
.font
=
664 theme
->a_menu_text_hilite
->texture
[0].data
.text
.font
= theme
->mfont
;
665 theme
->a_menu_text_item
->texture
[0].data
.text
.color
= theme
->menu_color
;
666 theme
->a_menu_text_disabled
->texture
[0].data
.text
.color
=
667 theme
->menu_disabled_color
;
668 theme
->a_menu_text_hilite
->texture
[0].data
.text
.color
=
669 theme
->menu_hilite_color
;
670 theme
->a_menu_bullet
->texture
[0].data
.mask
.color
=
671 theme
->menu_bullet_color
;
673 theme
->a_disabled_focused_max
->texture
[0].type
=
674 theme
->a_disabled_unfocused_max
->texture
[0].type
=
675 theme
->a_hover_focused_max
->texture
[0].type
=
676 theme
->a_hover_unfocused_max
->texture
[0].type
=
677 theme
->a_toggled_focused_max
->texture
[0].type
=
678 theme
->a_toggled_unfocused_max
->texture
[0].type
=
679 theme
->a_focused_unpressed_max
->texture
[0].type
=
680 theme
->a_focused_pressed_max
->texture
[0].type
=
681 theme
->a_unfocused_unpressed_max
->texture
[0].type
=
682 theme
->a_unfocused_pressed_max
->texture
[0].type
=
683 theme
->a_disabled_focused_close
->texture
[0].type
=
684 theme
->a_disabled_unfocused_close
->texture
[0].type
=
685 theme
->a_hover_focused_close
->texture
[0].type
=
686 theme
->a_hover_unfocused_close
->texture
[0].type
=
687 theme
->a_focused_unpressed_close
->texture
[0].type
=
688 theme
->a_focused_pressed_close
->texture
[0].type
=
689 theme
->a_unfocused_unpressed_close
->texture
[0].type
=
690 theme
->a_unfocused_pressed_close
->texture
[0].type
=
691 theme
->a_disabled_focused_desk
->texture
[0].type
=
692 theme
->a_disabled_unfocused_desk
->texture
[0].type
=
693 theme
->a_hover_focused_desk
->texture
[0].type
=
694 theme
->a_hover_unfocused_desk
->texture
[0].type
=
695 theme
->a_toggled_focused_desk
->texture
[0].type
=
696 theme
->a_toggled_unfocused_desk
->texture
[0].type
=
697 theme
->a_focused_unpressed_desk
->texture
[0].type
=
698 theme
->a_focused_pressed_desk
->texture
[0].type
=
699 theme
->a_unfocused_unpressed_desk
->texture
[0].type
=
700 theme
->a_unfocused_pressed_desk
->texture
[0].type
=
701 theme
->a_disabled_focused_shade
->texture
[0].type
=
702 theme
->a_disabled_unfocused_shade
->texture
[0].type
=
703 theme
->a_hover_focused_shade
->texture
[0].type
=
704 theme
->a_hover_unfocused_shade
->texture
[0].type
=
705 theme
->a_toggled_focused_shade
->texture
[0].type
=
706 theme
->a_toggled_unfocused_shade
->texture
[0].type
=
707 theme
->a_focused_unpressed_shade
->texture
[0].type
=
708 theme
->a_focused_pressed_shade
->texture
[0].type
=
709 theme
->a_unfocused_unpressed_shade
->texture
[0].type
=
710 theme
->a_unfocused_pressed_shade
->texture
[0].type
=
711 theme
->a_disabled_focused_iconify
->texture
[0].type
=
712 theme
->a_disabled_unfocused_iconify
->texture
[0].type
=
713 theme
->a_hover_focused_iconify
->texture
[0].type
=
714 theme
->a_hover_unfocused_iconify
->texture
[0].type
=
715 theme
->a_focused_unpressed_iconify
->texture
[0].type
=
716 theme
->a_focused_pressed_iconify
->texture
[0].type
=
717 theme
->a_unfocused_unpressed_iconify
->texture
[0].type
=
718 theme
->a_unfocused_pressed_iconify
->texture
[0].type
=
719 theme
->a_menu_bullet
->texture
[0].type
= RR_TEXTURE_MASK
;
721 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.mask
=
722 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.mask
=
723 theme
->max_disabled_mask
;
724 theme
->a_hover_focused_max
->texture
[0].data
.mask
.mask
=
725 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.mask
=
726 theme
->max_hover_mask
;
727 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.mask
=
728 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.mask
=
729 theme
->max_pressed_mask
;
730 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.mask
=
731 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.mask
=
733 theme
->a_toggled_focused_max
->texture
[0].data
.mask
.mask
=
734 theme
->a_toggled_unfocused_max
->texture
[0].data
.mask
.mask
=
735 theme
->max_toggled_mask
;
736 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.mask
=
737 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.mask
=
738 theme
->close_disabled_mask
;
739 theme
->a_hover_focused_close
->texture
[0].data
.mask
.mask
=
740 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.mask
=
741 theme
->close_hover_mask
;
742 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.mask
=
743 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.mask
=
744 theme
->close_pressed_mask
;
745 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.mask
=
746 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.mask
=
748 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.mask
=
749 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.mask
=
750 theme
->desk_disabled_mask
;
751 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.mask
=
752 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.mask
=
753 theme
->desk_hover_mask
;
754 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.mask
=
755 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.mask
=
756 theme
->desk_pressed_mask
;
757 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.mask
=
758 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.mask
=
760 theme
->a_toggled_focused_desk
->texture
[0].data
.mask
.mask
=
761 theme
->a_toggled_unfocused_desk
->texture
[0].data
.mask
.mask
=
762 theme
->desk_toggled_mask
;
763 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.mask
=
764 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.mask
=
765 theme
->shade_disabled_mask
;
766 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.mask
=
767 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.mask
=
768 theme
->shade_hover_mask
;
769 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.mask
=
770 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.mask
=
771 theme
->shade_pressed_mask
;
772 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.mask
=
773 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.mask
=
775 theme
->a_toggled_focused_shade
->texture
[0].data
.mask
.mask
=
776 theme
->a_toggled_unfocused_shade
->texture
[0].data
.mask
.mask
=
777 theme
->shade_toggled_mask
;
778 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.mask
=
779 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.mask
=
780 theme
->iconify_disabled_mask
;
781 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.mask
=
782 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.mask
=
783 theme
->iconify_hover_mask
;
784 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.mask
=
785 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.mask
=
786 theme
->iconify_pressed_mask
;
787 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
788 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
790 theme
->a_menu_bullet
->texture
[0].data
.mask
.mask
=
791 theme
->menu_bullet_mask
;
792 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.color
=
793 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.color
=
794 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.color
=
795 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.color
=
796 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.color
=
797 theme
->titlebut_disabled_focused_color
;
798 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.color
=
799 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.color
=
800 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.color
=
801 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.color
=
802 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.color
=
803 theme
->titlebut_disabled_unfocused_color
;
804 theme
->a_hover_focused_max
->texture
[0].data
.mask
.color
=
805 theme
->a_hover_focused_close
->texture
[0].data
.mask
.color
=
806 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.color
=
807 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.color
=
808 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.color
=
809 theme
->titlebut_hover_focused_color
;
810 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.color
=
811 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.color
=
812 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.color
=
813 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.color
=
814 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.color
=
815 theme
->titlebut_hover_unfocused_color
;
816 theme
->a_toggled_focused_max
->texture
[0].data
.mask
.color
=
817 theme
->a_toggled_focused_desk
->texture
[0].data
.mask
.color
=
818 theme
->a_toggled_focused_shade
->texture
[0].data
.mask
.color
=
819 theme
->titlebut_toggled_focused_color
;
820 theme
->a_toggled_unfocused_max
->texture
[0].data
.mask
.color
=
821 theme
->a_toggled_unfocused_desk
->texture
[0].data
.mask
.color
=
822 theme
->a_toggled_unfocused_shade
->texture
[0].data
.mask
.color
=
823 theme
->titlebut_toggled_unfocused_color
;
824 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.color
=
825 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.color
=
826 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.color
=
827 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.color
=
828 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.color
=
829 theme
->titlebut_focused_unpressed_color
;
830 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.color
=
831 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.color
=
832 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.color
=
833 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.color
=
834 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.color
=
835 theme
->titlebut_focused_pressed_color
;
836 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.color
=
837 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.color
=
838 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.color
=
839 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.color
=
840 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.color
=
841 theme
->titlebut_unfocused_unpressed_color
;
842 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.color
=
843 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.color
=
844 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.color
=
845 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.color
=
846 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.color
=
847 theme
->titlebut_unfocused_pressed_color
;
848 theme
->a_menu_bullet
->texture
[0].data
.mask
.color
=
849 theme
->menu_bullet_color
;
851 XrmDestroyDatabase(db
);
853 theme
->label_height
= theme
->winfont_height
;
854 theme
->title_height
= theme
->label_height
+ theme
->bevel
* 2;
855 theme
->button_size
= theme
->label_height
- 2;
856 theme
->grip_width
= theme
->title_height
* 1.5;
861 void RrThemeFree(RrTheme
*theme
)
866 RrColorFree(theme
->b_color
);
867 RrColorFree(theme
->cb_unfocused_color
);
868 RrColorFree(theme
->cb_focused_color
);
869 RrColorFree(theme
->title_unfocused_color
);
870 RrColorFree(theme
->title_focused_color
);
871 RrColorFree(theme
->titlebut_disabled_focused_color
);
872 RrColorFree(theme
->titlebut_disabled_unfocused_color
);
873 RrColorFree(theme
->titlebut_hover_focused_color
);
874 RrColorFree(theme
->titlebut_hover_unfocused_color
);
875 RrColorFree(theme
->titlebut_toggled_focused_color
);
876 RrColorFree(theme
->titlebut_toggled_unfocused_color
);
877 RrColorFree(theme
->titlebut_unfocused_pressed_color
);
878 RrColorFree(theme
->titlebut_focused_pressed_color
);
879 RrColorFree(theme
->titlebut_unfocused_unpressed_color
);
880 RrColorFree(theme
->titlebut_focused_unpressed_color
);
881 RrColorFree(theme
->menu_color
);
882 RrColorFree(theme
->menu_title_color
);
883 RrColorFree(theme
->menu_disabled_color
);
884 RrColorFree(theme
->menu_hilite_color
);
885 RrColorFree(theme
->menu_bullet_color
);
887 RrPixmapMaskFree(theme
->max_mask
);
888 RrPixmapMaskFree(theme
->max_toggled_mask
);
889 RrPixmapMaskFree(theme
->max_disabled_mask
);
890 RrPixmapMaskFree(theme
->max_hover_mask
);
891 RrPixmapMaskFree(theme
->max_pressed_mask
);
892 RrPixmapMaskFree(theme
->desk_mask
);
893 RrPixmapMaskFree(theme
->desk_toggled_mask
);
894 RrPixmapMaskFree(theme
->desk_disabled_mask
);
895 RrPixmapMaskFree(theme
->desk_hover_mask
);
896 RrPixmapMaskFree(theme
->desk_pressed_mask
);
897 RrPixmapMaskFree(theme
->shade_mask
);
898 RrPixmapMaskFree(theme
->shade_toggled_mask
);
899 RrPixmapMaskFree(theme
->shade_disabled_mask
);
900 RrPixmapMaskFree(theme
->shade_hover_mask
);
901 RrPixmapMaskFree(theme
->shade_pressed_mask
);
902 RrPixmapMaskFree(theme
->iconify_mask
);
903 RrPixmapMaskFree(theme
->iconify_disabled_mask
);
904 RrPixmapMaskFree(theme
->iconify_hover_mask
);
905 RrPixmapMaskFree(theme
->iconify_pressed_mask
);
906 RrPixmapMaskFree(theme
->close_mask
);
907 RrPixmapMaskFree(theme
->close_disabled_mask
);
908 RrPixmapMaskFree(theme
->close_hover_mask
);
909 RrPixmapMaskFree(theme
->close_pressed_mask
);
910 RrPixmapMaskFree(theme
->menu_bullet_mask
);
912 RrFontClose(theme
->winfont_focused
);
913 RrFontClose(theme
->winfont_unfocused
);
914 RrFontClose(theme
->mtitlefont
);
915 RrFontClose(theme
->mfont
);
917 RrAppearanceFree(theme
->a_disabled_focused_max
);
918 RrAppearanceFree(theme
->a_disabled_unfocused_max
);
919 RrAppearanceFree(theme
->a_hover_focused_max
);
920 RrAppearanceFree(theme
->a_hover_unfocused_max
);
921 RrAppearanceFree(theme
->a_toggled_focused_max
);
922 RrAppearanceFree(theme
->a_toggled_unfocused_max
);
923 RrAppearanceFree(theme
->a_focused_unpressed_max
);
924 RrAppearanceFree(theme
->a_focused_pressed_max
);
925 RrAppearanceFree(theme
->a_unfocused_unpressed_max
);
926 RrAppearanceFree(theme
->a_unfocused_pressed_max
);
927 RrAppearanceFree(theme
->a_disabled_focused_close
);
928 RrAppearanceFree(theme
->a_disabled_unfocused_close
);
929 RrAppearanceFree(theme
->a_hover_focused_close
);
930 RrAppearanceFree(theme
->a_hover_unfocused_close
);
931 RrAppearanceFree(theme
->a_focused_unpressed_close
);
932 RrAppearanceFree(theme
->a_focused_pressed_close
);
933 RrAppearanceFree(theme
->a_unfocused_unpressed_close
);
934 RrAppearanceFree(theme
->a_unfocused_pressed_close
);
935 RrAppearanceFree(theme
->a_disabled_focused_desk
);
936 RrAppearanceFree(theme
->a_disabled_unfocused_desk
);
937 RrAppearanceFree(theme
->a_hover_focused_desk
);
938 RrAppearanceFree(theme
->a_hover_unfocused_desk
);
939 RrAppearanceFree(theme
->a_toggled_focused_desk
);
940 RrAppearanceFree(theme
->a_toggled_unfocused_desk
);
941 RrAppearanceFree(theme
->a_focused_unpressed_desk
);
942 RrAppearanceFree(theme
->a_focused_pressed_desk
);
943 RrAppearanceFree(theme
->a_unfocused_unpressed_desk
);
944 RrAppearanceFree(theme
->a_unfocused_pressed_desk
);
945 RrAppearanceFree(theme
->a_disabled_focused_shade
);
946 RrAppearanceFree(theme
->a_disabled_unfocused_shade
);
947 RrAppearanceFree(theme
->a_hover_focused_shade
);
948 RrAppearanceFree(theme
->a_hover_unfocused_shade
);
949 RrAppearanceFree(theme
->a_toggled_focused_shade
);
950 RrAppearanceFree(theme
->a_toggled_unfocused_shade
);
951 RrAppearanceFree(theme
->a_focused_unpressed_shade
);
952 RrAppearanceFree(theme
->a_focused_pressed_shade
);
953 RrAppearanceFree(theme
->a_unfocused_unpressed_shade
);
954 RrAppearanceFree(theme
->a_unfocused_pressed_shade
);
955 RrAppearanceFree(theme
->a_disabled_focused_iconify
);
956 RrAppearanceFree(theme
->a_disabled_unfocused_iconify
);
957 RrAppearanceFree(theme
->a_hover_focused_iconify
);
958 RrAppearanceFree(theme
->a_hover_unfocused_iconify
);
959 RrAppearanceFree(theme
->a_focused_unpressed_iconify
);
960 RrAppearanceFree(theme
->a_focused_pressed_iconify
);
961 RrAppearanceFree(theme
->a_unfocused_unpressed_iconify
);
962 RrAppearanceFree(theme
->a_unfocused_pressed_iconify
);
963 RrAppearanceFree(theme
->a_focused_grip
);
964 RrAppearanceFree(theme
->a_unfocused_grip
);
965 RrAppearanceFree(theme
->a_focused_title
);
966 RrAppearanceFree(theme
->a_unfocused_title
);
967 RrAppearanceFree(theme
->a_focused_label
);
968 RrAppearanceFree(theme
->a_unfocused_label
);
969 RrAppearanceFree(theme
->a_icon
);
970 RrAppearanceFree(theme
->a_focused_handle
);
971 RrAppearanceFree(theme
->a_unfocused_handle
);
972 RrAppearanceFree(theme
->a_menu
);
973 RrAppearanceFree(theme
->a_menu_title
);
974 RrAppearanceFree(theme
->a_menu_item
);
975 RrAppearanceFree(theme
->a_menu_disabled
);
976 RrAppearanceFree(theme
->a_menu_hilite
);
977 RrAppearanceFree(theme
->a_menu_text_item
);
978 RrAppearanceFree(theme
->a_menu_text_disabled
);
979 RrAppearanceFree(theme
->a_menu_text_hilite
);
980 RrAppearanceFree(theme
->a_clear
);
981 RrAppearanceFree(theme
->a_clear_tex
);
982 RrAppearanceFree(theme
->app_hilite_bg
);
983 RrAppearanceFree(theme
->app_unhilite_bg
);
984 RrAppearanceFree(theme
->app_hilite_label
);
985 RrAppearanceFree(theme
->app_unhilite_label
);
989 static XrmDatabase
loaddb(RrTheme
*theme
, char *name
)
993 char *s
= g_build_filename(g_get_home_dir(), ".openbox", "themes",
994 name
, "themerc", NULL
);
995 if ((db
= XrmGetFileDatabase(s
)))
996 theme
->path
= g_path_get_dirname(s
);
999 char *s
= g_build_filename(THEMEDIR
, name
, "themerc", NULL
);
1000 if ((db
= XrmGetFileDatabase(s
)))
1001 theme
->path
= g_path_get_dirname(s
);
1005 char *s
= g_build_filename(name
, "themerc", NULL
);
1006 if ((db
= XrmGetFileDatabase(s
)))
1007 theme
->path
= g_path_get_dirname(s
);
1014 static char *create_class_name(char *rname
)
1016 char *rclass
= g_strdup(rname
);
1021 p
= strchr(p
+1, '.');
1022 if (p
== NULL
) break;
1024 if (*p
== '\0') break;
1029 static gboolean
read_int(XrmDatabase db
, char *rname
, int *value
)
1031 gboolean ret
= FALSE
;
1032 char *rclass
= create_class_name(rname
);
1033 char *rettype
, *end
;
1036 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1037 retvalue
.addr
!= NULL
) {
1038 *value
= (int)strtol(retvalue
.addr
, &end
, 10);
1039 if (end
!= retvalue
.addr
)
1047 static gboolean
read_string(XrmDatabase db
, char *rname
, char **value
)
1049 gboolean ret
= FALSE
;
1050 char *rclass
= create_class_name(rname
);
1054 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1055 retvalue
.addr
!= NULL
) {
1056 *value
= retvalue
.addr
;
1064 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
1065 gchar
*rname
, RrColor
**value
)
1067 gboolean ret
= FALSE
;
1068 char *rclass
= create_class_name(rname
);
1072 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1073 retvalue
.addr
!= NULL
) {
1074 RrColor
*c
= RrColorParse(inst
, retvalue
.addr
);
1085 static gboolean
read_mask(const RrInstance
*inst
,
1086 gchar
*maskname
, RrTheme
*theme
,
1087 RrPixmapMask
**value
)
1089 gboolean ret
= FALSE
;
1091 int hx
, hy
; /* ignored */
1095 s
= g_build_filename(theme
->path
, maskname
, NULL
);
1096 if (XReadBitmapFileData(s
, &w
, &h
, &b
, &hx
, &hy
) == BitmapSuccess
) {
1098 *value
= RrPixmapMaskNew(inst
, w
, h
, (char*)b
);
1106 static void parse_appearance(gchar
*tex
, RrSurfaceColorType
*grad
,
1107 RrReliefType
*relief
, RrBevelType
*bevel
,
1108 gboolean
*interlaced
, gboolean
*border
,
1109 gboolean allow_trans
)
1113 /* convert to all lowercase */
1114 for (t
= tex
; *t
!= '\0'; ++t
)
1115 *t
= g_ascii_tolower(*t
);
1117 if (allow_trans
&& strstr(tex
, "parentrelative") != NULL
) {
1118 *grad
= RR_SURFACE_PARENTREL
;
1120 if (strstr(tex
, "gradient") != NULL
) {
1121 if (strstr(tex
, "crossdiagonal") != NULL
)
1122 *grad
= RR_SURFACE_CROSS_DIAGONAL
;
1123 else if (strstr(tex
, "pyramid") != NULL
)
1124 *grad
= RR_SURFACE_PYRAMID
;
1125 else if (strstr(tex
, "horizontal") != NULL
)
1126 *grad
= RR_SURFACE_HORIZONTAL
;
1127 else if (strstr(tex
, "vertical") != NULL
)
1128 *grad
= RR_SURFACE_VERTICAL
;
1130 *grad
= RR_SURFACE_DIAGONAL
;
1132 *grad
= RR_SURFACE_SOLID
;
1135 if (strstr(tex
, "sunken") != NULL
)
1136 *relief
= RR_RELIEF_SUNKEN
;
1137 else if (strstr(tex
, "flat") != NULL
)
1138 *relief
= RR_RELIEF_FLAT
;
1140 *relief
= RR_RELIEF_RAISED
;
1143 if (*relief
== RR_RELIEF_FLAT
) {
1144 if (strstr(tex
, "border") != NULL
)
1147 if (strstr(tex
, "bevel2") != NULL
)
1148 *bevel
= RR_BEVEL_2
;
1150 *bevel
= RR_BEVEL_1
;
1153 if (strstr(tex
, "interlaced") != NULL
)
1156 *interlaced
= FALSE
;
1161 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
1162 gchar
*rname
, RrAppearance
*value
,
1163 gboolean allow_trans
)
1165 gboolean ret
= FALSE
;
1166 char *rclass
= create_class_name(rname
), *cname
, *ctoname
, *bcname
;
1170 cname
= g_strconcat(rname
, ".color", NULL
);
1171 ctoname
= g_strconcat(rname
, ".colorTo", NULL
);
1172 bcname
= g_strconcat(rname
, ".borderColor", NULL
);
1174 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1175 retvalue
.addr
!= NULL
) {
1176 parse_appearance(retvalue
.addr
,
1177 &value
->surface
.grad
,
1178 &value
->surface
.relief
,
1179 &value
->surface
.bevel
,
1180 &value
->surface
.interlaced
,
1181 &value
->surface
.border
,
1183 if (!read_color(db
, inst
, cname
, &value
->surface
.primary
))
1184 value
->surface
.primary
= RrColorNew(inst
, 0, 0, 0);
1185 if (!read_color(db
, inst
, ctoname
, &value
->surface
.secondary
))
1186 value
->surface
.secondary
= RrColorNew(inst
, 0, 0, 0);
1187 if (value
->surface
.border
)
1188 if (!read_color(db
, inst
, bcname
,
1189 &value
->surface
.border_color
))
1190 value
->surface
.border_color
= RrColorNew(inst
, 0, 0, 0);
1201 static void set_default_appearance(RrAppearance
*a
)
1203 a
->surface
.grad
= RR_SURFACE_SOLID
;
1204 a
->surface
.relief
= RR_RELIEF_FLAT
;
1205 a
->surface
.bevel
= RR_BEVEL_1
;
1206 a
->surface
.interlaced
= FALSE
;
1207 a
->surface
.border
= FALSE
;
1208 a
->surface
.primary
= RrColorNew(a
->inst
, 0, 0, 0);
1209 a
->surface
.secondary
= RrColorNew(a
->inst
, 0, 0, 0);