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
->show_handle
= TRUE
;
40 theme
->a_disabled_focused_max
= RrAppearanceNew(inst
, 1);
41 theme
->a_disabled_unfocused_max
= RrAppearanceNew(inst
, 1);
42 theme
->a_hover_focused_max
= RrAppearanceNew(inst
, 1);
43 theme
->a_hover_unfocused_max
= RrAppearanceNew(inst
, 1);
44 theme
->a_toggled_focused_max
= RrAppearanceNew(inst
, 1);
45 theme
->a_toggled_unfocused_max
= RrAppearanceNew(inst
, 1);
46 theme
->a_focused_unpressed_max
= RrAppearanceNew(inst
, 1);
47 theme
->a_focused_pressed_max
= RrAppearanceNew(inst
, 1);
48 theme
->a_unfocused_unpressed_max
= RrAppearanceNew(inst
, 1);
49 theme
->a_unfocused_pressed_max
= RrAppearanceNew(inst
, 1);
50 theme
->a_focused_grip
= RrAppearanceNew(inst
, 0);
51 theme
->a_unfocused_grip
= RrAppearanceNew(inst
, 0);
52 theme
->a_focused_title
= RrAppearanceNew(inst
, 0);
53 theme
->a_unfocused_title
= RrAppearanceNew(inst
, 0);
54 theme
->a_focused_label
= RrAppearanceNew(inst
, 1);
55 theme
->a_unfocused_label
= RrAppearanceNew(inst
, 1);
56 theme
->a_icon
= RrAppearanceNew(inst
, 1);
57 theme
->a_focused_handle
= RrAppearanceNew(inst
, 0);
58 theme
->a_unfocused_handle
= RrAppearanceNew(inst
, 0);
59 theme
->a_menu
= RrAppearanceNew(inst
, 0);
60 theme
->a_menu_title
= RrAppearanceNew(inst
, 1);
61 theme
->a_menu_item
= RrAppearanceNew(inst
, 0);
62 theme
->a_menu_disabled
= RrAppearanceNew(inst
, 0);
63 theme
->a_menu_selected
= RrAppearanceNew(inst
, 0);
64 theme
->a_menu_text_item
= RrAppearanceNew(inst
, 1);
65 theme
->a_menu_text_disabled
= RrAppearanceNew(inst
, 1);
66 theme
->a_menu_text_selected
= RrAppearanceNew(inst
, 1);
67 theme
->a_menu_bullet
= RrAppearanceNew(inst
, 1);
68 theme
->a_clear
= RrAppearanceNew(inst
, 0);
69 theme
->a_clear_tex
= RrAppearanceNew(inst
, 1);
71 theme
->app_selected_bg
= RrAppearanceNew(inst
, 0);
72 theme
->app_unselected_bg
= RrAppearanceNew(inst
, 0);
73 theme
->app_selected_label
= RrAppearanceNew(inst
, 1);
74 theme
->app_unselected_label
= RrAppearanceNew(inst
, 1);
77 db
= loaddb(theme
, name
);
79 g_warning("Failed to load the theme '%s'\n"
80 "Falling back to the default: '%s'",
83 theme
->name
= g_path_get_basename(name
);
86 db
= loaddb(theme
, DEFAULT_THEME
);
88 g_warning("Failed to load the theme '%s'.", DEFAULT_THEME
);
91 theme
->name
= g_path_get_basename(DEFAULT_THEME
);
94 /* load the font stuff */
95 if (!read_string(db
, "window.label.focus.font", &font_str
))
96 font_str
= "arial,sans:bold:pixelsize=10:shadow=y:shadowtint=50";
98 if (!(theme
->winfont_focused
= RrFontOpen(inst
, font_str
))) {
102 theme
->winfont_height
= RrFontHeight(theme
->winfont_focused
);
104 if (!read_string(db
, "window.label.unfocus.font", &font_str
))
105 /* font_str will already be set to the last one */;
107 if (!(theme
->winfont_unfocused
= RrFontOpen(inst
, font_str
))) {
111 theme
->winfont_height
= MAX(theme
->winfont_height
,
112 RrFontHeight(theme
->winfont_unfocused
));
114 winjust
= RR_JUSTIFY_LEFT
;
115 if (read_string(db
, "window.label.justify", &str
)) {
116 if (!g_ascii_strcasecmp(str
, "right"))
117 winjust
= RR_JUSTIFY_RIGHT
;
118 else if (!g_ascii_strcasecmp(str
, "center"))
119 winjust
= RR_JUSTIFY_CENTER
;
122 if (!read_string(db
, "menu.title.font", &font_str
))
123 font_str
= "arial,sans:bold:pixelsize=12:shadow=y";
125 if (!(theme
->mtitlefont
= RrFontOpen(inst
, font_str
))) {
129 theme
->mtitlefont_height
= RrFontHeight(theme
->mtitlefont
);
131 mtitlejust
= RR_JUSTIFY_LEFT
;
132 if (read_string(db
, "menu.title.justify", &str
)) {
133 if (!g_ascii_strcasecmp(str
, "right"))
134 mtitlejust
= RR_JUSTIFY_RIGHT
;
135 else if (!g_ascii_strcasecmp(str
, "center"))
136 mtitlejust
= RR_JUSTIFY_CENTER
;
139 if (!read_string(db
, "menu.items.font", &font_str
))
140 font_str
= "arial,sans:bold:pixelsize=11:shadow=y";
142 if (!(theme
->mfont
= RrFontOpen(inst
, font_str
))) {
146 theme
->mfont_height
= RrFontHeight(theme
->mfont
);
148 /* load direct dimensions */
149 if (!read_int(db
, "menuOverlap", &theme
->menu_overlap
) ||
150 theme
->menu_overlap
< 0 || theme
->menu_overlap
> 20)
151 theme
->menu_overlap
= 0;
152 if (!read_int(db
, "handleWidth", &theme
->handle_height
))
153 theme
->handle_height
= 6;
154 if (!theme
->handle_height
)
155 theme
->show_handle
= FALSE
;
156 if (theme
->handle_height
<= 0 || theme
->handle_height
> 100)
157 theme
->handle_height
= 6;
158 if (!read_int(db
, "bevelWidth", &theme
->bevel
) ||
159 theme
->bevel
<= 0 || theme
->bevel
> 100)
161 if (!read_int(db
, "borderWidth", &theme
->bwidth
) ||
162 theme
->bwidth
< 0 || theme
->bwidth
> 100)
164 if (!read_int(db
, "frameWidth", &theme
->cbwidth
) ||
165 theme
->cbwidth
< 0 || theme
->cbwidth
> 100)
166 theme
->cbwidth
= theme
->bevel
;
169 if (!read_color(db
, inst
,
170 "borderColor", &theme
->b_color
))
171 theme
->b_color
= RrColorNew(inst
, 0, 0, 0);
172 if (!read_color(db
, inst
,
173 "window.frame.focusColor", &theme
->cb_focused_color
))
174 theme
->cb_focused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
175 if (!read_color(db
, inst
,
176 "window.frame.unfocusColor",&theme
->cb_unfocused_color
))
177 theme
->cb_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
178 if (!read_color(db
, inst
,
179 "window.label.focus.textColor",
180 &theme
->title_focused_color
))
181 theme
->title_focused_color
= RrColorNew(inst
, 0x0, 0x0, 0x0);
182 if (!read_color(db
, inst
,
183 "window.label.unfocus.textColor",
184 &theme
->title_unfocused_color
))
185 theme
->title_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
186 if (!read_color(db
, inst
,
187 "window.button.focus.imageColor",
188 &theme
->titlebut_focused_unpressed_color
))
189 theme
->titlebut_focused_unpressed_color
= RrColorNew(inst
, 0, 0, 0);
190 if (!read_color(db
, inst
,
191 "window.button.unfocus.imageColor",
192 &theme
->titlebut_unfocused_unpressed_color
))
193 theme
->titlebut_unfocused_unpressed_color
=
194 RrColorNew(inst
, 0xff, 0xff, 0xff);
195 if (!read_color(db
, inst
,
196 "window.button.pressed.focus.imageColor",
197 &theme
->titlebut_focused_pressed_color
))
198 theme
->titlebut_focused_pressed_color
=
200 theme
->titlebut_focused_unpressed_color
->r
,
201 theme
->titlebut_focused_unpressed_color
->g
,
202 theme
->titlebut_focused_unpressed_color
->b
);
203 if (!read_color(db
, inst
,
204 "window.button.pressed.unfocus.imageColor",
205 &theme
->titlebut_unfocused_pressed_color
))
206 theme
->titlebut_unfocused_pressed_color
=
208 theme
->titlebut_unfocused_unpressed_color
->r
,
209 theme
->titlebut_unfocused_unpressed_color
->g
,
210 theme
->titlebut_unfocused_unpressed_color
->b
);
211 if (!read_color(db
, inst
,
212 "window.button.disabled.focus.imageColor",
213 &theme
->titlebut_disabled_focused_color
))
214 theme
->titlebut_disabled_focused_color
=
215 RrColorNew(inst
, 0xff, 0xff, 0xff);
216 if (!read_color(db
, inst
,
217 "window.button.disabled.unfocus.imageColor",
218 &theme
->titlebut_disabled_unfocused_color
))
219 theme
->titlebut_disabled_unfocused_color
= RrColorNew(inst
, 0, 0, 0);
220 if (!read_color(db
, inst
,
221 "window.button.hover.focus.imageColor",
222 &theme
->titlebut_hover_focused_color
))
223 theme
->titlebut_hover_focused_color
=
225 theme
->titlebut_focused_unpressed_color
->r
,
226 theme
->titlebut_focused_unpressed_color
->g
,
227 theme
->titlebut_focused_unpressed_color
->b
);
228 if (!read_color(db
, inst
,
229 "window.button.hover.unfocus.imageColor",
230 &theme
->titlebut_hover_unfocused_color
))
231 theme
->titlebut_hover_unfocused_color
=
233 theme
->titlebut_unfocused_unpressed_color
->r
,
234 theme
->titlebut_unfocused_unpressed_color
->g
,
235 theme
->titlebut_unfocused_unpressed_color
->b
);
236 if (!read_color(db
, inst
,
237 "window.button.toggled.focus.imageColor",
238 &theme
->titlebut_toggled_focused_color
))
239 theme
->titlebut_toggled_focused_color
=
241 theme
->titlebut_focused_pressed_color
->r
,
242 theme
->titlebut_focused_pressed_color
->g
,
243 theme
->titlebut_focused_pressed_color
->b
);
244 if (!read_color(db
, inst
,
245 "window.button.toggled.unfocus.imageColor",
246 &theme
->titlebut_toggled_unfocused_color
))
247 theme
->titlebut_toggled_unfocused_color
=
249 theme
->titlebut_unfocused_pressed_color
->r
,
250 theme
->titlebut_unfocused_pressed_color
->g
,
251 theme
->titlebut_unfocused_pressed_color
->b
);
252 if (!read_color(db
, inst
,
253 "menu.title.textColor", &theme
->menu_title_color
))
254 theme
->menu_title_color
= RrColorNew(inst
, 0, 0, 0);
255 if (!read_color(db
, inst
,
256 "menu.items.textColor", &theme
->menu_color
))
257 theme
->menu_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
258 if (!read_color(db
, inst
,
259 "menu.bullet.imageColor", &theme
->menu_bullet_color
))
260 theme
->menu_bullet_color
= RrColorNew(inst
, 0, 0, 0);
261 if (!read_color(db
, inst
,
262 "menu.disabled.textColor", &theme
->menu_disabled_color
))
263 theme
->menu_disabled_color
= RrColorNew(inst
, 0, 0, 0);
264 if (!read_color(db
, inst
,
265 "menu.selected.textColor", &theme
->menu_selected_color
))
266 theme
->menu_selected_color
= RrColorNew(inst
, 0, 0, 0);
269 if (read_mask(inst
, "max.xbm", theme
, &theme
->max_mask
)) {
270 if (!read_mask(inst
, "max_pressed.xbm", theme
,
271 &theme
->max_pressed_mask
)) {
272 theme
->max_pressed_mask
= RrPixmapMaskCopy(theme
->max_mask
);
274 if (!read_mask(inst
, "max_toggled.xbm", theme
,
275 &theme
->max_toggled_mask
)) {
276 theme
->max_toggled_mask
=
277 RrPixmapMaskCopy(theme
->max_pressed_mask
);
279 if (!read_mask(inst
, "max_disabled.xbm", theme
,
280 &theme
->max_disabled_mask
)) {
281 theme
->max_disabled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
283 if (!read_mask(inst
, "max_hover.xbm", theme
, &theme
->max_hover_mask
)) {
284 theme
->max_hover_mask
= RrPixmapMaskCopy(theme
->max_mask
);
288 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
289 theme
->max_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
292 guchar data
[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
293 theme
->max_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
295 theme
->max_pressed_mask
= RrPixmapMaskCopy(theme
->max_mask
);
296 theme
->max_disabled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
297 theme
->max_hover_mask
= RrPixmapMaskCopy(theme
->max_mask
);
300 if (read_mask(inst
, "iconify.xbm", theme
, &theme
->iconify_mask
)) {
301 if (!read_mask(inst
, "iconify_pressed.xbm", theme
,
302 &theme
->iconify_pressed_mask
)) {
303 theme
->iconify_pressed_mask
=
304 RrPixmapMaskCopy(theme
->iconify_mask
);
306 if (!read_mask(inst
, "iconify_disabled.xbm", theme
,
307 &theme
->iconify_disabled_mask
)) {
308 theme
->iconify_disabled_mask
=
309 RrPixmapMaskCopy(theme
->iconify_mask
);
311 if (!read_mask(inst
, "iconify_hover.xbm", theme
,
312 &theme
->iconify_hover_mask
)) {
313 theme
->iconify_hover_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
317 guchar data
[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
318 theme
->iconify_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
320 theme
->iconify_pressed_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
321 theme
->iconify_disabled_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
322 theme
->iconify_hover_mask
= RrPixmapMaskCopy(theme
->iconify_mask
);
325 if (read_mask(inst
, "desk.xbm", theme
, &theme
->desk_mask
)) {
326 if (!read_mask(inst
, "desk_pressed.xbm", theme
,
327 &theme
->desk_pressed_mask
)) {
328 theme
->desk_pressed_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
330 if (!read_mask(inst
, "desk_toggled.xbm", theme
,
331 &theme
->desk_toggled_mask
)) {
332 theme
->desk_toggled_mask
=
333 RrPixmapMaskCopy(theme
->desk_pressed_mask
);
335 if (!read_mask(inst
, "desk_disabled.xbm", theme
,
336 &theme
->desk_disabled_mask
)) {
337 theme
->desk_disabled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
339 if (!read_mask(inst
, "desk_hover.xbm", theme
,
340 &theme
->desk_hover_mask
)) {
341 theme
->desk_hover_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
345 guchar data
[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
346 theme
->desk_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
349 guchar data
[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
350 theme
->desk_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7,
353 theme
->desk_pressed_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
354 theme
->desk_disabled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
355 theme
->desk_hover_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
358 if (read_mask(inst
, "shade.xbm", theme
, &theme
->shade_mask
)) {
359 if (!read_mask(inst
, "shade_pressed.xbm", theme
,
360 &theme
->shade_pressed_mask
)) {
361 theme
->shade_pressed_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
363 if (!read_mask(inst
, "shade_toggled.xbm", theme
,
364 &theme
->shade_toggled_mask
)) {
365 theme
->shade_toggled_mask
=
366 RrPixmapMaskCopy(theme
->shade_pressed_mask
);
368 if (!read_mask(inst
, "shade_disabled.xbm", theme
,
369 &theme
->shade_disabled_mask
)) {
370 theme
->shade_disabled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
372 if (!read_mask(inst
, "shade_hover.xbm", theme
,
373 &theme
->shade_hover_mask
)) {
374 theme
->shade_hover_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
378 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
379 theme
->shade_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
382 guchar data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
383 theme
->shade_toggled_mask
= RrPixmapMaskNew(inst
, 7, 7,
386 theme
->shade_pressed_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
387 theme
->shade_disabled_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
388 theme
->shade_hover_mask
= RrPixmapMaskCopy(theme
->shade_mask
);
391 if (read_mask(inst
, "close.xbm", theme
, &theme
->close_mask
)) {
392 if (!read_mask(inst
, "close_pressed.xbm", theme
,
393 &theme
->close_pressed_mask
)) {
394 theme
->close_pressed_mask
= RrPixmapMaskCopy(theme
->close_mask
);
396 if (!read_mask(inst
, "close_disabled.xbm", theme
,
397 &theme
->close_disabled_mask
)) {
398 theme
->close_disabled_mask
= RrPixmapMaskCopy(theme
->close_mask
);
400 if (!read_mask(inst
, "close_hover.xbm", theme
,
401 &theme
->close_hover_mask
)) {
402 theme
->close_hover_mask
= RrPixmapMaskCopy(theme
->close_mask
);
406 guchar data
[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
407 theme
->close_mask
= RrPixmapMaskNew(inst
, 7, 7, (char*)data
);
409 theme
->close_pressed_mask
= RrPixmapMaskCopy(theme
->close_mask
);
410 theme
->close_disabled_mask
= RrPixmapMaskCopy(theme
->close_mask
);
411 theme
->close_hover_mask
= RrPixmapMaskCopy(theme
->close_mask
);
414 if (!read_mask(inst
, "bullet.xbm", theme
, &theme
->menu_bullet_mask
)) {
415 guchar data
[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
416 theme
->menu_bullet_mask
= RrPixmapMaskNew(inst
, 4, 7, (char*)data
);
419 /* read the decoration textures */
420 if (!read_appearance(db
, inst
,
421 "window.title.focus", theme
->a_focused_title
,
423 set_default_appearance(theme
->a_focused_title
);
424 if (!read_appearance(db
, inst
,
425 "window.title.unfocus", theme
->a_unfocused_title
,
427 set_default_appearance(theme
->a_unfocused_title
);
428 if (!read_appearance(db
, inst
,
429 "window.label.focus", theme
->a_focused_label
,
431 set_default_appearance(theme
->a_focused_label
);
432 if (!read_appearance(db
, inst
,
433 "window.label.unfocus", theme
->a_unfocused_label
,
435 set_default_appearance(theme
->a_unfocused_label
);
436 if (!read_appearance(db
, inst
,
437 "window.handle.focus", theme
->a_focused_handle
,
439 set_default_appearance(theme
->a_focused_handle
);
440 if (!read_appearance(db
, inst
,
441 "window.handle.unfocus",theme
->a_unfocused_handle
,
443 set_default_appearance(theme
->a_unfocused_handle
);
444 if (!read_appearance(db
, inst
,
445 "window.grip.focus", theme
->a_focused_grip
,
447 set_default_appearance(theme
->a_focused_grip
);
448 if (!read_appearance(db
, inst
,
449 "window.grip.unfocus", theme
->a_unfocused_grip
,
451 set_default_appearance(theme
->a_unfocused_grip
);
452 if (!read_appearance(db
, inst
,
453 "menu.items", theme
->a_menu
,
455 set_default_appearance(theme
->a_menu
);
456 if (!read_appearance(db
, inst
,
457 "menu.title", theme
->a_menu_title
,
459 set_default_appearance(theme
->a_menu_title
);
460 if (!read_appearance(db
, inst
,
461 "menu.selected", theme
->a_menu_selected
,
463 set_default_appearance(theme
->a_menu_selected
);
465 /* read the appearances for rendering non-decorations */
466 if (!read_appearance(db
, inst
,
467 "window.title.focus", theme
->app_selected_bg
,
469 set_default_appearance(theme
->app_selected_bg
);
470 if (!read_appearance(db
, inst
,
471 "window.label.focus", theme
->app_selected_label
,
473 set_default_appearance(theme
->app_selected_label
);
474 if (!read_appearance(db
, inst
,
475 "window.title.unfocus", theme
->app_unselected_bg
,
477 set_default_appearance(theme
->app_unselected_bg
);
478 if (!read_appearance(db
, inst
,
479 "window.label.unfocus", theme
->app_unselected_label
,
481 set_default_appearance(theme
->app_unselected_label
);
483 /* read buttons textures */
484 if (!read_appearance(db
, inst
,
485 "window.button.disabled.focus",
486 theme
->a_disabled_focused_max
,
488 set_default_appearance(theme
->a_disabled_focused_max
);
489 if (!read_appearance(db
, inst
,
490 "window.button.disabled.unfocus",
491 theme
->a_disabled_unfocused_max
,
493 set_default_appearance(theme
->a_disabled_unfocused_max
);
494 if (!read_appearance(db
, inst
,
495 "window.button.pressed.focus",
496 theme
->a_focused_pressed_max
,
498 set_default_appearance(theme
->a_focused_pressed_max
);
499 if (!read_appearance(db
, inst
,
500 "window.button.pressed.unfocus",
501 theme
->a_unfocused_pressed_max
,
503 set_default_appearance(theme
->a_unfocused_pressed_max
);
504 if (!read_appearance(db
, inst
,
505 "window.button.toggled.focus",
506 theme
->a_toggled_focused_max
,
509 RrAppearanceFree(theme
->a_toggled_focused_max
);
510 theme
->a_toggled_focused_max
=
511 RrAppearanceCopy(theme
->a_focused_pressed_max
);
513 if (!read_appearance(db
, inst
,
514 "window.button.toggled.unfocus",
515 theme
->a_toggled_unfocused_max
,
518 RrAppearanceFree(theme
->a_toggled_unfocused_max
);
519 theme
->a_toggled_unfocused_max
=
520 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
522 if (!read_appearance(db
, inst
,
523 "window.button.focus",
524 theme
->a_focused_unpressed_max
,
526 set_default_appearance(theme
->a_focused_unpressed_max
);
527 if (!read_appearance(db
, inst
,
528 "window.button.unfocus",
529 theme
->a_unfocused_unpressed_max
,
531 set_default_appearance(theme
->a_unfocused_unpressed_max
);
532 if (!read_appearance(db
, inst
,
533 "window.button.hover.focus",
534 theme
->a_hover_focused_max
,
537 RrAppearanceFree(theme
->a_hover_focused_max
);
538 theme
->a_hover_focused_max
=
539 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
541 if (!read_appearance(db
, inst
,
542 "window.button.hover.unfocus",
543 theme
->a_hover_unfocused_max
,
546 RrAppearanceFree(theme
->a_hover_unfocused_max
);
547 theme
->a_hover_unfocused_max
=
548 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
551 theme
->a_disabled_focused_close
=
552 RrAppearanceCopy(theme
->a_disabled_focused_max
);
553 theme
->a_disabled_unfocused_close
=
554 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
555 theme
->a_hover_focused_close
=
556 RrAppearanceCopy(theme
->a_hover_focused_max
);
557 theme
->a_hover_unfocused_close
=
558 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
559 theme
->a_unfocused_unpressed_close
=
560 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
561 theme
->a_unfocused_pressed_close
=
562 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
563 theme
->a_focused_unpressed_close
=
564 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
565 theme
->a_focused_pressed_close
=
566 RrAppearanceCopy(theme
->a_focused_pressed_max
);
567 theme
->a_disabled_focused_desk
=
568 RrAppearanceCopy(theme
->a_disabled_focused_max
);
569 theme
->a_disabled_unfocused_desk
=
570 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
571 theme
->a_hover_focused_desk
=
572 RrAppearanceCopy(theme
->a_hover_focused_max
);
573 theme
->a_hover_unfocused_desk
=
574 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
575 theme
->a_toggled_focused_desk
=
576 RrAppearanceCopy(theme
->a_toggled_focused_max
);
577 theme
->a_toggled_unfocused_desk
=
578 RrAppearanceCopy(theme
->a_toggled_unfocused_max
);
579 theme
->a_unfocused_unpressed_desk
=
580 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
581 theme
->a_unfocused_pressed_desk
=
582 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
583 theme
->a_focused_unpressed_desk
=
584 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
585 theme
->a_focused_pressed_desk
=
586 RrAppearanceCopy(theme
->a_focused_pressed_max
);
587 theme
->a_disabled_focused_shade
=
588 RrAppearanceCopy(theme
->a_disabled_focused_max
);
589 theme
->a_disabled_unfocused_shade
=
590 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
591 theme
->a_hover_focused_shade
=
592 RrAppearanceCopy(theme
->a_hover_focused_max
);
593 theme
->a_hover_unfocused_shade
=
594 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
595 theme
->a_toggled_focused_shade
=
596 RrAppearanceCopy(theme
->a_toggled_focused_max
);
597 theme
->a_toggled_unfocused_shade
=
598 RrAppearanceCopy(theme
->a_toggled_unfocused_max
);
599 theme
->a_unfocused_unpressed_shade
=
600 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
601 theme
->a_unfocused_pressed_shade
=
602 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
603 theme
->a_focused_unpressed_shade
=
604 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
605 theme
->a_focused_pressed_shade
=
606 RrAppearanceCopy(theme
->a_focused_pressed_max
);
607 theme
->a_disabled_focused_iconify
=
608 RrAppearanceCopy(theme
->a_disabled_focused_max
);
609 theme
->a_disabled_unfocused_iconify
=
610 RrAppearanceCopy(theme
->a_disabled_focused_max
);
611 theme
->a_hover_focused_iconify
=
612 RrAppearanceCopy(theme
->a_hover_focused_max
);
613 theme
->a_hover_unfocused_iconify
=
614 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
615 theme
->a_unfocused_unpressed_iconify
=
616 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
617 theme
->a_unfocused_pressed_iconify
=
618 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
619 theme
->a_focused_unpressed_iconify
=
620 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
621 theme
->a_focused_pressed_iconify
=
622 RrAppearanceCopy(theme
->a_focused_pressed_max
);
624 theme
->a_icon
->surface
.grad
=
625 theme
->a_clear
->surface
.grad
=
626 theme
->a_clear_tex
->surface
.grad
=
627 theme
->a_menu_item
->surface
.grad
=
628 theme
->a_menu_disabled
->surface
.grad
=
629 theme
->a_menu_text_item
->surface
.grad
=
630 theme
->a_menu_text_disabled
->surface
.grad
=
631 theme
->a_menu_text_selected
->surface
.grad
=
632 theme
->a_menu_bullet
->surface
.grad
= RR_SURFACE_PARENTREL
;
634 /* set up the textures */
635 theme
->a_focused_label
->texture
[0].type
=
636 theme
->app_selected_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
637 theme
->a_focused_label
->texture
[0].data
.text
.justify
= winjust
;
638 theme
->app_selected_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
639 theme
->a_focused_label
->texture
[0].data
.text
.font
=
640 theme
->app_selected_label
->texture
[0].data
.text
.font
=
641 theme
->winfont_focused
;
642 theme
->a_focused_label
->texture
[0].data
.text
.color
=
643 theme
->app_selected_label
->texture
[0].data
.text
.color
=
644 theme
->title_focused_color
;
646 theme
->a_unfocused_label
->texture
[0].type
=
647 theme
->app_unselected_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
648 theme
->a_unfocused_label
->texture
[0].data
.text
.justify
= winjust
;
649 theme
->app_unselected_label
->texture
[0].data
.text
.justify
=
651 theme
->a_unfocused_label
->texture
[0].data
.text
.font
=
652 theme
->app_unselected_label
->texture
[0].data
.text
.font
=
653 theme
->winfont_unfocused
;
654 theme
->a_unfocused_label
->texture
[0].data
.text
.color
=
655 theme
->app_unselected_label
->texture
[0].data
.text
.color
=
656 theme
->title_unfocused_color
;
658 theme
->a_menu_title
->texture
[0].type
= RR_TEXTURE_TEXT
;
659 theme
->a_menu_title
->texture
[0].data
.text
.justify
= mtitlejust
;
660 theme
->a_menu_title
->texture
[0].data
.text
.font
= theme
->mtitlefont
;
661 theme
->a_menu_title
->texture
[0].data
.text
.color
= theme
->menu_title_color
;
663 theme
->a_menu_text_item
->texture
[0].type
=
664 theme
->a_menu_text_disabled
->texture
[0].type
=
665 theme
->a_menu_text_selected
->texture
[0].type
= RR_TEXTURE_TEXT
;
666 theme
->a_menu_text_item
->texture
[0].data
.text
.justify
=
667 theme
->a_menu_text_disabled
->texture
[0].data
.text
.justify
=
668 theme
->a_menu_text_selected
->texture
[0].data
.text
.justify
=
670 theme
->a_menu_text_item
->texture
[0].data
.text
.font
=
671 theme
->a_menu_text_disabled
->texture
[0].data
.text
.font
=
672 theme
->a_menu_text_selected
->texture
[0].data
.text
.font
= theme
->mfont
;
673 theme
->a_menu_text_item
->texture
[0].data
.text
.color
= theme
->menu_color
;
674 theme
->a_menu_text_disabled
->texture
[0].data
.text
.color
=
675 theme
->menu_disabled_color
;
676 theme
->a_menu_text_selected
->texture
[0].data
.text
.color
=
677 theme
->menu_selected_color
;
678 theme
->a_menu_bullet
->texture
[0].data
.mask
.color
=
679 theme
->menu_bullet_color
;
681 theme
->a_disabled_focused_max
->texture
[0].type
=
682 theme
->a_disabled_unfocused_max
->texture
[0].type
=
683 theme
->a_hover_focused_max
->texture
[0].type
=
684 theme
->a_hover_unfocused_max
->texture
[0].type
=
685 theme
->a_toggled_focused_max
->texture
[0].type
=
686 theme
->a_toggled_unfocused_max
->texture
[0].type
=
687 theme
->a_focused_unpressed_max
->texture
[0].type
=
688 theme
->a_focused_pressed_max
->texture
[0].type
=
689 theme
->a_unfocused_unpressed_max
->texture
[0].type
=
690 theme
->a_unfocused_pressed_max
->texture
[0].type
=
691 theme
->a_disabled_focused_close
->texture
[0].type
=
692 theme
->a_disabled_unfocused_close
->texture
[0].type
=
693 theme
->a_hover_focused_close
->texture
[0].type
=
694 theme
->a_hover_unfocused_close
->texture
[0].type
=
695 theme
->a_focused_unpressed_close
->texture
[0].type
=
696 theme
->a_focused_pressed_close
->texture
[0].type
=
697 theme
->a_unfocused_unpressed_close
->texture
[0].type
=
698 theme
->a_unfocused_pressed_close
->texture
[0].type
=
699 theme
->a_disabled_focused_desk
->texture
[0].type
=
700 theme
->a_disabled_unfocused_desk
->texture
[0].type
=
701 theme
->a_hover_focused_desk
->texture
[0].type
=
702 theme
->a_hover_unfocused_desk
->texture
[0].type
=
703 theme
->a_toggled_focused_desk
->texture
[0].type
=
704 theme
->a_toggled_unfocused_desk
->texture
[0].type
=
705 theme
->a_focused_unpressed_desk
->texture
[0].type
=
706 theme
->a_focused_pressed_desk
->texture
[0].type
=
707 theme
->a_unfocused_unpressed_desk
->texture
[0].type
=
708 theme
->a_unfocused_pressed_desk
->texture
[0].type
=
709 theme
->a_disabled_focused_shade
->texture
[0].type
=
710 theme
->a_disabled_unfocused_shade
->texture
[0].type
=
711 theme
->a_hover_focused_shade
->texture
[0].type
=
712 theme
->a_hover_unfocused_shade
->texture
[0].type
=
713 theme
->a_toggled_focused_shade
->texture
[0].type
=
714 theme
->a_toggled_unfocused_shade
->texture
[0].type
=
715 theme
->a_focused_unpressed_shade
->texture
[0].type
=
716 theme
->a_focused_pressed_shade
->texture
[0].type
=
717 theme
->a_unfocused_unpressed_shade
->texture
[0].type
=
718 theme
->a_unfocused_pressed_shade
->texture
[0].type
=
719 theme
->a_disabled_focused_iconify
->texture
[0].type
=
720 theme
->a_disabled_unfocused_iconify
->texture
[0].type
=
721 theme
->a_hover_focused_iconify
->texture
[0].type
=
722 theme
->a_hover_unfocused_iconify
->texture
[0].type
=
723 theme
->a_focused_unpressed_iconify
->texture
[0].type
=
724 theme
->a_focused_pressed_iconify
->texture
[0].type
=
725 theme
->a_unfocused_unpressed_iconify
->texture
[0].type
=
726 theme
->a_unfocused_pressed_iconify
->texture
[0].type
=
727 theme
->a_menu_bullet
->texture
[0].type
= RR_TEXTURE_MASK
;
729 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.mask
=
730 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.mask
=
731 theme
->max_disabled_mask
;
732 theme
->a_hover_focused_max
->texture
[0].data
.mask
.mask
=
733 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.mask
=
734 theme
->max_hover_mask
;
735 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.mask
=
736 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.mask
=
737 theme
->max_pressed_mask
;
738 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.mask
=
739 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.mask
=
741 theme
->a_toggled_focused_max
->texture
[0].data
.mask
.mask
=
742 theme
->a_toggled_unfocused_max
->texture
[0].data
.mask
.mask
=
743 theme
->max_toggled_mask
;
744 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.mask
=
745 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.mask
=
746 theme
->close_disabled_mask
;
747 theme
->a_hover_focused_close
->texture
[0].data
.mask
.mask
=
748 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.mask
=
749 theme
->close_hover_mask
;
750 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.mask
=
751 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.mask
=
752 theme
->close_pressed_mask
;
753 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.mask
=
754 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.mask
=
756 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.mask
=
757 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.mask
=
758 theme
->desk_disabled_mask
;
759 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.mask
=
760 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.mask
=
761 theme
->desk_hover_mask
;
762 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.mask
=
763 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.mask
=
764 theme
->desk_pressed_mask
;
765 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.mask
=
766 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.mask
=
768 theme
->a_toggled_focused_desk
->texture
[0].data
.mask
.mask
=
769 theme
->a_toggled_unfocused_desk
->texture
[0].data
.mask
.mask
=
770 theme
->desk_toggled_mask
;
771 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.mask
=
772 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.mask
=
773 theme
->shade_disabled_mask
;
774 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.mask
=
775 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.mask
=
776 theme
->shade_hover_mask
;
777 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.mask
=
778 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.mask
=
779 theme
->shade_pressed_mask
;
780 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.mask
=
781 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.mask
=
783 theme
->a_toggled_focused_shade
->texture
[0].data
.mask
.mask
=
784 theme
->a_toggled_unfocused_shade
->texture
[0].data
.mask
.mask
=
785 theme
->shade_toggled_mask
;
786 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.mask
=
787 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.mask
=
788 theme
->iconify_disabled_mask
;
789 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.mask
=
790 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.mask
=
791 theme
->iconify_hover_mask
;
792 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.mask
=
793 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.mask
=
794 theme
->iconify_pressed_mask
;
795 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
796 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
798 theme
->a_menu_bullet
->texture
[0].data
.mask
.mask
=
799 theme
->menu_bullet_mask
;
800 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.color
=
801 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.color
=
802 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.color
=
803 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.color
=
804 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.color
=
805 theme
->titlebut_disabled_focused_color
;
806 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.color
=
807 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.color
=
808 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.color
=
809 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.color
=
810 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.color
=
811 theme
->titlebut_disabled_unfocused_color
;
812 theme
->a_hover_focused_max
->texture
[0].data
.mask
.color
=
813 theme
->a_hover_focused_close
->texture
[0].data
.mask
.color
=
814 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.color
=
815 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.color
=
816 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.color
=
817 theme
->titlebut_hover_focused_color
;
818 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.color
=
819 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.color
=
820 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.color
=
821 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.color
=
822 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.color
=
823 theme
->titlebut_hover_unfocused_color
;
824 theme
->a_toggled_focused_max
->texture
[0].data
.mask
.color
=
825 theme
->a_toggled_focused_desk
->texture
[0].data
.mask
.color
=
826 theme
->a_toggled_focused_shade
->texture
[0].data
.mask
.color
=
827 theme
->titlebut_toggled_focused_color
;
828 theme
->a_toggled_unfocused_max
->texture
[0].data
.mask
.color
=
829 theme
->a_toggled_unfocused_desk
->texture
[0].data
.mask
.color
=
830 theme
->a_toggled_unfocused_shade
->texture
[0].data
.mask
.color
=
831 theme
->titlebut_toggled_unfocused_color
;
832 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.color
=
833 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.color
=
834 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.color
=
835 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.color
=
836 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.color
=
837 theme
->titlebut_focused_unpressed_color
;
838 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.color
=
839 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.color
=
840 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.color
=
841 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.color
=
842 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.color
=
843 theme
->titlebut_focused_pressed_color
;
844 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.color
=
845 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.color
=
846 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.color
=
847 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.color
=
848 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.color
=
849 theme
->titlebut_unfocused_unpressed_color
;
850 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.color
=
851 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.color
=
852 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.color
=
853 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.color
=
854 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.color
=
855 theme
->titlebut_unfocused_pressed_color
;
856 theme
->a_menu_bullet
->texture
[0].data
.mask
.color
=
857 theme
->menu_bullet_color
;
859 XrmDestroyDatabase(db
);
861 theme
->label_height
= theme
->winfont_height
;
862 theme
->title_height
= theme
->label_height
+ theme
->bevel
* 2;
863 theme
->button_size
= theme
->label_height
- 2;
864 theme
->grip_width
= theme
->title_height
* 1.5;
869 void RrThemeFree(RrTheme
*theme
)
874 RrColorFree(theme
->b_color
);
875 RrColorFree(theme
->cb_unfocused_color
);
876 RrColorFree(theme
->cb_focused_color
);
877 RrColorFree(theme
->title_unfocused_color
);
878 RrColorFree(theme
->title_focused_color
);
879 RrColorFree(theme
->titlebut_disabled_focused_color
);
880 RrColorFree(theme
->titlebut_disabled_unfocused_color
);
881 RrColorFree(theme
->titlebut_hover_focused_color
);
882 RrColorFree(theme
->titlebut_hover_unfocused_color
);
883 RrColorFree(theme
->titlebut_toggled_focused_color
);
884 RrColorFree(theme
->titlebut_toggled_unfocused_color
);
885 RrColorFree(theme
->titlebut_unfocused_pressed_color
);
886 RrColorFree(theme
->titlebut_focused_pressed_color
);
887 RrColorFree(theme
->titlebut_unfocused_unpressed_color
);
888 RrColorFree(theme
->titlebut_focused_unpressed_color
);
889 RrColorFree(theme
->menu_color
);
890 RrColorFree(theme
->menu_title_color
);
891 RrColorFree(theme
->menu_disabled_color
);
892 RrColorFree(theme
->menu_selected_color
);
893 RrColorFree(theme
->menu_bullet_color
);
895 RrPixmapMaskFree(theme
->max_mask
);
896 RrPixmapMaskFree(theme
->max_toggled_mask
);
897 RrPixmapMaskFree(theme
->max_disabled_mask
);
898 RrPixmapMaskFree(theme
->max_hover_mask
);
899 RrPixmapMaskFree(theme
->max_pressed_mask
);
900 RrPixmapMaskFree(theme
->desk_mask
);
901 RrPixmapMaskFree(theme
->desk_toggled_mask
);
902 RrPixmapMaskFree(theme
->desk_disabled_mask
);
903 RrPixmapMaskFree(theme
->desk_hover_mask
);
904 RrPixmapMaskFree(theme
->desk_pressed_mask
);
905 RrPixmapMaskFree(theme
->shade_mask
);
906 RrPixmapMaskFree(theme
->shade_toggled_mask
);
907 RrPixmapMaskFree(theme
->shade_disabled_mask
);
908 RrPixmapMaskFree(theme
->shade_hover_mask
);
909 RrPixmapMaskFree(theme
->shade_pressed_mask
);
910 RrPixmapMaskFree(theme
->iconify_mask
);
911 RrPixmapMaskFree(theme
->iconify_disabled_mask
);
912 RrPixmapMaskFree(theme
->iconify_hover_mask
);
913 RrPixmapMaskFree(theme
->iconify_pressed_mask
);
914 RrPixmapMaskFree(theme
->close_mask
);
915 RrPixmapMaskFree(theme
->close_disabled_mask
);
916 RrPixmapMaskFree(theme
->close_hover_mask
);
917 RrPixmapMaskFree(theme
->close_pressed_mask
);
918 RrPixmapMaskFree(theme
->menu_bullet_mask
);
920 RrFontClose(theme
->winfont_focused
);
921 RrFontClose(theme
->winfont_unfocused
);
922 RrFontClose(theme
->mtitlefont
);
923 RrFontClose(theme
->mfont
);
925 RrAppearanceFree(theme
->a_disabled_focused_max
);
926 RrAppearanceFree(theme
->a_disabled_unfocused_max
);
927 RrAppearanceFree(theme
->a_hover_focused_max
);
928 RrAppearanceFree(theme
->a_hover_unfocused_max
);
929 RrAppearanceFree(theme
->a_toggled_focused_max
);
930 RrAppearanceFree(theme
->a_toggled_unfocused_max
);
931 RrAppearanceFree(theme
->a_focused_unpressed_max
);
932 RrAppearanceFree(theme
->a_focused_pressed_max
);
933 RrAppearanceFree(theme
->a_unfocused_unpressed_max
);
934 RrAppearanceFree(theme
->a_unfocused_pressed_max
);
935 RrAppearanceFree(theme
->a_disabled_focused_close
);
936 RrAppearanceFree(theme
->a_disabled_unfocused_close
);
937 RrAppearanceFree(theme
->a_hover_focused_close
);
938 RrAppearanceFree(theme
->a_hover_unfocused_close
);
939 RrAppearanceFree(theme
->a_focused_unpressed_close
);
940 RrAppearanceFree(theme
->a_focused_pressed_close
);
941 RrAppearanceFree(theme
->a_unfocused_unpressed_close
);
942 RrAppearanceFree(theme
->a_unfocused_pressed_close
);
943 RrAppearanceFree(theme
->a_disabled_focused_desk
);
944 RrAppearanceFree(theme
->a_disabled_unfocused_desk
);
945 RrAppearanceFree(theme
->a_hover_focused_desk
);
946 RrAppearanceFree(theme
->a_hover_unfocused_desk
);
947 RrAppearanceFree(theme
->a_toggled_focused_desk
);
948 RrAppearanceFree(theme
->a_toggled_unfocused_desk
);
949 RrAppearanceFree(theme
->a_focused_unpressed_desk
);
950 RrAppearanceFree(theme
->a_focused_pressed_desk
);
951 RrAppearanceFree(theme
->a_unfocused_unpressed_desk
);
952 RrAppearanceFree(theme
->a_unfocused_pressed_desk
);
953 RrAppearanceFree(theme
->a_disabled_focused_shade
);
954 RrAppearanceFree(theme
->a_disabled_unfocused_shade
);
955 RrAppearanceFree(theme
->a_hover_focused_shade
);
956 RrAppearanceFree(theme
->a_hover_unfocused_shade
);
957 RrAppearanceFree(theme
->a_toggled_focused_shade
);
958 RrAppearanceFree(theme
->a_toggled_unfocused_shade
);
959 RrAppearanceFree(theme
->a_focused_unpressed_shade
);
960 RrAppearanceFree(theme
->a_focused_pressed_shade
);
961 RrAppearanceFree(theme
->a_unfocused_unpressed_shade
);
962 RrAppearanceFree(theme
->a_unfocused_pressed_shade
);
963 RrAppearanceFree(theme
->a_disabled_focused_iconify
);
964 RrAppearanceFree(theme
->a_disabled_unfocused_iconify
);
965 RrAppearanceFree(theme
->a_hover_focused_iconify
);
966 RrAppearanceFree(theme
->a_hover_unfocused_iconify
);
967 RrAppearanceFree(theme
->a_focused_unpressed_iconify
);
968 RrAppearanceFree(theme
->a_focused_pressed_iconify
);
969 RrAppearanceFree(theme
->a_unfocused_unpressed_iconify
);
970 RrAppearanceFree(theme
->a_unfocused_pressed_iconify
);
971 RrAppearanceFree(theme
->a_focused_grip
);
972 RrAppearanceFree(theme
->a_unfocused_grip
);
973 RrAppearanceFree(theme
->a_focused_title
);
974 RrAppearanceFree(theme
->a_unfocused_title
);
975 RrAppearanceFree(theme
->a_focused_label
);
976 RrAppearanceFree(theme
->a_unfocused_label
);
977 RrAppearanceFree(theme
->a_icon
);
978 RrAppearanceFree(theme
->a_focused_handle
);
979 RrAppearanceFree(theme
->a_unfocused_handle
);
980 RrAppearanceFree(theme
->a_menu
);
981 RrAppearanceFree(theme
->a_menu_title
);
982 RrAppearanceFree(theme
->a_menu_item
);
983 RrAppearanceFree(theme
->a_menu_disabled
);
984 RrAppearanceFree(theme
->a_menu_selected
);
985 RrAppearanceFree(theme
->a_menu_text_item
);
986 RrAppearanceFree(theme
->a_menu_text_disabled
);
987 RrAppearanceFree(theme
->a_menu_text_selected
);
988 RrAppearanceFree(theme
->a_clear
);
989 RrAppearanceFree(theme
->a_clear_tex
);
990 RrAppearanceFree(theme
->app_selected_bg
);
991 RrAppearanceFree(theme
->app_unselected_bg
);
992 RrAppearanceFree(theme
->app_selected_label
);
993 RrAppearanceFree(theme
->app_unselected_label
);
997 static XrmDatabase
loaddb(RrTheme
*theme
, char *name
)
1001 char *s
= g_build_filename(g_get_home_dir(), ".openbox", "themes",
1002 name
, "themerc", NULL
);
1003 if ((db
= XrmGetFileDatabase(s
)))
1004 theme
->path
= g_path_get_dirname(s
);
1007 char *s
= g_build_filename(THEMEDIR
, name
, "themerc", NULL
);
1008 if ((db
= XrmGetFileDatabase(s
)))
1009 theme
->path
= g_path_get_dirname(s
);
1013 char *s
= g_build_filename(name
, "themerc", NULL
);
1014 if ((db
= XrmGetFileDatabase(s
)))
1015 theme
->path
= g_path_get_dirname(s
);
1022 static char *create_class_name(char *rname
)
1024 char *rclass
= g_strdup(rname
);
1029 p
= strchr(p
+1, '.');
1030 if (p
== NULL
) break;
1032 if (*p
== '\0') break;
1037 static gboolean
read_int(XrmDatabase db
, char *rname
, int *value
)
1039 gboolean ret
= FALSE
;
1040 char *rclass
= create_class_name(rname
);
1041 char *rettype
, *end
;
1044 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1045 retvalue
.addr
!= NULL
) {
1046 *value
= (int)strtol(retvalue
.addr
, &end
, 10);
1047 if (end
!= retvalue
.addr
)
1055 static gboolean
read_string(XrmDatabase db
, char *rname
, char **value
)
1057 gboolean ret
= FALSE
;
1058 char *rclass
= create_class_name(rname
);
1062 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1063 retvalue
.addr
!= NULL
) {
1064 *value
= retvalue
.addr
;
1072 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
1073 gchar
*rname
, RrColor
**value
)
1075 gboolean ret
= FALSE
;
1076 char *rclass
= create_class_name(rname
);
1080 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1081 retvalue
.addr
!= NULL
) {
1082 RrColor
*c
= RrColorParse(inst
, retvalue
.addr
);
1093 static gboolean
read_mask(const RrInstance
*inst
,
1094 gchar
*maskname
, RrTheme
*theme
,
1095 RrPixmapMask
**value
)
1097 gboolean ret
= FALSE
;
1099 int hx
, hy
; /* ignored */
1103 s
= g_build_filename(theme
->path
, maskname
, NULL
);
1104 if (XReadBitmapFileData(s
, &w
, &h
, &b
, &hx
, &hy
) == BitmapSuccess
) {
1106 *value
= RrPixmapMaskNew(inst
, w
, h
, (char*)b
);
1114 static void parse_appearance(gchar
*tex
, RrSurfaceColorType
*grad
,
1115 RrReliefType
*relief
, RrBevelType
*bevel
,
1116 gboolean
*interlaced
, gboolean
*border
,
1117 gboolean allow_trans
)
1121 /* convert to all lowercase */
1122 for (t
= tex
; *t
!= '\0'; ++t
)
1123 *t
= g_ascii_tolower(*t
);
1125 if (allow_trans
&& strstr(tex
, "parentrelative") != NULL
) {
1126 *grad
= RR_SURFACE_PARENTREL
;
1128 if (strstr(tex
, "gradient") != NULL
) {
1129 if (strstr(tex
, "crossdiagonal") != NULL
)
1130 *grad
= RR_SURFACE_CROSS_DIAGONAL
;
1131 else if (strstr(tex
, "pyramid") != NULL
)
1132 *grad
= RR_SURFACE_PYRAMID
;
1133 else if (strstr(tex
, "horizontal") != NULL
)
1134 *grad
= RR_SURFACE_HORIZONTAL
;
1135 else if (strstr(tex
, "vertical") != NULL
)
1136 *grad
= RR_SURFACE_VERTICAL
;
1138 *grad
= RR_SURFACE_DIAGONAL
;
1140 *grad
= RR_SURFACE_SOLID
;
1143 if (strstr(tex
, "sunken") != NULL
)
1144 *relief
= RR_RELIEF_SUNKEN
;
1145 else if (strstr(tex
, "flat") != NULL
)
1146 *relief
= RR_RELIEF_FLAT
;
1148 *relief
= RR_RELIEF_RAISED
;
1151 if (*relief
== RR_RELIEF_FLAT
) {
1152 if (strstr(tex
, "border") != NULL
)
1155 if (strstr(tex
, "bevel2") != NULL
)
1156 *bevel
= RR_BEVEL_2
;
1158 *bevel
= RR_BEVEL_1
;
1161 if (strstr(tex
, "interlaced") != NULL
)
1164 *interlaced
= FALSE
;
1169 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
1170 gchar
*rname
, RrAppearance
*value
,
1171 gboolean allow_trans
)
1173 gboolean ret
= FALSE
;
1174 char *rclass
= create_class_name(rname
);
1175 char *cname
, *ctoname
, *bcname
, *icname
;
1179 cname
= g_strconcat(rname
, ".color", NULL
);
1180 ctoname
= g_strconcat(rname
, ".colorTo", NULL
);
1181 bcname
= g_strconcat(rname
, ".borderColor", NULL
);
1182 icname
= g_strconcat(rname
, ".interlaceColor", NULL
);
1184 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1185 retvalue
.addr
!= NULL
) {
1186 parse_appearance(retvalue
.addr
,
1187 &value
->surface
.grad
,
1188 &value
->surface
.relief
,
1189 &value
->surface
.bevel
,
1190 &value
->surface
.interlaced
,
1191 &value
->surface
.border
,
1193 if (!read_color(db
, inst
, cname
, &value
->surface
.primary
))
1194 value
->surface
.primary
= RrColorNew(inst
, 0, 0, 0);
1195 if (!read_color(db
, inst
, ctoname
, &value
->surface
.secondary
))
1196 value
->surface
.secondary
= RrColorNew(inst
, 0, 0, 0);
1197 if (value
->surface
.border
)
1198 if (!read_color(db
, inst
, bcname
,
1199 &value
->surface
.border_color
))
1200 value
->surface
.border_color
= RrColorNew(inst
, 0, 0, 0);
1201 if (value
->surface
.interlaced
)
1202 if (!read_color(db
, inst
, icname
,
1203 &value
->surface
.interlace_color
))
1204 value
->surface
.interlace_color
= RrColorNew(inst
, 0, 0, 0);
1216 static void set_default_appearance(RrAppearance
*a
)
1218 a
->surface
.grad
= RR_SURFACE_SOLID
;
1219 a
->surface
.relief
= RR_RELIEF_FLAT
;
1220 a
->surface
.bevel
= RR_BEVEL_1
;
1221 a
->surface
.interlaced
= FALSE
;
1222 a
->surface
.border
= FALSE
;
1223 a
->surface
.primary
= RrColorNew(a
->inst
, 0, 0, 0);
1224 a
->surface
.secondary
= RrColorNew(a
->inst
, 0, 0, 0);