8 #include <X11/Xresource.h>
10 static XrmDatabase
loaddb(RrTheme
*theme
, char *name
);
11 static gboolean
read_int(XrmDatabase db
, char *rname
, int *value
);
12 static gboolean
read_string(XrmDatabase db
, char *rname
, char **value
);
13 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
14 gchar
*rname
, RrColor
**value
);
15 static gboolean
read_mask(const RrInstance
*inst
,
16 gchar
*maskname
, RrTheme
*theme
,
17 RrPixmapMask
**value
);
18 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
19 gchar
*rname
, RrAppearance
*value
,
20 gboolean allow_trans
);
21 static void set_default_appearance(RrAppearance
*a
);
23 RrTheme
* RrThemeNew(const RrInstance
*inst
, gchar
*name
)
25 XrmDatabase db
= NULL
;
26 RrJustify winjust
, mtitlejust
, mjust
;
31 theme
= g_new0(RrTheme
, 1);
35 theme
->a_disabled_focused_max
= RrAppearanceNew(inst
, 1);
36 theme
->a_disabled_unfocused_max
= RrAppearanceNew(inst
, 1);
37 theme
->a_hover_focused_max
= RrAppearanceNew(inst
, 1);
38 theme
->a_hover_unfocused_max
= RrAppearanceNew(inst
, 1);
39 theme
->a_focused_unpressed_max
= RrAppearanceNew(inst
, 1);
40 theme
->a_focused_pressed_max
= RrAppearanceNew(inst
, 1);
41 theme
->a_focused_pressed_set_max
= RrAppearanceNew(inst
, 1);
42 theme
->a_unfocused_unpressed_max
= RrAppearanceNew(inst
, 1);
43 theme
->a_unfocused_pressed_max
= RrAppearanceNew(inst
, 1);
44 theme
->a_unfocused_pressed_set_max
= RrAppearanceNew(inst
, 1);
45 theme
->a_focused_grip
= RrAppearanceNew(inst
, 0);
46 theme
->a_unfocused_grip
= RrAppearanceNew(inst
, 0);
47 theme
->a_focused_title
= RrAppearanceNew(inst
, 0);
48 theme
->a_unfocused_title
= RrAppearanceNew(inst
, 0);
49 theme
->a_focused_label
= RrAppearanceNew(inst
, 1);
50 theme
->a_unfocused_label
= RrAppearanceNew(inst
, 1);
51 theme
->a_icon
= RrAppearanceNew(inst
, 1);
52 theme
->a_focused_handle
= RrAppearanceNew(inst
, 0);
53 theme
->a_unfocused_handle
= RrAppearanceNew(inst
, 0);
54 theme
->a_menu
= RrAppearanceNew(inst
, 0);
55 theme
->a_menu_title
= RrAppearanceNew(inst
, 1);
56 theme
->a_menu_item
= RrAppearanceNew(inst
, 1);
57 theme
->a_menu_disabled
= RrAppearanceNew(inst
, 1);
58 theme
->a_menu_hilite
= RrAppearanceNew(inst
, 1);
60 theme
->app_hilite_bg
= RrAppearanceNew(inst
, 0);
61 theme
->app_unhilite_bg
= RrAppearanceNew(inst
, 0);
62 theme
->app_hilite_label
= RrAppearanceNew(inst
, 1);
63 theme
->app_unhilite_label
= RrAppearanceNew(inst
, 1);
64 theme
->app_icon
= RrAppearanceNew(inst
, 1);
67 db
= loaddb(theme
, name
);
69 g_warning("Failed to load the theme '%s'\n"
70 "Falling back to the default: '%s'",
73 theme
->name
= g_path_get_basename(name
);
76 db
= loaddb(theme
, DEFAULT_THEME
);
78 g_warning("Failed to load the theme '%s'.", DEFAULT_THEME
);
81 theme
->name
= g_path_get_basename(DEFAULT_THEME
);
84 /* load the font stuff */
85 if (!read_string(db
, "window.title.xftfont", &font_str
))
86 font_str
= "arial,sans:bold:pixelsize=10:shadow=y:shadowtint=50";
88 if (!(theme
->winfont
= RrFontOpen(inst
, font_str
))) {
92 theme
->winfont_height
= RrFontHeight(theme
->winfont
);
94 winjust
= RR_JUSTIFY_LEFT
;
95 if (read_string(db
, "window.justify", &str
)) {
96 if (!g_ascii_strcasecmp(str
, "right"))
97 winjust
= RR_JUSTIFY_RIGHT
;
98 else if (!g_ascii_strcasecmp(str
, "center"))
99 winjust
= RR_JUSTIFY_CENTER
;
102 if (!read_string(db
, "menu.title.xftfont", &font_str
))
103 font_str
= "arial,sans:bold:pixelsize=12:shadow=y";
105 if (!(theme
->mtitlefont
= RrFontOpen(inst
, font_str
))) {
109 theme
->mtitlefont_height
= RrFontHeight(theme
->mtitlefont
);
111 mtitlejust
= RR_JUSTIFY_LEFT
;
112 if (read_string(db
, "menu.title.justify", &str
)) {
113 if (!g_ascii_strcasecmp(str
, "right"))
114 mtitlejust
= RR_JUSTIFY_RIGHT
;
115 else if (!g_ascii_strcasecmp(str
, "center"))
116 mtitlejust
= RR_JUSTIFY_CENTER
;
119 if (!read_string(db
, "menu.frame.xftfont", &font_str
))
120 font_str
= "arial,sans:bold:pixelsize=11:shadow=y";
122 if (!(theme
->mfont
= RrFontOpen(inst
, font_str
))) {
126 theme
->mfont_height
= RrFontHeight(theme
->mfont
);
128 mjust
= RR_JUSTIFY_LEFT
;
129 if (read_string(db
, "menu.frame.justify", &str
)) {
130 if (!g_ascii_strcasecmp(str
, "right"))
131 mjust
= RR_JUSTIFY_RIGHT
;
132 else if (!g_ascii_strcasecmp(str
, "center"))
133 mjust
= RR_JUSTIFY_CENTER
;
136 /* load the title layout */
137 if (!read_string(db
, "window.title.layout", &font_str
))
139 theme
->title_layout
= g_strdup(font_str
);
141 /* load direct dimensions */
142 if (!read_int(db
, "menuOverlap", &theme
->menu_overlap
) ||
143 theme
->menu_overlap
< 0 || theme
->menu_overlap
> 20)
144 theme
->handle_height
= 0;
145 if (!read_int(db
, "handleWidth", &theme
->handle_height
) ||
146 theme
->handle_height
< 0 || theme
->handle_height
> 100)
147 theme
->handle_height
= 6;
148 if (!read_int(db
, "bevelWidth", &theme
->bevel
) ||
149 theme
->bevel
<= 0 || theme
->bevel
> 100) theme
->bevel
= 3;
150 if (!read_int(db
, "borderWidth", &theme
->bwidth
) ||
151 theme
->bwidth
< 0 || theme
->bwidth
> 100) theme
->bwidth
= 1;
152 if (!read_int(db
, "frameWidth", &theme
->cbwidth
) ||
153 theme
->cbwidth
< 0 || theme
->cbwidth
> 100)
154 theme
->cbwidth
= theme
->bevel
;
157 if (!read_color(db
, inst
,
158 "borderColor", &theme
->b_color
))
159 theme
->b_color
= RrColorNew(inst
, 0, 0, 0);
160 if (!read_color(db
, inst
,
161 "window.frame.focusColor", &theme
->cb_focused_color
))
162 theme
->cb_focused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
163 if (!read_color(db
, inst
,
164 "window.frame.unfocusColor",&theme
->cb_unfocused_color
))
165 theme
->cb_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
166 if (!read_color(db
, inst
,
167 "window.label.focus.textColor",
168 &theme
->title_focused_color
))
169 theme
->title_focused_color
= RrColorNew(inst
, 0x0, 0x0, 0x0);
170 if (!read_color(db
, inst
,
171 "window.label.unfocus.textColor",
172 &theme
->title_unfocused_color
))
173 theme
->title_unfocused_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
174 if (!read_color(db
, inst
,
175 "window.button.focus.picColor",
176 &theme
->titlebut_focused_unpressed_color
))
177 theme
->titlebut_focused_unpressed_color
= RrColorNew(inst
, 0, 0, 0);
178 if (!read_color(db
, inst
,
179 "window.button.unfocus.picColor",
180 &theme
->titlebut_unfocused_unpressed_color
))
181 theme
->titlebut_unfocused_unpressed_color
=
182 RrColorNew(inst
, 0xff, 0xff, 0xff);
183 if (!read_color(db
, inst
,
184 "window.button.pressed.focus.picColor",
185 &theme
->titlebut_focused_pressed_color
))
186 theme
->titlebut_focused_pressed_color
=
188 theme
->titlebut_focused_unpressed_color
->r
,
189 theme
->titlebut_focused_unpressed_color
->g
,
190 theme
->titlebut_focused_unpressed_color
->b
);
191 if (!read_color(db
, inst
,
192 "window.button.pressed.unfocus.picColor",
193 &theme
->titlebut_unfocused_pressed_color
))
194 theme
->titlebut_unfocused_pressed_color
=
196 theme
->titlebut_unfocused_unpressed_color
->r
,
197 theme
->titlebut_unfocused_unpressed_color
->g
,
198 theme
->titlebut_unfocused_unpressed_color
->b
);
199 if (!read_color(db
, inst
,
200 "window.button.disabled.focus.picColor",
201 &theme
->titlebut_disabled_focused_color
))
202 theme
->titlebut_disabled_focused_color
=
203 RrColorNew(inst
, 0xff, 0xff, 0xff);
204 if (!read_color(db
, inst
,
205 "window.button.disabled.unfocus.picColor",
206 &theme
->titlebut_disabled_unfocused_color
))
207 theme
->titlebut_disabled_unfocused_color
= RrColorNew(inst
, 0, 0, 0);
208 if (!read_color(db
, inst
,
209 "window.button.hover.focus.picColor",
210 &theme
->titlebut_hover_focused_color
))
211 theme
->titlebut_hover_focused_color
=
213 theme
->titlebut_focused_unpressed_color
->r
,
214 theme
->titlebut_focused_unpressed_color
->g
,
215 theme
->titlebut_focused_unpressed_color
->b
);
216 if (!read_color(db
, inst
,
217 "window.button.hover.unfocus.picColor",
218 &theme
->titlebut_hover_unfocused_color
))
219 theme
->titlebut_hover_unfocused_color
=
221 theme
->titlebut_unfocused_unpressed_color
->r
,
222 theme
->titlebut_unfocused_unpressed_color
->g
,
223 theme
->titlebut_unfocused_unpressed_color
->b
);
224 if (!read_color(db
, inst
,
225 "menu.title.textColor", &theme
->menu_title_color
))
226 theme
->menu_title_color
= RrColorNew(inst
, 0, 0, 0);
227 if (!read_color(db
, inst
,
228 "menu.frame.textColor", &theme
->menu_color
))
229 theme
->menu_color
= RrColorNew(inst
, 0xff, 0xff, 0xff);
230 if (!read_color(db
, inst
,
231 "menu.frame.disableColor", &theme
->menu_disabled_color
))
232 theme
->menu_disabled_color
= RrColorNew(inst
, 0, 0, 0);
233 if (!read_color(db
, inst
,
234 "menu.hilite.textColor", &theme
->menu_hilite_color
))
235 theme
->menu_hilite_color
= RrColorNew(inst
, 0, 0, 0);
237 if (read_mask(inst
, "max.xbm", theme
, &theme
->max_unset_mask
)){
238 if (!read_mask(inst
, "max_t.xbm", theme
, &theme
->max_set_mask
)) {
239 theme
->max_set_mask
= RrPixmapMaskCopy(theme
->max_unset_mask
);
243 char data
[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
244 theme
->max_unset_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
247 char data
[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
248 theme
->max_set_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
252 if (!read_mask(inst
, "iconify.xbm", theme
, &theme
->iconify_mask
)) {
253 char data
[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
254 theme
->iconify_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
257 if (read_mask(inst
, "stick.xbm", theme
, &theme
->desk_unset_mask
)) {
258 if (!read_mask(inst
, "stick_t.xbm", theme
, &theme
->desk_set_mask
)) {
259 theme
->desk_set_mask
=
260 RrPixmapMaskCopy(theme
->desk_unset_mask
);
264 char data
[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
265 theme
->desk_unset_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
268 char data
[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
269 theme
->desk_set_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
273 if (read_mask(inst
, "shade.xbm", theme
, &theme
->shade_unset_mask
)) {
274 if (!read_mask(inst
, "shade_t.xbm", theme
, &theme
->shade_set_mask
)) {
275 theme
->shade_set_mask
=
276 RrPixmapMaskCopy(theme
->shade_unset_mask
);
280 char data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
281 theme
->shade_unset_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
284 char data
[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
285 theme
->shade_set_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
289 if (!read_mask(inst
, "close.xbm", theme
, &theme
->close_mask
)) {
290 char data
[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
291 theme
->close_mask
= RrPixmapMaskNew(inst
, 7, 7, data
);
294 /* read the decoration textures */
295 if (!read_appearance(db
, inst
,
296 "window.title.focus", theme
->a_focused_title
,
298 set_default_appearance(theme
->a_focused_title
);
299 if (!read_appearance(db
, inst
,
300 "window.title.unfocus", theme
->a_unfocused_title
,
302 set_default_appearance(theme
->a_unfocused_title
);
303 if (!read_appearance(db
, inst
,
304 "window.label.focus", theme
->a_focused_label
,
306 set_default_appearance(theme
->a_focused_label
);
307 if (!read_appearance(db
, inst
,
308 "window.label.unfocus", theme
->a_unfocused_label
,
310 set_default_appearance(theme
->a_unfocused_label
);
311 if (!read_appearance(db
, inst
,
312 "window.handle.focus", theme
->a_focused_handle
,
314 set_default_appearance(theme
->a_focused_handle
);
315 if (!read_appearance(db
, inst
,
316 "window.handle.unfocus",theme
->a_unfocused_handle
,
318 set_default_appearance(theme
->a_unfocused_handle
);
319 if (!read_appearance(db
, inst
,
320 "window.grip.focus", theme
->a_focused_grip
,
322 set_default_appearance(theme
->a_focused_grip
);
323 if (!read_appearance(db
, inst
,
324 "window.grip.unfocus", theme
->a_unfocused_grip
,
326 set_default_appearance(theme
->a_unfocused_grip
);
327 if (!read_appearance(db
, inst
,
328 "menu.frame", theme
->a_menu
,
330 set_default_appearance(theme
->a_menu
);
331 if (!read_appearance(db
, inst
,
332 "menu.title", theme
->a_menu_title
,
334 set_default_appearance(theme
->a_menu_title
);
335 if (!read_appearance(db
, inst
,
336 "menu.hilite", theme
->a_menu_hilite
,
338 set_default_appearance(theme
->a_menu_hilite
);
340 /* read the appearances for rendering non-decorations */
341 if (!read_appearance(db
, inst
,
342 "window.title.focus", theme
->app_hilite_bg
,
344 set_default_appearance(theme
->app_hilite_bg
);
345 if (!read_appearance(db
, inst
,
346 "window.label.focus", theme
->app_hilite_label
,
348 set_default_appearance(theme
->app_hilite_label
);
349 if (!read_appearance(db
, inst
,
350 "window.title.unfocus", theme
->app_unhilite_bg
,
352 set_default_appearance(theme
->app_unhilite_bg
);
353 if (!read_appearance(db
, inst
,
354 "window.label.unfocus", theme
->app_unhilite_label
,
356 set_default_appearance(theme
->app_unhilite_label
);
358 /* read buttons textures */
359 if (!read_appearance(db
, inst
,
360 "window.button.disabled.focus",
361 theme
->a_disabled_focused_max
,
363 set_default_appearance(theme
->a_disabled_focused_max
);
364 if (!read_appearance(db
, inst
,
365 "window.button.disabled.unfocus",
366 theme
->a_disabled_unfocused_max
,
368 set_default_appearance(theme
->a_disabled_unfocused_max
);
369 if (!read_appearance(db
, inst
,
370 "window.button.pressed.focus",
371 theme
->a_focused_pressed_max
,
373 if (!read_appearance(db
, inst
,
374 "window.button.pressed",
375 theme
->a_focused_pressed_max
,
377 set_default_appearance(theme
->a_focused_pressed_max
);
378 if (!read_appearance(db
, inst
,
379 "window.button.pressed.unfocus",
380 theme
->a_unfocused_pressed_max
,
382 if (!read_appearance(db
, inst
,
383 "window.button.pressed",
384 theme
->a_unfocused_pressed_max
,
386 set_default_appearance(theme
->a_unfocused_pressed_max
);
387 if (!read_appearance(db
, inst
,
388 "window.button.focus",
389 theme
->a_focused_unpressed_max
,
391 set_default_appearance(theme
->a_focused_unpressed_max
);
392 if (!read_appearance(db
, inst
,
393 "window.button.unfocus",
394 theme
->a_unfocused_unpressed_max
,
396 set_default_appearance(theme
->a_unfocused_unpressed_max
);
397 if (!read_appearance(db
, inst
,
398 "window.button.hover.focus",
399 theme
->a_hover_focused_max
,
401 theme
->a_hover_focused_max
=
402 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
403 if (!read_appearance(db
, inst
,
404 "window.button.hover.unfocus",
405 theme
->a_hover_unfocused_max
,
407 theme
->a_hover_unfocused_max
=
408 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
410 theme
->a_disabled_focused_close
=
411 RrAppearanceCopy(theme
->a_disabled_focused_max
);
412 theme
->a_disabled_unfocused_close
=
413 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
414 theme
->a_hover_focused_close
=
415 RrAppearanceCopy(theme
->a_hover_focused_max
);
416 theme
->a_hover_unfocused_close
=
417 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
418 theme
->a_unfocused_unpressed_close
=
419 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
420 theme
->a_unfocused_pressed_close
=
421 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
422 theme
->a_focused_unpressed_close
=
423 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
424 theme
->a_focused_pressed_close
=
425 RrAppearanceCopy(theme
->a_focused_pressed_max
);
426 theme
->a_disabled_focused_desk
=
427 RrAppearanceCopy(theme
->a_disabled_focused_max
);
428 theme
->a_disabled_unfocused_desk
=
429 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
430 theme
->a_hover_focused_desk
=
431 RrAppearanceCopy(theme
->a_hover_focused_max
);
432 theme
->a_hover_unfocused_desk
=
433 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
434 theme
->a_unfocused_unpressed_desk
=
435 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
436 theme
->a_unfocused_pressed_desk
=
437 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
438 theme
->a_unfocused_pressed_set_desk
=
439 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
440 theme
->a_focused_unpressed_desk
=
441 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
442 theme
->a_focused_pressed_desk
=
443 RrAppearanceCopy(theme
->a_focused_pressed_max
);
444 theme
->a_focused_pressed_set_desk
=
445 RrAppearanceCopy(theme
->a_focused_pressed_max
);
446 theme
->a_disabled_focused_shade
=
447 RrAppearanceCopy(theme
->a_disabled_focused_max
);
448 theme
->a_disabled_unfocused_shade
=
449 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
450 theme
->a_hover_focused_shade
=
451 RrAppearanceCopy(theme
->a_hover_focused_max
);
452 theme
->a_hover_unfocused_shade
=
453 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
454 theme
->a_unfocused_unpressed_shade
=
455 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
456 theme
->a_unfocused_pressed_shade
=
457 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
458 theme
->a_unfocused_pressed_set_shade
=
459 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
460 theme
->a_focused_unpressed_shade
=
461 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
462 theme
->a_focused_pressed_shade
=
463 RrAppearanceCopy(theme
->a_focused_pressed_max
);
464 theme
->a_focused_pressed_set_shade
=
465 RrAppearanceCopy(theme
->a_focused_pressed_max
);
466 theme
->a_disabled_focused_iconify
=
467 RrAppearanceCopy(theme
->a_disabled_focused_max
);
468 theme
->a_disabled_unfocused_iconify
=
469 RrAppearanceCopy(theme
->a_disabled_focused_max
);
470 theme
->a_hover_focused_iconify
=
471 RrAppearanceCopy(theme
->a_hover_focused_max
);
472 theme
->a_hover_unfocused_iconify
=
473 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
474 theme
->a_unfocused_unpressed_iconify
=
475 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
476 theme
->a_unfocused_pressed_iconify
=
477 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
478 theme
->a_focused_unpressed_iconify
=
479 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
480 theme
->a_focused_pressed_iconify
=
481 RrAppearanceCopy(theme
->a_focused_pressed_max
);
482 theme
->a_unfocused_pressed_set_max
=
483 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
484 theme
->a_focused_pressed_set_max
=
485 RrAppearanceCopy(theme
->a_focused_pressed_max
);
487 theme
->a_icon
->surface
.grad
= RR_SURFACE_PARENTREL
;
489 /* set up the textures */
490 theme
->a_focused_label
->texture
[0].type
=
491 theme
->app_hilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
492 theme
->a_focused_label
->texture
[0].data
.text
.justify
= winjust
;
493 theme
->app_hilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
494 theme
->a_focused_label
->texture
[0].data
.text
.font
=
495 theme
->app_hilite_label
->texture
[0].data
.text
.font
= theme
->winfont
;
496 theme
->a_focused_label
->texture
[0].data
.text
.color
=
497 theme
->app_hilite_label
->texture
[0].data
.text
.color
=
498 theme
->title_focused_color
;
500 theme
->a_unfocused_label
->texture
[0].type
=
501 theme
->app_unhilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
502 theme
->a_unfocused_label
->texture
[0].data
.text
.justify
= winjust
;
503 theme
->app_unhilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
504 theme
->a_unfocused_label
->texture
[0].data
.text
.font
=
505 theme
->app_unhilite_label
->texture
[0].data
.text
.font
= theme
->winfont
;
506 theme
->a_unfocused_label
->texture
[0].data
.text
.color
=
507 theme
->app_unhilite_label
->texture
[0].data
.text
.color
=
508 theme
->title_unfocused_color
;
510 theme
->a_menu_title
->texture
[0].type
= RR_TEXTURE_TEXT
;
511 theme
->a_menu_title
->texture
[0].data
.text
.justify
= mtitlejust
;
512 theme
->a_menu_title
->texture
[0].data
.text
.font
= theme
->mtitlefont
;
513 theme
->a_menu_title
->texture
[0].data
.text
.color
= theme
->menu_title_color
;
515 theme
->a_menu_item
->surface
.grad
=
516 theme
->a_menu_disabled
->surface
.grad
=
517 theme
->app_icon
->surface
.grad
= RR_SURFACE_PARENTREL
;
519 theme
->a_menu_item
->texture
[0].type
=
520 theme
->a_menu_disabled
->texture
[0].type
=
521 theme
->a_menu_hilite
->texture
[0].type
= RR_TEXTURE_TEXT
;
522 theme
->a_menu_item
->texture
[0].data
.text
.justify
=
523 theme
->a_menu_disabled
->texture
[0].data
.text
.justify
=
524 theme
->a_menu_hilite
->texture
[0].data
.text
.justify
= mjust
;
525 theme
->a_menu_item
->texture
[0].data
.text
.font
=
526 theme
->a_menu_disabled
->texture
[0].data
.text
.font
=
527 theme
->a_menu_hilite
->texture
[0].data
.text
.font
= theme
->mfont
;
528 theme
->a_menu_item
->texture
[0].data
.text
.color
= theme
->menu_color
;
529 theme
->a_menu_disabled
->texture
[0].data
.text
.color
=
530 theme
->menu_disabled_color
;
531 theme
->a_menu_hilite
->texture
[0].data
.text
.color
=
532 theme
->menu_hilite_color
;
534 theme
->a_disabled_focused_max
->texture
[0].type
=
535 theme
->a_disabled_unfocused_max
->texture
[0].type
=
536 theme
->a_hover_focused_max
->texture
[0].type
=
537 theme
->a_hover_unfocused_max
->texture
[0].type
=
538 theme
->a_focused_unpressed_max
->texture
[0].type
=
539 theme
->a_focused_pressed_max
->texture
[0].type
=
540 theme
->a_focused_pressed_set_max
->texture
[0].type
=
541 theme
->a_unfocused_unpressed_max
->texture
[0].type
=
542 theme
->a_unfocused_pressed_max
->texture
[0].type
=
543 theme
->a_unfocused_pressed_set_max
->texture
[0].type
=
544 theme
->a_disabled_focused_close
->texture
[0].type
=
545 theme
->a_disabled_unfocused_close
->texture
[0].type
=
546 theme
->a_hover_focused_close
->texture
[0].type
=
547 theme
->a_hover_unfocused_close
->texture
[0].type
=
548 theme
->a_focused_unpressed_close
->texture
[0].type
=
549 theme
->a_focused_pressed_close
->texture
[0].type
=
550 theme
->a_unfocused_unpressed_close
->texture
[0].type
=
551 theme
->a_unfocused_pressed_close
->texture
[0].type
=
552 theme
->a_disabled_focused_desk
->texture
[0].type
=
553 theme
->a_disabled_unfocused_desk
->texture
[0].type
=
554 theme
->a_hover_focused_desk
->texture
[0].type
=
555 theme
->a_hover_unfocused_desk
->texture
[0].type
=
556 theme
->a_focused_unpressed_desk
->texture
[0].type
=
557 theme
->a_focused_pressed_desk
->texture
[0].type
=
558 theme
->a_focused_pressed_set_desk
->texture
[0].type
=
559 theme
->a_unfocused_unpressed_desk
->texture
[0].type
=
560 theme
->a_unfocused_pressed_desk
->texture
[0].type
=
561 theme
->a_unfocused_pressed_set_desk
->texture
[0].type
=
562 theme
->a_disabled_focused_shade
->texture
[0].type
=
563 theme
->a_disabled_unfocused_shade
->texture
[0].type
=
564 theme
->a_hover_focused_shade
->texture
[0].type
=
565 theme
->a_hover_unfocused_shade
->texture
[0].type
=
566 theme
->a_focused_unpressed_shade
->texture
[0].type
=
567 theme
->a_focused_pressed_shade
->texture
[0].type
=
568 theme
->a_focused_pressed_set_shade
->texture
[0].type
=
569 theme
->a_unfocused_unpressed_shade
->texture
[0].type
=
570 theme
->a_unfocused_pressed_shade
->texture
[0].type
=
571 theme
->a_unfocused_pressed_set_shade
->texture
[0].type
=
572 theme
->a_disabled_focused_iconify
->texture
[0].type
=
573 theme
->a_disabled_unfocused_iconify
->texture
[0].type
=
574 theme
->a_hover_focused_iconify
->texture
[0].type
=
575 theme
->a_hover_unfocused_iconify
->texture
[0].type
=
576 theme
->a_focused_unpressed_iconify
->texture
[0].type
=
577 theme
->a_focused_pressed_iconify
->texture
[0].type
=
578 theme
->a_unfocused_unpressed_iconify
->texture
[0].type
=
579 theme
->a_unfocused_pressed_iconify
->texture
[0].type
= RR_TEXTURE_MASK
;
580 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.mask
=
581 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.mask
=
582 theme
->a_hover_focused_max
->texture
[0].data
.mask
.mask
=
583 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.mask
=
584 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.mask
=
585 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.mask
=
586 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.mask
=
587 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.mask
=
588 theme
->max_unset_mask
;
589 theme
->a_focused_pressed_set_max
->texture
[0].data
.mask
.mask
=
590 theme
->a_unfocused_pressed_set_max
->texture
[0].data
.mask
.mask
=
592 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.mask
=
593 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.mask
=
594 theme
->a_hover_focused_close
->texture
[0].data
.mask
.mask
=
595 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.mask
=
596 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.mask
=
597 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.mask
=
598 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.mask
=
599 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.mask
=
601 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.mask
=
602 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.mask
=
603 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.mask
=
604 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.mask
=
605 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.mask
=
606 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.mask
=
607 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.mask
=
608 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.mask
=
609 theme
->desk_unset_mask
;
610 theme
->a_focused_pressed_set_desk
->texture
[0].data
.mask
.mask
=
611 theme
->a_unfocused_pressed_set_desk
->texture
[0].data
.mask
.mask
=
612 theme
->desk_set_mask
;
613 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.mask
=
614 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.mask
=
615 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.mask
=
616 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.mask
=
617 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.mask
=
618 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.mask
=
619 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.mask
=
620 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.mask
=
621 theme
->shade_unset_mask
;
622 theme
->a_focused_pressed_set_shade
->texture
[0].data
.mask
.mask
=
623 theme
->a_unfocused_pressed_set_shade
->texture
[0].data
.mask
.mask
=
624 theme
->shade_set_mask
;
625 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.mask
=
626 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.mask
=
627 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.mask
=
628 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.mask
=
629 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
630 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
631 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.mask
=
632 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.mask
=
634 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.color
=
635 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.color
=
636 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.color
=
637 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.color
=
638 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.color
=
639 theme
->titlebut_disabled_focused_color
;
640 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.color
=
641 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.color
=
642 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.color
=
643 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.color
=
644 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.color
=
645 theme
->titlebut_disabled_unfocused_color
;
646 theme
->a_hover_focused_max
->texture
[0].data
.mask
.color
=
647 theme
->a_hover_focused_close
->texture
[0].data
.mask
.color
=
648 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.color
=
649 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.color
=
650 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.color
=
651 theme
->titlebut_hover_focused_color
;
652 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.color
=
653 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.color
=
654 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.color
=
655 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.color
=
656 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.color
=
657 theme
->titlebut_hover_unfocused_color
;
658 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.color
=
659 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.color
=
660 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.color
=
661 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.color
=
662 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.color
=
663 theme
->titlebut_focused_unpressed_color
;
664 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.color
=
665 theme
->a_focused_pressed_set_max
->texture
[0].data
.mask
.color
=
666 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.color
=
667 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.color
=
668 theme
->a_focused_pressed_set_desk
->texture
[0].data
.mask
.color
=
669 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.color
=
670 theme
->a_focused_pressed_set_shade
->texture
[0].data
.mask
.color
=
671 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.color
=
672 theme
->titlebut_focused_pressed_color
;
673 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.color
=
674 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.color
=
675 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.color
=
676 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.color
=
677 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.color
=
678 theme
->titlebut_unfocused_unpressed_color
;
679 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.color
=
680 theme
->a_unfocused_pressed_set_max
->texture
[0].data
.mask
.color
=
681 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.color
=
682 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.color
=
683 theme
->a_unfocused_pressed_set_desk
->texture
[0].data
.mask
.color
=
684 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.color
=
685 theme
->a_unfocused_pressed_set_shade
->texture
[0].data
.mask
.color
=
686 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.color
=
687 theme
->titlebut_unfocused_pressed_color
;
689 XrmDestroyDatabase(db
);
691 theme
->label_height
= theme
->winfont_height
;
692 theme
->title_height
= theme
->label_height
+ theme
->bevel
* 2;
693 theme
->button_size
= theme
->label_height
- 2;
694 theme
->grip_width
= theme
->button_size
* 2;
699 void RrThemeFree(RrTheme
*theme
)
704 RrColorFree(theme
->b_color
);
705 RrColorFree(theme
->cb_unfocused_color
);
706 RrColorFree(theme
->cb_focused_color
);
707 RrColorFree(theme
->title_unfocused_color
);
708 RrColorFree(theme
->title_focused_color
);
709 RrColorFree(theme
->titlebut_disabled_focused_color
);
710 RrColorFree(theme
->titlebut_disabled_unfocused_color
);
711 RrColorFree(theme
->titlebut_hover_focused_color
);
712 RrColorFree(theme
->titlebut_hover_unfocused_color
);
713 RrColorFree(theme
->titlebut_unfocused_pressed_color
);
714 RrColorFree(theme
->titlebut_focused_pressed_color
);
715 RrColorFree(theme
->titlebut_unfocused_unpressed_color
);
716 RrColorFree(theme
->titlebut_focused_unpressed_color
);
717 RrColorFree(theme
->menu_color
);
718 RrColorFree(theme
->menu_title_color
);
719 RrColorFree(theme
->menu_disabled_color
);
720 RrColorFree(theme
->menu_hilite_color
);
722 RrPixmapMaskFree(theme
->max_set_mask
);
723 RrPixmapMaskFree(theme
->max_unset_mask
);
724 RrPixmapMaskFree(theme
->desk_set_mask
);
725 RrPixmapMaskFree(theme
->desk_unset_mask
);
726 RrPixmapMaskFree(theme
->shade_set_mask
);
727 RrPixmapMaskFree(theme
->shade_unset_mask
);
728 RrPixmapMaskFree(theme
->iconify_mask
);
729 RrPixmapMaskFree(theme
->close_mask
);
731 RrFontClose(theme
->winfont
);
732 RrFontClose(theme
->mtitlefont
);
733 RrFontClose(theme
->mfont
);
735 g_free(theme
->title_layout
);
737 RrAppearanceFree(theme
->a_disabled_focused_max
);
738 RrAppearanceFree(theme
->a_disabled_unfocused_max
);
739 RrAppearanceFree(theme
->a_hover_focused_max
);
740 RrAppearanceFree(theme
->a_hover_unfocused_max
);
741 RrAppearanceFree(theme
->a_focused_unpressed_max
);
742 RrAppearanceFree(theme
->a_focused_pressed_max
);
743 RrAppearanceFree(theme
->a_focused_pressed_set_max
);
744 RrAppearanceFree(theme
->a_unfocused_unpressed_max
);
745 RrAppearanceFree(theme
->a_unfocused_pressed_max
);
746 RrAppearanceFree(theme
->a_unfocused_pressed_set_max
);
747 RrAppearanceFree(theme
->a_disabled_focused_close
);
748 RrAppearanceFree(theme
->a_disabled_unfocused_close
);
749 RrAppearanceFree(theme
->a_hover_focused_close
);
750 RrAppearanceFree(theme
->a_hover_unfocused_close
);
751 RrAppearanceFree(theme
->a_focused_unpressed_close
);
752 RrAppearanceFree(theme
->a_focused_pressed_close
);
753 RrAppearanceFree(theme
->a_unfocused_unpressed_close
);
754 RrAppearanceFree(theme
->a_unfocused_pressed_close
);
755 RrAppearanceFree(theme
->a_disabled_focused_desk
);
756 RrAppearanceFree(theme
->a_disabled_unfocused_desk
);
757 RrAppearanceFree(theme
->a_hover_focused_desk
);
758 RrAppearanceFree(theme
->a_hover_unfocused_desk
);
759 RrAppearanceFree(theme
->a_focused_unpressed_desk
);
760 RrAppearanceFree(theme
->a_focused_pressed_desk
);
761 RrAppearanceFree(theme
->a_unfocused_unpressed_desk
);
762 RrAppearanceFree(theme
->a_unfocused_pressed_desk
);
763 RrAppearanceFree(theme
->a_disabled_focused_shade
);
764 RrAppearanceFree(theme
->a_disabled_unfocused_shade
);
765 RrAppearanceFree(theme
->a_hover_focused_shade
);
766 RrAppearanceFree(theme
->a_hover_unfocused_shade
);
767 RrAppearanceFree(theme
->a_focused_unpressed_shade
);
768 RrAppearanceFree(theme
->a_focused_pressed_shade
);
769 RrAppearanceFree(theme
->a_unfocused_unpressed_shade
);
770 RrAppearanceFree(theme
->a_unfocused_pressed_shade
);
771 RrAppearanceFree(theme
->a_disabled_focused_iconify
);
772 RrAppearanceFree(theme
->a_disabled_unfocused_iconify
);
773 RrAppearanceFree(theme
->a_hover_focused_iconify
);
774 RrAppearanceFree(theme
->a_hover_unfocused_iconify
);
775 RrAppearanceFree(theme
->a_focused_unpressed_iconify
);
776 RrAppearanceFree(theme
->a_focused_pressed_iconify
);
777 RrAppearanceFree(theme
->a_unfocused_unpressed_iconify
);
778 RrAppearanceFree(theme
->a_unfocused_pressed_iconify
);
779 RrAppearanceFree(theme
->a_focused_grip
);
780 RrAppearanceFree(theme
->a_unfocused_grip
);
781 RrAppearanceFree(theme
->a_focused_title
);
782 RrAppearanceFree(theme
->a_unfocused_title
);
783 RrAppearanceFree(theme
->a_focused_label
);
784 RrAppearanceFree(theme
->a_unfocused_label
);
785 RrAppearanceFree(theme
->a_icon
);
786 RrAppearanceFree(theme
->a_focused_handle
);
787 RrAppearanceFree(theme
->a_unfocused_handle
);
788 RrAppearanceFree(theme
->a_menu
);
789 RrAppearanceFree(theme
->a_menu_title
);
790 RrAppearanceFree(theme
->a_menu_item
);
791 RrAppearanceFree(theme
->a_menu_disabled
);
792 RrAppearanceFree(theme
->a_menu_hilite
);
793 RrAppearanceFree(theme
->app_hilite_bg
);
794 RrAppearanceFree(theme
->app_unhilite_bg
);
795 RrAppearanceFree(theme
->app_hilite_label
);
796 RrAppearanceFree(theme
->app_unhilite_label
);
797 RrAppearanceFree(theme
->app_icon
);
801 static XrmDatabase
loaddb(RrTheme
*theme
, char *name
)
805 if ((db
= XrmGetFileDatabase(name
)))
806 theme
->path
= g_path_get_dirname(name
);
808 char *s
= g_build_filename(g_get_home_dir(), ".openbox", "themes",
810 if ((db
= XrmGetFileDatabase(s
)))
811 theme
->path
= g_path_get_dirname(s
);
815 char *s
= g_build_filename(THEMEDIR
, name
, NULL
);
816 if ((db
= XrmGetFileDatabase(s
)))
817 theme
->path
= g_path_get_dirname(s
);
824 static char *create_class_name(char *rname
)
826 char *rclass
= g_strdup(rname
);
831 p
= strchr(p
+1, '.');
832 if (p
== NULL
) break;
834 if (*p
== '\0') break;
839 static gboolean
read_int(XrmDatabase db
, char *rname
, int *value
)
841 gboolean ret
= FALSE
;
842 char *rclass
= create_class_name(rname
);
846 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
847 retvalue
.addr
!= NULL
) {
848 *value
= (int)strtol(retvalue
.addr
, &end
, 10);
849 if (end
!= retvalue
.addr
)
857 static gboolean
read_string(XrmDatabase db
, char *rname
, char **value
)
859 gboolean ret
= FALSE
;
860 char *rclass
= create_class_name(rname
);
864 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
865 retvalue
.addr
!= NULL
) {
866 *value
= retvalue
.addr
;
874 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
875 gchar
*rname
, RrColor
**value
)
877 gboolean ret
= FALSE
;
878 char *rclass
= create_class_name(rname
);
882 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
883 retvalue
.addr
!= NULL
) {
884 RrColor
*c
= RrColorParse(inst
, retvalue
.addr
);
895 static gboolean
read_mask(const RrInstance
*inst
,
896 gchar
*maskname
, RrTheme
*theme
,
897 RrPixmapMask
**value
)
899 gboolean ret
= FALSE
;
902 int hx
, hy
; /* ignored */
906 data_dir
= g_strdup_printf("%s_data", theme
->name
);
908 s
= g_build_filename(g_get_home_dir(), ".openbox", "themes",
909 data_dir
, maskname
, NULL
);
910 if (XReadBitmapFileData(s
, &w
, &h
, &b
, &hx
, &hy
) == BitmapSuccess
)
914 s
= g_build_filename(THEMEDIR
, data_dir
, maskname
, NULL
);
915 if (XReadBitmapFileData(s
, &w
, &h
, &b
, &hx
, &hy
) == BitmapSuccess
)
919 s
= g_build_filename(theme
->path
, data_dir
, maskname
, NULL
);
920 if (XReadBitmapFileData(s
, &w
, &h
, &b
, &hx
, &hy
) == BitmapSuccess
)
926 *value
= RrPixmapMaskNew(inst
, w
, h
, (char*)b
);
936 static void parse_appearance(gchar
*tex
, RrSurfaceColorType
*grad
,
937 RrReliefType
*relief
, RrBevelType
*bevel
,
938 gboolean
*interlaced
, gboolean
*border
,
939 gboolean allow_trans
)
943 /* convert to all lowercase */
944 for (t
= tex
; *t
!= '\0'; ++t
)
945 *t
= g_ascii_tolower(*t
);
947 if (allow_trans
&& strstr(tex
, "parentrelative") != NULL
) {
948 *grad
= RR_SURFACE_PARENTREL
;
950 if (strstr(tex
, "gradient") != NULL
) {
951 if (strstr(tex
, "crossdiagonal") != NULL
)
952 *grad
= RR_SURFACE_CROSS_DIAGONAL
;
953 else if (strstr(tex
, "pyramid") != NULL
)
954 *grad
= RR_SURFACE_PYRAMID
;
955 else if (strstr(tex
, "horizontal") != NULL
)
956 *grad
= RR_SURFACE_HORIZONTAL
;
957 else if (strstr(tex
, "vertical") != NULL
)
958 *grad
= RR_SURFACE_VERTICAL
;
960 *grad
= RR_SURFACE_DIAGONAL
;
962 *grad
= RR_SURFACE_SOLID
;
965 if (strstr(tex
, "sunken") != NULL
)
966 *relief
= RR_RELIEF_SUNKEN
;
967 else if (strstr(tex
, "flat") != NULL
)
968 *relief
= RR_RELIEF_FLAT
;
970 *relief
= RR_RELIEF_RAISED
;
973 if (*relief
== RR_RELIEF_FLAT
) {
974 if (strstr(tex
, "border") != NULL
)
977 if (strstr(tex
, "bevel2") != NULL
)
983 if (strstr(tex
, "interlaced") != NULL
)
991 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
992 gchar
*rname
, RrAppearance
*value
,
993 gboolean allow_trans
)
995 gboolean ret
= FALSE
;
996 char *rclass
= create_class_name(rname
), *cname
, *ctoname
, *bcname
;
1000 cname
= g_strconcat(rname
, ".color", NULL
);
1001 ctoname
= g_strconcat(rname
, ".colorTo", NULL
);
1002 bcname
= g_strconcat(rname
, ".borderColor", NULL
);
1004 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1005 retvalue
.addr
!= NULL
) {
1006 parse_appearance(retvalue
.addr
,
1007 &value
->surface
.grad
,
1008 &value
->surface
.relief
,
1009 &value
->surface
.bevel
,
1010 &value
->surface
.interlaced
,
1011 &value
->surface
.border
,
1013 if (!read_color(db
, inst
, cname
, &value
->surface
.primary
))
1014 value
->surface
.primary
= RrColorNew(inst
, 0, 0, 0);
1015 if (!read_color(db
, inst
, ctoname
, &value
->surface
.secondary
))
1016 value
->surface
.secondary
= RrColorNew(inst
, 0, 0, 0);
1017 if (value
->surface
.border
)
1018 if (!read_color(db
, inst
, bcname
,
1019 &value
->surface
.border_color
))
1020 value
->surface
.border_color
= RrColorNew(inst
, 0, 0, 0);
1031 static void set_default_appearance(RrAppearance
*a
)
1033 a
->surface
.grad
= RR_SURFACE_SOLID
;
1034 a
->surface
.relief
= RR_RELIEF_FLAT
;
1035 a
->surface
.bevel
= RR_BEVEL_1
;
1036 a
->surface
.interlaced
= FALSE
;
1037 a
->surface
.border
= FALSE
;
1038 a
->surface
.primary
= RrColorNew(a
->inst
, 0, 0, 0);
1039 a
->surface
.secondary
= RrColorNew(a
->inst
, 0, 0, 0);