1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 theme.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.
26 #include "obt/paths.h"
29 #include <X11/Xresource.h>
34 static XrmDatabase
loaddb(const gchar
*name
, gchar
**path
);
35 static gboolean
read_int(XrmDatabase db
, const gchar
*rname
, gint
*value
);
36 static gboolean
read_string(XrmDatabase db
, const gchar
*rname
, gchar
**value
);
37 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
38 const gchar
*rname
, RrColor
**value
);
39 static gboolean
read_mask(const RrInstance
*inst
, const gchar
*path
,
40 RrTheme
*theme
, const gchar
*maskname
,
41 RrPixmapMask
**value
);
42 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
43 const gchar
*rname
, RrAppearance
*value
,
44 gboolean allow_trans
);
45 static int parse_inline_number(const char *p
);
46 static RrPixel32
* read_c_image(gint width
, gint height
, const guint8
*data
);
47 static void set_default_appearance(RrAppearance
*a
);
49 static RrFont
*get_font(RrFont
*target
, RrFont
**default_font
,
50 const RrInstance
*inst
)
56 /* Only load the default font once */
58 RrFontRef(*default_font
);
60 *default_font
= RrFontOpenDefault(inst
);
66 #define READ_INT(x_resstr, x_var, x_min, x_max, x_def) \
67 if (!read_int(db, x_resstr, & x_var) || \
68 x_var < x_min || x_var > x_max) \
71 #define READ_COLOR(x_resstr, x_var, x_def) \
72 if (!read_color(db, inst, x_resstr, & x_var)) \
75 #define READ_COLOR_(x_res1, x_res2, x_var, x_def) \
76 if (!read_color(db, inst, x_res1, & x_var) && \
77 !read_color(db, inst, x_res2, & x_var)) \
80 #define READ_MASK_COPY(x_file, x_var, x_copysrc) \
81 if (!read_mask(inst, path, theme, x_file, & x_var)) \
82 x_var = RrPixmapMaskCopy(x_copysrc);
84 #define READ_APPEARANCE(x_resstr, x_var, x_parrel) \
85 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) \
86 set_default_appearance(x_var);
88 #define READ_APPEARANCE_COPY(x_resstr, x_var, x_parrel, x_defval) \
89 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) {\
90 RrAppearanceFree(x_var); \
91 x_var = RrAppearanceCopy(x_defval); }
93 #define READ_APPEARANCE_(x_res1, x_res2, x_var, x_parrel, x_defval) \
94 if (!read_appearance(db, inst, x_res1, x_var, x_parrel) && \
95 !read_appearance(db, inst, x_res2, x_var, x_parrel)) {\
96 RrAppearanceFree(x_var); \
97 x_var = RrAppearanceCopy(x_defval); }
99 RrTheme
* RrThemeNew(const RrInstance
*inst
, const gchar
*name
,
100 gboolean allow_fallback
,
101 RrFont
*active_window_font
, RrFont
*inactive_window_font
,
102 RrFont
*menu_title_font
, RrFont
*menu_item_font
,
103 RrFont
*active_osd_font
, RrFont
*inactive_osd_font
)
105 XrmDatabase db
= NULL
;
106 RrJustify winjust
, mtitlejust
;
109 RrFont
*default_font
= NULL
;
112 gint menu_overlap
= 0;
113 RrAppearance
*a_disabled_focused_tmp
;
114 RrAppearance
*a_disabled_unfocused_tmp
;
115 RrAppearance
*a_hover_focused_tmp
;
116 RrAppearance
*a_hover_unfocused_tmp
;
117 RrAppearance
*a_focused_unpressed_tmp
;
118 RrAppearance
*a_focused_pressed_tmp
;
119 RrAppearance
*a_unfocused_unpressed_tmp
;
120 RrAppearance
*a_unfocused_pressed_tmp
;
121 RrAppearance
*a_toggled_hover_focused_tmp
;
122 RrAppearance
*a_toggled_hover_unfocused_tmp
;
123 RrAppearance
*a_toggled_focused_unpressed_tmp
;
124 RrAppearance
*a_toggled_focused_pressed_tmp
;
125 RrAppearance
*a_toggled_unfocused_unpressed_tmp
;
126 RrAppearance
*a_toggled_unfocused_pressed_tmp
;
129 db
= loaddb(name
, &path
);
131 g_message("Unable to load the theme '%s'", name
);
133 g_message("Falling back to the default theme '%s'",
135 /* fallback to the default theme */
140 if (allow_fallback
) {
141 db
= loaddb(DEFAULT_THEME
, &path
);
143 g_message("Unable to load the theme '%s'", DEFAULT_THEME
);
150 /* initialize temp reading textures */
151 a_disabled_focused_tmp
= RrAppearanceNew(inst
, 1);
152 a_disabled_unfocused_tmp
= RrAppearanceNew(inst
, 1);
153 a_hover_focused_tmp
= RrAppearanceNew(inst
, 1);
154 a_hover_unfocused_tmp
= RrAppearanceNew(inst
, 1);
155 a_toggled_focused_unpressed_tmp
= RrAppearanceNew(inst
, 1);
156 a_toggled_unfocused_unpressed_tmp
= RrAppearanceNew(inst
, 1);
157 a_toggled_hover_focused_tmp
= RrAppearanceNew(inst
, 1);
158 a_toggled_hover_unfocused_tmp
= RrAppearanceNew(inst
, 1);
159 a_toggled_focused_pressed_tmp
= RrAppearanceNew(inst
, 1);
160 a_toggled_unfocused_pressed_tmp
= RrAppearanceNew(inst
, 1);
161 a_focused_unpressed_tmp
= RrAppearanceNew(inst
, 1);
162 a_focused_pressed_tmp
= RrAppearanceNew(inst
, 1);
163 a_unfocused_unpressed_tmp
= RrAppearanceNew(inst
, 1);
164 a_unfocused_pressed_tmp
= RrAppearanceNew(inst
, 1);
166 /* initialize theme */
167 theme
= g_slice_new0(RrTheme
, 1);
170 theme
->name
= g_strdup(name
? name
: DEFAULT_THEME
);
173 theme
->btn_max
= RrButtonNew(inst
);
174 theme
->btn_close
= RrButtonNew(inst
);
175 theme
->btn_desk
= RrButtonNew(inst
);
176 theme
->btn_shade
= RrButtonNew(inst
);
177 theme
->btn_iconify
= RrButtonNew(inst
);
179 /* init appearances */
180 theme
->a_focused_grip
= RrAppearanceNew(inst
, 0);
181 theme
->a_unfocused_grip
= RrAppearanceNew(inst
, 0);
182 theme
->a_focused_title
= RrAppearanceNew(inst
, 0);
183 theme
->a_unfocused_title
= RrAppearanceNew(inst
, 0);
184 theme
->a_focused_label
= RrAppearanceNew(inst
, 1);
185 theme
->a_unfocused_label
= RrAppearanceNew(inst
, 1);
186 theme
->a_icon
= RrAppearanceNew(inst
, 1);
187 theme
->a_focused_handle
= RrAppearanceNew(inst
, 0);
188 theme
->a_unfocused_handle
= RrAppearanceNew(inst
, 0);
189 theme
->a_menu
= RrAppearanceNew(inst
, 0);
190 theme
->a_menu_title
= RrAppearanceNew(inst
, 0);
191 theme
->a_menu_text_title
= RrAppearanceNew(inst
, 1);
192 theme
->a_menu_normal
= RrAppearanceNew(inst
, 0);
193 theme
->a_menu_selected
= RrAppearanceNew(inst
, 0);
194 theme
->a_menu_disabled
= RrAppearanceNew(inst
, 0);
195 /* a_menu_disabled_selected is copied from a_menu_selected */
196 theme
->a_menu_text_normal
= RrAppearanceNew(inst
, 1);
197 theme
->a_menu_text_selected
= RrAppearanceNew(inst
, 1);
198 theme
->a_menu_text_disabled
= RrAppearanceNew(inst
, 1);
199 theme
->a_menu_text_disabled_selected
= RrAppearanceNew(inst
, 1);
200 theme
->a_menu_bullet_normal
= RrAppearanceNew(inst
, 1);
201 theme
->a_menu_bullet_selected
= RrAppearanceNew(inst
, 1);
202 theme
->a_clear
= RrAppearanceNew(inst
, 0);
203 theme
->a_clear_tex
= RrAppearanceNew(inst
, 1);
204 theme
->osd_bg
= RrAppearanceNew(inst
, 0);
205 theme
->osd_hilite_label
= RrAppearanceNew(inst
, 1);
206 theme
->osd_hilite_bg
= RrAppearanceNew(inst
, 0);
207 theme
->osd_unhilite_label
= RrAppearanceNew(inst
, 1);
208 theme
->osd_unhilite_bg
= RrAppearanceNew(inst
, 0);
210 /* load the font stuff */
211 theme
->win_font_focused
= get_font(active_window_font
,
212 &default_font
, inst
);
213 theme
->win_font_unfocused
= get_font(inactive_window_font
,
214 &default_font
, inst
);
216 winjust
= RR_JUSTIFY_LEFT
;
217 if (read_string(db
, "window.label.text.justify", &str
)) {
218 if (!g_ascii_strcasecmp(str
, "right"))
219 winjust
= RR_JUSTIFY_RIGHT
;
220 else if (!g_ascii_strcasecmp(str
, "center"))
221 winjust
= RR_JUSTIFY_CENTER
;
224 theme
->menu_title_font
= get_font(menu_title_font
, &default_font
, inst
);
226 mtitlejust
= RR_JUSTIFY_LEFT
;
227 if (read_string(db
, "menu.title.text.justify", &str
)) {
228 if (!g_ascii_strcasecmp(str
, "right"))
229 mtitlejust
= RR_JUSTIFY_RIGHT
;
230 else if (!g_ascii_strcasecmp(str
, "center"))
231 mtitlejust
= RR_JUSTIFY_CENTER
;
234 theme
->menu_font
= get_font(menu_item_font
, &default_font
, inst
);
236 theme
->osd_font_hilite
= get_font(active_osd_font
, &default_font
, inst
);
237 theme
->osd_font_unhilite
= get_font(inactive_osd_font
, &default_font
,inst
);
239 /* load direct dimensions */
240 READ_INT("menu.overlap", menu_overlap
, -100, 100, 0);
241 READ_INT("menu.overlap.x", theme
->menu_overlap_x
, -100, 100, menu_overlap
);
242 READ_INT("menu.overlap.y", theme
->menu_overlap_y
, -100, 100, menu_overlap
);
243 READ_INT("window.handle.width", theme
->handle_height
, 0, 100, 6);
244 READ_INT("padding.width", theme
->paddingx
, 0, 100, 3);
245 READ_INT("padding.height", theme
->paddingy
, 0, 100, theme
->paddingx
);
246 READ_INT("border.width", theme
->fbwidth
, 0, 100, 1);
247 READ_INT("menu.border.width", theme
->mbwidth
, 0, 100, theme
->fbwidth
);
248 READ_INT("osd.border.width", theme
->obwidth
, 0, 100, theme
->fbwidth
);
249 READ_INT("menu.separator.width", theme
->menu_sep_width
, 1, 100, 1);
250 READ_INT("menu.separator.padding.width", theme
->menu_sep_paddingx
, 0, 100, 6);
251 READ_INT("menu.separator.padding.height", theme
->menu_sep_paddingy
, 0, 100, 3);
252 READ_INT("window.client.padding.width", theme
->cbwidthx
, 0, 100,
254 READ_INT("window.client.padding.height", theme
->cbwidthy
, 0, 100,
258 READ_COLOR_("window.active.border.color", "border.color",
259 theme
->frame_focused_border_color
, RrColorNew(inst
, 0, 0, 0));
261 /* title separator focused color inherits from focused border color */
262 READ_COLOR("window.active.title.separator.color",
263 theme
->title_separator_focused_color
,
264 RrColorCopy(theme
->frame_focused_border_color
));
266 /* unfocused border color inherits from frame focused border color */
267 READ_COLOR("window.inactive.border.color",
268 theme
->frame_unfocused_border_color
,
269 RrColorCopy(theme
->frame_focused_border_color
));
271 /* title separator unfocused color inherits from unfocused border color */
272 READ_COLOR("window.inactive.title.separator.color",
273 theme
->title_separator_unfocused_color
,
274 RrColorCopy(theme
->frame_unfocused_border_color
));
276 /* menu border color inherits from frame focused border color */
277 READ_COLOR("menu.border.color", theme
->menu_border_color
,
278 RrColorCopy(theme
->frame_focused_border_color
));
280 /* osd border color inherits from frame focused border color */
281 READ_COLOR("osd.border.color", theme
->osd_border_color
,
282 RrColorCopy(theme
->frame_focused_border_color
));
284 READ_COLOR("window.active.client.color", theme
->cb_focused_color
,
285 RrColorNew(inst
, 0xff, 0xff, 0xff));
287 READ_COLOR("window.inactive.client.color", theme
->cb_unfocused_color
,
288 RrColorNew(inst
, 0xff, 0xff, 0xff));
290 READ_COLOR("window.active.label.text.color", theme
->title_focused_color
,
291 RrColorNew(inst
, 0x0, 0x0, 0x0));
293 READ_COLOR_("osd.active.label.text.color",
294 "osd.label.text.color",
295 theme
->osd_color
, RrColorCopy(theme
->title_focused_color
));
297 READ_COLOR("window.inactive.label.text.color", theme
->title_unfocused_color
,
298 RrColorCopy(theme
->title_unfocused_color
));
300 READ_COLOR("osd.inactive.label.text.color", theme
->osd_text_inactive_color
,
301 RrColorNew(inst
, 0xff, 0xff, 0xff));
303 READ_COLOR("window.inactive.label.text.color",
304 theme
->title_unfocused_color
,
305 RrColorNew(inst
, 0xff, 0xff, 0xff));
307 READ_COLOR("window.active.button.unpressed.image.color",
308 theme
->titlebut_focused_unpressed_color
,
309 RrColorNew(inst
, 0, 0, 0));
311 READ_COLOR("window.inactive.button.unpressed.image.color",
312 theme
->titlebut_unfocused_unpressed_color
,
313 RrColorNew(inst
, 0xff, 0xff, 0xff));
315 READ_COLOR("window.active.button.pressed.image.color",
316 theme
->titlebut_focused_pressed_color
,
317 RrColorCopy(theme
->titlebut_focused_unpressed_color
));
319 READ_COLOR("window.inactive.button.pressed.image.color",
320 theme
->titlebut_unfocused_pressed_color
,
321 RrColorCopy(theme
->titlebut_unfocused_unpressed_color
));
323 READ_COLOR("window.active.button.disabled.image.color",
324 theme
->titlebut_disabled_focused_color
,
325 RrColorNew(inst
, 0xff, 0xff, 0xff));
327 READ_COLOR("window.inactive.button.disabled.image.color",
328 theme
->titlebut_disabled_unfocused_color
,
329 RrColorNew(inst
, 0, 0, 0));
331 READ_COLOR("window.active.button.hover.image.color",
332 theme
->titlebut_hover_focused_color
,
333 RrColorCopy(theme
->titlebut_focused_unpressed_color
));
335 READ_COLOR("window.inactive.button.hover.image.color",
336 theme
->titlebut_hover_unfocused_color
,
337 RrColorCopy(theme
->titlebut_unfocused_unpressed_color
));
339 READ_COLOR_("window.active.button.toggled.unpressed.image.color",
340 "window.active.button.toggled.image.color",
341 theme
->titlebut_toggled_focused_unpressed_color
,
342 RrColorCopy(theme
->titlebut_focused_pressed_color
));
344 READ_COLOR_("window.inactive.button.toggled.unpressed.image.color",
345 "window.inactive.button.toggled.image.color",
346 theme
->titlebut_toggled_unfocused_unpressed_color
,
347 RrColorCopy(theme
->titlebut_unfocused_pressed_color
));
349 READ_COLOR("window.active.button.toggled.hover.image.color",
350 theme
->titlebut_toggled_hover_focused_color
,
351 RrColorCopy(theme
->titlebut_toggled_focused_unpressed_color
));
353 READ_COLOR("window.inactive.button.toggled.hover.image.color",
354 theme
->titlebut_toggled_hover_unfocused_color
,
355 RrColorCopy(theme
->titlebut_toggled_unfocused_unpressed_color
));
357 READ_COLOR("window.active.button.toggled.pressed.image.color",
358 theme
->titlebut_toggled_focused_pressed_color
,
359 RrColorCopy(theme
->titlebut_focused_pressed_color
));
361 READ_COLOR("window.inactive.button.toggled.pressed.image.color",
362 theme
->titlebut_toggled_unfocused_pressed_color
,
363 RrColorCopy(theme
->titlebut_unfocused_pressed_color
));
365 READ_COLOR("menu.title.text.color", theme
->menu_title_color
,
366 RrColorNew(inst
, 0, 0, 0));
368 READ_COLOR("menu.items.text.color", theme
->menu_color
,
369 RrColorNew(inst
, 0xff, 0xff, 0xff));
371 READ_COLOR("menu.items.disabled.text.color", theme
->menu_disabled_color
,
372 RrColorNew(inst
, 0, 0, 0));
374 READ_COLOR("menu.items.active.disabled.text.color",
375 theme
->menu_disabled_selected_color
,
376 RrColorCopy(theme
->menu_disabled_color
));
378 READ_COLOR("menu.items.active.text.color", theme
->menu_selected_color
,
379 RrColorNew(inst
, 0, 0, 0));
381 READ_COLOR("menu.separator.color", theme
->menu_sep_color
,
382 RrColorCopy(theme
->menu_color
));
384 /* load the image masks */
386 /* maximize button masks */
388 if (!read_mask(inst
, path
, theme
, "max.xbm", &theme
->btn_max
->mask
)) {
389 guchar data
[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
390 theme
->btn_max
->mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
393 if (!read_mask(inst
, path
, theme
, "max_toggled.xbm",
394 &theme
->btn_max
->toggled_mask
))
397 theme
->btn_max
->toggled_mask
= RrPixmapMaskCopy(theme
->btn_max
->mask
);
399 guchar data
[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
400 theme
->btn_max
->toggled_mask
= RrPixmapMaskNew(inst
, 6, 6,(gchar
*)data
);
403 READ_MASK_COPY("max_pressed.xbm", theme
->btn_max
->pressed_mask
,
404 theme
->btn_max
->mask
);
405 READ_MASK_COPY("max_disabled.xbm", theme
->btn_max
->disabled_mask
,
406 theme
->btn_max
->mask
);
407 READ_MASK_COPY("max_hover.xbm", theme
->btn_max
->hover_mask
,
408 theme
->btn_max
->mask
);
409 READ_MASK_COPY("max_toggled_pressed.xbm",
410 theme
->btn_max
->toggled_pressed_mask
,
411 theme
->btn_max
->toggled_mask
);
412 READ_MASK_COPY("max_toggled_hover.xbm",
413 theme
->btn_max
->toggled_hover_mask
,
414 theme
->btn_max
->toggled_mask
);
416 /* iconify button masks */
417 if (!read_mask(inst
, path
, theme
, "iconify.xbm", &theme
->btn_iconify
->mask
)) {
418 guchar data
[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
419 theme
->btn_iconify
->mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
421 READ_MASK_COPY("iconify_pressed.xbm", theme
->btn_iconify
->pressed_mask
,
422 theme
->btn_iconify
->mask
);
423 READ_MASK_COPY("iconify_disabled.xbm", theme
->btn_iconify
->disabled_mask
,
424 theme
->btn_iconify
->mask
);
425 READ_MASK_COPY("iconify_hover.xbm", theme
->btn_iconify
->hover_mask
,
426 theme
->btn_iconify
->mask
);
428 /* all desktops button masks */
430 if (!read_mask(inst
, path
, theme
, "desk.xbm", &theme
->btn_desk
->mask
)) {
431 guchar data
[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
432 theme
->btn_desk
->mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
435 if (!read_mask(inst
, path
, theme
, "desk_toggled.xbm",
436 &theme
->btn_desk
->toggled_mask
)) {
438 theme
->btn_desk
->toggled_mask
= RrPixmapMaskCopy(theme
->btn_desk
->mask
);
440 guchar data
[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
441 theme
->btn_desk
->toggled_mask
=
442 RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
445 READ_MASK_COPY("desk_pressed.xbm", theme
->btn_desk
->pressed_mask
,
446 theme
->btn_desk
->mask
);
447 READ_MASK_COPY("desk_disabled.xbm", theme
->btn_desk
->disabled_mask
,
448 theme
->btn_desk
->mask
);
449 READ_MASK_COPY("desk_hover.xbm", theme
->btn_desk
->hover_mask
, theme
->btn_desk
->mask
);
450 READ_MASK_COPY("desk_toggled_pressed.xbm",
451 theme
->btn_desk
->toggled_pressed_mask
, theme
->btn_desk
->toggled_mask
);
452 READ_MASK_COPY("desk_toggled_hover.xbm", theme
->btn_desk
->toggled_hover_mask
,
453 theme
->btn_desk
->toggled_mask
);
455 /* shade button masks */
456 if (!read_mask(inst
, path
, theme
, "shade.xbm", &theme
->btn_shade
->mask
)) {
457 guchar data
[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
458 theme
->btn_shade
->mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
460 READ_MASK_COPY("shade_toggled.xbm", theme
->btn_shade
->toggled_mask
,
461 theme
->btn_shade
->mask
);
462 READ_MASK_COPY("shade_pressed.xbm", theme
->btn_shade
->pressed_mask
,
463 theme
->btn_shade
->mask
);
464 READ_MASK_COPY("shade_disabled.xbm", theme
->btn_shade
->disabled_mask
,
465 theme
->btn_shade
->mask
);
466 READ_MASK_COPY("shade_hover.xbm", theme
->btn_shade
->hover_mask
,
467 theme
->btn_shade
->mask
);
468 READ_MASK_COPY("shade_toggled_pressed.xbm",
469 theme
->btn_shade
->toggled_pressed_mask
,
470 theme
->btn_shade
->toggled_mask
);
471 READ_MASK_COPY("shade_toggled_hover.xbm",
472 theme
->btn_shade
->toggled_hover_mask
,
473 theme
->btn_shade
->toggled_mask
);
475 /* close button masks */
476 if (!read_mask(inst
, path
, theme
, "close.xbm", &theme
->btn_close
->mask
)) {
477 guchar data
[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
478 theme
->btn_close
->mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
480 READ_MASK_COPY("close_pressed.xbm", theme
->btn_close
->pressed_mask
,
481 theme
->btn_close
->mask
);
482 READ_MASK_COPY("close_disabled.xbm", theme
->btn_close
->disabled_mask
,
483 theme
->btn_close
->mask
);
484 READ_MASK_COPY("close_hover.xbm", theme
->btn_close
->hover_mask
,
485 theme
->btn_close
->mask
);
487 /* submenu bullet mask */
488 if (!read_mask(inst
, path
, theme
, "bullet.xbm", &theme
->menu_bullet_mask
))
490 guchar data
[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
491 theme
->menu_bullet_mask
= RrPixmapMaskNew(inst
, 4, 7, (gchar
*)data
);
494 /* up and down arrows */
496 guchar data
[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 };
497 theme
->down_arrow_mask
= RrPixmapMaskNew(inst
, 9, 4, (gchar
*)data
);
500 guchar data
[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 };
501 theme
->up_arrow_mask
= RrPixmapMaskNew(inst
, 9, 4, (gchar
*)data
);
504 /* setup the default window icon */
505 theme
->def_win_icon
= read_c_image(OB_DEFAULT_ICON_WIDTH
,
506 OB_DEFAULT_ICON_HEIGHT
,
507 OB_DEFAULT_ICON_pixel_data
);
508 theme
->def_win_icon_w
= OB_DEFAULT_ICON_WIDTH
;
509 theme
->def_win_icon_h
= OB_DEFAULT_ICON_HEIGHT
;
511 /* the toggled hover mask = the toggled unpressed mask (i.e. no change) */
512 theme
->btn_max
->toggled_hover_mask
=
513 RrPixmapMaskCopy(theme
->btn_max
->toggled_mask
);
514 theme
->btn_desk
->toggled_hover_mask
=
515 RrPixmapMaskCopy(theme
->btn_desk
->toggled_mask
);
516 theme
->btn_shade
->toggled_hover_mask
=
517 RrPixmapMaskCopy(theme
->btn_shade
->toggled_mask
);
518 /* the toggled pressed mask = the toggled unpressed mask (i.e. no change)*/
519 theme
->btn_max
->toggled_pressed_mask
=
520 RrPixmapMaskCopy(theme
->btn_max
->toggled_mask
);
521 theme
->btn_desk
->toggled_pressed_mask
=
522 RrPixmapMaskCopy(theme
->btn_desk
->toggled_mask
);
523 theme
->btn_shade
->toggled_pressed_mask
=
524 RrPixmapMaskCopy(theme
->btn_shade
->toggled_mask
);
526 /* read the decoration textures */
527 READ_APPEARANCE("window.active.title.bg", theme
->a_focused_title
, FALSE
);
528 READ_APPEARANCE("window.inactive.title.bg", theme
->a_unfocused_title
,
530 READ_APPEARANCE("window.active.label.bg", theme
->a_focused_label
, TRUE
);
531 READ_APPEARANCE("window.inactive.label.bg", theme
->a_unfocused_label
,
533 READ_APPEARANCE("window.active.handle.bg", theme
->a_focused_handle
, FALSE
);
534 READ_APPEARANCE("window.inactive.handle.bg",theme
->a_unfocused_handle
,
536 READ_APPEARANCE("window.active.grip.bg", theme
->a_focused_grip
, TRUE
);
537 READ_APPEARANCE("window.inactive.grip.bg", theme
->a_unfocused_grip
, TRUE
);
538 READ_APPEARANCE("menu.items.bg", theme
->a_menu
, FALSE
);
539 READ_APPEARANCE("menu.title.bg", theme
->a_menu_title
, TRUE
);
540 READ_APPEARANCE("menu.items.active.bg", theme
->a_menu_selected
, TRUE
);
542 theme
->a_menu_disabled_selected
=
543 RrAppearanceCopy(theme
->a_menu_selected
);
545 /* read appearances for non-decorations (on-screen-display) */
546 if (!read_appearance(db
, inst
, "osd.bg", theme
->osd_bg
, FALSE
)) {
547 RrAppearanceFree(theme
->osd_bg
);
548 theme
->osd_bg
= RrAppearanceCopy(theme
->a_focused_title
);
550 if (!read_appearance(db
, inst
, "osd.active.label.bg",
551 theme
->osd_hilite_label
, TRUE
) &&
552 !read_appearance(db
, inst
, "osd.label.bg",
553 theme
->osd_hilite_label
, TRUE
)) {
554 RrAppearanceFree(theme
->osd_hilite_label
);
555 theme
->osd_hilite_label
= RrAppearanceCopy(theme
->a_focused_label
);
557 if (!read_appearance(db
, inst
, "osd.inactive.label.bg",
558 theme
->osd_unhilite_label
, TRUE
)) {
559 RrAppearanceFree(theme
->osd_unhilite_label
);
560 theme
->osd_unhilite_label
= RrAppearanceCopy(theme
->a_unfocused_label
);
562 /* osd_hilite_fg can't be parentrel */
563 if (!read_appearance(db
, inst
, "osd.hilight.bg",
564 theme
->osd_hilite_bg
, FALSE
)) {
565 RrAppearanceFree(theme
->osd_hilite_bg
);
566 if (theme
->a_focused_label
->surface
.grad
!= RR_SURFACE_PARENTREL
)
567 theme
->osd_hilite_bg
= RrAppearanceCopy(theme
->a_focused_label
);
569 theme
->osd_hilite_bg
= RrAppearanceCopy(theme
->a_focused_title
);
571 /* osd_unhilite_fg can't be parentrel either */
572 if (!read_appearance(db
, inst
, "osd.unhilight.bg",
573 theme
->osd_unhilite_bg
, FALSE
)) {
574 RrAppearanceFree(theme
->osd_unhilite_bg
);
575 if (theme
->a_unfocused_label
->surface
.grad
!= RR_SURFACE_PARENTREL
)
576 theme
->osd_unhilite_bg
=RrAppearanceCopy(theme
->a_unfocused_label
);
578 theme
->osd_unhilite_bg
=RrAppearanceCopy(theme
->a_unfocused_title
);
581 /* read buttons textures */
583 /* bases: unpressed, pressed, disabled */
584 READ_APPEARANCE("window.active.button.unpressed.bg",
585 a_focused_unpressed_tmp
, TRUE
);
586 READ_APPEARANCE("window.inactive.button.unpressed.bg",
587 a_unfocused_unpressed_tmp
, TRUE
);
588 READ_APPEARANCE("window.active.button.pressed.bg",
589 a_focused_pressed_tmp
, TRUE
);
590 READ_APPEARANCE("window.inactive.button.pressed.bg",
591 a_unfocused_pressed_tmp
, TRUE
);
592 READ_APPEARANCE("window.active.button.disabled.bg",
593 a_disabled_focused_tmp
, TRUE
);
594 READ_APPEARANCE("window.inactive.button.disabled.bg",
595 a_disabled_unfocused_tmp
, TRUE
);
598 READ_APPEARANCE_COPY("window.active.button.hover.bg",
599 a_hover_focused_tmp
, TRUE
,
600 a_focused_unpressed_tmp
);
601 READ_APPEARANCE_COPY("window.inactive.button.hover.bg",
602 a_hover_unfocused_tmp
, TRUE
,
603 a_unfocused_unpressed_tmp
);
605 /* toggled unpressed */
606 READ_APPEARANCE_("window.active.button.toggled.unpressed.bg",
607 "window.active.button.toggled.bg",
608 a_toggled_focused_unpressed_tmp
, TRUE
,
609 a_focused_pressed_tmp
);
610 READ_APPEARANCE_("window.inactive.button.toggled.unpressed.bg",
611 "window.inactive.button.toggled.bg",
612 a_toggled_unfocused_unpressed_tmp
, TRUE
,
613 a_unfocused_pressed_tmp
);
615 /* toggled pressed */
616 READ_APPEARANCE_COPY("window.active.button.toggled.pressed.bg",
617 a_toggled_focused_pressed_tmp
, TRUE
,
618 a_focused_pressed_tmp
);
619 READ_APPEARANCE_COPY("window.inactive.button.toggled.pressed.bg",
620 a_toggled_unfocused_pressed_tmp
, TRUE
,
621 a_unfocused_pressed_tmp
);
624 READ_APPEARANCE_COPY("window.active.button.toggled.hover.bg",
625 a_toggled_hover_focused_tmp
, TRUE
,
626 a_toggled_focused_unpressed_tmp
);
627 READ_APPEARANCE_COPY("window.inactive.button.toggled.hover.bg",
628 a_toggled_hover_unfocused_tmp
, TRUE
,
629 a_toggled_unfocused_unpressed_tmp
);
632 /* now do individual buttons, if specified */
636 /* bases: unpressed, pressed, disabled */
637 READ_APPEARANCE_COPY("window.active.button-max.unpressed.bg",
638 theme
->btn_max
->a_focused_unpressed
, TRUE
,
639 a_focused_unpressed_tmp
);
640 READ_APPEARANCE_COPY("window.inactive.button-max.unpressed.bg",
641 theme
->btn_max
->a_unfocused_unpressed
, TRUE
,
642 a_unfocused_unpressed_tmp
);
643 READ_APPEARANCE_COPY("window.active.button-max.pressed.bg",
644 theme
->btn_max
->a_focused_pressed
, TRUE
,
645 a_focused_pressed_tmp
);
646 READ_APPEARANCE_COPY("window.inactive.button-max.pressed.bg",
647 theme
->btn_max
->a_unfocused_pressed
, TRUE
,
648 a_unfocused_pressed_tmp
);
649 READ_APPEARANCE_COPY("window.active.button-max.disabled.bg",
650 theme
->btn_max
->a_disabled_focused
, TRUE
,
651 a_disabled_focused_tmp
);
652 READ_APPEARANCE_COPY("window.inactive.button-max.disabled.bg",
653 theme
->btn_max
->a_disabled_unfocused
, TRUE
,
654 a_disabled_unfocused_tmp
);
657 READ_APPEARANCE_COPY("window.active.button-max.hover.bg",
658 theme
->btn_max
->a_hover_focused
, TRUE
,
659 theme
->btn_max
->a_focused_unpressed
);
660 READ_APPEARANCE_COPY("window.inactive.button-max.hover.bg",
661 theme
->btn_max
->a_hover_unfocused
, TRUE
,
662 theme
->btn_max
->a_unfocused_unpressed
);
664 /* toggled unpressed */
665 READ_APPEARANCE_("window.active.button-max.toggled.unpressed.bg",
666 "window.active.button-max.toggled.bg",
667 theme
->btn_max
->a_toggled_focused_unpressed
, TRUE
,
668 theme
->btn_max
->a_focused_pressed
);
669 READ_APPEARANCE_("window.inactive.button-max.toggled.unpressed.bg",
670 "window.inactive.button-max.toggled.bg",
671 theme
->btn_max
->a_toggled_unfocused_unpressed
, TRUE
,
672 theme
->btn_max
->a_unfocused_pressed
);
674 /* toggled pressed */
675 READ_APPEARANCE_COPY("window.active.button-max.toggled.pressed.bg",
676 theme
->btn_max
->a_toggled_focused_pressed
, TRUE
,
677 theme
->btn_max
->a_focused_pressed
);
678 READ_APPEARANCE_COPY("window.inactive.button-max.toggled.pressed.bg",
679 theme
->btn_max
->a_toggled_unfocused_pressed
, TRUE
,
680 theme
->btn_max
->a_unfocused_pressed
);
683 READ_APPEARANCE_COPY("window.active.button-max.toggled.hover.bg",
684 theme
->btn_max
->a_toggled_hover_focused
, TRUE
,
685 theme
->btn_max
->a_toggled_focused_unpressed
);
686 READ_APPEARANCE_COPY("window.inactive.button-max.toggled.hover.bg",
687 theme
->btn_max
->a_toggled_hover_unfocused
, TRUE
,
688 theme
->btn_max
->a_toggled_unfocused_unpressed
);
691 READ_APPEARANCE_COPY("window.active.button-close.unpressed.bg",
692 theme
->btn_close
->a_focused_unpressed
, TRUE
,
693 a_focused_unpressed_tmp
);
694 READ_APPEARANCE_COPY("window.inactive.button-close.unpressed.bg",
695 theme
->btn_close
->a_unfocused_unpressed
, TRUE
,
696 a_unfocused_unpressed_tmp
);
697 READ_APPEARANCE_COPY("window.active.button-close.pressed.bg",
698 theme
->btn_close
->a_focused_pressed
, TRUE
,
699 a_focused_pressed_tmp
);
700 READ_APPEARANCE_COPY("window.inactive.button-close.pressed.bg",
701 theme
->btn_close
->a_unfocused_pressed
, TRUE
,
702 a_unfocused_pressed_tmp
);
703 READ_APPEARANCE_COPY("window.active.button-close.disabled.bg",
704 theme
->btn_close
->a_disabled_focused
, TRUE
,
705 a_disabled_focused_tmp
);
706 READ_APPEARANCE_COPY("window.inactive.button-close.disabled.bg",
707 theme
->btn_close
->a_disabled_unfocused
, TRUE
,
708 a_disabled_unfocused_tmp
);
709 READ_APPEARANCE_COPY("window.active.button-close.hover.bg",
710 theme
->btn_close
->a_hover_focused
, TRUE
,
711 theme
->btn_close
->a_focused_unpressed
);
712 READ_APPEARANCE_COPY("window.inactive.button-close.hover.bg",
713 theme
->btn_close
->a_hover_unfocused
, TRUE
,
714 theme
->btn_close
->a_unfocused_unpressed
);
718 /* bases: unpressed, pressed, disabled */
719 READ_APPEARANCE_COPY("window.active.button-desk.unpressed.bg",
720 theme
->btn_desk
->a_focused_unpressed
, TRUE
,
721 a_focused_unpressed_tmp
);
722 READ_APPEARANCE_COPY("window.inactive.button-desk.unpressed.bg",
723 theme
->btn_desk
->a_unfocused_unpressed
, TRUE
,
724 a_unfocused_unpressed_tmp
);
725 READ_APPEARANCE_COPY("window.active.button-desk.pressed.bg",
726 theme
->btn_desk
->a_focused_pressed
, TRUE
,
727 a_focused_pressed_tmp
);
728 READ_APPEARANCE_COPY("window.inactive.button-desk.pressed.bg",
729 theme
->btn_desk
->a_unfocused_pressed
, TRUE
,
730 a_unfocused_pressed_tmp
);
731 READ_APPEARANCE_COPY("window.active.button-desk.disabled.bg",
732 theme
->btn_desk
->a_disabled_focused
, TRUE
,
733 a_disabled_focused_tmp
);
734 READ_APPEARANCE_COPY("window.inactive.button-desk.disabled.bg",
735 theme
->btn_desk
->a_disabled_unfocused
, TRUE
,
736 a_disabled_unfocused_tmp
);
739 READ_APPEARANCE_COPY("window.active.button-desk.hover.bg",
740 theme
->btn_desk
->a_hover_focused
, TRUE
,
741 theme
->btn_desk
->a_focused_unpressed
);
742 READ_APPEARANCE_COPY("window.inactive.button-desk.hover.bg",
743 theme
->btn_desk
->a_hover_unfocused
, TRUE
,
744 theme
->btn_desk
->a_unfocused_unpressed
);
746 /* toggled unpressed */
747 READ_APPEARANCE_("window.active.button-desk.toggled.unpressed.bg",
748 "window.active.button-desk.toggled.bg",
749 theme
->btn_desk
->a_toggled_focused_unpressed
, TRUE
,
750 theme
->btn_desk
->a_focused_pressed
);
751 READ_APPEARANCE_("window.inactive.button-desk.toggled.unpressed.bg",
752 "window.inactive.button-desk.toggled.bg",
753 theme
->btn_desk
->a_toggled_unfocused_unpressed
, TRUE
,
754 theme
->btn_desk
->a_unfocused_pressed
);
756 /* toggled pressed */
757 READ_APPEARANCE_COPY("window.active.button-desk.toggled.pressed.bg",
758 theme
->btn_desk
->a_toggled_focused_pressed
, TRUE
,
759 theme
->btn_desk
->a_focused_pressed
);
760 READ_APPEARANCE_COPY("window.inactive.button-desk.toggled.pressed.bg",
761 theme
->btn_desk
->a_toggled_unfocused_pressed
, TRUE
,
762 theme
->btn_desk
->a_unfocused_pressed
);
765 READ_APPEARANCE_COPY("window.active.button-desk.toggled.hover.bg",
766 theme
->btn_desk
->a_toggled_hover_focused
, TRUE
,
767 theme
->btn_desk
->a_toggled_focused_unpressed
);
768 READ_APPEARANCE_COPY("window.inactive.button-desk.toggled.hover.bg",
769 theme
->btn_desk
->a_toggled_hover_unfocused
, TRUE
,
770 theme
->btn_desk
->a_toggled_unfocused_unpressed
);
774 /* bases: unpressed, pressed, disabled */
775 READ_APPEARANCE_COPY("window.active.button-shade.unpressed.bg",
776 theme
->btn_shade
->a_focused_unpressed
, TRUE
,
777 a_focused_unpressed_tmp
);
778 READ_APPEARANCE_COPY("window.inactive.button-shade.unpressed.bg",
779 theme
->btn_shade
->a_unfocused_unpressed
, TRUE
,
780 a_unfocused_unpressed_tmp
);
781 READ_APPEARANCE_COPY("window.active.button-shade.pressed.bg",
782 theme
->btn_shade
->a_focused_pressed
, TRUE
,
783 a_focused_pressed_tmp
);
784 READ_APPEARANCE_COPY("window.inactive.button-shade.pressed.bg",
785 theme
->btn_shade
->a_unfocused_pressed
, TRUE
,
786 a_unfocused_pressed_tmp
);
787 READ_APPEARANCE_COPY("window.active.button-shade.disabled.bg",
788 theme
->btn_shade
->a_disabled_focused
, TRUE
,
789 a_disabled_focused_tmp
);
790 READ_APPEARANCE_COPY("window.inactive.button-shade.disabled.bg",
791 theme
->btn_shade
->a_disabled_unfocused
, TRUE
,
792 a_disabled_unfocused_tmp
);
795 READ_APPEARANCE_COPY("window.active.button-shade.hover.bg",
796 theme
->btn_shade
->a_hover_focused
, TRUE
,
797 theme
->btn_shade
->a_focused_unpressed
);
798 READ_APPEARANCE_COPY("window.inactive.button-shade.hover.bg",
799 theme
->btn_shade
->a_hover_unfocused
, TRUE
,
800 theme
->btn_shade
->a_unfocused_unpressed
);
802 /* toggled unpressed */
803 READ_APPEARANCE_("window.active.button-shade.toggled.unpressed.bg",
804 "window.active.button-shade.toggled.bg",
805 theme
->btn_shade
->a_toggled_focused_unpressed
, TRUE
,
806 theme
->btn_shade
->a_focused_pressed
);
807 READ_APPEARANCE_("window.inactive.button-shade.toggled.unpressed.bg",
808 "window.inactive.button-shade.toggled.bg",
809 theme
->btn_shade
->a_toggled_unfocused_unpressed
, TRUE
,
810 theme
->btn_shade
->a_unfocused_pressed
);
812 /* toggled pressed */
813 READ_APPEARANCE_COPY("window.active.button-shade.toggled.pressed.bg",
814 theme
->btn_shade
->a_toggled_focused_pressed
, TRUE
,
815 theme
->btn_shade
->a_focused_pressed
);
816 READ_APPEARANCE_COPY("window.inactive.button-shade.toggled.pressed.bg",
817 theme
->btn_shade
->a_toggled_unfocused_pressed
, TRUE
,
818 theme
->btn_shade
->a_unfocused_pressed
);
821 READ_APPEARANCE_COPY("window.active.button-shade.toggled.hover.bg",
822 theme
->btn_shade
->a_toggled_hover_focused
, TRUE
,
823 theme
->btn_shade
->a_toggled_focused_unpressed
);
824 READ_APPEARANCE_COPY("window.inactive.button-shade.toggled.hover.bg",
825 theme
->btn_shade
->a_toggled_hover_unfocused
, TRUE
,
826 theme
->btn_shade
->a_toggled_unfocused_unpressed
);
829 READ_APPEARANCE_COPY("window.active.button-iconify.unpressed.bg",
830 theme
->btn_iconify
->a_focused_unpressed
, TRUE
,
831 a_focused_unpressed_tmp
);
832 READ_APPEARANCE_COPY("window.inactive.button-iconify.unpressed.bg",
833 theme
->btn_iconify
->a_unfocused_unpressed
, TRUE
,
834 a_unfocused_unpressed_tmp
);
835 READ_APPEARANCE_COPY("window.active.button-iconify.pressed.bg",
836 theme
->btn_iconify
->a_focused_pressed
, TRUE
,
837 a_focused_pressed_tmp
);
838 READ_APPEARANCE_COPY("window.inactive.button-iconify.pressed.bg",
839 theme
->btn_iconify
->a_unfocused_pressed
, TRUE
,
840 a_unfocused_pressed_tmp
);
841 READ_APPEARANCE_COPY("window.active.button-iconify.disabled.bg",
842 theme
->btn_iconify
->a_disabled_focused
, TRUE
,
843 a_disabled_focused_tmp
);
844 READ_APPEARANCE_COPY("window.inactive.button-iconify.disabled.bg",
845 theme
->btn_iconify
->a_disabled_unfocused
, TRUE
,
846 a_disabled_unfocused_tmp
);
847 READ_APPEARANCE_COPY("window.active.button-iconify.hover.bg",
848 theme
->btn_iconify
->a_hover_focused
, TRUE
,
849 theme
->btn_iconify
->a_focused_unpressed
);
850 READ_APPEARANCE_COPY("window.inactive.button-iconify.hover.bg",
851 theme
->btn_iconify
->a_hover_unfocused
, TRUE
,
852 theme
->btn_iconify
->a_unfocused_unpressed
);
854 theme
->a_icon
->surface
.grad
=
855 theme
->a_clear
->surface
.grad
=
856 theme
->a_clear_tex
->surface
.grad
=
857 theme
->a_menu_text_title
->surface
.grad
=
858 theme
->a_menu_normal
->surface
.grad
=
859 theme
->a_menu_disabled
->surface
.grad
=
860 theme
->a_menu_text_normal
->surface
.grad
=
861 theme
->a_menu_text_selected
->surface
.grad
=
862 theme
->a_menu_text_disabled
->surface
.grad
=
863 theme
->a_menu_text_disabled_selected
->surface
.grad
=
864 theme
->a_menu_bullet_normal
->surface
.grad
=
865 theme
->a_menu_bullet_selected
->surface
.grad
= RR_SURFACE_PARENTREL
;
867 /* set up the textures */
868 theme
->a_focused_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
869 theme
->a_focused_label
->texture
[0].data
.text
.justify
= winjust
;
870 theme
->a_focused_label
->texture
[0].data
.text
.font
=theme
->win_font_focused
;
871 theme
->a_focused_label
->texture
[0].data
.text
.color
=
872 theme
->title_focused_color
;
874 if (read_string(db
, "window.active.label.text.font", &str
)) {
878 if (strstr(str
, "shadow=y")) {
879 if ((p
= strstr(str
, "shadowoffset=")))
880 i
= parse_inline_number(p
+ strlen("shadowoffset="));
883 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_x
= i
;
884 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_y
= i
;
886 if ((p
= strstr(str
, "shadowtint=")))
888 i
= parse_inline_number(p
+ strlen("shadowtint="));
889 j
= (i
> 0 ? 0 : 255);
892 theme
->title_focused_shadow_color
= RrColorNew(inst
, j
, j
, j
);
893 theme
->title_focused_shadow_alpha
= i
;
895 theme
->title_focused_shadow_color
= RrColorNew(inst
, 0, 0, 0);
896 theme
->title_focused_shadow_alpha
= 50;
900 theme
->a_focused_label
->texture
[0].data
.text
.shadow_color
=
901 theme
->title_focused_shadow_color
;
902 theme
->a_focused_label
->texture
[0].data
.text
.shadow_alpha
=
903 theme
->title_focused_shadow_alpha
;
905 theme
->osd_hilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
906 theme
->osd_hilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
907 theme
->osd_hilite_label
->texture
[0].data
.text
.font
=
908 theme
->osd_font_hilite
;
909 theme
->osd_hilite_label
->texture
[0].data
.text
.color
=
910 theme
->osd_text_active_color
;
912 if (read_string(db
, "osd.active.label.text.font", &str
) ||
913 read_string(db
, "osd.label.text.font", &str
))
918 if (strstr(str
, "shadow=y")) {
919 if ((p
= strstr(str
, "shadowoffset=")))
920 i
= parse_inline_number(p
+ strlen("shadowoffset="));
923 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_x
= i
;
924 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_y
= i
;
926 if ((p
= strstr(str
, "shadowtint=")))
928 i
= parse_inline_number(p
+ strlen("shadowtint="));
929 j
= (i
> 0 ? 0 : 255);
932 theme
->osd_text_active_shadow_color
= RrColorNew(inst
, j
, j
, j
);
933 theme
->osd_text_active_shadow_alpha
= i
;
935 theme
->osd_text_active_shadow_color
= RrColorNew(inst
, 0, 0, 0);
936 theme
->osd_text_active_shadow_alpha
= 50;
939 /* inherit the font settings from the focused label */
940 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_x
=
941 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_x
;
942 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_y
=
943 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_y
;
944 if (theme
->title_focused_shadow_color
)
945 theme
->osd_text_active_shadow_color
=
947 theme
->title_focused_shadow_color
->r
,
948 theme
->title_focused_shadow_color
->g
,
949 theme
->title_focused_shadow_color
->b
);
951 theme
->osd_text_active_shadow_color
= RrColorNew(inst
, 0, 0, 0);
952 theme
->osd_text_active_shadow_alpha
=
953 theme
->title_focused_shadow_alpha
;
956 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_color
=
957 theme
->osd_text_active_shadow_color
;
958 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_alpha
=
959 theme
->osd_text_active_shadow_alpha
;
961 theme
->a_unfocused_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
962 theme
->a_unfocused_label
->texture
[0].data
.text
.justify
= winjust
;
963 theme
->a_unfocused_label
->texture
[0].data
.text
.font
=
964 theme
->win_font_unfocused
;
965 theme
->a_unfocused_label
->texture
[0].data
.text
.color
=
966 theme
->title_unfocused_color
;
968 if (read_string(db
, "window.inactive.label.text.font", &str
)) {
972 if (strstr(str
, "shadow=y")) {
973 if ((p
= strstr(str
, "shadowoffset=")))
974 i
= parse_inline_number(p
+ strlen("shadowoffset="));
977 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_x
= i
;
978 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_y
= i
;
980 if ((p
= strstr(str
, "shadowtint=")))
982 i
= parse_inline_number(p
+ strlen("shadowtint="));
983 j
= (i
> 0 ? 0 : 255);
986 theme
->title_unfocused_shadow_color
= RrColorNew(inst
, j
, j
, j
);
987 theme
->title_unfocused_shadow_alpha
= i
;
989 theme
->title_unfocused_shadow_color
= RrColorNew(inst
, 0, 0, 0);
990 theme
->title_unfocused_shadow_alpha
= 50;
994 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_color
=
995 theme
->title_unfocused_shadow_color
;
996 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_alpha
=
997 theme
->title_unfocused_shadow_alpha
;
999 theme
->osd_unhilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
1000 theme
->osd_unhilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
1001 theme
->osd_unhilite_label
->texture
[0].data
.text
.font
=
1002 theme
->osd_font_unhilite
;
1003 theme
->osd_unhilite_label
->texture
[0].data
.text
.color
=
1004 theme
->osd_text_inactive_color
;
1006 if (read_string(db
, "osd.inactive.label.text.font", &str
))
1011 if (strstr(str
, "shadow=y")) {
1012 if ((p
= strstr(str
, "shadowoffset=")))
1013 i
= parse_inline_number(p
+ strlen("shadowoffset="));
1016 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_x
=i
;
1017 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_y
=i
;
1019 if ((p
= strstr(str
, "shadowtint=")))
1021 i
= parse_inline_number(p
+ strlen("shadowtint="));
1022 j
= (i
> 0 ? 0 : 255);
1025 theme
->osd_text_inactive_shadow_color
= RrColorNew(inst
, j
, j
, j
);
1026 theme
->osd_text_inactive_shadow_alpha
= i
;
1028 theme
->osd_text_inactive_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1029 theme
->osd_text_inactive_shadow_alpha
= 50;
1032 /* inherit the font settings from the unfocused label */
1033 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_x
=
1034 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_x
;
1035 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_y
=
1036 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_y
;
1037 if (theme
->title_unfocused_shadow_color
)
1038 theme
->osd_text_inactive_shadow_color
=
1040 theme
->title_unfocused_shadow_color
->r
,
1041 theme
->title_unfocused_shadow_color
->g
,
1042 theme
->title_unfocused_shadow_color
->b
);
1044 theme
->osd_text_inactive_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1045 theme
->osd_text_inactive_shadow_alpha
=
1046 theme
->title_unfocused_shadow_alpha
;
1049 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_color
=
1050 theme
->osd_text_inactive_shadow_color
;
1051 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_alpha
=
1052 theme
->osd_text_inactive_shadow_alpha
;
1054 theme
->a_menu_text_title
->texture
[0].type
= RR_TEXTURE_TEXT
;
1055 theme
->a_menu_text_title
->texture
[0].data
.text
.justify
= mtitlejust
;
1056 theme
->a_menu_text_title
->texture
[0].data
.text
.font
=
1057 theme
->menu_title_font
;
1058 theme
->a_menu_text_title
->texture
[0].data
.text
.color
=
1059 theme
->menu_title_color
;
1061 if (read_string(db
, "menu.title.text.font", &str
)) {
1065 if (strstr(str
, "shadow=y")) {
1066 if ((p
= strstr(str
, "shadowoffset=")))
1067 i
= parse_inline_number(p
+ strlen("shadowoffset="));
1070 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_offset_x
= i
;
1071 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_offset_y
= i
;
1073 if ((p
= strstr(str
, "shadowtint=")))
1075 i
= parse_inline_number(p
+ strlen("shadowtint="));
1076 j
= (i
> 0 ? 0 : 255);
1079 theme
->menu_title_shadow_color
= RrColorNew(inst
, j
, j
, j
);
1080 theme
->menu_title_shadow_alpha
= i
;
1082 theme
->menu_title_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1083 theme
->menu_title_shadow_alpha
= 50;
1087 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_color
=
1088 theme
->menu_title_shadow_color
;
1089 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_alpha
=
1090 theme
->menu_title_shadow_alpha
;
1092 theme
->a_menu_text_normal
->texture
[0].type
=
1093 theme
->a_menu_text_selected
->texture
[0].type
=
1094 theme
->a_menu_text_disabled
->texture
[0].type
=
1095 theme
->a_menu_text_disabled_selected
->texture
[0].type
=
1097 theme
->a_menu_text_normal
->texture
[0].data
.text
.justify
=
1098 theme
->a_menu_text_selected
->texture
[0].data
.text
.justify
=
1099 theme
->a_menu_text_disabled
->texture
[0].data
.text
.justify
=
1100 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.justify
=
1102 theme
->a_menu_text_normal
->texture
[0].data
.text
.font
=
1103 theme
->a_menu_text_selected
->texture
[0].data
.text
.font
=
1104 theme
->a_menu_text_disabled
->texture
[0].data
.text
.font
=
1105 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.font
=
1107 theme
->a_menu_text_normal
->texture
[0].data
.text
.color
= theme
->menu_color
;
1108 theme
->a_menu_text_selected
->texture
[0].data
.text
.color
=
1109 theme
->menu_selected_color
;
1110 theme
->a_menu_text_disabled
->texture
[0].data
.text
.color
=
1111 theme
->menu_disabled_color
;
1112 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.color
=
1113 theme
->menu_disabled_selected_color
;
1115 if (read_string(db
, "menu.items.font", &str
)) {
1119 if (strstr(str
, "shadow=y")) {
1120 if ((p
= strstr(str
, "shadowoffset=")))
1121 i
= parse_inline_number(p
+ strlen("shadowoffset="));
1124 theme
->a_menu_text_normal
->
1125 texture
[0].data
.text
.shadow_offset_x
= i
;
1126 theme
->a_menu_text_normal
->
1127 texture
[0].data
.text
.shadow_offset_y
= i
;
1128 theme
->a_menu_text_selected
->
1129 texture
[0].data
.text
.shadow_offset_x
= i
;
1130 theme
->a_menu_text_selected
->
1131 texture
[0].data
.text
.shadow_offset_y
= i
;
1132 theme
->a_menu_text_disabled
->
1133 texture
[0].data
.text
.shadow_offset_x
= i
;
1134 theme
->a_menu_text_disabled
->
1135 texture
[0].data
.text
.shadow_offset_y
= i
;
1136 theme
->a_menu_text_disabled_selected
->
1137 texture
[0].data
.text
.shadow_offset_x
= i
;
1138 theme
->a_menu_text_disabled_selected
->
1139 texture
[0].data
.text
.shadow_offset_y
= i
;
1141 if ((p
= strstr(str
, "shadowtint=")))
1143 i
= parse_inline_number(p
+ strlen("shadowtint="));
1144 j
= (i
> 0 ? 0 : 255);
1147 theme
->menu_text_normal_shadow_color
= RrColorNew(inst
, j
, j
, j
);
1148 theme
->menu_text_selected_shadow_color
= RrColorNew(inst
, j
, j
, j
);
1149 theme
->menu_text_disabled_shadow_color
= RrColorNew(inst
, j
, j
, j
);
1150 theme
->menu_text_normal_shadow_alpha
= i
;
1151 theme
->menu_text_selected_shadow_alpha
= i
;
1152 theme
->menu_text_disabled_shadow_alpha
= i
;
1153 theme
->menu_text_disabled_selected_shadow_alpha
= i
;
1155 theme
->menu_text_normal_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1156 theme
->menu_text_selected_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1157 theme
->menu_text_disabled_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1158 theme
->menu_text_normal_shadow_alpha
= 50;
1159 theme
->menu_text_selected_shadow_alpha
= 50;
1160 theme
->menu_text_disabled_selected_shadow_alpha
= 50;
1164 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_color
=
1165 theme
->menu_text_normal_shadow_color
;
1166 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_alpha
=
1167 theme
->menu_text_normal_shadow_alpha
;
1168 theme
->a_menu_text_selected
->texture
[0].data
.text
.shadow_color
=
1169 theme
->menu_text_selected_shadow_color
;
1170 theme
->a_menu_text_selected
->texture
[0].data
.text
.shadow_alpha
=
1171 theme
->menu_text_selected_shadow_alpha
;
1172 theme
->a_menu_text_disabled
->texture
[0].data
.text
.shadow_color
=
1173 theme
->menu_text_disabled_shadow_color
;
1174 theme
->a_menu_text_disabled
->texture
[0].data
.text
.shadow_alpha
=
1175 theme
->menu_text_disabled_shadow_alpha
;
1176 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.shadow_color
=
1177 theme
->menu_text_disabled_shadow_color
;
1178 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.shadow_alpha
=
1179 theme
->menu_text_disabled_shadow_alpha
;
1181 theme
->btn_max
->a_disabled_focused
->texture
[0].type
=
1182 theme
->btn_max
->a_disabled_unfocused
->texture
[0].type
=
1183 theme
->btn_max
->a_hover_focused
->texture
[0].type
=
1184 theme
->btn_max
->a_hover_unfocused
->texture
[0].type
=
1185 theme
->btn_max
->a_toggled_hover_focused
->texture
[0].type
=
1186 theme
->btn_max
->a_toggled_hover_unfocused
->texture
[0].type
=
1187 theme
->btn_max
->a_toggled_focused_unpressed
->texture
[0].type
=
1188 theme
->btn_max
->a_toggled_unfocused_unpressed
->texture
[0].type
=
1189 theme
->btn_max
->a_toggled_focused_pressed
->texture
[0].type
=
1190 theme
->btn_max
->a_toggled_unfocused_pressed
->texture
[0].type
=
1191 theme
->btn_max
->a_focused_unpressed
->texture
[0].type
=
1192 theme
->btn_max
->a_focused_pressed
->texture
[0].type
=
1193 theme
->btn_max
->a_unfocused_unpressed
->texture
[0].type
=
1194 theme
->btn_max
->a_unfocused_pressed
->texture
[0].type
=
1195 theme
->btn_close
->a_disabled_focused
->texture
[0].type
=
1196 theme
->btn_close
->a_disabled_unfocused
->texture
[0].type
=
1197 theme
->btn_close
->a_hover_focused
->texture
[0].type
=
1198 theme
->btn_close
->a_hover_unfocused
->texture
[0].type
=
1199 theme
->btn_close
->a_focused_unpressed
->texture
[0].type
=
1200 theme
->btn_close
->a_focused_pressed
->texture
[0].type
=
1201 theme
->btn_close
->a_unfocused_unpressed
->texture
[0].type
=
1202 theme
->btn_close
->a_unfocused_pressed
->texture
[0].type
=
1203 theme
->btn_desk
->a_disabled_focused
->texture
[0].type
=
1204 theme
->btn_desk
->a_disabled_unfocused
->texture
[0].type
=
1205 theme
->btn_desk
->a_hover_focused
->texture
[0].type
=
1206 theme
->btn_desk
->a_hover_unfocused
->texture
[0].type
=
1207 theme
->btn_desk
->a_toggled_hover_focused
->texture
[0].type
=
1208 theme
->btn_desk
->a_toggled_hover_unfocused
->texture
[0].type
=
1209 theme
->btn_desk
->a_toggled_focused_unpressed
->texture
[0].type
=
1210 theme
->btn_desk
->a_toggled_unfocused_unpressed
->texture
[0].type
=
1211 theme
->btn_desk
->a_toggled_focused_pressed
->texture
[0].type
=
1212 theme
->btn_desk
->a_toggled_unfocused_pressed
->texture
[0].type
=
1213 theme
->btn_desk
->a_focused_unpressed
->texture
[0].type
=
1214 theme
->btn_desk
->a_focused_pressed
->texture
[0].type
=
1215 theme
->btn_desk
->a_unfocused_unpressed
->texture
[0].type
=
1216 theme
->btn_desk
->a_unfocused_pressed
->texture
[0].type
=
1217 theme
->btn_shade
->a_disabled_focused
->texture
[0].type
=
1218 theme
->btn_shade
->a_disabled_unfocused
->texture
[0].type
=
1219 theme
->btn_shade
->a_hover_focused
->texture
[0].type
=
1220 theme
->btn_shade
->a_hover_unfocused
->texture
[0].type
=
1221 theme
->btn_shade
->a_toggled_hover_focused
->texture
[0].type
=
1222 theme
->btn_shade
->a_toggled_hover_unfocused
->texture
[0].type
=
1223 theme
->btn_shade
->a_toggled_focused_unpressed
->texture
[0].type
=
1224 theme
->btn_shade
->a_toggled_unfocused_unpressed
->texture
[0].type
=
1225 theme
->btn_shade
->a_toggled_focused_pressed
->texture
[0].type
=
1226 theme
->btn_shade
->a_toggled_unfocused_pressed
->texture
[0].type
=
1227 theme
->btn_shade
->a_focused_unpressed
->texture
[0].type
=
1228 theme
->btn_shade
->a_focused_pressed
->texture
[0].type
=
1229 theme
->btn_shade
->a_unfocused_unpressed
->texture
[0].type
=
1230 theme
->btn_shade
->a_unfocused_pressed
->texture
[0].type
=
1231 theme
->btn_iconify
->a_disabled_focused
->texture
[0].type
=
1232 theme
->btn_iconify
->a_disabled_unfocused
->texture
[0].type
=
1233 theme
->btn_iconify
->a_hover_focused
->texture
[0].type
=
1234 theme
->btn_iconify
->a_hover_unfocused
->texture
[0].type
=
1235 theme
->btn_iconify
->a_focused_unpressed
->texture
[0].type
=
1236 theme
->btn_iconify
->a_focused_pressed
->texture
[0].type
=
1237 theme
->btn_iconify
->a_unfocused_unpressed
->texture
[0].type
=
1238 theme
->btn_iconify
->a_unfocused_pressed
->texture
[0].type
=
1239 theme
->a_menu_bullet_normal
->texture
[0].type
=
1240 theme
->a_menu_bullet_selected
->texture
[0].type
= RR_TEXTURE_MASK
;
1242 theme
->btn_max
->a_disabled_focused
->texture
[0].data
.mask
.mask
=
1243 theme
->btn_max
->a_disabled_unfocused
->texture
[0].data
.mask
.mask
=
1244 theme
->btn_max
->disabled_mask
;
1245 theme
->btn_max
->a_hover_focused
->texture
[0].data
.mask
.mask
=
1246 theme
->btn_max
->a_hover_unfocused
->texture
[0].data
.mask
.mask
=
1247 theme
->btn_max
->hover_mask
;
1248 theme
->btn_max
->a_focused_pressed
->texture
[0].data
.mask
.mask
=
1249 theme
->btn_max
->a_unfocused_pressed
->texture
[0].data
.mask
.mask
=
1250 theme
->btn_max
->pressed_mask
;
1251 theme
->btn_max
->a_focused_unpressed
->texture
[0].data
.mask
.mask
=
1252 theme
->btn_max
->a_unfocused_unpressed
->texture
[0].data
.mask
.mask
=
1253 theme
->btn_max
->mask
;
1254 theme
->btn_max
->a_toggled_hover_focused
->texture
[0].data
.mask
.mask
=
1255 theme
->btn_max
->a_toggled_hover_unfocused
->texture
[0].data
.mask
.mask
=
1256 theme
->btn_max
->toggled_hover_mask
;
1257 theme
->btn_max
->a_toggled_focused_unpressed
->texture
[0].data
.mask
.mask
=
1258 theme
->btn_max
->a_toggled_unfocused_unpressed
->texture
[0].data
.mask
.mask
=
1259 theme
->btn_max
->toggled_mask
;
1260 theme
->btn_max
->a_toggled_focused_pressed
->texture
[0].data
.mask
.mask
=
1261 theme
->btn_max
->a_toggled_unfocused_pressed
->texture
[0].data
.mask
.mask
=
1262 theme
->btn_max
->toggled_pressed_mask
;
1263 theme
->btn_close
->a_disabled_focused
->texture
[0].data
.mask
.mask
=
1264 theme
->btn_close
->a_disabled_unfocused
->texture
[0].data
.mask
.mask
=
1265 theme
->btn_close
->disabled_mask
;
1266 theme
->btn_close
->a_hover_focused
->texture
[0].data
.mask
.mask
=
1267 theme
->btn_close
->a_hover_unfocused
->texture
[0].data
.mask
.mask
=
1268 theme
->btn_close
->hover_mask
;
1269 theme
->btn_close
->a_focused_pressed
->texture
[0].data
.mask
.mask
=
1270 theme
->btn_close
->a_unfocused_pressed
->texture
[0].data
.mask
.mask
=
1271 theme
->btn_close
->pressed_mask
;
1272 theme
->btn_close
->a_focused_unpressed
->texture
[0].data
.mask
.mask
=
1273 theme
->btn_close
->a_unfocused_unpressed
->texture
[0].data
.mask
.mask
=
1274 theme
->btn_close
->mask
;
1275 theme
->btn_desk
->a_disabled_focused
->texture
[0].data
.mask
.mask
=
1276 theme
->btn_desk
->a_disabled_unfocused
->texture
[0].data
.mask
.mask
=
1277 theme
->btn_desk
->disabled_mask
;
1278 theme
->btn_desk
->a_hover_focused
->texture
[0].data
.mask
.mask
=
1279 theme
->btn_desk
->a_hover_unfocused
->texture
[0].data
.mask
.mask
=
1280 theme
->btn_desk
->hover_mask
;
1281 theme
->btn_desk
->a_focused_pressed
->texture
[0].data
.mask
.mask
=
1282 theme
->btn_desk
->a_unfocused_pressed
->texture
[0].data
.mask
.mask
=
1283 theme
->btn_desk
->pressed_mask
;
1284 theme
->btn_desk
->a_focused_unpressed
->texture
[0].data
.mask
.mask
=
1285 theme
->btn_desk
->a_unfocused_unpressed
->texture
[0].data
.mask
.mask
=
1286 theme
->btn_desk
->mask
;
1287 theme
->btn_desk
->a_toggled_hover_focused
->texture
[0].data
.mask
.mask
=
1288 theme
->btn_desk
->a_toggled_hover_unfocused
->texture
[0].data
.mask
.mask
=
1289 theme
->btn_desk
->toggled_hover_mask
;
1290 theme
->btn_desk
->a_toggled_focused_unpressed
->texture
[0].data
.mask
.mask
=
1291 theme
->btn_desk
->a_toggled_unfocused_unpressed
->texture
[0].data
.mask
.mask
=
1292 theme
->btn_desk
->toggled_mask
;
1293 theme
->btn_desk
->a_toggled_focused_pressed
->texture
[0].data
.mask
.mask
=
1294 theme
->btn_desk
->a_toggled_unfocused_pressed
->texture
[0].data
.mask
.mask
=
1295 theme
->btn_desk
->toggled_pressed_mask
;
1296 theme
->btn_shade
->a_disabled_focused
->texture
[0].data
.mask
.mask
=
1297 theme
->btn_shade
->a_disabled_unfocused
->texture
[0].data
.mask
.mask
=
1298 theme
->btn_shade
->disabled_mask
;
1299 theme
->btn_shade
->a_hover_focused
->texture
[0].data
.mask
.mask
=
1300 theme
->btn_shade
->a_hover_unfocused
->texture
[0].data
.mask
.mask
=
1301 theme
->btn_shade
->hover_mask
;
1302 theme
->btn_shade
->a_focused_pressed
->texture
[0].data
.mask
.mask
=
1303 theme
->btn_shade
->a_unfocused_pressed
->texture
[0].data
.mask
.mask
=
1304 theme
->btn_shade
->pressed_mask
;
1305 theme
->btn_shade
->a_focused_unpressed
->texture
[0].data
.mask
.mask
=
1306 theme
->btn_shade
->a_unfocused_unpressed
->texture
[0].data
.mask
.mask
=
1307 theme
->btn_shade
->mask
;
1308 theme
->btn_shade
->a_toggled_hover_focused
->texture
[0].data
.mask
.mask
=
1309 theme
->btn_shade
->a_toggled_hover_unfocused
->texture
[0].data
.mask
.mask
=
1310 theme
->btn_shade
->toggled_hover_mask
;
1311 theme
->btn_shade
->a_toggled_focused_unpressed
->texture
[0].data
.mask
.mask
=
1312 theme
->btn_shade
->a_toggled_unfocused_unpressed
->texture
[0].data
.mask
.mask
=
1313 theme
->btn_shade
->toggled_mask
;
1314 theme
->btn_shade
->a_toggled_focused_pressed
->texture
[0].data
.mask
.mask
=
1315 theme
->btn_shade
->a_toggled_unfocused_pressed
->texture
[0].data
.mask
.mask
=
1316 theme
->btn_shade
->toggled_pressed_mask
;
1317 theme
->btn_iconify
->a_disabled_focused
->texture
[0].data
.mask
.mask
=
1318 theme
->btn_iconify
->a_disabled_unfocused
->texture
[0].data
.mask
.mask
=
1319 theme
->btn_iconify
->disabled_mask
;
1320 theme
->btn_iconify
->a_hover_focused
->texture
[0].data
.mask
.mask
=
1321 theme
->btn_iconify
->a_hover_unfocused
->texture
[0].data
.mask
.mask
=
1322 theme
->btn_iconify
->hover_mask
;
1323 theme
->btn_iconify
->a_focused_pressed
->texture
[0].data
.mask
.mask
=
1324 theme
->btn_iconify
->a_unfocused_pressed
->texture
[0].data
.mask
.mask
=
1325 theme
->btn_iconify
->pressed_mask
;
1326 theme
->btn_iconify
->a_focused_unpressed
->texture
[0].data
.mask
.mask
=
1327 theme
->btn_iconify
->a_unfocused_unpressed
->texture
[0].data
.mask
.mask
=
1328 theme
->btn_iconify
->mask
;
1329 theme
->a_menu_bullet_normal
->texture
[0].data
.mask
.mask
=
1330 theme
->a_menu_bullet_selected
->texture
[0].data
.mask
.mask
=
1331 theme
->menu_bullet_mask
;
1332 theme
->btn_max
->a_disabled_focused
->texture
[0].data
.mask
.color
=
1333 theme
->btn_close
->a_disabled_focused
->texture
[0].data
.mask
.color
=
1334 theme
->btn_desk
->a_disabled_focused
->texture
[0].data
.mask
.color
=
1335 theme
->btn_shade
->a_disabled_focused
->texture
[0].data
.mask
.color
=
1336 theme
->btn_iconify
->a_disabled_focused
->texture
[0].data
.mask
.color
=
1337 theme
->titlebut_disabled_focused_color
;
1338 theme
->btn_max
->a_disabled_unfocused
->texture
[0].data
.mask
.color
=
1339 theme
->btn_close
->a_disabled_unfocused
->texture
[0].data
.mask
.color
=
1340 theme
->btn_desk
->a_disabled_unfocused
->texture
[0].data
.mask
.color
=
1341 theme
->btn_shade
->a_disabled_unfocused
->texture
[0].data
.mask
.color
=
1342 theme
->btn_iconify
->a_disabled_unfocused
->texture
[0].data
.mask
.color
=
1343 theme
->titlebut_disabled_unfocused_color
;
1344 theme
->btn_max
->a_hover_focused
->texture
[0].data
.mask
.color
=
1345 theme
->btn_close
->a_hover_focused
->texture
[0].data
.mask
.color
=
1346 theme
->btn_desk
->a_hover_focused
->texture
[0].data
.mask
.color
=
1347 theme
->btn_shade
->a_hover_focused
->texture
[0].data
.mask
.color
=
1348 theme
->btn_iconify
->a_hover_focused
->texture
[0].data
.mask
.color
=
1349 theme
->titlebut_hover_focused_color
;
1350 theme
->btn_max
->a_hover_unfocused
->texture
[0].data
.mask
.color
=
1351 theme
->btn_close
->a_hover_unfocused
->texture
[0].data
.mask
.color
=
1352 theme
->btn_desk
->a_hover_unfocused
->texture
[0].data
.mask
.color
=
1353 theme
->btn_shade
->a_hover_unfocused
->texture
[0].data
.mask
.color
=
1354 theme
->btn_iconify
->a_hover_unfocused
->texture
[0].data
.mask
.color
=
1355 theme
->titlebut_hover_unfocused_color
;
1356 theme
->btn_max
->a_toggled_hover_focused
->texture
[0].data
.mask
.color
=
1357 theme
->btn_desk
->a_toggled_hover_focused
->texture
[0].data
.mask
.color
=
1358 theme
->btn_shade
->a_toggled_hover_focused
->texture
[0].data
.mask
.color
=
1359 theme
->titlebut_toggled_hover_focused_color
;
1360 theme
->btn_max
->a_toggled_hover_unfocused
->texture
[0].data
.mask
.color
=
1361 theme
->btn_desk
->a_toggled_hover_unfocused
->texture
[0].data
.mask
.color
=
1362 theme
->btn_shade
->a_toggled_hover_unfocused
->texture
[0].data
.mask
.color
=
1363 theme
->titlebut_toggled_hover_unfocused_color
;
1364 theme
->btn_max
->a_toggled_focused_unpressed
->texture
[0].data
.mask
.color
=
1365 theme
->btn_desk
->a_toggled_focused_unpressed
->texture
[0].data
.mask
.color
=
1366 theme
->btn_shade
->a_toggled_focused_unpressed
->texture
[0].data
.mask
.color
=
1367 theme
->titlebut_toggled_focused_unpressed_color
;
1368 theme
->btn_max
->a_toggled_unfocused_unpressed
->texture
[0].data
.mask
.color
=
1369 theme
->btn_desk
->a_toggled_unfocused_unpressed
->texture
[0].data
.mask
.color
=
1370 theme
->btn_shade
->a_toggled_unfocused_unpressed
->texture
[0].data
.mask
.color
=
1371 theme
->titlebut_toggled_unfocused_unpressed_color
;
1372 theme
->btn_max
->a_toggled_focused_pressed
->texture
[0].data
.mask
.color
=
1373 theme
->btn_desk
->a_toggled_focused_pressed
->texture
[0].data
.mask
.color
=
1374 theme
->btn_shade
->a_toggled_focused_pressed
->texture
[0].data
.mask
.color
=
1375 theme
->titlebut_toggled_focused_pressed_color
;
1376 theme
->btn_max
->a_toggled_unfocused_pressed
->texture
[0].data
.mask
.color
=
1377 theme
->btn_desk
->a_toggled_unfocused_pressed
->texture
[0].data
.mask
.color
=
1378 theme
->btn_shade
->a_toggled_unfocused_pressed
->texture
[0].data
.mask
.color
=
1379 theme
->titlebut_toggled_unfocused_pressed_color
;
1380 theme
->btn_max
->a_focused_unpressed
->texture
[0].data
.mask
.color
=
1381 theme
->btn_close
->a_focused_unpressed
->texture
[0].data
.mask
.color
=
1382 theme
->btn_desk
->a_focused_unpressed
->texture
[0].data
.mask
.color
=
1383 theme
->btn_shade
->a_focused_unpressed
->texture
[0].data
.mask
.color
=
1384 theme
->btn_iconify
->a_focused_unpressed
->texture
[0].data
.mask
.color
=
1385 theme
->titlebut_focused_unpressed_color
;
1386 theme
->btn_max
->a_focused_pressed
->texture
[0].data
.mask
.color
=
1387 theme
->btn_close
->a_focused_pressed
->texture
[0].data
.mask
.color
=
1388 theme
->btn_desk
->a_focused_pressed
->texture
[0].data
.mask
.color
=
1389 theme
->btn_shade
->a_focused_pressed
->texture
[0].data
.mask
.color
=
1390 theme
->btn_iconify
->a_focused_pressed
->texture
[0].data
.mask
.color
=
1391 theme
->titlebut_focused_pressed_color
;
1392 theme
->btn_max
->a_unfocused_unpressed
->texture
[0].data
.mask
.color
=
1393 theme
->btn_close
->a_unfocused_unpressed
->texture
[0].data
.mask
.color
=
1394 theme
->btn_desk
->a_unfocused_unpressed
->texture
[0].data
.mask
.color
=
1395 theme
->btn_shade
->a_unfocused_unpressed
->texture
[0].data
.mask
.color
=
1396 theme
->btn_iconify
->a_unfocused_unpressed
->texture
[0].data
.mask
.color
=
1397 theme
->titlebut_unfocused_unpressed_color
;
1398 theme
->btn_max
->a_unfocused_pressed
->texture
[0].data
.mask
.color
=
1399 theme
->btn_close
->a_unfocused_pressed
->texture
[0].data
.mask
.color
=
1400 theme
->btn_desk
->a_unfocused_pressed
->texture
[0].data
.mask
.color
=
1401 theme
->btn_shade
->a_unfocused_pressed
->texture
[0].data
.mask
.color
=
1402 theme
->btn_iconify
->a_unfocused_pressed
->texture
[0].data
.mask
.color
=
1403 theme
->titlebut_unfocused_pressed_color
;
1404 theme
->a_menu_bullet_normal
->texture
[0].data
.mask
.color
=
1406 theme
->a_menu_bullet_selected
->texture
[0].data
.mask
.color
=
1407 theme
->menu_selected_color
;
1410 XrmDestroyDatabase(db
);
1412 /* set the font heights */
1413 theme
->win_font_height
= RrFontHeight
1414 (theme
->win_font_focused
,
1415 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_y
);
1416 theme
->win_font_height
=
1417 MAX(theme
->win_font_height
,
1419 (theme
->win_font_focused
,
1420 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_y
));
1421 theme
->menu_title_font_height
= RrFontHeight
1422 (theme
->menu_title_font
,
1423 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_offset_y
);
1424 theme
->menu_font_height
= RrFontHeight
1426 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_offset_y
);
1428 /* calculate some last extents */
1430 gint ft
, fb
, fl
, fr
, ut
, ub
, ul
, ur
;
1432 RrMargins(theme
->a_focused_label
, &fl
, &ft
, &fr
, &fb
);
1433 RrMargins(theme
->a_unfocused_label
, &ul
, &ut
, &ur
, &ub
);
1434 theme
->label_height
= theme
->win_font_height
+ MAX(ft
+ fb
, ut
+ ub
);
1435 theme
->label_height
+= theme
->label_height
% 2;
1437 /* this would be nice I think, since padding.width can now be 0,
1438 but it breaks frame.c horribly and I don't feel like fixing that
1439 right now, so if anyone complains, here is how to keep text from
1440 going over the title's bevel/border with a padding.width of 0 and a
1441 bevelless/borderless label
1442 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1443 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1444 theme->title_height = theme->label_height +
1445 MAX(MAX(theme->padding * 2, ft + fb),
1446 MAX(theme->padding * 2, ut + ub));
1448 theme
->title_height
= theme
->label_height
+ theme
->paddingy
* 2;
1450 RrMargins(theme
->a_menu_title
, &ul
, &ut
, &ur
, &ub
);
1451 theme
->menu_title_label_height
= theme
->menu_title_font_height
+ut
+ub
;
1452 theme
->menu_title_height
= theme
->menu_title_label_height
+
1453 theme
->paddingy
* 2;
1455 theme
->button_size
= theme
->label_height
- 2;
1456 theme
->grip_width
= 25;
1458 RrAppearanceFree(a_disabled_focused_tmp
);
1459 RrAppearanceFree(a_disabled_unfocused_tmp
);
1460 RrAppearanceFree(a_hover_focused_tmp
);
1461 RrAppearanceFree(a_hover_unfocused_tmp
);
1462 RrAppearanceFree(a_focused_unpressed_tmp
);
1463 RrAppearanceFree(a_focused_pressed_tmp
);
1464 RrAppearanceFree(a_unfocused_unpressed_tmp
);
1465 RrAppearanceFree(a_unfocused_pressed_tmp
);
1466 RrAppearanceFree(a_toggled_hover_focused_tmp
);
1467 RrAppearanceFree(a_toggled_hover_unfocused_tmp
);
1468 RrAppearanceFree(a_toggled_focused_unpressed_tmp
);
1469 RrAppearanceFree(a_toggled_focused_pressed_tmp
);
1470 RrAppearanceFree(a_toggled_unfocused_unpressed_tmp
);
1471 RrAppearanceFree(a_toggled_unfocused_pressed_tmp
);
1476 void RrThemeFree(RrTheme
*theme
)
1479 g_free(theme
->name
);
1481 RrButtonFree(theme
->btn_max
);
1482 RrButtonFree(theme
->btn_close
);
1483 RrButtonFree(theme
->btn_desk
);
1484 RrButtonFree(theme
->btn_shade
);
1485 RrButtonFree(theme
->btn_iconify
);
1487 RrColorFree(theme
->menu_border_color
);
1488 RrColorFree(theme
->osd_border_color
);
1489 RrColorFree(theme
->frame_focused_border_color
);
1490 RrColorFree(theme
->frame_unfocused_border_color
);
1491 RrColorFree(theme
->title_separator_focused_color
);
1492 RrColorFree(theme
->title_separator_unfocused_color
);
1493 RrColorFree(theme
->cb_unfocused_color
);
1494 RrColorFree(theme
->cb_focused_color
);
1495 RrColorFree(theme
->title_focused_color
);
1496 RrColorFree(theme
->title_unfocused_color
);
1497 RrColorFree(theme
->titlebut_disabled_focused_color
);
1498 RrColorFree(theme
->titlebut_disabled_unfocused_color
);
1499 RrColorFree(theme
->titlebut_hover_focused_color
);
1500 RrColorFree(theme
->titlebut_hover_unfocused_color
);
1501 RrColorFree(theme
->titlebut_toggled_hover_focused_color
);
1502 RrColorFree(theme
->titlebut_toggled_hover_unfocused_color
);
1503 RrColorFree(theme
->titlebut_toggled_focused_pressed_color
);
1504 RrColorFree(theme
->titlebut_toggled_unfocused_pressed_color
);
1505 RrColorFree(theme
->titlebut_toggled_focused_unpressed_color
);
1506 RrColorFree(theme
->titlebut_toggled_unfocused_unpressed_color
);
1507 RrColorFree(theme
->titlebut_focused_pressed_color
);
1508 RrColorFree(theme
->titlebut_unfocused_pressed_color
);
1509 RrColorFree(theme
->titlebut_focused_unpressed_color
);
1510 RrColorFree(theme
->titlebut_unfocused_unpressed_color
);
1511 RrColorFree(theme
->menu_title_color
);
1512 RrColorFree(theme
->menu_sep_color
);
1513 RrColorFree(theme
->menu_color
);
1514 RrColorFree(theme
->menu_selected_color
);
1515 RrColorFree(theme
->menu_disabled_color
);
1516 RrColorFree(theme
->menu_disabled_selected_color
);
1517 RrColorFree(theme
->title_focused_shadow_color
);
1518 RrColorFree(theme
->title_unfocused_shadow_color
);
1519 RrColorFree(theme
->osd_text_active_color
);
1520 RrColorFree(theme
->osd_text_inactive_color
);
1521 RrColorFree(theme
->osd_text_active_shadow_color
);
1522 RrColorFree(theme
->osd_text_inactive_shadow_color
);
1523 RrColorFree(theme
->menu_title_shadow_color
);
1524 RrColorFree(theme
->menu_text_normal_shadow_color
);
1525 RrColorFree(theme
->menu_text_selected_shadow_color
);
1526 RrColorFree(theme
->menu_text_disabled_shadow_color
);
1527 RrColorFree(theme
->menu_text_disabled_selected_shadow_color
);
1529 g_free(theme
->def_win_icon
);
1531 RrPixmapMaskFree(theme
->menu_bullet_mask
);
1532 RrPixmapMaskFree(theme
->down_arrow_mask
);
1533 RrPixmapMaskFree(theme
->up_arrow_mask
);
1535 RrFontClose(theme
->win_font_focused
);
1536 RrFontClose(theme
->win_font_unfocused
);
1537 RrFontClose(theme
->menu_title_font
);
1538 RrFontClose(theme
->menu_font
);
1539 RrFontClose(theme
->osd_font_hilite
);
1540 RrFontClose(theme
->osd_font_unhilite
);
1542 RrAppearanceFree(theme
->a_disabled_focused_max
);
1543 RrAppearanceFree(theme
->a_disabled_unfocused_max
);
1544 RrAppearanceFree(theme
->a_hover_focused_max
);
1545 RrAppearanceFree(theme
->a_hover_unfocused_max
);
1546 RrAppearanceFree(theme
->a_toggled_hover_focused_max
);
1547 RrAppearanceFree(theme
->a_toggled_hover_unfocused_max
);
1548 RrAppearanceFree(theme
->a_toggled_focused_unpressed_max
);
1549 RrAppearanceFree(theme
->a_toggled_focused_pressed_max
);
1550 RrAppearanceFree(theme
->a_toggled_unfocused_unpressed_max
);
1551 RrAppearanceFree(theme
->a_toggled_unfocused_pressed_max
);
1552 RrAppearanceFree(theme
->a_focused_unpressed_max
);
1553 RrAppearanceFree(theme
->a_focused_pressed_max
);
1554 RrAppearanceFree(theme
->a_unfocused_unpressed_max
);
1555 RrAppearanceFree(theme
->a_unfocused_pressed_max
);
1556 RrAppearanceFree(theme
->a_disabled_focused_close
);
1557 RrAppearanceFree(theme
->a_disabled_unfocused_close
);
1558 RrAppearanceFree(theme
->a_hover_focused_close
);
1559 RrAppearanceFree(theme
->a_hover_unfocused_close
);
1560 RrAppearanceFree(theme
->a_focused_unpressed_close
);
1561 RrAppearanceFree(theme
->a_focused_pressed_close
);
1562 RrAppearanceFree(theme
->a_unfocused_unpressed_close
);
1563 RrAppearanceFree(theme
->a_unfocused_pressed_close
);
1564 RrAppearanceFree(theme
->a_disabled_focused_desk
);
1565 RrAppearanceFree(theme
->a_disabled_unfocused_desk
);
1566 RrAppearanceFree(theme
->a_hover_focused_desk
);
1567 RrAppearanceFree(theme
->a_hover_unfocused_desk
);
1568 RrAppearanceFree(theme
->a_toggled_hover_focused_desk
);
1569 RrAppearanceFree(theme
->a_toggled_hover_unfocused_desk
);
1570 RrAppearanceFree(theme
->a_toggled_focused_unpressed_desk
);
1571 RrAppearanceFree(theme
->a_toggled_focused_pressed_desk
);
1572 RrAppearanceFree(theme
->a_toggled_unfocused_unpressed_desk
);
1573 RrAppearanceFree(theme
->a_toggled_unfocused_pressed_desk
);
1574 RrAppearanceFree(theme
->a_focused_unpressed_desk
);
1575 RrAppearanceFree(theme
->a_focused_pressed_desk
);
1576 RrAppearanceFree(theme
->a_unfocused_unpressed_desk
);
1577 RrAppearanceFree(theme
->a_unfocused_pressed_desk
);
1578 RrAppearanceFree(theme
->a_disabled_focused_shade
);
1579 RrAppearanceFree(theme
->a_disabled_unfocused_shade
);
1580 RrAppearanceFree(theme
->a_hover_focused_shade
);
1581 RrAppearanceFree(theme
->a_hover_unfocused_shade
);
1582 RrAppearanceFree(theme
->a_toggled_hover_focused_shade
);
1583 RrAppearanceFree(theme
->a_toggled_hover_unfocused_shade
);
1584 RrAppearanceFree(theme
->a_toggled_focused_unpressed_shade
);
1585 RrAppearanceFree(theme
->a_toggled_focused_pressed_shade
);
1586 RrAppearanceFree(theme
->a_toggled_unfocused_unpressed_shade
);
1587 RrAppearanceFree(theme
->a_toggled_unfocused_pressed_shade
);
1588 RrAppearanceFree(theme
->a_focused_unpressed_shade
);
1589 RrAppearanceFree(theme
->a_focused_pressed_shade
);
1590 RrAppearanceFree(theme
->a_unfocused_unpressed_shade
);
1591 RrAppearanceFree(theme
->a_unfocused_pressed_shade
);
1592 RrAppearanceFree(theme
->a_disabled_focused_iconify
);
1593 RrAppearanceFree(theme
->a_disabled_unfocused_iconify
);
1594 RrAppearanceFree(theme
->a_hover_focused_iconify
);
1595 RrAppearanceFree(theme
->a_hover_unfocused_iconify
);
1596 RrAppearanceFree(theme
->a_focused_unpressed_iconify
);
1597 RrAppearanceFree(theme
->a_focused_pressed_iconify
);
1598 RrAppearanceFree(theme
->a_unfocused_unpressed_iconify
);
1599 RrAppearanceFree(theme
->a_unfocused_pressed_iconify
);
1600 RrAppearanceFree(theme
->a_focused_grip
);
1601 RrAppearanceFree(theme
->a_unfocused_grip
);
1602 RrAppearanceFree(theme
->a_focused_title
);
1603 RrAppearanceFree(theme
->a_unfocused_title
);
1604 RrAppearanceFree(theme
->a_focused_label
);
1605 RrAppearanceFree(theme
->a_unfocused_label
);
1606 RrAppearanceFree(theme
->a_icon
);
1607 RrAppearanceFree(theme
->a_focused_handle
);
1608 RrAppearanceFree(theme
->a_unfocused_handle
);
1609 RrAppearanceFree(theme
->a_menu
);
1610 RrAppearanceFree(theme
->a_menu_title
);
1611 RrAppearanceFree(theme
->a_menu_text_title
);
1612 RrAppearanceFree(theme
->a_menu_normal
);
1613 RrAppearanceFree(theme
->a_menu_selected
);
1614 RrAppearanceFree(theme
->a_menu_disabled
);
1615 RrAppearanceFree(theme
->a_menu_disabled_selected
);
1616 RrAppearanceFree(theme
->a_menu_text_normal
);
1617 RrAppearanceFree(theme
->a_menu_text_selected
);
1618 RrAppearanceFree(theme
->a_menu_text_disabled
);
1619 RrAppearanceFree(theme
->a_menu_text_disabled_selected
);
1620 RrAppearanceFree(theme
->a_menu_bullet_normal
);
1621 RrAppearanceFree(theme
->a_menu_bullet_selected
);
1622 RrAppearanceFree(theme
->a_clear
);
1623 RrAppearanceFree(theme
->a_clear_tex
);
1624 RrAppearanceFree(theme
->osd_bg
);
1625 RrAppearanceFree(theme
->osd_hilite_bg
);
1626 RrAppearanceFree(theme
->osd_hilite_label
);
1627 RrAppearanceFree(theme
->osd_unhilite_bg
);
1628 RrAppearanceFree(theme
->osd_unhilite_label
);
1630 g_slice_free(RrTheme
, theme
);
1634 static XrmDatabase
loaddb(const gchar
*name
, gchar
**path
)
1637 XrmDatabase db
= NULL
;
1640 if (name
[0] == '/') {
1641 s
= g_build_filename(name
, "openbox-3", "themerc", NULL
);
1642 if ((db
= XrmGetFileDatabase(s
)))
1643 *path
= g_path_get_dirname(s
);
1648 p
= obt_paths_new();
1650 /* XXX backwards compatibility, remove me sometime later */
1651 s
= g_build_filename(g_get_home_dir(), ".themes", name
,
1652 "openbox-3", "themerc", NULL
);
1653 if ((db
= XrmGetFileDatabase(s
)))
1654 *path
= g_path_get_dirname(s
);
1657 for (it
= obt_paths_data_dirs(p
); !db
&& it
; it
= g_slist_next(it
))
1659 s
= g_build_filename(it
->data
, "themes", name
,
1660 "openbox-3", "themerc", NULL
);
1661 if ((db
= XrmGetFileDatabase(s
)))
1662 *path
= g_path_get_dirname(s
);
1670 s
= g_build_filename(name
, "themerc", NULL
);
1671 if ((db
= XrmGetFileDatabase(s
)))
1672 *path
= g_path_get_dirname(s
);
1679 static gchar
*create_class_name(const gchar
*rname
)
1681 gchar
*rclass
= g_strdup(rname
);
1686 p
= strchr(p
+1, '.');
1687 if (p
== NULL
) break;
1689 if (*p
== '\0') break;
1694 static gboolean
read_int(XrmDatabase db
, const gchar
*rname
, gint
*value
)
1696 gboolean ret
= FALSE
;
1697 gchar
*rclass
= create_class_name(rname
);
1698 gchar
*rettype
, *end
;
1701 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1702 retvalue
.addr
!= NULL
) {
1703 *value
= (gint
)strtol(retvalue
.addr
, &end
, 10);
1704 if (end
!= retvalue
.addr
)
1712 static gboolean
read_string(XrmDatabase db
, const gchar
*rname
, gchar
**value
)
1714 gboolean ret
= FALSE
;
1715 gchar
*rclass
= create_class_name(rname
);
1719 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1720 retvalue
.addr
!= NULL
) {
1721 *value
= retvalue
.addr
;
1729 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
1730 const gchar
*rname
, RrColor
**value
)
1732 gboolean ret
= FALSE
;
1733 gchar
*rclass
= create_class_name(rname
);
1737 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1738 retvalue
.addr
!= NULL
) {
1739 RrColor
*c
= RrColorParse(inst
, retvalue
.addr
);
1750 static gboolean
read_mask(const RrInstance
*inst
, const gchar
*path
,
1751 RrTheme
*theme
, const gchar
*maskname
,
1752 RrPixmapMask
**value
)
1754 gboolean ret
= FALSE
;
1756 gint hx
, hy
; /* ignored */
1760 s
= g_build_filename(path
, maskname
, NULL
);
1761 if (XReadBitmapFileData(s
, &w
, &h
, &b
, &hx
, &hy
) == BitmapSuccess
) {
1763 *value
= RrPixmapMaskNew(inst
, w
, h
, (gchar
*)b
);
1771 static void parse_appearance(gchar
*tex
, RrSurfaceColorType
*grad
,
1772 RrReliefType
*relief
, RrBevelType
*bevel
,
1773 gboolean
*interlaced
, gboolean
*border
,
1774 gboolean allow_trans
)
1778 /* convert to all lowercase */
1779 for (t
= tex
; *t
!= '\0'; ++t
)
1780 *t
= g_ascii_tolower(*t
);
1782 if (allow_trans
&& strstr(tex
, "parentrelative") != NULL
) {
1783 *grad
= RR_SURFACE_PARENTREL
;
1785 if (strstr(tex
, "gradient") != NULL
) {
1786 if (strstr(tex
, "crossdiagonal") != NULL
)
1787 *grad
= RR_SURFACE_CROSS_DIAGONAL
;
1788 else if (strstr(tex
, "pyramid") != NULL
)
1789 *grad
= RR_SURFACE_PYRAMID
;
1790 else if (strstr(tex
, "mirrorhorizontal") != NULL
)
1791 *grad
= RR_SURFACE_MIRROR_HORIZONTAL
;
1792 else if (strstr(tex
, "horizontal") != NULL
)
1793 *grad
= RR_SURFACE_HORIZONTAL
;
1794 else if (strstr(tex
, "splitvertical") != NULL
)
1795 *grad
= RR_SURFACE_SPLIT_VERTICAL
;
1796 else if (strstr(tex
, "vertical") != NULL
)
1797 *grad
= RR_SURFACE_VERTICAL
;
1799 *grad
= RR_SURFACE_DIAGONAL
;
1801 *grad
= RR_SURFACE_SOLID
;
1805 if (strstr(tex
, "sunken") != NULL
)
1806 *relief
= RR_RELIEF_SUNKEN
;
1807 else if (strstr(tex
, "flat") != NULL
)
1808 *relief
= RR_RELIEF_FLAT
;
1809 else if (strstr(tex
, "raised") != NULL
)
1810 *relief
= RR_RELIEF_RAISED
;
1812 *relief
= (*grad
== RR_SURFACE_PARENTREL
) ?
1813 RR_RELIEF_FLAT
: RR_RELIEF_RAISED
;
1816 if (*relief
== RR_RELIEF_FLAT
) {
1817 if (strstr(tex
, "border") != NULL
)
1820 if (strstr(tex
, "bevel2") != NULL
)
1821 *bevel
= RR_BEVEL_2
;
1823 *bevel
= RR_BEVEL_1
;
1826 if (strstr(tex
, "interlaced") != NULL
)
1829 *interlaced
= FALSE
;
1832 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
1833 const gchar
*rname
, RrAppearance
*value
,
1834 gboolean allow_trans
)
1836 gboolean ret
= FALSE
;
1837 gchar
*rclass
= create_class_name(rname
);
1838 gchar
*cname
, *ctoname
, *bcname
, *icname
, *hname
, *sname
;
1839 gchar
*csplitname
, *ctosplitname
;
1844 cname
= g_strconcat(rname
, ".color", NULL
);
1845 ctoname
= g_strconcat(rname
, ".colorTo", NULL
);
1846 bcname
= g_strconcat(rname
, ".border.color", NULL
);
1847 icname
= g_strconcat(rname
, ".interlace.color", NULL
);
1848 hname
= g_strconcat(rname
, ".highlight", NULL
);
1849 sname
= g_strconcat(rname
, ".shadow", NULL
);
1850 csplitname
= g_strconcat(rname
, ".color.splitTo", NULL
);
1851 ctosplitname
= g_strconcat(rname
, ".colorTo.splitTo", NULL
);
1853 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1854 retvalue
.addr
!= NULL
) {
1855 parse_appearance(retvalue
.addr
,
1856 &value
->surface
.grad
,
1857 &value
->surface
.relief
,
1858 &value
->surface
.bevel
,
1859 &value
->surface
.interlaced
,
1860 &value
->surface
.border
,
1862 if (!read_color(db
, inst
, cname
, &value
->surface
.primary
))
1863 value
->surface
.primary
= RrColorNew(inst
, 0, 0, 0);
1864 if (!read_color(db
, inst
, ctoname
, &value
->surface
.secondary
))
1865 value
->surface
.secondary
= RrColorNew(inst
, 0, 0, 0);
1866 if (value
->surface
.border
)
1867 if (!read_color(db
, inst
, bcname
,
1868 &value
->surface
.border_color
))
1869 value
->surface
.border_color
= RrColorNew(inst
, 0, 0, 0);
1870 if (value
->surface
.interlaced
)
1871 if (!read_color(db
, inst
, icname
,
1872 &value
->surface
.interlace_color
))
1873 value
->surface
.interlace_color
= RrColorNew(inst
, 0, 0, 0);
1874 if (read_int(db
, hname
, &i
) && i
>= 0)
1875 value
->surface
.bevel_light_adjust
= i
;
1876 if (read_int(db
, sname
, &i
) && i
>= 0 && i
<= 256)
1877 value
->surface
.bevel_dark_adjust
= i
;
1879 if (value
->surface
.grad
== RR_SURFACE_SPLIT_VERTICAL
) {
1882 if (!read_color(db
, inst
, csplitname
,
1883 &value
->surface
.split_primary
))
1885 r
= value
->surface
.primary
->r
;
1887 g
= value
->surface
.primary
->g
;
1889 b
= value
->surface
.primary
->b
;
1891 if (r
> 0xFF) r
= 0xFF;
1892 if (g
> 0xFF) g
= 0xFF;
1893 if (b
> 0xFF) b
= 0xFF;
1894 value
->surface
.split_primary
= RrColorNew(inst
, r
, g
, b
);
1897 if (!read_color(db
, inst
, ctosplitname
,
1898 &value
->surface
.split_secondary
))
1900 r
= value
->surface
.secondary
->r
;
1902 g
= value
->surface
.secondary
->g
;
1904 b
= value
->surface
.secondary
->b
;
1906 if (r
> 0xFF) r
= 0xFF;
1907 if (g
> 0xFF) g
= 0xFF;
1908 if (b
> 0xFF) b
= 0xFF;
1909 value
->surface
.split_secondary
= RrColorNew(inst
, r
, g
, b
);
1916 g_free(ctosplitname
);
1928 static int parse_inline_number(const char *p
)
1936 for (; isdigit(*p
); ++p
)
1937 res
= res
* 10 + *p
- '0';
1942 static void set_default_appearance(RrAppearance
*a
)
1944 a
->surface
.grad
= RR_SURFACE_SOLID
;
1945 a
->surface
.relief
= RR_RELIEF_FLAT
;
1946 a
->surface
.bevel
= RR_BEVEL_1
;
1947 a
->surface
.interlaced
= FALSE
;
1948 a
->surface
.border
= FALSE
;
1949 a
->surface
.primary
= RrColorNew(a
->inst
, 0, 0, 0);
1950 a
->surface
.secondary
= RrColorNew(a
->inst
, 0, 0, 0);
1953 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1954 an RrTextureRGBA. */
1955 static RrPixel32
* read_c_image(gint width
, gint height
, const guint8
*data
)
1960 p
= im
= g_memdup(data
, width
* height
* sizeof(RrPixel32
));
1962 for (i
= 0; i
< width
* height
; ++i
) {
1963 guchar a
= ((*p
>> 24) & 0xff);
1964 guchar b
= ((*p
>> 16) & 0xff);
1965 guchar g
= ((*p
>> 8) & 0xff);
1966 guchar r
= ((*p
>> 0) & 0xff);
1968 *p
= ((r
<< RrDefaultRedOffset
) +
1969 (g
<< RrDefaultGreenOffset
) +
1970 (b
<< RrDefaultBlueOffset
) +
1971 (a
<< RrDefaultAlphaOffset
));