1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 frame_default_config.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
24 #include "render/render.h"
25 #include "render/mask.h"
26 #include "render/icon.h"
28 static XrmDatabase loaddb(const gchar *name, gchar **path);
29 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value);
30 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value);
31 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
32 const gchar *rname, RrColor **value);
33 static gboolean read_mask(const RrInstance *inst, const gchar *path,
34 ObFrameThemeConfig *theme, const gchar *maskname, RrPixmapMask **value);
35 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
36 const gchar *rname, RrAppearance *value, gboolean allow_trans);
37 static int parse_inline_number(const char *p);
38 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data);
39 static void set_default_appearance(RrAppearance *a);
41 gint load_theme_config(const RrInstance *inst, const gchar *name,
42 const gchar * path, XrmDatabase db, RrFont *active_window_font,
43 RrFont *inactive_window_font, RrFont *menu_title_font,
44 RrFont *menu_item_font, RrFont *osd_font)
46 RrJustify winjust, mtitlejust;
48 ObFrameThemeConfig * theme = &theme_config;
51 theme->name = g_strdup(name ? name : DEFAULT_THEME);
53 theme->a_disabled_focused_max = RrAppearanceNew(inst, 1);
54 theme->a_disabled_unfocused_max = RrAppearanceNew(inst, 1);
55 theme->a_hover_focused_max = RrAppearanceNew(inst, 1);
56 theme->a_hover_unfocused_max = RrAppearanceNew(inst, 1);
57 theme->a_toggled_focused_unpressed_max = RrAppearanceNew(inst, 1);
58 theme->a_toggled_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
59 theme->a_toggled_hover_focused_max = RrAppearanceNew(inst, 1);
60 theme->a_toggled_hover_unfocused_max = RrAppearanceNew(inst, 1);
61 theme->a_toggled_focused_pressed_max = RrAppearanceNew(inst, 1);
62 theme->a_toggled_unfocused_pressed_max = RrAppearanceNew(inst, 1);
63 theme->a_focused_unpressed_max = RrAppearanceNew(inst, 1);
64 theme->a_focused_pressed_max = RrAppearanceNew(inst, 1);
65 theme->a_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
66 theme->a_unfocused_pressed_max = RrAppearanceNew(inst, 1);
67 theme->a_focused_grip = RrAppearanceNew(inst, 0);
68 theme->a_unfocused_grip = RrAppearanceNew(inst, 0);
69 theme->a_focused_title = RrAppearanceNew(inst, 0);
70 theme->a_unfocused_title = RrAppearanceNew(inst, 0);
71 theme->a_focused_label = RrAppearanceNew(inst, 1);
72 theme->a_unfocused_label = RrAppearanceNew(inst, 1);
73 theme->a_icon = RrAppearanceNew(inst, 1);
74 theme->a_focused_handle = RrAppearanceNew(inst, 0);
75 theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
76 theme->a_menu = RrAppearanceNew(inst, 0);
77 theme->a_menu_title = RrAppearanceNew(inst, 0);
78 theme->a_menu_text_title = RrAppearanceNew(inst, 1);
79 theme->a_menu_normal = RrAppearanceNew(inst, 0);
80 theme->a_menu_selected = RrAppearanceNew(inst, 0);
81 theme->a_menu_disabled = RrAppearanceNew(inst, 0);
82 theme->a_menu_disabled_selected = RrAppearanceNew(inst, 0);
83 theme->a_menu_text_normal = RrAppearanceNew(inst, 1);
84 theme->a_menu_text_selected = RrAppearanceNew(inst, 1);
85 theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
86 theme->a_menu_text_disabled_selected = RrAppearanceNew(inst, 1);
87 theme->a_menu_bullet_normal = RrAppearanceNew(inst, 1);
88 theme->a_menu_bullet_selected = RrAppearanceNew(inst, 1);
89 theme->a_clear = RrAppearanceNew(inst, 0);
90 theme->a_clear_tex = RrAppearanceNew(inst, 1);
91 theme->osd_hilite_bg = RrAppearanceNew(inst, 0);
92 theme->osd_hilite_label = RrAppearanceNew(inst, 1);
93 theme->osd_hilite_fg = RrAppearanceNew(inst, 0);
94 theme->osd_unhilite_fg = RrAppearanceNew(inst, 0);
96 /* load the font stuff */
97 if (active_window_font) {
98 theme->win_font_focused = active_window_font;
99 RrFontRef(active_window_font);
102 theme->win_font_focused = RrFontOpenDefault(inst);
104 if (inactive_window_font) {
105 theme->win_font_unfocused = inactive_window_font;
106 RrFontRef(inactive_window_font);
109 theme->win_font_unfocused = RrFontOpenDefault(inst);
111 winjust = RR_JUSTIFY_LEFT;
112 if (read_string(db, "window.label.text.justify", &str)) {
113 if (!g_ascii_strcasecmp(str, "right"))
114 winjust = RR_JUSTIFY_RIGHT;
115 else if (!g_ascii_strcasecmp(str, "center"))
116 winjust = RR_JUSTIFY_CENTER;
119 if (menu_title_font) {
120 theme->menu_title_font = menu_title_font;
121 RrFontRef(menu_title_font);
124 theme->menu_title_font = RrFontOpenDefault(inst);
126 mtitlejust = RR_JUSTIFY_LEFT;
127 if (read_string(db, "menu.title.text.justify", &str)) {
128 if (!g_ascii_strcasecmp(str, "right"))
129 mtitlejust = RR_JUSTIFY_RIGHT;
130 else if (!g_ascii_strcasecmp(str, "center"))
131 mtitlejust = RR_JUSTIFY_CENTER;
134 if (menu_item_font) {
135 theme->menu_font = menu_item_font;
136 RrFontRef(menu_item_font);
139 theme->menu_font = RrFontOpenDefault(inst);
142 theme->osd_font = osd_font;
146 theme->osd_font = RrFontOpenDefault(inst);
148 /* load direct dimensions */
149 if (!read_int(db, "menu.overlap", &theme->menu_overlap)
150 || theme->menu_overlap < -100 || theme->menu_overlap > 100)
151 theme->menu_overlap = 0;
152 if (!read_int(db, "window.handle.width", &theme->handle_height)
153 || theme->handle_height < 0 || theme->handle_height > 100)
154 theme->handle_height = 6;
155 if (!read_int(db, "padding.width", &theme->paddingx) || theme->paddingx < 0
156 || theme->paddingx > 100)
158 if (!read_int(db, "padding.height", &theme->paddingy) || theme->paddingy
159 < 0 || theme->paddingy > 100)
160 theme->paddingy = theme->paddingx;
161 if (!read_int(db, "border.width", &theme->fbwidth) || theme->fbwidth < 0
162 || theme->fbwidth > 100)
164 /* menu border width inherits from the frame border width */
165 if (!read_int(db, "menu.border.width", &theme->mbwidth) || theme->mbwidth
166 < 0 || theme->mbwidth > 100)
167 theme->mbwidth = theme->fbwidth;
168 /* osd border width inherits from the frame border width */
169 if (!read_int(db, "osd.border.width", &theme->obwidth) || theme->obwidth
170 < 0 || theme->obwidth > 100)
171 theme->obwidth = theme->fbwidth;
172 if (!read_int(db, "window.client.padding.width", &theme->cbwidthx)
173 || theme->cbwidthx < 0 || theme->cbwidthx > 100)
174 theme->cbwidthx = theme->paddingx;
175 if (!read_int(db, "window.client.padding.height", &theme->cbwidthy)
176 || theme->cbwidthy < 0 || theme->cbwidthy > 100)
177 theme->cbwidthy = theme->cbwidthx;
180 if (!read_color(db, inst, "window.active.border.color",
181 &theme->frame_focused_border_color) && !read_color(db, inst,
182 "border.color", &theme->frame_focused_border_color))
183 theme->frame_focused_border_color = RrColorNew(inst, 0, 0, 0);
184 /* title separator focused color inherits from focused boder color */
185 if (!read_color(db, inst, "window.active.title.separator.color",
186 &theme->title_separator_focused_color))
187 theme->title_separator_focused_color = RrColorNew(inst,
188 theme->frame_focused_border_color->r,
189 theme->frame_focused_border_color->g,
190 theme->frame_focused_border_color->b);
191 /* unfocused border color inherits from frame focused border color */
192 if (!read_color(db, inst, "window.inactive.border.color",
193 &theme->frame_unfocused_border_color))
194 theme->frame_unfocused_border_color = RrColorNew(inst,
195 theme->frame_focused_border_color->r,
196 theme->frame_focused_border_color->g,
197 theme->frame_focused_border_color->b);
198 /* title separator unfocused color inherits from unfocused boder color */
199 if (!read_color(db, inst, "window.inactive.title.separator.color",
200 &theme->title_separator_unfocused_color))
201 theme->title_separator_unfocused_color = RrColorNew(inst,
202 theme->frame_unfocused_border_color->r,
203 theme->frame_unfocused_border_color->g,
204 theme->frame_unfocused_border_color->b);
206 /* menu border color inherits from frame focused border color */
207 if (!read_color(db, inst, "menu.border.color", &theme->menu_border_color))
208 theme->menu_border_color = RrColorNew(inst,
209 theme->frame_focused_border_color->r,
210 theme->frame_focused_border_color->g,
211 theme->frame_focused_border_color->b);
212 /* osd border color inherits from frame focused border color */
213 if (!read_color(db, inst, "osd.border.color", &theme->osd_border_color))
214 theme->osd_border_color = RrColorNew(inst,
215 theme->frame_focused_border_color->r,
216 theme->frame_focused_border_color->g,
217 theme->frame_focused_border_color->b);
218 if (!read_color(db, inst, "window.active.client.color",
219 &theme->cb_focused_color))
220 theme->cb_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
221 if (!read_color(db, inst, "window.inactive.client.color",
222 &theme->cb_unfocused_color))
223 theme->cb_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
224 if (!read_color(db, inst, "window.active.label.text.color",
225 &theme->title_focused_color))
226 theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0);
227 if (!read_color(db, inst, "osd.label.text.color", &theme->osd_color))
228 theme->osd_color = RrColorNew(inst, theme->title_focused_color->r,
229 theme->title_focused_color->g, theme->title_focused_color->b);
230 if (!read_color(db, inst, "window.inactive.label.text.color",
231 &theme->title_unfocused_color))
232 theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
233 if (!read_color(db, inst, "window.active.button.unpressed.image.color",
234 &theme->titlebut_focused_unpressed_color))
235 theme->titlebut_focused_unpressed_color = RrColorNew(inst, 0, 0, 0);
236 if (!read_color(db, inst, "window.inactive.button.unpressed.image.color",
237 &theme->titlebut_unfocused_unpressed_color))
238 theme->titlebut_unfocused_unpressed_color = RrColorNew(inst, 0xff,
240 if (!read_color(db, inst, "window.active.button.pressed.image.color",
241 &theme->titlebut_focused_pressed_color))
242 theme->titlebut_focused_pressed_color = RrColorNew(inst,
243 theme->titlebut_focused_unpressed_color->r,
244 theme->titlebut_focused_unpressed_color->g,
245 theme->titlebut_focused_unpressed_color->b);
246 if (!read_color(db, inst, "window.inactive.button.pressed.image.color",
247 &theme->titlebut_unfocused_pressed_color))
248 theme->titlebut_unfocused_pressed_color = RrColorNew(inst,
249 theme->titlebut_unfocused_unpressed_color->r,
250 theme->titlebut_unfocused_unpressed_color->g,
251 theme->titlebut_unfocused_unpressed_color->b);
252 if (!read_color(db, inst, "window.active.button.disabled.image.color",
253 &theme->titlebut_disabled_focused_color))
254 theme->titlebut_disabled_focused_color = RrColorNew(inst, 0xff, 0xff,
256 if (!read_color(db, inst, "window.inactive.button.disabled.image.color",
257 &theme->titlebut_disabled_unfocused_color))
258 theme->titlebut_disabled_unfocused_color = RrColorNew(inst, 0, 0, 0);
259 if (!read_color(db, inst, "window.active.button.hover.image.color",
260 &theme->titlebut_hover_focused_color))
261 theme->titlebut_hover_focused_color = RrColorNew(inst,
262 theme->titlebut_focused_unpressed_color->r,
263 theme->titlebut_focused_unpressed_color->g,
264 theme->titlebut_focused_unpressed_color->b);
265 if (!read_color(db, inst, "window.inactive.button.hover.image.color",
266 &theme->titlebut_hover_unfocused_color))
267 theme->titlebut_hover_unfocused_color = RrColorNew(inst,
268 theme->titlebut_unfocused_unpressed_color->r,
269 theme->titlebut_unfocused_unpressed_color->g,
270 theme->titlebut_unfocused_unpressed_color->b);
271 if (!read_color(db, inst,
272 "window.active.button.toggled.unpressed.image.color",
273 &theme->titlebut_toggled_focused_unpressed_color) && !read_color(
274 db, inst, "window.active.button.toggled.image.color",
275 &theme->titlebut_toggled_focused_unpressed_color))
276 theme->titlebut_toggled_focused_unpressed_color = RrColorNew(inst,
277 theme->titlebut_focused_pressed_color->r,
278 theme->titlebut_focused_pressed_color->g,
279 theme->titlebut_focused_pressed_color->b);
280 if (!read_color(db, inst,
281 "window.inactive.button.toggled.unpressed.image.color",
282 &theme->titlebut_toggled_unfocused_unpressed_color) && !read_color(
283 db, inst, "window.inactive.button.toggled.image.color",
284 &theme->titlebut_toggled_unfocused_unpressed_color))
285 theme->titlebut_toggled_unfocused_unpressed_color = RrColorNew(inst,
286 theme->titlebut_unfocused_pressed_color->r,
287 theme->titlebut_unfocused_pressed_color->g,
288 theme->titlebut_unfocused_pressed_color->b);
289 if (!read_color(db, inst, "window.active.button.toggled.hover.image.color",
290 &theme->titlebut_toggled_hover_focused_color))
291 theme->titlebut_toggled_hover_focused_color = RrColorNew(inst,
292 theme->titlebut_toggled_focused_unpressed_color->r,
293 theme->titlebut_toggled_focused_unpressed_color->g,
294 theme->titlebut_toggled_focused_unpressed_color->b);
295 if (!read_color(db, inst,
296 "window.inactive.button.toggled.hover.image.color",
297 &theme->titlebut_toggled_hover_unfocused_color))
298 theme->titlebut_toggled_hover_unfocused_color = RrColorNew(inst,
299 theme->titlebut_toggled_unfocused_unpressed_color->r,
300 theme->titlebut_toggled_unfocused_unpressed_color->g,
301 theme->titlebut_toggled_unfocused_unpressed_color->b);
302 if (!read_color(db, inst,
303 "window.active.button.toggled.pressed.image.color",
304 &theme->titlebut_toggled_focused_pressed_color))
305 theme->titlebut_toggled_focused_pressed_color = RrColorNew(inst,
306 theme->titlebut_focused_pressed_color->r,
307 theme->titlebut_focused_pressed_color->g,
308 theme->titlebut_focused_pressed_color->b);
309 if (!read_color(db, inst,
310 "window.inactive.button.toggled.pressed.image.color",
311 &theme->titlebut_toggled_unfocused_pressed_color))
312 theme->titlebut_toggled_unfocused_pressed_color = RrColorNew(inst,
313 theme->titlebut_unfocused_pressed_color->r,
314 theme->titlebut_unfocused_pressed_color->g,
315 theme->titlebut_unfocused_pressed_color->b);
316 if (!read_color(db, inst, "menu.title.text.color", &theme->menu_title_color))
317 theme->menu_title_color = RrColorNew(inst, 0, 0, 0);
318 if (!read_color(db, inst, "menu.items.text.color", &theme->menu_color))
319 theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff);
320 if (!read_color(db, inst, "menu.items.disabled.text.color",
321 &theme->menu_disabled_color))
322 theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0);
323 if (!read_color(db, inst, "menu.items.active.disabled.text.color",
324 &theme->menu_disabled_selected_color))
325 theme->menu_disabled_selected_color = RrColorNew(inst,
326 theme->menu_disabled_color->r, theme->menu_disabled_color->g,
327 theme->menu_disabled_color->b);
328 if (!read_color(db, inst, "menu.items.active.text.color",
329 &theme->menu_selected_color))
330 theme->menu_selected_color = RrColorNew(inst, 0, 0, 0);
332 /* load the image masks */
334 /* maximize button masks */
336 if (!read_mask(inst, path, theme, "max.xbm", &theme->max_mask)) {
337 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
338 theme->max_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
341 if (!read_mask(inst, path, theme, "max_toggled.xbm",
342 &theme->max_toggled_mask)) {
344 theme->max_toggled_mask = RrPixmapMaskCopy(theme->max_mask);
346 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
347 theme->max_toggled_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
350 if (!read_mask(inst, path, theme, "max_pressed.xbm",
351 &theme->max_pressed_mask))
352 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
353 if (!read_mask(inst, path, theme, "max_disabled.xbm",
354 &theme->max_disabled_mask))
355 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
356 if (!read_mask(inst, path, theme, "max_hover.xbm", &theme->max_hover_mask))
357 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
358 if (!read_mask(inst, path, theme, "max_toggled_pressed.xbm",
359 &theme->max_toggled_pressed_mask))
360 theme->max_toggled_pressed_mask
361 = RrPixmapMaskCopy(theme->max_toggled_mask);
362 if (!read_mask(inst, path, theme, "max_toggled_hover.xbm",
363 &theme->max_toggled_hover_mask))
364 theme->max_toggled_hover_mask
365 = RrPixmapMaskCopy(theme->max_toggled_mask);
367 /* iconify button masks */
368 if (!read_mask(inst, path, theme, "iconify.xbm", &theme->iconify_mask)) {
369 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
370 theme->iconify_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
372 if (!read_mask(inst, path, theme, "iconify_pressed.xbm",
373 &theme->iconify_pressed_mask))
374 theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
375 if (!read_mask(inst, path, theme, "iconify_disabled.xbm",
376 &theme->iconify_disabled_mask))
377 theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
378 if (!read_mask(inst, path, theme, "iconify_hover.xbm",
379 &theme->iconify_hover_mask))
380 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
382 /* all desktops button masks */
384 if (!read_mask(inst, path, theme, "desk.xbm", &theme->desk_mask)) {
385 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
386 theme->desk_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
389 if (!read_mask(inst, path, theme, "desk_toggled.xbm",
390 &theme->desk_toggled_mask)) {
392 theme->desk_toggled_mask = RrPixmapMaskCopy(theme->desk_mask);
394 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
395 theme->desk_toggled_mask
396 = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
399 if (!read_mask(inst, path, theme, "desk_pressed.xbm",
400 &theme->desk_pressed_mask))
401 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
402 if (!read_mask(inst, path, theme, "desk_disabled.xbm",
403 &theme->desk_disabled_mask))
404 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
405 if (!read_mask(inst, path, theme, "desk_hover.xbm", &theme->desk_hover_mask))
406 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
407 if (!read_mask(inst, path, theme, "desk_toggled_pressed.xbm",
408 &theme->desk_toggled_pressed_mask))
409 theme->desk_toggled_pressed_mask
410 = RrPixmapMaskCopy(theme->desk_toggled_mask);
411 if (!read_mask(inst, path, theme, "desk_toggled_hover.xbm",
412 &theme->desk_toggled_hover_mask))
413 theme->desk_toggled_hover_mask
414 = RrPixmapMaskCopy(theme->desk_toggled_mask);
416 /* shade button masks */
417 if (!read_mask(inst, path, theme, "shade.xbm", &theme->shade_mask)) {
418 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
419 theme->shade_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
421 if (!read_mask(inst, path, theme, "shade_toggled.xbm",
422 &theme->shade_toggled_mask))
423 theme->shade_toggled_mask = RrPixmapMaskCopy(theme->shade_mask);
424 if (!read_mask(inst, path, theme, "shade_pressed.xbm",
425 &theme->shade_pressed_mask))
426 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
427 if (!read_mask(inst, path, theme, "shade_disabled.xbm",
428 &theme->shade_disabled_mask))
429 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
430 if (!read_mask(inst, path, theme, "shade_hover.xbm",
431 &theme->shade_hover_mask))
432 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
433 if (!read_mask(inst, path, theme, "shade_toggled_pressed.xbm",
434 &theme->shade_toggled_pressed_mask))
435 theme->shade_toggled_pressed_mask
436 = RrPixmapMaskCopy(theme->shade_toggled_mask);
437 if (!read_mask(inst, path, theme, "shade_toggled_hover.xbm",
438 &theme->shade_toggled_hover_mask))
439 theme->shade_toggled_hover_mask
440 = RrPixmapMaskCopy(theme->shade_toggled_mask);
442 /* close button masks */
443 if (!read_mask(inst, path, theme, "close.xbm", &theme->close_mask)) {
444 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
445 theme->close_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
447 if (!read_mask(inst, path, theme, "close_pressed.xbm",
448 &theme->close_pressed_mask))
449 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
450 if (!read_mask(inst, path, theme, "close_disabled.xbm",
451 &theme->close_disabled_mask))
452 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
453 if (!read_mask(inst, path, theme, "close_hover.xbm",
454 &theme->close_hover_mask))
455 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
457 /* submenu bullet mask */
458 if (!read_mask(inst, path, theme, "bullet.xbm", &theme->menu_bullet_mask)) {
459 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
460 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
463 /* setup the default window icon */
464 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
465 OB_DEFAULT_ICON_HEIGHT, OB_DEFAULT_ICON_pixel_data);
467 /* the toggled hover mask = the toggled unpressed mask (i.e. no change) */
468 theme->max_toggled_hover_mask = RrPixmapMaskCopy(theme->max_toggled_mask);
469 theme->desk_toggled_hover_mask = RrPixmapMaskCopy(theme->desk_toggled_mask);
470 theme->shade_toggled_hover_mask
471 = RrPixmapMaskCopy(theme->shade_toggled_mask);
472 /* the toggled pressed mask = the toggled unpressed mask (i.e. no change)*/
473 theme->max_toggled_pressed_mask = RrPixmapMaskCopy(theme->max_toggled_mask);
474 theme->desk_toggled_pressed_mask
475 = RrPixmapMaskCopy(theme->desk_toggled_mask);
476 theme->shade_toggled_pressed_mask
477 = RrPixmapMaskCopy(theme->shade_toggled_mask);
479 /* read the decoration textures */
480 if (!read_appearance(db, inst, "window.active.title.bg",
481 theme->a_focused_title, FALSE))
482 set_default_appearance(theme->a_focused_title);
483 if (!read_appearance(db, inst, "window.inactive.title.bg",
484 theme->a_unfocused_title, FALSE))
485 set_default_appearance(theme->a_unfocused_title);
486 if (!read_appearance(db, inst, "window.active.label.bg",
487 theme->a_focused_label, TRUE))
488 set_default_appearance(theme->a_focused_label);
489 if (!read_appearance(db, inst, "window.inactive.label.bg",
490 theme->a_unfocused_label, TRUE))
491 set_default_appearance(theme->a_unfocused_label);
492 if (!read_appearance(db, inst, "window.active.handle.bg",
493 theme->a_focused_handle, FALSE))
494 set_default_appearance(theme->a_focused_handle);
495 if (!read_appearance(db, inst, "window.inactive.handle.bg",
496 theme->a_unfocused_handle, FALSE))
497 set_default_appearance(theme->a_unfocused_handle);
498 if (!read_appearance(db, inst, "window.active.grip.bg",
499 theme->a_focused_grip, TRUE))
500 set_default_appearance(theme->a_focused_grip);
501 if (!read_appearance(db, inst, "window.inactive.grip.bg",
502 theme->a_unfocused_grip, TRUE))
503 set_default_appearance(theme->a_unfocused_grip);
504 if (!read_appearance(db, inst, "menu.items.bg", theme->a_menu, FALSE))
505 set_default_appearance(theme->a_menu);
506 if (!read_appearance(db, inst, "menu.title.bg", theme->a_menu_title, TRUE))
507 set_default_appearance(theme->a_menu_title);
508 if (!read_appearance(db, inst, "menu.items.active.bg",
509 theme->a_menu_selected, TRUE))
510 set_default_appearance(theme->a_menu_selected);
511 theme->a_menu_disabled_selected = RrAppearanceCopy(theme->a_menu_selected);
513 /* read appearances for non-decorations (on-screen-display) */
514 if (!read_appearance(db, inst, "osd.bg", theme->osd_hilite_bg, FALSE)) {
515 RrAppearanceFree(theme->osd_hilite_bg);
516 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
518 if (!read_appearance(db, inst, "osd.label.bg", theme->osd_hilite_label,
520 RrAppearanceFree(theme->osd_hilite_label);
521 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
523 /* osd_hilite_fg can't be parentrel */
524 if (!read_appearance(db, inst, "osd.hilight.bg", theme->osd_hilite_fg,
526 RrAppearanceFree(theme->osd_hilite_fg);
527 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
528 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_label);
530 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_title);
532 /* osd_unhilite_fg can't be parentrel either */
533 if (!read_appearance(db, inst, "osd.unhilight.bg", theme->osd_unhilite_fg,
535 RrAppearanceFree(theme->osd_unhilite_fg);
536 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
537 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_label);
539 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_title);
542 /* read buttons textures */
543 if (!read_appearance(db, inst, "window.active.button.disabled.bg",
544 theme->a_disabled_focused_max, TRUE))
545 set_default_appearance(theme->a_disabled_focused_max);
546 if (!read_appearance(db, inst, "window.inactive.button.disabled.bg",
547 theme->a_disabled_unfocused_max, TRUE))
548 set_default_appearance(theme->a_disabled_unfocused_max);
549 if (!read_appearance(db, inst, "window.active.button.pressed.bg",
550 theme->a_focused_pressed_max, TRUE))
551 set_default_appearance(theme->a_focused_pressed_max);
552 if (!read_appearance(db, inst, "window.inactive.button.pressed.bg",
553 theme->a_unfocused_pressed_max, TRUE))
554 set_default_appearance(theme->a_unfocused_pressed_max);
555 if (!read_appearance(db, inst, "window.active.button.toggled.unpressed.bg",
556 theme->a_toggled_focused_unpressed_max, TRUE) && !read_appearance(
557 db, inst, "window.active.button.toggled.bg",
558 theme->a_toggled_focused_unpressed_max, TRUE)) {
559 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
560 theme->a_toggled_focused_unpressed_max
561 = RrAppearanceCopy(theme->a_focused_pressed_max);
563 if (!read_appearance(db, inst,
564 "window.inactive.button.toggled.unpressed.bg",
565 theme->a_toggled_unfocused_unpressed_max, TRUE)
566 && !read_appearance(db, inst, "window.inactive.button.toggled.bg",
567 theme->a_toggled_unfocused_unpressed_max, TRUE)) {
568 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
569 theme->a_toggled_unfocused_unpressed_max
570 = RrAppearanceCopy(theme->a_unfocused_pressed_max);
572 if (!read_appearance(db, inst, "window.active.button.toggled.hover.bg",
573 theme->a_toggled_hover_focused_max, TRUE)) {
574 RrAppearanceFree(theme->a_toggled_hover_focused_max);
575 theme->a_toggled_hover_focused_max
576 = RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
578 if (!read_appearance(db, inst, "window.inactive.button.toggled.hover.bg",
579 theme->a_toggled_hover_unfocused_max, TRUE)) {
580 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
581 theme->a_toggled_hover_unfocused_max
582 = RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
584 if (!read_appearance(db, inst, "window.active.button.toggled.pressed.bg",
585 theme->a_toggled_focused_pressed_max, TRUE)) {
586 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
587 theme->a_toggled_focused_pressed_max
588 = RrAppearanceCopy(theme->a_focused_pressed_max);
590 if (!read_appearance(db, inst, "window.inactive.button.toggled.pressed.bg",
591 theme->a_toggled_unfocused_pressed_max, TRUE)) {
592 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
593 theme->a_toggled_unfocused_pressed_max
594 = RrAppearanceCopy(theme->a_unfocused_pressed_max);
596 if (!read_appearance(db, inst, "window.active.button.unpressed.bg",
597 theme->a_focused_unpressed_max, TRUE))
598 set_default_appearance(theme->a_focused_unpressed_max);
599 if (!read_appearance(db, inst, "window.inactive.button.unpressed.bg",
600 theme->a_unfocused_unpressed_max, TRUE))
601 set_default_appearance(theme->a_unfocused_unpressed_max);
602 if (!read_appearance(db, inst, "window.active.button.hover.bg",
603 theme->a_hover_focused_max, TRUE)) {
604 RrAppearanceFree(theme->a_hover_focused_max);
605 theme->a_hover_focused_max
606 = RrAppearanceCopy(theme->a_focused_unpressed_max);
608 if (!read_appearance(db, inst, "window.inactive.button.hover.bg",
609 theme->a_hover_unfocused_max, TRUE)) {
610 RrAppearanceFree(theme->a_hover_unfocused_max);
611 theme->a_hover_unfocused_max
612 = RrAppearanceCopy(theme->a_unfocused_unpressed_max);
615 theme->a_disabled_focused_close
616 = RrAppearanceCopy(theme->a_disabled_focused_max);
617 theme->a_disabled_unfocused_close
618 = RrAppearanceCopy(theme->a_disabled_unfocused_max);
619 theme->a_hover_focused_close = RrAppearanceCopy(theme->a_hover_focused_max);
620 theme->a_hover_unfocused_close
621 = RrAppearanceCopy(theme->a_hover_unfocused_max);
622 theme->a_unfocused_unpressed_close
623 = RrAppearanceCopy(theme->a_unfocused_unpressed_max);
624 theme->a_unfocused_pressed_close
625 = RrAppearanceCopy(theme->a_unfocused_pressed_max);
626 theme->a_focused_unpressed_close
627 = RrAppearanceCopy(theme->a_focused_unpressed_max);
628 theme->a_focused_pressed_close
629 = RrAppearanceCopy(theme->a_focused_pressed_max);
630 theme->a_disabled_focused_desk
631 = RrAppearanceCopy(theme->a_disabled_focused_max);
632 theme->a_disabled_unfocused_desk
633 = RrAppearanceCopy(theme->a_disabled_unfocused_max);
634 theme->a_hover_focused_desk = RrAppearanceCopy(theme->a_hover_focused_max);
635 theme->a_hover_unfocused_desk
636 = RrAppearanceCopy(theme->a_hover_unfocused_max);
637 theme->a_toggled_hover_focused_desk
638 = RrAppearanceCopy(theme->a_toggled_hover_focused_max);
639 theme->a_toggled_hover_unfocused_desk
640 = RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
641 theme->a_toggled_focused_unpressed_desk
642 = RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
643 theme->a_toggled_unfocused_unpressed_desk
644 = RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
645 theme->a_toggled_focused_pressed_desk
646 = RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
647 theme->a_toggled_unfocused_pressed_desk
648 = RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
649 theme->a_unfocused_unpressed_desk
650 = RrAppearanceCopy(theme->a_unfocused_unpressed_max);
651 theme->a_unfocused_pressed_desk
652 = RrAppearanceCopy(theme->a_unfocused_pressed_max);
653 theme->a_focused_unpressed_desk
654 = RrAppearanceCopy(theme->a_focused_unpressed_max);
655 theme->a_focused_pressed_desk
656 = RrAppearanceCopy(theme->a_focused_pressed_max);
657 theme->a_disabled_focused_shade
658 = RrAppearanceCopy(theme->a_disabled_focused_max);
659 theme->a_disabled_unfocused_shade
660 = RrAppearanceCopy(theme->a_disabled_unfocused_max);
661 theme->a_hover_focused_shade = RrAppearanceCopy(theme->a_hover_focused_max);
662 theme->a_hover_unfocused_shade
663 = RrAppearanceCopy(theme->a_hover_unfocused_max);
664 theme->a_toggled_hover_focused_shade
665 = RrAppearanceCopy(theme->a_toggled_hover_focused_max);
666 theme->a_toggled_hover_unfocused_shade
667 = RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
668 theme->a_toggled_focused_unpressed_shade
669 = RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
670 theme->a_toggled_unfocused_unpressed_shade
671 = RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
672 theme->a_toggled_focused_pressed_shade
673 = RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
674 theme->a_toggled_unfocused_pressed_shade
675 = RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
676 theme->a_unfocused_unpressed_shade
677 = RrAppearanceCopy(theme->a_unfocused_unpressed_max);
678 theme->a_unfocused_pressed_shade
679 = RrAppearanceCopy(theme->a_unfocused_pressed_max);
680 theme->a_focused_unpressed_shade
681 = RrAppearanceCopy(theme->a_focused_unpressed_max);
682 theme->a_focused_pressed_shade
683 = RrAppearanceCopy(theme->a_focused_pressed_max);
684 theme->a_disabled_focused_iconify
685 = RrAppearanceCopy(theme->a_disabled_focused_max);
686 theme->a_disabled_unfocused_iconify
687 = RrAppearanceCopy(theme->a_disabled_focused_max);
688 theme->a_hover_focused_iconify
689 = RrAppearanceCopy(theme->a_hover_focused_max);
690 theme->a_hover_unfocused_iconify
691 = RrAppearanceCopy(theme->a_hover_unfocused_max);
692 theme->a_unfocused_unpressed_iconify
693 = RrAppearanceCopy(theme->a_unfocused_unpressed_max);
694 theme->a_unfocused_pressed_iconify
695 = RrAppearanceCopy(theme->a_unfocused_pressed_max);
696 theme->a_focused_unpressed_iconify
697 = RrAppearanceCopy(theme->a_focused_unpressed_max);
698 theme->a_focused_pressed_iconify
699 = RrAppearanceCopy(theme->a_focused_pressed_max);
701 theme->a_icon->surface.grad
702 = theme->a_clear->surface.grad
703 = theme->a_clear_tex->surface.grad
704 = theme->a_menu_text_title->surface.grad
705 = theme->a_menu_normal->surface.grad
706 = theme->a_menu_disabled->surface.grad
707 = theme->a_menu_text_normal->surface.grad
708 = theme->a_menu_text_selected->surface.grad
709 = theme->a_menu_text_disabled->surface.grad
710 = theme->a_menu_text_disabled_selected->surface.grad
711 = theme->a_menu_bullet_normal->surface.grad
712 = theme->a_menu_bullet_selected->surface.grad
713 = RR_SURFACE_PARENTREL;
715 /* set up the textures */
716 theme->a_focused_label->texture[0].type = RR_TEXTURE_TEXT;
717 theme->a_focused_label->texture[0].data.text.justify = winjust;
718 theme->a_focused_label->texture[0].data.text.font=theme->win_font_focused;
719 theme->a_focused_label->texture[0].data.text.color
720 = theme->title_focused_color;
722 if (read_string(db, "window.active.label.text.font", &str)) {
726 if (strstr(str, "shadow=y")) {
727 if ((p = strstr(str, "shadowoffset=")))
728 i = parse_inline_number(p + strlen("shadowoffset="));
731 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
732 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
734 if ((p = strstr(str, "shadowtint="))) {
735 i = parse_inline_number(p + strlen("shadowtint="));
736 j = (i > 0 ? 0 : 255);
739 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
740 theme->title_focused_shadow_alpha = i;
743 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
744 theme->title_focused_shadow_alpha = 50;
748 theme->a_focused_label->texture[0].data.text.shadow_color
749 = theme->title_focused_shadow_color;
750 theme->a_focused_label->texture[0].data.text.shadow_alpha
751 = theme->title_focused_shadow_alpha;
753 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
754 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
755 theme->osd_hilite_label->texture[0].data.text.font = theme->osd_font;
756 theme->osd_hilite_label->texture[0].data.text.color = theme->osd_color;
758 if (read_string(db, "osd.label.text.font", &str)) {
762 if (strstr(str, "shadow=y")) {
763 if ((p = strstr(str, "shadowoffset=")))
764 i = parse_inline_number(p + strlen("shadowoffset="));
767 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
768 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
769 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
770 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
772 if ((p = strstr(str, "shadowtint="))) {
773 i = parse_inline_number(p + strlen("shadowtint="));
774 j = (i > 0 ? 0 : 255);
777 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
778 theme->title_focused_shadow_alpha = i;
779 theme->osd_shadow_color = RrColorNew(inst, j, j, j);
780 theme->osd_shadow_alpha = i;
783 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
784 theme->title_focused_shadow_alpha = 50;
785 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
786 theme->osd_shadow_alpha = 50;
790 /* inherit the font settings from the focused label */
791 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x
792 = theme->a_focused_label->texture[0].data.text.shadow_offset_x;
793 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y
794 = theme->a_focused_label->texture[0].data.text.shadow_offset_y;
795 if (theme->title_focused_shadow_color)
796 theme->osd_shadow_color = RrColorNew(inst,
797 theme->title_focused_shadow_color->r,
798 theme->title_focused_shadow_color->g,
799 theme->title_focused_shadow_color->b);
801 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
802 theme->osd_shadow_alpha = theme->title_focused_shadow_alpha;
805 theme->osd_hilite_label->texture[0].data.text.shadow_color
806 = theme->osd_shadow_color;
807 theme->osd_hilite_label->texture[0].data.text.shadow_alpha
808 = theme->osd_shadow_alpha;
810 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
811 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
812 theme->a_unfocused_label->texture[0].data.text.font
813 = theme->win_font_unfocused;
814 theme->a_unfocused_label->texture[0].data.text.color
815 = theme->title_unfocused_color;
817 if (read_string(db, "window.inactive.label.text.font", &str)) {
821 if (strstr(str, "shadow=y")) {
822 if ((p = strstr(str, "shadowoffset=")))
823 i = parse_inline_number(p + strlen("shadowoffset="));
826 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
827 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
829 if ((p = strstr(str, "shadowtint="))) {
830 i = parse_inline_number(p + strlen("shadowtint="));
831 j = (i > 0 ? 0 : 255);
834 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
835 theme->title_unfocused_shadow_alpha = i;
838 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
839 theme->title_unfocused_shadow_alpha = 50;
843 theme->a_unfocused_label->texture[0].data.text.shadow_color
844 = theme->title_unfocused_shadow_color;
845 theme->a_unfocused_label->texture[0].data.text.shadow_alpha
846 = theme->title_unfocused_shadow_alpha;
848 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
849 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
850 theme->a_menu_text_title->texture[0].data.text.font
851 = theme->menu_title_font;
852 theme->a_menu_text_title->texture[0].data.text.color
853 = theme->menu_title_color;
855 if (read_string(db, "menu.title.text.font", &str)) {
859 if (strstr(str, "shadow=y")) {
860 if ((p = strstr(str, "shadowoffset=")))
861 i = parse_inline_number(p + strlen("shadowoffset="));
864 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
865 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
867 if ((p = strstr(str, "shadowtint="))) {
868 i = parse_inline_number(p + strlen("shadowtint="));
869 j = (i > 0 ? 0 : 255);
872 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
873 theme->menu_title_shadow_alpha = i;
876 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
877 theme->menu_title_shadow_alpha = 50;
881 theme->a_menu_text_title->texture[0].data.text.shadow_color
882 = theme->menu_title_shadow_color;
883 theme->a_menu_text_title->texture[0].data.text.shadow_alpha
884 = theme->menu_title_shadow_alpha;
886 theme->a_menu_text_normal->texture[0].type
887 = theme->a_menu_text_selected->texture[0].type
888 = theme->a_menu_text_disabled->texture[0].type
889 = theme->a_menu_text_disabled_selected->texture[0].type
891 theme->a_menu_text_normal->texture[0].data.text.justify
892 = theme->a_menu_text_selected->texture[0].data.text.justify
893 = theme->a_menu_text_disabled->texture[0].data.text.justify
894 = theme->a_menu_text_disabled_selected->texture[0].data.text.justify
896 theme->a_menu_text_normal->texture[0].data.text.font
897 = theme->a_menu_text_selected->texture[0].data.text.font
898 = theme->a_menu_text_disabled->texture[0].data.text.font
899 = theme->a_menu_text_disabled_selected->texture[0].data.text.font
901 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
902 theme->a_menu_text_selected->texture[0].data.text.color
903 = theme->menu_selected_color;
904 theme->a_menu_text_disabled->texture[0].data.text.color
905 = theme->menu_disabled_color;
906 theme->a_menu_text_disabled_selected->texture[0].data.text.color
907 = theme->menu_disabled_selected_color;
909 if (read_string(db, "menu.items.font", &str)) {
913 if (strstr(str, "shadow=y")) {
914 if ((p = strstr(str, "shadowoffset=")))
915 i = parse_inline_number(p + strlen("shadowoffset="));
918 theme->a_menu_text_normal->
919 texture[0].data.text.shadow_offset_x = i;
920 theme->a_menu_text_normal->
921 texture[0].data.text.shadow_offset_y = i;
922 theme->a_menu_text_selected->
923 texture[0].data.text.shadow_offset_x = i;
924 theme->a_menu_text_selected->
925 texture[0].data.text.shadow_offset_y = i;
926 theme->a_menu_text_disabled->
927 texture[0].data.text.shadow_offset_x = i;
928 theme->a_menu_text_disabled->
929 texture[0].data.text.shadow_offset_y = i;
930 theme->a_menu_text_disabled_selected->
931 texture[0].data.text.shadow_offset_x = i;
932 theme->a_menu_text_disabled_selected->
933 texture[0].data.text.shadow_offset_y = i;
935 if ((p = strstr(str, "shadowtint="))) {
936 i = parse_inline_number(p + strlen("shadowtint="));
937 j = (i > 0 ? 0 : 255);
940 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
941 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
942 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
943 theme->menu_text_normal_shadow_alpha = i;
944 theme->menu_text_selected_shadow_alpha = i;
945 theme->menu_text_disabled_shadow_alpha = i;
946 theme->menu_text_disabled_selected_shadow_alpha = i;
949 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
950 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
951 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
952 theme->menu_text_normal_shadow_alpha = 50;
953 theme->menu_text_selected_shadow_alpha = 50;
954 theme->menu_text_disabled_selected_shadow_alpha = 50;
958 theme->a_menu_text_normal->texture[0].data.text.shadow_color
959 = theme->menu_text_normal_shadow_color;
960 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha
961 = theme->menu_text_normal_shadow_alpha;
962 theme->a_menu_text_selected->texture[0].data.text.shadow_color
963 = theme->menu_text_selected_shadow_color;
964 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha
965 = theme->menu_text_selected_shadow_alpha;
966 theme->a_menu_text_disabled->texture[0].data.text.shadow_color
967 = theme->menu_text_disabled_shadow_color;
968 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha
969 = theme->menu_text_disabled_shadow_alpha;
970 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color
971 = theme->menu_text_disabled_shadow_color;
972 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha
973 = theme->menu_text_disabled_shadow_alpha;
975 theme->a_disabled_focused_max->texture[0].type
976 = theme->a_disabled_unfocused_max->texture[0].type
977 = theme->a_hover_focused_max->texture[0].type
978 = theme->a_hover_unfocused_max->texture[0].type
979 = theme->a_toggled_hover_focused_max->texture[0].type
980 = theme->a_toggled_hover_unfocused_max->texture[0].type
981 = theme->a_toggled_focused_unpressed_max->texture[0].type
982 = theme->a_toggled_unfocused_unpressed_max->texture[0].type
983 = theme->a_toggled_focused_pressed_max->texture[0].type
984 = theme->a_toggled_unfocused_pressed_max->texture[0].type
985 = theme->a_focused_unpressed_max->texture[0].type
986 = theme->a_focused_pressed_max->texture[0].type
987 = theme->a_unfocused_unpressed_max->texture[0].type
988 = theme->a_unfocused_pressed_max->texture[0].type
989 = theme->a_disabled_focused_close->texture[0].type
990 = theme->a_disabled_unfocused_close->texture[0].type
991 = theme->a_hover_focused_close->texture[0].type
992 = theme->a_hover_unfocused_close->texture[0].type
993 = theme->a_focused_unpressed_close->texture[0].type
994 = theme->a_focused_pressed_close->texture[0].type
995 = theme->a_unfocused_unpressed_close->texture[0].type
996 = theme->a_unfocused_pressed_close->texture[0].type
997 = theme->a_disabled_focused_desk->texture[0].type
998 = theme->a_disabled_unfocused_desk->texture[0].type
999 = theme->a_hover_focused_desk->texture[0].type
1000 = theme->a_hover_unfocused_desk->texture[0].type
1001 = theme->a_toggled_hover_focused_desk->texture[0].type
1002 = theme->a_toggled_hover_unfocused_desk->texture[0].type
1003 = theme->a_toggled_focused_unpressed_desk->texture[0].type
1004 = theme->a_toggled_unfocused_unpressed_desk->texture[0].type
1005 = theme->a_toggled_focused_pressed_desk->texture[0].type
1006 = theme->a_toggled_unfocused_pressed_desk->texture[0].type
1007 = theme->a_focused_unpressed_desk->texture[0].type
1008 = theme->a_focused_pressed_desk->texture[0].type
1009 = theme->a_unfocused_unpressed_desk->texture[0].type
1010 = theme->a_unfocused_pressed_desk->texture[0].type
1011 = theme->a_disabled_focused_shade->texture[0].type
1012 = theme->a_disabled_unfocused_shade->texture[0].type
1013 = theme->a_hover_focused_shade->texture[0].type
1014 = theme->a_hover_unfocused_shade->texture[0].type
1015 = theme->a_toggled_hover_focused_shade->texture[0].type
1016 = theme->a_toggled_hover_unfocused_shade->texture[0].type
1017 = theme->a_toggled_focused_unpressed_shade->texture[0].type
1018 = theme->a_toggled_unfocused_unpressed_shade->texture[0].type
1019 = theme->a_toggled_focused_pressed_shade->texture[0].type
1020 = theme->a_toggled_unfocused_pressed_shade->texture[0].type
1021 = theme->a_focused_unpressed_shade->texture[0].type
1022 = theme->a_focused_pressed_shade->texture[0].type
1023 = theme->a_unfocused_unpressed_shade->texture[0].type
1024 = theme->a_unfocused_pressed_shade->texture[0].type
1025 = theme->a_disabled_focused_iconify->texture[0].type
1026 = theme->a_disabled_unfocused_iconify->texture[0].type
1027 = theme->a_hover_focused_iconify->texture[0].type
1028 = theme->a_hover_unfocused_iconify->texture[0].type
1029 = theme->a_focused_unpressed_iconify->texture[0].type
1030 = theme->a_focused_pressed_iconify->texture[0].type
1031 = theme->a_unfocused_unpressed_iconify->texture[0].type
1032 = theme->a_unfocused_pressed_iconify->texture[0].type
1033 = theme->a_menu_bullet_normal->texture[0].type
1034 = theme->a_menu_bullet_selected->texture[0].type
1037 theme->a_disabled_focused_max->texture[0].data.mask.mask
1038 = theme->a_disabled_unfocused_max->texture[0].data.mask.mask
1039 = theme->max_disabled_mask;
1040 theme->a_hover_focused_max->texture[0].data.mask.mask
1041 = theme->a_hover_unfocused_max->texture[0].data.mask.mask
1042 = theme->max_hover_mask;
1043 theme->a_focused_pressed_max->texture[0].data.mask.mask
1044 = theme->a_unfocused_pressed_max->texture[0].data.mask.mask
1045 = theme->max_pressed_mask;
1046 theme->a_focused_unpressed_max->texture[0].data.mask.mask
1047 = theme->a_unfocused_unpressed_max->texture[0].data.mask.mask
1049 theme->a_toggled_hover_focused_max->texture[0].data.mask.mask
1050 = theme->a_toggled_hover_unfocused_max->texture[0].data.mask.mask
1051 = theme->max_toggled_hover_mask;
1052 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.mask
1053 = theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.mask
1054 = theme->max_toggled_mask;
1055 theme->a_toggled_focused_pressed_max->texture[0].data.mask.mask
1056 = theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.mask
1057 = theme->max_toggled_pressed_mask;
1058 theme->a_disabled_focused_close->texture[0].data.mask.mask
1059 = theme->a_disabled_unfocused_close->texture[0].data.mask.mask
1060 = theme->close_disabled_mask;
1061 theme->a_hover_focused_close->texture[0].data.mask.mask
1062 = theme->a_hover_unfocused_close->texture[0].data.mask.mask
1063 = theme->close_hover_mask;
1064 theme->a_focused_pressed_close->texture[0].data.mask.mask
1065 = theme->a_unfocused_pressed_close->texture[0].data.mask.mask
1066 = theme->close_pressed_mask;
1067 theme->a_focused_unpressed_close->texture[0].data.mask.mask
1068 = theme->a_unfocused_unpressed_close->texture[0].data.mask.mask
1069 = theme->close_mask;
1070 theme->a_disabled_focused_desk->texture[0].data.mask.mask
1071 = theme->a_disabled_unfocused_desk->texture[0].data.mask.mask
1072 = theme->desk_disabled_mask;
1073 theme->a_hover_focused_desk->texture[0].data.mask.mask
1074 = theme->a_hover_unfocused_desk->texture[0].data.mask.mask
1075 = theme->desk_hover_mask;
1076 theme->a_focused_pressed_desk->texture[0].data.mask.mask
1077 = theme->a_unfocused_pressed_desk->texture[0].data.mask.mask
1078 = theme->desk_pressed_mask;
1079 theme->a_focused_unpressed_desk->texture[0].data.mask.mask
1080 = theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask
1082 theme->a_toggled_hover_focused_desk->texture[0].data.mask.mask
1083 = theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.mask
1084 = theme->desk_toggled_hover_mask;
1085 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.mask
1086 = theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.mask
1087 = theme->desk_toggled_mask;
1088 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.mask
1089 = theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.mask
1090 = theme->desk_toggled_pressed_mask;
1091 theme->a_disabled_focused_shade->texture[0].data.mask.mask
1092 = theme->a_disabled_unfocused_shade->texture[0].data.mask.mask
1093 = theme->shade_disabled_mask;
1094 theme->a_hover_focused_shade->texture[0].data.mask.mask
1095 = theme->a_hover_unfocused_shade->texture[0].data.mask.mask
1096 = theme->shade_hover_mask;
1097 theme->a_focused_pressed_shade->texture[0].data.mask.mask
1098 = theme->a_unfocused_pressed_shade->texture[0].data.mask.mask
1099 = theme->shade_pressed_mask;
1100 theme->a_focused_unpressed_shade->texture[0].data.mask.mask
1101 = theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask
1102 = theme->shade_mask;
1103 theme->a_toggled_hover_focused_shade->texture[0].data.mask.mask
1104 = theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.mask
1105 = theme->shade_toggled_hover_mask;
1106 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.mask
1107 = theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.mask
1108 = theme->shade_toggled_mask;
1109 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.mask
1110 = theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.mask
1111 = theme->shade_toggled_pressed_mask;
1112 theme->a_disabled_focused_iconify->texture[0].data.mask.mask
1113 = theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask
1114 = theme->iconify_disabled_mask;
1115 theme->a_hover_focused_iconify->texture[0].data.mask.mask
1116 = theme->a_hover_unfocused_iconify->texture[0].data.mask.mask
1117 = theme->iconify_hover_mask;
1118 theme->a_focused_pressed_iconify->texture[0].data.mask.mask
1119 = theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask
1120 = theme->iconify_pressed_mask;
1121 theme->a_focused_unpressed_iconify->texture[0].data.mask.mask
1122 = theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask
1123 = theme->iconify_mask;
1124 theme->a_menu_bullet_normal->texture[0].data.mask.mask
1125 = theme->a_menu_bullet_selected->texture[0].data.mask.mask
1126 = theme->menu_bullet_mask;
1127 theme->a_disabled_focused_max->texture[0].data.mask.color
1128 = theme->a_disabled_focused_close->texture[0].data.mask.color
1129 = theme->a_disabled_focused_desk->texture[0].data.mask.color
1130 = theme->a_disabled_focused_shade->texture[0].data.mask.color
1131 = theme->a_disabled_focused_iconify->texture[0].data.mask.color
1132 = theme->titlebut_disabled_focused_color;
1133 theme->a_disabled_unfocused_max->texture[0].data.mask.color
1134 = theme->a_disabled_unfocused_close->texture[0].data.mask.color
1135 = theme->a_disabled_unfocused_desk->texture[0].data.mask.color
1136 = theme->a_disabled_unfocused_shade->texture[0].data.mask.color
1137 = theme->a_disabled_unfocused_iconify->texture[0].data.mask.color
1138 = theme->titlebut_disabled_unfocused_color;
1139 theme->a_hover_focused_max->texture[0].data.mask.color
1140 = theme->a_hover_focused_close->texture[0].data.mask.color
1141 = theme->a_hover_focused_desk->texture[0].data.mask.color
1142 = theme->a_hover_focused_shade->texture[0].data.mask.color
1143 = theme->a_hover_focused_iconify->texture[0].data.mask.color
1144 = theme->titlebut_hover_focused_color;
1145 theme->a_hover_unfocused_max->texture[0].data.mask.color
1146 = theme->a_hover_unfocused_close->texture[0].data.mask.color
1147 = theme->a_hover_unfocused_desk->texture[0].data.mask.color
1148 = theme->a_hover_unfocused_shade->texture[0].data.mask.color
1149 = theme->a_hover_unfocused_iconify->texture[0].data.mask.color
1150 = theme->titlebut_hover_unfocused_color;
1151 theme->a_toggled_hover_focused_max->texture[0].data.mask.color
1152 = theme->a_toggled_hover_focused_desk->texture[0].data.mask.color
1153 = theme->a_toggled_hover_focused_shade->texture[0].data.mask.color
1154 = theme->titlebut_toggled_hover_focused_color;
1155 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.color
1156 = theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.color
1157 = theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.color
1158 = theme->titlebut_toggled_hover_unfocused_color;
1159 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.color
1160 = theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.color
1161 = theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.color
1162 = theme->titlebut_toggled_focused_unpressed_color;
1163 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.color
1164 = theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.color
1165 = theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.color
1166 = theme->titlebut_toggled_unfocused_unpressed_color;
1167 theme->a_toggled_focused_pressed_max->texture[0].data.mask.color
1168 = theme->a_toggled_focused_pressed_desk->texture[0].data.mask.color
1169 = theme->a_toggled_focused_pressed_shade->texture[0].data.mask.color
1170 = theme->titlebut_toggled_focused_pressed_color;
1171 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.color
1172 = theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.color
1173 = theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.color
1174 = theme->titlebut_toggled_unfocused_pressed_color;
1175 theme->a_focused_unpressed_max->texture[0].data.mask.color
1176 = theme->a_focused_unpressed_close->texture[0].data.mask.color
1177 = theme->a_focused_unpressed_desk->texture[0].data.mask.color
1178 = theme->a_focused_unpressed_shade->texture[0].data.mask.color
1179 = theme->a_focused_unpressed_iconify->texture[0].data.mask.color
1180 = theme->titlebut_focused_unpressed_color;
1181 theme->a_focused_pressed_max->texture[0].data.mask.color
1182 = theme->a_focused_pressed_close->texture[0].data.mask.color
1183 = theme->a_focused_pressed_desk->texture[0].data.mask.color
1184 = theme->a_focused_pressed_shade->texture[0].data.mask.color
1185 = theme->a_focused_pressed_iconify->texture[0].data.mask.color
1186 = theme->titlebut_focused_pressed_color;
1187 theme->a_unfocused_unpressed_max->texture[0].data.mask.color
1188 = theme->a_unfocused_unpressed_close->texture[0].data.mask.color
1189 = theme->a_unfocused_unpressed_desk->texture[0].data.mask.color
1190 = theme->a_unfocused_unpressed_shade->texture[0].data.mask.color
1191 = theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color
1192 = theme->titlebut_unfocused_unpressed_color;
1193 theme->a_unfocused_pressed_max->texture[0].data.mask.color
1194 = theme->a_unfocused_pressed_close->texture[0].data.mask.color
1195 = theme->a_unfocused_pressed_desk->texture[0].data.mask.color
1196 = theme->a_unfocused_pressed_shade->texture[0].data.mask.color
1197 = theme->a_unfocused_pressed_iconify->texture[0].data.mask.color
1198 = theme->titlebut_unfocused_pressed_color;
1199 theme->a_menu_bullet_normal->texture[0].data.mask.color = theme->menu_color;
1200 theme->a_menu_bullet_selected->texture[0].data.mask.color
1201 = theme->menu_selected_color;
1203 /* set the font heights */
1204 theme->win_font_height = RrFontHeight(theme->win_font_focused,
1205 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1206 theme->win_font_height = MAX(theme->win_font_height, RrFontHeight(
1207 theme->win_font_focused,
1208 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1209 theme->menu_title_font_height = RrFontHeight(theme->menu_title_font,
1210 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1211 theme->menu_font_height = RrFontHeight(theme->menu_font,
1212 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1214 /* calculate some last extents */
1216 gint ft, fb, fl, fr, ut, ub, ul, ur;
1218 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1219 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1220 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1221 theme->label_height += theme->label_height % 2;
1223 /* this would be nice I think, since padding.width can now be 0,
1224 but it breaks frame.c horribly and I don't feel like fixing that
1225 right now, so if anyone complains, here is how to keep text from
1226 going over the title's bevel/border with a padding.width of 0 and a
1227 bevelless/borderless label
1228 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1229 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1230 theme->title_height = theme->label_height +
1231 MAX(MAX(theme->padding * 2, ft + fb),
1232 MAX(theme->padding * 2, ut + ub));
1234 theme->title_height = theme->label_height + theme->paddingy * 2;
1236 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1237 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1238 theme->menu_title_height = theme->menu_title_label_height
1239 + theme->paddingy * 2;
1241 theme->button_size = theme->label_height - 2;
1242 theme->grip_width = 25;
1247 static gchar *create_class_name(const gchar *rname)
1249 gchar *rclass = g_strdup(rname);
1254 p = strchr(p+1, '.');
1264 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1266 gboolean ret = FALSE;
1267 gchar *rclass = create_class_name(rname);
1268 gchar *rettype, *end;
1271 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && retvalue.addr
1273 *value = (gint)strtol(retvalue.addr, &end, 10);
1274 if (end != retvalue.addr)
1282 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1284 gboolean ret = FALSE;
1285 gchar *rclass = create_class_name(rname);
1289 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && retvalue.addr
1291 *value = retvalue.addr;
1299 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1300 const gchar *rname, RrColor **value)
1302 gboolean ret = FALSE;
1303 gchar *rclass = create_class_name(rname);
1307 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && retvalue.addr
1309 RrColor *c = RrColorParse(inst, retvalue.addr);
1320 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1321 ObFrameThemeConfig *theme, const gchar *maskname, RrPixmapMask **value)
1323 gboolean ret = FALSE;
1325 gint hx, hy; /* ignored */
1329 s = g_build_filename(path, maskname, NULL);
1330 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1332 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1340 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1341 RrReliefType *relief, RrBevelType *bevel, gboolean *interlaced,
1342 gboolean *border, gboolean allow_trans)
1346 /* convert to all lowercase */
1347 for (t = tex; *t != '\0'; ++t)
1348 *t = g_ascii_tolower(*t);
1350 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1351 *grad = RR_SURFACE_PARENTREL;
1354 if (strstr(tex, "gradient") != NULL) {
1355 if (strstr(tex, "crossdiagonal") != NULL)
1356 *grad = RR_SURFACE_CROSS_DIAGONAL;
1357 else if (strstr(tex, "pyramid") != NULL)
1358 *grad = RR_SURFACE_PYRAMID;
1359 else if (strstr(tex, "mirrorhorizontal") != NULL)
1360 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1361 else if (strstr(tex, "horizontal") != NULL)
1362 *grad = RR_SURFACE_HORIZONTAL;
1363 else if (strstr(tex, "splitvertical") != NULL)
1364 *grad = RR_SURFACE_SPLIT_VERTICAL;
1365 else if (strstr(tex, "vertical") != NULL)
1366 *grad = RR_SURFACE_VERTICAL;
1368 *grad = RR_SURFACE_DIAGONAL;
1371 *grad = RR_SURFACE_SOLID;
1375 if (strstr(tex, "sunken") != NULL)
1376 *relief = RR_RELIEF_SUNKEN;
1377 else if (strstr(tex, "flat") != NULL)
1378 *relief = RR_RELIEF_FLAT;
1379 else if (strstr(tex, "raised") != NULL)
1380 *relief = RR_RELIEF_RAISED;
1382 *relief = (*grad == RR_SURFACE_PARENTREL) ? RR_RELIEF_FLAT
1386 if (*relief == RR_RELIEF_FLAT) {
1387 if (strstr(tex, "border") != NULL)
1391 if (strstr(tex, "bevel2") != NULL)
1392 *bevel = RR_BEVEL_2;
1394 *bevel = RR_BEVEL_1;
1397 if (strstr(tex, "interlaced") != NULL)
1400 *interlaced = FALSE;
1403 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1404 const gchar *rname, RrAppearance *value, gboolean allow_trans)
1406 gboolean ret = FALSE;
1407 gchar *rclass = create_class_name(rname);
1408 gchar *cname, *ctoname, *bcname, *icname, *hname, *sname;
1409 gchar *csplitname, *ctosplitname;
1414 cname = g_strconcat(rname, ".color", NULL);
1415 ctoname = g_strconcat(rname, ".colorTo", NULL);
1416 bcname = g_strconcat(rname, ".border.color", NULL);
1417 icname = g_strconcat(rname, ".interlace.color", NULL);
1418 hname = g_strconcat(rname, ".highlight", NULL);
1419 sname = g_strconcat(rname, ".shadow", NULL);
1420 csplitname = g_strconcat(rname, ".color.splitTo", NULL);
1421 ctosplitname = g_strconcat(rname, ".colorTo.splitTo", NULL);
1423 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) && retvalue.addr
1425 parse_appearance(retvalue.addr, &value->surface.grad,
1426 &value->surface.relief, &value->surface.bevel,
1427 &value->surface.interlaced, &value->surface.border, allow_trans);
1428 if (!read_color(db, inst, cname, &value->surface.primary))
1429 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1430 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1431 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1432 if (value->surface.border)
1433 if (!read_color(db, inst, bcname, &value->surface.border_color))
1434 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1435 if (value->surface.interlaced)
1436 if (!read_color(db, inst, icname, &value->surface.interlace_color))
1437 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1438 if (read_int(db, hname, &i) && i >= 0)
1439 value->surface.bevel_light_adjust = i;
1440 if (read_int(db, sname, &i) && i >= 0 && i <= 256)
1441 value->surface.bevel_dark_adjust = i;
1443 if (value->surface.grad == RR_SURFACE_SPLIT_VERTICAL) {
1446 if (!read_color(db, inst, csplitname, &value->surface.split_primary)) {
1447 r = value->surface.primary->r;
1449 g = value->surface.primary->g;
1451 b = value->surface.primary->b;
1459 value->surface.split_primary = RrColorNew(inst, r, g, b);
1462 if (!read_color(db, inst, ctosplitname,
1463 &value->surface.split_secondary)) {
1464 r = value->surface.secondary->r;
1466 g = value->surface.secondary->g;
1468 b = value->surface.secondary->b;
1476 value->surface.split_secondary = RrColorNew(inst, r, g, b);
1483 g_free(ctosplitname);
1495 static int parse_inline_number(const char *p)
1503 for (; isdigit(*p); ++p)
1504 res = res * 10 + *p - '0';
1509 static void set_default_appearance(RrAppearance *a)
1511 a->surface.grad = RR_SURFACE_SOLID;
1512 a->surface.relief = RR_RELIEF_FLAT;
1513 a->surface.bevel = RR_BEVEL_1;
1514 a->surface.interlaced = FALSE;
1515 a->surface.border = FALSE;
1516 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1517 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
1520 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1521 an RrTextureRGBA. */
1522 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
1527 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
1529 for (i = 0; i < width * height; ++i) {
1530 guchar a = ((*p >> 24) & 0xff);
1531 guchar b = ((*p >> 16) & 0xff);
1532 guchar g = ((*p >> 8) & 0xff);
1533 guchar r = ((*p >> 0) & 0xff);
1535 *p = ((r << RrDefaultRedOffset) + (g << RrDefaultGreenOffset) + (b
1536 << RrDefaultBlueOffset) + (a << RrDefaultAlphaOffset));