]> Dogcows Code - chaz/openbox/blob - render/theme.c
b1b15ff249c08496890332e885014c556cb6e172
[chaz/openbox] / render / theme.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 theme.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
6
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.
11
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.
16
17 See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #include "render.h"
21 #include "color.h"
22 #include "font.h"
23 #include "mask.h"
24 #include "theme.h"
25 #include "icon.h"
26 #include "parser/parse.h"
27
28 #include <X11/Xlib.h>
29 #include <X11/Xresource.h>
30 #include <ctype.h>
31 #include <stdlib.h>
32 #include <string.h>
33
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);
48
49 RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
50 gboolean allow_fallback,
51 RrFont *active_window_font, RrFont *inactive_window_font,
52 RrFont *menu_title_font, RrFont *menu_item_font,
53 RrFont *osd_font)
54 {
55 XrmDatabase db = NULL;
56 RrJustify winjust, mtitlejust;
57 gchar *str;
58 RrTheme *theme;
59 gchar *path;
60 gboolean userdef;
61
62 if (name) {
63 db = loaddb(name, &path);
64 if (db == NULL) {
65 g_message("Unable to load the theme '%s'", name);
66 if (allow_fallback)
67 g_message("Falling back to the default theme '%s'",
68 DEFAULT_THEME);
69 /* fallback to the default theme */
70 name = NULL;
71 }
72 }
73 if (name == NULL) {
74 if (allow_fallback) {
75 db = loaddb(DEFAULT_THEME, &path);
76 if (db == NULL) {
77 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
78 return NULL;
79 }
80 } else
81 return NULL;
82 }
83
84 theme = g_new0(RrTheme, 1);
85
86 theme->inst = inst;
87 theme->name = g_strdup(name ? name : DEFAULT_THEME);
88
89 theme->a_disabled_focused_max = RrAppearanceNew(inst, 1);
90 theme->a_disabled_unfocused_max = RrAppearanceNew(inst, 1);
91 theme->a_hover_focused_max = RrAppearanceNew(inst, 1);
92 theme->a_hover_unfocused_max = RrAppearanceNew(inst, 1);
93 theme->a_toggled_focused_unpressed_max = RrAppearanceNew(inst, 1);
94 theme->a_toggled_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
95 theme->a_toggled_hover_focused_max = RrAppearanceNew(inst, 1);
96 theme->a_toggled_hover_unfocused_max = RrAppearanceNew(inst, 1);
97 theme->a_toggled_focused_pressed_max = RrAppearanceNew(inst, 1);
98 theme->a_toggled_unfocused_pressed_max = RrAppearanceNew(inst, 1);
99 theme->a_focused_unpressed_max = RrAppearanceNew(inst, 1);
100 theme->a_focused_pressed_max = RrAppearanceNew(inst, 1);
101 theme->a_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
102 theme->a_unfocused_pressed_max = RrAppearanceNew(inst, 1);
103 theme->a_focused_grip = RrAppearanceNew(inst, 0);
104 theme->a_unfocused_grip = RrAppearanceNew(inst, 0);
105 theme->a_focused_title = RrAppearanceNew(inst, 0);
106 theme->a_unfocused_title = RrAppearanceNew(inst, 0);
107 theme->a_focused_label = RrAppearanceNew(inst, 1);
108 theme->a_unfocused_label = RrAppearanceNew(inst, 1);
109 theme->a_icon = RrAppearanceNew(inst, 1);
110 theme->a_focused_handle = RrAppearanceNew(inst, 0);
111 theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
112 theme->a_menu = RrAppearanceNew(inst, 0);
113 theme->a_menu_title = RrAppearanceNew(inst, 0);
114 theme->a_menu_text_title = RrAppearanceNew(inst, 1);
115 theme->a_menu_normal = RrAppearanceNew(inst, 0);
116 theme->a_menu_selected = RrAppearanceNew(inst, 0);
117 theme->a_menu_disabled = RrAppearanceNew(inst, 0);
118 /* a_menu_disabled_selected is copied from a_menu_selected */
119 theme->a_menu_text_normal = RrAppearanceNew(inst, 1);
120 theme->a_menu_text_selected = RrAppearanceNew(inst, 1);
121 theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
122 theme->a_menu_text_disabled_selected = RrAppearanceNew(inst, 1);
123 theme->a_menu_bullet_normal = RrAppearanceNew(inst, 1);
124 theme->a_menu_bullet_selected = RrAppearanceNew(inst, 1);
125 theme->a_clear = RrAppearanceNew(inst, 0);
126 theme->a_clear_tex = RrAppearanceNew(inst, 1);
127 theme->osd_hilite_bg = RrAppearanceNew(inst, 0);
128 theme->osd_hilite_label = RrAppearanceNew(inst, 1);
129 theme->osd_hilite_fg = RrAppearanceNew(inst, 0);
130 theme->osd_unhilite_fg = RrAppearanceNew(inst, 0);
131
132 /* load the font stuff */
133 if (active_window_font) {
134 theme->win_font_focused = active_window_font;
135 RrFontRef(active_window_font);
136 } else
137 theme->win_font_focused = RrFontOpenDefault(inst);
138
139 if (inactive_window_font) {
140 theme->win_font_unfocused = inactive_window_font;
141 RrFontRef(inactive_window_font);
142 } else
143 theme->win_font_unfocused = RrFontOpenDefault(inst);
144
145 winjust = RR_JUSTIFY_LEFT;
146 if (read_string(db, "window.label.text.justify", &str)) {
147 if (!g_ascii_strcasecmp(str, "right"))
148 winjust = RR_JUSTIFY_RIGHT;
149 else if (!g_ascii_strcasecmp(str, "center"))
150 winjust = RR_JUSTIFY_CENTER;
151 }
152
153 if (menu_title_font) {
154 theme->menu_title_font = menu_title_font;
155 RrFontRef(menu_title_font);
156 } else
157 theme->menu_title_font = RrFontOpenDefault(inst);
158
159 mtitlejust = RR_JUSTIFY_LEFT;
160 if (read_string(db, "menu.title.text.justify", &str)) {
161 if (!g_ascii_strcasecmp(str, "right"))
162 mtitlejust = RR_JUSTIFY_RIGHT;
163 else if (!g_ascii_strcasecmp(str, "center"))
164 mtitlejust = RR_JUSTIFY_CENTER;
165 }
166
167 if (menu_item_font) {
168 theme->menu_font = menu_item_font;
169 RrFontRef(menu_item_font);
170 } else
171 theme->menu_font = RrFontOpenDefault(inst);
172
173 if (osd_font) {
174 theme->osd_font = osd_font;
175 RrFontRef(osd_font);
176 } else
177 theme->osd_font = RrFontOpenDefault(inst);
178
179 /* load direct dimensions */
180 if ((!read_int(db, "menu.overlap.x", &theme->menu_overlap_x) &&
181 !read_int(db, "menu.overlap", &theme->menu_overlap_x)) ||
182 theme->menu_overlap_x < -100 || theme->menu_overlap_x > 100)
183 theme->menu_overlap_x = 0;
184 if ((!read_int(db, "menu.overlap.y", &theme->menu_overlap_y) &&
185 !read_int(db, "menu.overlap", &theme->menu_overlap_y)) ||
186 theme->menu_overlap_y < -100 || theme->menu_overlap_y > 100)
187 theme->menu_overlap_y = 0;
188 if (!read_int(db, "window.handle.width", &theme->handle_height) ||
189 theme->handle_height < 0 || theme->handle_height > 100)
190 theme->handle_height = 6;
191 if (!read_int(db, "padding.width", &theme->paddingx) ||
192 theme->paddingx < 0 || theme->paddingx > 100)
193 theme->paddingx = 3;
194 if (!read_int(db, "padding.height", &theme->paddingy) ||
195 theme->paddingy < 0 || theme->paddingy > 100)
196 theme->paddingy = theme->paddingx;
197 if (!read_int(db, "border.width", &theme->fbwidth) ||
198 theme->fbwidth < 0 || theme->fbwidth > 100)
199 theme->fbwidth = 1;
200 /* menu border width inherits from the frame border width */
201 if (!read_int(db, "menu.border.width", &theme->mbwidth) ||
202 theme->mbwidth < 0 || theme->mbwidth > 100)
203 theme->mbwidth = theme->fbwidth;
204 /* osd border width inherits from the frame border width */
205 if (!read_int(db, "osd.border.width", &theme->obwidth) ||
206 theme->obwidth < 0 || theme->obwidth > 100)
207 theme->obwidth = theme->fbwidth;
208 if (!read_int(db, "window.client.padding.width", &theme->cbwidthx) ||
209 theme->cbwidthx < 0 || theme->cbwidthx > 100)
210 theme->cbwidthx = theme->paddingx;
211 if (!read_int(db, "window.client.padding.height", &theme->cbwidthy) ||
212 theme->cbwidthy < 0 || theme->cbwidthy > 100)
213 theme->cbwidthy = theme->cbwidthx;
214
215 /* load colors */
216 if (!read_color(db, inst,
217 "window.active.border.color",
218 &theme->frame_focused_border_color) &&
219 !read_color(db, inst,
220 "border.color",
221 &theme->frame_focused_border_color))
222 theme->frame_focused_border_color = RrColorNew(inst, 0, 0, 0);
223 /* title separator focused color inherits from focused boder color */
224 if (!read_color(db, inst,
225 "window.active.title.separator.color",
226 &theme->title_separator_focused_color))
227 theme->title_separator_focused_color =
228 RrColorNew(inst,
229 theme->frame_focused_border_color->r,
230 theme->frame_focused_border_color->g,
231 theme->frame_focused_border_color->b);
232 /* unfocused border color inherits from frame focused border color */
233 if (!read_color(db, inst,
234 "window.inactive.border.color",
235 &theme->frame_unfocused_border_color))
236 theme->frame_unfocused_border_color =
237 RrColorNew(inst, theme->frame_focused_border_color->r,
238 theme->frame_focused_border_color->g,
239 theme->frame_focused_border_color->b);
240 /* title separator unfocused color inherits from unfocused boder color */
241 if (!read_color(db, inst,
242 "window.inactive.title.separator.color",
243 &theme->title_separator_unfocused_color))
244 theme->title_separator_unfocused_color =
245 RrColorNew(inst,
246 theme->frame_unfocused_border_color->r,
247 theme->frame_unfocused_border_color->g,
248 theme->frame_unfocused_border_color->b);
249
250 /* menu border color inherits from frame focused border color */
251 if (!read_color(db, inst, "menu.border.color", &theme->menu_border_color))
252 theme->menu_border_color =
253 RrColorNew(inst,
254 theme->frame_focused_border_color->r,
255 theme->frame_focused_border_color->g,
256 theme->frame_focused_border_color->b);
257 /* osd border color inherits from frame focused border color */
258 if (!read_color(db, inst, "osd.border.color", &theme->osd_border_color))
259 theme->osd_border_color =
260 RrColorNew(inst,
261 theme->frame_focused_border_color->r,
262 theme->frame_focused_border_color->g,
263 theme->frame_focused_border_color->b);
264 if (!read_color(db, inst,
265 "window.active.client.color",
266 &theme->cb_focused_color))
267 theme->cb_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
268 if (!read_color(db, inst,
269 "window.inactive.client.color",
270 &theme->cb_unfocused_color))
271 theme->cb_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
272 if (!read_color(db, inst,
273 "window.active.label.text.color",
274 &theme->title_focused_color))
275 theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0);
276 if (!read_color(db, inst, "osd.label.text.color", &theme->osd_color))
277 theme->osd_color = RrColorNew(inst,
278 theme->title_focused_color->r,
279 theme->title_focused_color->g,
280 theme->title_focused_color->b);
281 if (!read_color(db, inst,
282 "window.inactive.label.text.color",
283 &theme->title_unfocused_color))
284 theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
285 if (!read_color(db, inst,
286 "window.active.button.unpressed.image.color",
287 &theme->titlebut_focused_unpressed_color))
288 theme->titlebut_focused_unpressed_color = RrColorNew(inst, 0, 0, 0);
289 if (!read_color(db, inst,
290 "window.inactive.button.unpressed.image.color",
291 &theme->titlebut_unfocused_unpressed_color))
292 theme->titlebut_unfocused_unpressed_color =
293 RrColorNew(inst, 0xff, 0xff, 0xff);
294 if (!read_color(db, inst,
295 "window.active.button.pressed.image.color",
296 &theme->titlebut_focused_pressed_color))
297 theme->titlebut_focused_pressed_color =
298 RrColorNew(inst,
299 theme->titlebut_focused_unpressed_color->r,
300 theme->titlebut_focused_unpressed_color->g,
301 theme->titlebut_focused_unpressed_color->b);
302 if (!read_color(db, inst,
303 "window.inactive.button.pressed.image.color",
304 &theme->titlebut_unfocused_pressed_color))
305 theme->titlebut_unfocused_pressed_color =
306 RrColorNew(inst,
307 theme->titlebut_unfocused_unpressed_color->r,
308 theme->titlebut_unfocused_unpressed_color->g,
309 theme->titlebut_unfocused_unpressed_color->b);
310 if (!read_color(db, inst,
311 "window.active.button.disabled.image.color",
312 &theme->titlebut_disabled_focused_color))
313 theme->titlebut_disabled_focused_color =
314 RrColorNew(inst, 0xff, 0xff, 0xff);
315 if (!read_color(db, inst,
316 "window.inactive.button.disabled.image.color",
317 &theme->titlebut_disabled_unfocused_color))
318 theme->titlebut_disabled_unfocused_color = RrColorNew(inst, 0, 0, 0);
319 if (!read_color(db, inst,
320 "window.active.button.hover.image.color",
321 &theme->titlebut_hover_focused_color))
322 theme->titlebut_hover_focused_color =
323 RrColorNew(inst,
324 theme->titlebut_focused_unpressed_color->r,
325 theme->titlebut_focused_unpressed_color->g,
326 theme->titlebut_focused_unpressed_color->b);
327 if (!read_color(db, inst,
328 "window.inactive.button.hover.image.color",
329 &theme->titlebut_hover_unfocused_color))
330 theme->titlebut_hover_unfocused_color =
331 RrColorNew(inst,
332 theme->titlebut_unfocused_unpressed_color->r,
333 theme->titlebut_unfocused_unpressed_color->g,
334 theme->titlebut_unfocused_unpressed_color->b);
335 if (!read_color(db, inst,
336 "window.active.button.toggled.unpressed.image.color",
337 &theme->titlebut_toggled_focused_unpressed_color) &&
338 !read_color(db, inst,
339 "window.active.button.toggled.image.color",
340 &theme->titlebut_toggled_focused_unpressed_color))
341 theme->titlebut_toggled_focused_unpressed_color =
342 RrColorNew(inst,
343 theme->titlebut_focused_pressed_color->r,
344 theme->titlebut_focused_pressed_color->g,
345 theme->titlebut_focused_pressed_color->b);
346 if (!read_color(db, inst,
347 "window.inactive.button.toggled.unpressed.image.color",
348 &theme->titlebut_toggled_unfocused_unpressed_color) &&
349 !read_color(db, inst,
350 "window.inactive.button.toggled.image.color",
351 &theme->titlebut_toggled_unfocused_unpressed_color))
352 theme->titlebut_toggled_unfocused_unpressed_color =
353 RrColorNew(inst,
354 theme->titlebut_unfocused_pressed_color->r,
355 theme->titlebut_unfocused_pressed_color->g,
356 theme->titlebut_unfocused_pressed_color->b);
357 if (!read_color(db, inst,
358 "window.active.button.toggled.hover.image.color",
359 &theme->titlebut_toggled_hover_focused_color))
360 theme->titlebut_toggled_hover_focused_color =
361 RrColorNew(inst,
362 theme->titlebut_toggled_focused_unpressed_color->r,
363 theme->titlebut_toggled_focused_unpressed_color->g,
364 theme->titlebut_toggled_focused_unpressed_color->b);
365 if (!read_color(db, inst,
366 "window.inactive.button.toggled.hover.image.color",
367 &theme->titlebut_toggled_hover_unfocused_color))
368 theme->titlebut_toggled_hover_unfocused_color =
369 RrColorNew(inst,
370 theme->titlebut_toggled_unfocused_unpressed_color->r,
371 theme->titlebut_toggled_unfocused_unpressed_color->g,
372 theme->titlebut_toggled_unfocused_unpressed_color->b);
373 if (!read_color(db, inst,
374 "window.active.button.toggled.pressed.image.color",
375 &theme->titlebut_toggled_focused_pressed_color))
376 theme->titlebut_toggled_focused_pressed_color =
377 RrColorNew(inst,
378 theme->titlebut_focused_pressed_color->r,
379 theme->titlebut_focused_pressed_color->g,
380 theme->titlebut_focused_pressed_color->b);
381 if (!read_color(db, inst,
382 "window.inactive.button.toggled.pressed.image.color",
383 &theme->titlebut_toggled_unfocused_pressed_color))
384 theme->titlebut_toggled_unfocused_pressed_color =
385 RrColorNew(inst,
386 theme->titlebut_unfocused_pressed_color->r,
387 theme->titlebut_unfocused_pressed_color->g,
388 theme->titlebut_unfocused_pressed_color->b);
389 if (!read_color(db, inst,
390 "menu.title.text.color", &theme->menu_title_color))
391 theme->menu_title_color = RrColorNew(inst, 0, 0, 0);
392 if (!read_color(db, inst,
393 "menu.items.text.color", &theme->menu_color))
394 theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff);
395 if (!read_color(db, inst,
396 "menu.items.disabled.text.color",
397 &theme->menu_disabled_color))
398 theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0);
399 if (!read_color(db, inst,
400 "menu.items.active.disabled.text.color",
401 &theme->menu_disabled_selected_color))
402 theme->menu_disabled_selected_color =
403 RrColorNew(inst,
404 theme->menu_disabled_color->r,
405 theme->menu_disabled_color->g,
406 theme->menu_disabled_color->b);
407 if (!read_color(db, inst,
408 "menu.items.active.text.color",
409 &theme->menu_selected_color))
410 theme->menu_selected_color = RrColorNew(inst, 0, 0, 0);
411
412 /* load the image masks */
413
414 /* maximize button masks */
415 userdef = TRUE;
416 if (!read_mask(inst, path, theme, "max.xbm", &theme->max_mask)) {
417 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
418 theme->max_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
419 userdef = FALSE;
420 }
421 if (!read_mask(inst, path, theme, "max_toggled.xbm",
422 &theme->max_toggled_mask))
423 {
424 if (userdef)
425 theme->max_toggled_mask = RrPixmapMaskCopy(theme->max_mask);
426 else {
427 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
428 theme->max_toggled_mask = RrPixmapMaskNew(inst, 6, 6,(gchar*)data);
429 }
430 }
431 if (!read_mask(inst, path, theme, "max_pressed.xbm",
432 &theme->max_pressed_mask))
433 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
434 if (!read_mask(inst,path,theme,"max_disabled.xbm",
435 &theme->max_disabled_mask))
436 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
437 if (!read_mask(inst, path, theme, "max_hover.xbm", &theme->max_hover_mask))
438 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
439 if (!read_mask(inst, path, theme, "max_toggled_pressed.xbm",
440 &theme->max_toggled_pressed_mask))
441 theme->max_toggled_pressed_mask =
442 RrPixmapMaskCopy(theme->max_toggled_mask);
443 if (!read_mask(inst, path, theme, "max_toggled_hover.xbm",
444 &theme->max_toggled_hover_mask))
445 theme->max_toggled_hover_mask =
446 RrPixmapMaskCopy(theme->max_toggled_mask);
447
448 /* iconify button masks */
449 if (!read_mask(inst, path, theme, "iconify.xbm", &theme->iconify_mask)) {
450 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
451 theme->iconify_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
452 }
453 if (!read_mask(inst, path, theme, "iconify_pressed.xbm",
454 &theme->iconify_pressed_mask))
455 theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
456 if (!read_mask(inst, path, theme, "iconify_disabled.xbm",
457 &theme->iconify_disabled_mask))
458 theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
459 if (!read_mask(inst, path, theme, "iconify_hover.xbm",
460 &theme->iconify_hover_mask))
461 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
462
463 /* all desktops button masks */
464 userdef = TRUE;
465 if (!read_mask(inst, path, theme, "desk.xbm", &theme->desk_mask)) {
466 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
467 theme->desk_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
468 userdef = FALSE;
469 }
470 if (!read_mask(inst, path, theme, "desk_toggled.xbm",
471 &theme->desk_toggled_mask)) {
472 if (userdef)
473 theme->desk_toggled_mask = RrPixmapMaskCopy(theme->desk_mask);
474 else {
475 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
476 theme->desk_toggled_mask =
477 RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
478 }
479 }
480 if (!read_mask(inst, path, theme, "desk_pressed.xbm",
481 &theme->desk_pressed_mask))
482 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
483 if (!read_mask(inst, path, theme, "desk_disabled.xbm",
484 &theme->desk_disabled_mask))
485 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
486 if (!read_mask(inst, path, theme, "desk_hover.xbm",
487 &theme->desk_hover_mask))
488 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
489 if (!read_mask(inst, path, theme, "desk_toggled_pressed.xbm",
490 &theme->desk_toggled_pressed_mask))
491 theme->desk_toggled_pressed_mask =
492 RrPixmapMaskCopy(theme->desk_toggled_mask);
493 if (!read_mask(inst, path, theme, "desk_toggled_hover.xbm",
494 &theme->desk_toggled_hover_mask))
495 theme->desk_toggled_hover_mask =
496 RrPixmapMaskCopy(theme->desk_toggled_mask);
497
498 /* shade button masks */
499 if (!read_mask(inst, path, theme, "shade.xbm", &theme->shade_mask)) {
500 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
501 theme->shade_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
502 }
503 if (!read_mask(inst, path, theme, "shade_toggled.xbm",
504 &theme->shade_toggled_mask))
505 theme->shade_toggled_mask = RrPixmapMaskCopy(theme->shade_mask);
506 if (!read_mask(inst, path, theme, "shade_pressed.xbm",
507 &theme->shade_pressed_mask))
508 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
509 if (!read_mask(inst, path, theme, "shade_disabled.xbm",
510 &theme->shade_disabled_mask))
511 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
512 if (!read_mask(inst, path, theme, "shade_hover.xbm",
513 &theme->shade_hover_mask))
514 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
515 if (!read_mask(inst, path, theme, "shade_toggled_pressed.xbm",
516 &theme->shade_toggled_pressed_mask))
517 theme->shade_toggled_pressed_mask =
518 RrPixmapMaskCopy(theme->shade_toggled_mask);
519 if (!read_mask(inst, path, theme, "shade_toggled_hover.xbm",
520 &theme->shade_toggled_hover_mask))
521 theme->shade_toggled_hover_mask =
522 RrPixmapMaskCopy(theme->shade_toggled_mask);
523
524 /* close button masks */
525 if (!read_mask(inst, path, theme, "close.xbm", &theme->close_mask)) {
526 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
527 theme->close_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
528 }
529 if (!read_mask(inst, path, theme, "close_pressed.xbm",
530 &theme->close_pressed_mask))
531 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
532 if (!read_mask(inst, path, theme, "close_disabled.xbm",
533 &theme->close_disabled_mask))
534 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
535 if (!read_mask(inst, path, theme, "close_hover.xbm",
536 &theme->close_hover_mask))
537 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
538
539 /* submenu bullet mask */
540 if (!read_mask(inst, path, theme, "bullet.xbm", &theme->menu_bullet_mask))
541 {
542 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
543 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
544 }
545
546 /* setup the default window icon */
547 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
548 OB_DEFAULT_ICON_HEIGHT,
549 OB_DEFAULT_ICON_pixel_data);
550
551 /* read the decoration textures */
552 if (!read_appearance(db, inst,
553 "window.active.title.bg", theme->a_focused_title,
554 FALSE))
555 set_default_appearance(theme->a_focused_title);
556 if (!read_appearance(db, inst,
557 "window.inactive.title.bg", theme->a_unfocused_title,
558 FALSE))
559 set_default_appearance(theme->a_unfocused_title);
560 if (!read_appearance(db, inst,
561 "window.active.label.bg", theme->a_focused_label,
562 TRUE))
563 set_default_appearance(theme->a_focused_label);
564 if (!read_appearance(db, inst,
565 "window.inactive.label.bg", theme->a_unfocused_label,
566 TRUE))
567 set_default_appearance(theme->a_unfocused_label);
568 if (!read_appearance(db, inst,
569 "window.active.handle.bg", theme->a_focused_handle,
570 FALSE))
571 set_default_appearance(theme->a_focused_handle);
572 if (!read_appearance(db, inst,
573 "window.inactive.handle.bg",theme->a_unfocused_handle,
574 FALSE))
575 set_default_appearance(theme->a_unfocused_handle);
576 if (!read_appearance(db, inst,
577 "window.active.grip.bg", theme->a_focused_grip,
578 TRUE))
579 set_default_appearance(theme->a_focused_grip);
580 if (!read_appearance(db, inst,
581 "window.inactive.grip.bg", theme->a_unfocused_grip,
582 TRUE))
583 set_default_appearance(theme->a_unfocused_grip);
584 if (!read_appearance(db, inst,
585 "menu.items.bg", theme->a_menu,
586 FALSE))
587 set_default_appearance(theme->a_menu);
588 if (!read_appearance(db, inst,
589 "menu.title.bg", theme->a_menu_title,
590 TRUE))
591 set_default_appearance(theme->a_menu_title);
592 if (!read_appearance(db, inst,
593 "menu.items.active.bg", theme->a_menu_selected,
594 TRUE))
595 set_default_appearance(theme->a_menu_selected);
596 theme->a_menu_disabled_selected =
597 RrAppearanceCopy(theme->a_menu_selected);
598
599 /* read appearances for non-decorations (on-screen-display) */
600 if (!read_appearance(db, inst, "osd.bg", theme->osd_hilite_bg, FALSE)) {
601 RrAppearanceFree(theme->osd_hilite_bg);
602 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
603 }
604 if (!read_appearance(db, inst, "osd.label.bg",
605 theme->osd_hilite_label, TRUE)) {
606 RrAppearanceFree(theme->osd_hilite_label);
607 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
608 }
609 /* osd_hilite_fg can't be parentrel */
610 if (!read_appearance(db, inst, "osd.hilight.bg",
611 theme->osd_hilite_fg, FALSE)) {
612 RrAppearanceFree(theme->osd_hilite_fg);
613 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
614 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_label);
615 else
616 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_title);
617 }
618 /* osd_unhilite_fg can't be parentrel either */
619 if (!read_appearance(db, inst, "osd.unhilight.bg",
620 theme->osd_unhilite_fg, FALSE)) {
621 RrAppearanceFree(theme->osd_unhilite_fg);
622 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
623 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_label);
624 else
625 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_title);
626 }
627
628 /* read buttons textures */
629 if (!read_appearance(db, inst,
630 "window.active.button.disabled.bg",
631 theme->a_disabled_focused_max,
632 TRUE))
633 set_default_appearance(theme->a_disabled_focused_max);
634 if (!read_appearance(db, inst,
635 "window.inactive.button.disabled.bg",
636 theme->a_disabled_unfocused_max,
637 TRUE))
638 set_default_appearance(theme->a_disabled_unfocused_max);
639 if (!read_appearance(db, inst,
640 "window.active.button.pressed.bg",
641 theme->a_focused_pressed_max,
642 TRUE))
643 set_default_appearance(theme->a_focused_pressed_max);
644 if (!read_appearance(db, inst,
645 "window.inactive.button.pressed.bg",
646 theme->a_unfocused_pressed_max,
647 TRUE))
648 set_default_appearance(theme->a_unfocused_pressed_max);
649 if (!read_appearance(db, inst,
650 "window.active.button.toggled.unpressed.bg",
651 theme->a_toggled_focused_unpressed_max,
652 TRUE) &&
653 !read_appearance(db, inst,
654 "window.active.button.toggled.bg",
655 theme->a_toggled_focused_unpressed_max,
656 TRUE))
657 {
658 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
659 theme->a_toggled_focused_unpressed_max =
660 RrAppearanceCopy(theme->a_focused_pressed_max);
661 }
662 if (!read_appearance(db, inst,
663 "window.inactive.button.toggled.unpressed.bg",
664 theme->a_toggled_unfocused_unpressed_max,
665 TRUE) &&
666 !read_appearance(db, inst,
667 "window.inactive.button.toggled.bg",
668 theme->a_toggled_unfocused_unpressed_max,
669 TRUE))
670 {
671 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
672 theme->a_toggled_unfocused_unpressed_max =
673 RrAppearanceCopy(theme->a_unfocused_pressed_max);
674 }
675 if (!read_appearance(db, inst,
676 "window.active.button.toggled.hover.bg",
677 theme->a_toggled_hover_focused_max,
678 TRUE))
679 {
680 RrAppearanceFree(theme->a_toggled_hover_focused_max);
681 theme->a_toggled_hover_focused_max =
682 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
683 }
684 if (!read_appearance(db, inst,
685 "window.inactive.button.toggled.hover.bg",
686 theme->a_toggled_hover_unfocused_max,
687 TRUE))
688 {
689 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
690 theme->a_toggled_hover_unfocused_max =
691 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
692 }
693 if (!read_appearance(db, inst,
694 "window.active.button.toggled.pressed.bg",
695 theme->a_toggled_focused_pressed_max,
696 TRUE))
697 {
698 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
699 theme->a_toggled_focused_pressed_max =
700 RrAppearanceCopy(theme->a_focused_pressed_max);
701 }
702 if (!read_appearance(db, inst,
703 "window.inactive.button.toggled.pressed.bg",
704 theme->a_toggled_unfocused_pressed_max,
705 TRUE))
706 {
707 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
708 theme->a_toggled_unfocused_pressed_max =
709 RrAppearanceCopy(theme->a_unfocused_pressed_max);
710 }
711 if (!read_appearance(db, inst,
712 "window.active.button.unpressed.bg",
713 theme->a_focused_unpressed_max,
714 TRUE))
715 set_default_appearance(theme->a_focused_unpressed_max);
716 if (!read_appearance(db, inst,
717 "window.inactive.button.unpressed.bg",
718 theme->a_unfocused_unpressed_max,
719 TRUE))
720 set_default_appearance(theme->a_unfocused_unpressed_max);
721 if (!read_appearance(db, inst,
722 "window.active.button.hover.bg",
723 theme->a_hover_focused_max,
724 TRUE))
725 {
726 RrAppearanceFree(theme->a_hover_focused_max);
727 theme->a_hover_focused_max =
728 RrAppearanceCopy(theme->a_focused_unpressed_max);
729 }
730 if (!read_appearance(db, inst,
731 "window.inactive.button.hover.bg",
732 theme->a_hover_unfocused_max,
733 TRUE))
734 {
735 RrAppearanceFree(theme->a_hover_unfocused_max);
736 theme->a_hover_unfocused_max =
737 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
738 }
739
740 theme->a_disabled_focused_close =
741 RrAppearanceCopy(theme->a_disabled_focused_max);
742 theme->a_disabled_unfocused_close =
743 RrAppearanceCopy(theme->a_disabled_unfocused_max);
744 theme->a_hover_focused_close =
745 RrAppearanceCopy(theme->a_hover_focused_max);
746 theme->a_hover_unfocused_close =
747 RrAppearanceCopy(theme->a_hover_unfocused_max);
748 theme->a_unfocused_unpressed_close =
749 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
750 theme->a_unfocused_pressed_close =
751 RrAppearanceCopy(theme->a_unfocused_pressed_max);
752 theme->a_focused_unpressed_close =
753 RrAppearanceCopy(theme->a_focused_unpressed_max);
754 theme->a_focused_pressed_close =
755 RrAppearanceCopy(theme->a_focused_pressed_max);
756 theme->a_disabled_focused_desk =
757 RrAppearanceCopy(theme->a_disabled_focused_max);
758 theme->a_disabled_unfocused_desk =
759 RrAppearanceCopy(theme->a_disabled_unfocused_max);
760 theme->a_hover_focused_desk =
761 RrAppearanceCopy(theme->a_hover_focused_max);
762 theme->a_hover_unfocused_desk =
763 RrAppearanceCopy(theme->a_hover_unfocused_max);
764 theme->a_toggled_hover_focused_desk =
765 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
766 theme->a_toggled_hover_unfocused_desk =
767 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
768 theme->a_toggled_focused_unpressed_desk =
769 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
770 theme->a_toggled_unfocused_unpressed_desk =
771 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
772 theme->a_toggled_focused_pressed_desk =
773 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
774 theme->a_toggled_unfocused_pressed_desk =
775 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
776 theme->a_unfocused_unpressed_desk =
777 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
778 theme->a_unfocused_pressed_desk =
779 RrAppearanceCopy(theme->a_unfocused_pressed_max);
780 theme->a_focused_unpressed_desk =
781 RrAppearanceCopy(theme->a_focused_unpressed_max);
782 theme->a_focused_pressed_desk =
783 RrAppearanceCopy(theme->a_focused_pressed_max);
784 theme->a_disabled_focused_shade =
785 RrAppearanceCopy(theme->a_disabled_focused_max);
786 theme->a_disabled_unfocused_shade =
787 RrAppearanceCopy(theme->a_disabled_unfocused_max);
788 theme->a_hover_focused_shade =
789 RrAppearanceCopy(theme->a_hover_focused_max);
790 theme->a_hover_unfocused_shade =
791 RrAppearanceCopy(theme->a_hover_unfocused_max);
792 theme->a_toggled_hover_focused_shade =
793 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
794 theme->a_toggled_hover_unfocused_shade =
795 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
796 theme->a_toggled_focused_unpressed_shade =
797 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
798 theme->a_toggled_unfocused_unpressed_shade =
799 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
800 theme->a_toggled_focused_pressed_shade =
801 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
802 theme->a_toggled_unfocused_pressed_shade =
803 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
804 theme->a_unfocused_unpressed_shade =
805 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
806 theme->a_unfocused_pressed_shade =
807 RrAppearanceCopy(theme->a_unfocused_pressed_max);
808 theme->a_focused_unpressed_shade =
809 RrAppearanceCopy(theme->a_focused_unpressed_max);
810 theme->a_focused_pressed_shade =
811 RrAppearanceCopy(theme->a_focused_pressed_max);
812 theme->a_disabled_focused_iconify =
813 RrAppearanceCopy(theme->a_disabled_focused_max);
814 theme->a_disabled_unfocused_iconify =
815 RrAppearanceCopy(theme->a_disabled_focused_max);
816 theme->a_hover_focused_iconify =
817 RrAppearanceCopy(theme->a_hover_focused_max);
818 theme->a_hover_unfocused_iconify =
819 RrAppearanceCopy(theme->a_hover_unfocused_max);
820 theme->a_unfocused_unpressed_iconify =
821 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
822 theme->a_unfocused_pressed_iconify =
823 RrAppearanceCopy(theme->a_unfocused_pressed_max);
824 theme->a_focused_unpressed_iconify =
825 RrAppearanceCopy(theme->a_focused_unpressed_max);
826 theme->a_focused_pressed_iconify =
827 RrAppearanceCopy(theme->a_focused_pressed_max);
828
829 theme->a_icon->surface.grad =
830 theme->a_clear->surface.grad =
831 theme->a_clear_tex->surface.grad =
832 theme->a_menu_text_title->surface.grad =
833 theme->a_menu_normal->surface.grad =
834 theme->a_menu_disabled->surface.grad =
835 theme->a_menu_text_normal->surface.grad =
836 theme->a_menu_text_selected->surface.grad =
837 theme->a_menu_text_disabled->surface.grad =
838 theme->a_menu_text_disabled_selected->surface.grad =
839 theme->a_menu_bullet_normal->surface.grad =
840 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
841
842 /* set up the textures */
843 theme->a_focused_label->texture[0].type = RR_TEXTURE_TEXT;
844 theme->a_focused_label->texture[0].data.text.justify = winjust;
845 theme->a_focused_label->texture[0].data.text.font=theme->win_font_focused;
846 theme->a_focused_label->texture[0].data.text.color =
847 theme->title_focused_color;
848
849 if (read_string(db, "window.active.label.text.font", &str)) {
850 char *p;
851 gint i = 0;
852 gint j;
853 if (strstr(str, "shadow=y")) {
854 if ((p = strstr(str, "shadowoffset=")))
855 i = parse_inline_number(p + strlen("shadowoffset="));
856 else
857 i = 1;
858 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
859 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
860 }
861 if ((p = strstr(str, "shadowtint=")))
862 {
863 i = parse_inline_number(p + strlen("shadowtint="));
864 j = (i > 0 ? 0 : 255);
865 i = ABS(i*255/100);
866
867 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
868 theme->title_focused_shadow_alpha = i;
869 } else {
870 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
871 theme->title_focused_shadow_alpha = 50;
872 }
873 }
874
875 theme->a_focused_label->texture[0].data.text.shadow_color =
876 theme->title_focused_shadow_color;
877 theme->a_focused_label->texture[0].data.text.shadow_alpha =
878 theme->title_focused_shadow_alpha;
879
880 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
881 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
882 theme->osd_hilite_label->texture[0].data.text.font = theme->osd_font;
883 theme->osd_hilite_label->texture[0].data.text.color = theme->osd_color;
884
885 if (read_string(db, "osd.label.text.font", &str)) {
886 char *p;
887 gint i = 0;
888 gint j;
889 if (strstr(str, "shadow=y")) {
890 if ((p = strstr(str, "shadowoffset=")))
891 i = parse_inline_number(p + strlen("shadowoffset="));
892 else
893 i = 1;
894 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
895 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
896 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
897 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
898 }
899 if ((p = strstr(str, "shadowtint=")))
900 {
901 i = parse_inline_number(p + strlen("shadowtint="));
902 j = (i > 0 ? 0 : 255);
903 i = ABS(i*255/100);
904
905 theme->osd_shadow_color = RrColorNew(inst, j, j, j);
906 theme->osd_shadow_alpha = i;
907 } else {
908 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
909 theme->osd_shadow_alpha = 50;
910 }
911 } else {
912 /* inherit the font settings from the focused label */
913 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x =
914 theme->a_focused_label->texture[0].data.text.shadow_offset_x;
915 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y =
916 theme->a_focused_label->texture[0].data.text.shadow_offset_y;
917 if (theme->title_focused_shadow_color)
918 theme->osd_shadow_color =
919 RrColorNew(inst,
920 theme->title_focused_shadow_color->r,
921 theme->title_focused_shadow_color->g,
922 theme->title_focused_shadow_color->b);
923 else
924 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
925 theme->osd_shadow_alpha = theme->title_focused_shadow_alpha;
926 }
927
928 theme->osd_hilite_label->texture[0].data.text.shadow_color =
929 theme->osd_shadow_color;
930 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
931 theme->osd_shadow_alpha;
932
933 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
934 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
935 theme->a_unfocused_label->texture[0].data.text.font =
936 theme->win_font_unfocused;
937 theme->a_unfocused_label->texture[0].data.text.color =
938 theme->title_unfocused_color;
939
940 if (read_string(db, "window.inactive.label.text.font", &str)) {
941 char *p;
942 gint i = 0;
943 gint j;
944 if (strstr(str, "shadow=y")) {
945 if ((p = strstr(str, "shadowoffset=")))
946 i = parse_inline_number(p + strlen("shadowoffset="));
947 else
948 i = 1;
949 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
950 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
951 }
952 if ((p = strstr(str, "shadowtint=")))
953 {
954 i = parse_inline_number(p + strlen("shadowtint="));
955 j = (i > 0 ? 0 : 255);
956 i = ABS(i*255/100);
957
958 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
959 theme->title_unfocused_shadow_alpha = i;
960 } else {
961 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
962 theme->title_unfocused_shadow_alpha = 50;
963 }
964 }
965
966 theme->a_unfocused_label->texture[0].data.text.shadow_color =
967 theme->title_unfocused_shadow_color;
968 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
969 theme->title_unfocused_shadow_alpha;
970
971 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
972 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
973 theme->a_menu_text_title->texture[0].data.text.font =
974 theme->menu_title_font;
975 theme->a_menu_text_title->texture[0].data.text.color =
976 theme->menu_title_color;
977
978 if (read_string(db, "menu.title.text.font", &str)) {
979 char *p;
980 gint i = 0;
981 gint j;
982 if (strstr(str, "shadow=y")) {
983 if ((p = strstr(str, "shadowoffset=")))
984 i = parse_inline_number(p + strlen("shadowoffset="));
985 else
986 i = 1;
987 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
988 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
989 }
990 if ((p = strstr(str, "shadowtint=")))
991 {
992 i = parse_inline_number(p + strlen("shadowtint="));
993 j = (i > 0 ? 0 : 255);
994 i = ABS(i*255/100);
995
996 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
997 theme->menu_title_shadow_alpha = i;
998 } else {
999 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
1000 theme->menu_title_shadow_alpha = 50;
1001 }
1002 }
1003
1004 theme->a_menu_text_title->texture[0].data.text.shadow_color =
1005 theme->menu_title_shadow_color;
1006 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
1007 theme->menu_title_shadow_alpha;
1008
1009 theme->a_menu_text_normal->texture[0].type =
1010 theme->a_menu_text_selected->texture[0].type =
1011 theme->a_menu_text_disabled->texture[0].type =
1012 theme->a_menu_text_disabled_selected->texture[0].type =
1013 RR_TEXTURE_TEXT;
1014 theme->a_menu_text_normal->texture[0].data.text.justify =
1015 theme->a_menu_text_selected->texture[0].data.text.justify =
1016 theme->a_menu_text_disabled->texture[0].data.text.justify =
1017 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
1018 RR_JUSTIFY_LEFT;
1019 theme->a_menu_text_normal->texture[0].data.text.font =
1020 theme->a_menu_text_selected->texture[0].data.text.font =
1021 theme->a_menu_text_disabled->texture[0].data.text.font =
1022 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
1023 theme->menu_font;
1024 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
1025 theme->a_menu_text_selected->texture[0].data.text.color =
1026 theme->menu_selected_color;
1027 theme->a_menu_text_disabled->texture[0].data.text.color =
1028 theme->menu_disabled_color;
1029 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
1030 theme->menu_disabled_selected_color;
1031
1032 if (read_string(db, "menu.items.font", &str)) {
1033 char *p;
1034 gint i = 0;
1035 gint j;
1036 if (strstr(str, "shadow=y")) {
1037 if ((p = strstr(str, "shadowoffset=")))
1038 i = parse_inline_number(p + strlen("shadowoffset="));
1039 else
1040 i = 1;
1041 theme->a_menu_text_normal->
1042 texture[0].data.text.shadow_offset_x = i;
1043 theme->a_menu_text_normal->
1044 texture[0].data.text.shadow_offset_y = i;
1045 theme->a_menu_text_selected->
1046 texture[0].data.text.shadow_offset_x = i;
1047 theme->a_menu_text_selected->
1048 texture[0].data.text.shadow_offset_y = i;
1049 theme->a_menu_text_disabled->
1050 texture[0].data.text.shadow_offset_x = i;
1051 theme->a_menu_text_disabled->
1052 texture[0].data.text.shadow_offset_y = i;
1053 theme->a_menu_text_disabled_selected->
1054 texture[0].data.text.shadow_offset_x = i;
1055 theme->a_menu_text_disabled_selected->
1056 texture[0].data.text.shadow_offset_y = i;
1057 }
1058 if ((p = strstr(str, "shadowtint=")))
1059 {
1060 i = parse_inline_number(p + strlen("shadowtint="));
1061 j = (i > 0 ? 0 : 255);
1062 i = ABS(i*255/100);
1063
1064 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
1065 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
1066 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
1067 theme->menu_text_normal_shadow_alpha = i;
1068 theme->menu_text_selected_shadow_alpha = i;
1069 theme->menu_text_disabled_shadow_alpha = i;
1070 theme->menu_text_disabled_selected_shadow_alpha = i;
1071 } else {
1072 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
1073 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
1074 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
1075 theme->menu_text_normal_shadow_alpha = 50;
1076 theme->menu_text_selected_shadow_alpha = 50;
1077 theme->menu_text_disabled_selected_shadow_alpha = 50;
1078 }
1079 }
1080
1081 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
1082 theme->menu_text_normal_shadow_color;
1083 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
1084 theme->menu_text_normal_shadow_alpha;
1085 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
1086 theme->menu_text_selected_shadow_color;
1087 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
1088 theme->menu_text_selected_shadow_alpha;
1089 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
1090 theme->menu_text_disabled_shadow_color;
1091 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
1092 theme->menu_text_disabled_shadow_alpha;
1093 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
1094 theme->menu_text_disabled_shadow_color;
1095 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
1096 theme->menu_text_disabled_shadow_alpha;
1097
1098 theme->a_disabled_focused_max->texture[0].type =
1099 theme->a_disabled_unfocused_max->texture[0].type =
1100 theme->a_hover_focused_max->texture[0].type =
1101 theme->a_hover_unfocused_max->texture[0].type =
1102 theme->a_toggled_hover_focused_max->texture[0].type =
1103 theme->a_toggled_hover_unfocused_max->texture[0].type =
1104 theme->a_toggled_focused_unpressed_max->texture[0].type =
1105 theme->a_toggled_unfocused_unpressed_max->texture[0].type =
1106 theme->a_toggled_focused_pressed_max->texture[0].type =
1107 theme->a_toggled_unfocused_pressed_max->texture[0].type =
1108 theme->a_focused_unpressed_max->texture[0].type =
1109 theme->a_focused_pressed_max->texture[0].type =
1110 theme->a_unfocused_unpressed_max->texture[0].type =
1111 theme->a_unfocused_pressed_max->texture[0].type =
1112 theme->a_disabled_focused_close->texture[0].type =
1113 theme->a_disabled_unfocused_close->texture[0].type =
1114 theme->a_hover_focused_close->texture[0].type =
1115 theme->a_hover_unfocused_close->texture[0].type =
1116 theme->a_focused_unpressed_close->texture[0].type =
1117 theme->a_focused_pressed_close->texture[0].type =
1118 theme->a_unfocused_unpressed_close->texture[0].type =
1119 theme->a_unfocused_pressed_close->texture[0].type =
1120 theme->a_disabled_focused_desk->texture[0].type =
1121 theme->a_disabled_unfocused_desk->texture[0].type =
1122 theme->a_hover_focused_desk->texture[0].type =
1123 theme->a_hover_unfocused_desk->texture[0].type =
1124 theme->a_toggled_hover_focused_desk->texture[0].type =
1125 theme->a_toggled_hover_unfocused_desk->texture[0].type =
1126 theme->a_toggled_focused_unpressed_desk->texture[0].type =
1127 theme->a_toggled_unfocused_unpressed_desk->texture[0].type =
1128 theme->a_toggled_focused_pressed_desk->texture[0].type =
1129 theme->a_toggled_unfocused_pressed_desk->texture[0].type =
1130 theme->a_focused_unpressed_desk->texture[0].type =
1131 theme->a_focused_pressed_desk->texture[0].type =
1132 theme->a_unfocused_unpressed_desk->texture[0].type =
1133 theme->a_unfocused_pressed_desk->texture[0].type =
1134 theme->a_disabled_focused_shade->texture[0].type =
1135 theme->a_disabled_unfocused_shade->texture[0].type =
1136 theme->a_hover_focused_shade->texture[0].type =
1137 theme->a_hover_unfocused_shade->texture[0].type =
1138 theme->a_toggled_hover_focused_shade->texture[0].type =
1139 theme->a_toggled_hover_unfocused_shade->texture[0].type =
1140 theme->a_toggled_focused_unpressed_shade->texture[0].type =
1141 theme->a_toggled_unfocused_unpressed_shade->texture[0].type =
1142 theme->a_toggled_focused_pressed_shade->texture[0].type =
1143 theme->a_toggled_unfocused_pressed_shade->texture[0].type =
1144 theme->a_focused_unpressed_shade->texture[0].type =
1145 theme->a_focused_pressed_shade->texture[0].type =
1146 theme->a_unfocused_unpressed_shade->texture[0].type =
1147 theme->a_unfocused_pressed_shade->texture[0].type =
1148 theme->a_disabled_focused_iconify->texture[0].type =
1149 theme->a_disabled_unfocused_iconify->texture[0].type =
1150 theme->a_hover_focused_iconify->texture[0].type =
1151 theme->a_hover_unfocused_iconify->texture[0].type =
1152 theme->a_focused_unpressed_iconify->texture[0].type =
1153 theme->a_focused_pressed_iconify->texture[0].type =
1154 theme->a_unfocused_unpressed_iconify->texture[0].type =
1155 theme->a_unfocused_pressed_iconify->texture[0].type =
1156 theme->a_menu_bullet_normal->texture[0].type =
1157 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
1158
1159 theme->a_disabled_focused_max->texture[0].data.mask.mask =
1160 theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
1161 theme->max_disabled_mask;
1162 theme->a_hover_focused_max->texture[0].data.mask.mask =
1163 theme->a_hover_unfocused_max->texture[0].data.mask.mask =
1164 theme->max_hover_mask;
1165 theme->a_focused_pressed_max->texture[0].data.mask.mask =
1166 theme->a_unfocused_pressed_max->texture[0].data.mask.mask =
1167 theme->max_pressed_mask;
1168 theme->a_focused_unpressed_max->texture[0].data.mask.mask =
1169 theme->a_unfocused_unpressed_max->texture[0].data.mask.mask =
1170 theme->max_mask;
1171 theme->a_toggled_hover_focused_max->texture[0].data.mask.mask =
1172 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.mask =
1173 theme->max_toggled_hover_mask;
1174 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.mask =
1175 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.mask =
1176 theme->max_toggled_mask;
1177 theme->a_toggled_focused_pressed_max->texture[0].data.mask.mask =
1178 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.mask =
1179 theme->max_toggled_pressed_mask;
1180 theme->a_disabled_focused_close->texture[0].data.mask.mask =
1181 theme->a_disabled_unfocused_close->texture[0].data.mask.mask =
1182 theme->close_disabled_mask;
1183 theme->a_hover_focused_close->texture[0].data.mask.mask =
1184 theme->a_hover_unfocused_close->texture[0].data.mask.mask =
1185 theme->close_hover_mask;
1186 theme->a_focused_pressed_close->texture[0].data.mask.mask =
1187 theme->a_unfocused_pressed_close->texture[0].data.mask.mask =
1188 theme->close_pressed_mask;
1189 theme->a_focused_unpressed_close->texture[0].data.mask.mask =
1190 theme->a_unfocused_unpressed_close->texture[0].data.mask.mask =
1191 theme->close_mask;
1192 theme->a_disabled_focused_desk->texture[0].data.mask.mask =
1193 theme->a_disabled_unfocused_desk->texture[0].data.mask.mask =
1194 theme->desk_disabled_mask;
1195 theme->a_hover_focused_desk->texture[0].data.mask.mask =
1196 theme->a_hover_unfocused_desk->texture[0].data.mask.mask =
1197 theme->desk_hover_mask;
1198 theme->a_focused_pressed_desk->texture[0].data.mask.mask =
1199 theme->a_unfocused_pressed_desk->texture[0].data.mask.mask =
1200 theme->desk_pressed_mask;
1201 theme->a_focused_unpressed_desk->texture[0].data.mask.mask =
1202 theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask =
1203 theme->desk_mask;
1204 theme->a_toggled_hover_focused_desk->texture[0].data.mask.mask =
1205 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.mask =
1206 theme->desk_toggled_hover_mask;
1207 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.mask =
1208 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.mask =
1209 theme->desk_toggled_mask;
1210 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.mask =
1211 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.mask =
1212 theme->desk_toggled_pressed_mask;
1213 theme->a_disabled_focused_shade->texture[0].data.mask.mask =
1214 theme->a_disabled_unfocused_shade->texture[0].data.mask.mask =
1215 theme->shade_disabled_mask;
1216 theme->a_hover_focused_shade->texture[0].data.mask.mask =
1217 theme->a_hover_unfocused_shade->texture[0].data.mask.mask =
1218 theme->shade_hover_mask;
1219 theme->a_focused_pressed_shade->texture[0].data.mask.mask =
1220 theme->a_unfocused_pressed_shade->texture[0].data.mask.mask =
1221 theme->shade_pressed_mask;
1222 theme->a_focused_unpressed_shade->texture[0].data.mask.mask =
1223 theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask =
1224 theme->shade_mask;
1225 theme->a_toggled_hover_focused_shade->texture[0].data.mask.mask =
1226 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.mask =
1227 theme->shade_toggled_hover_mask;
1228 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.mask =
1229 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.mask =
1230 theme->shade_toggled_mask;
1231 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.mask =
1232 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.mask =
1233 theme->shade_toggled_pressed_mask;
1234 theme->a_disabled_focused_iconify->texture[0].data.mask.mask =
1235 theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask =
1236 theme->iconify_disabled_mask;
1237 theme->a_hover_focused_iconify->texture[0].data.mask.mask =
1238 theme->a_hover_unfocused_iconify->texture[0].data.mask.mask =
1239 theme->iconify_hover_mask;
1240 theme->a_focused_pressed_iconify->texture[0].data.mask.mask =
1241 theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask =
1242 theme->iconify_pressed_mask;
1243 theme->a_focused_unpressed_iconify->texture[0].data.mask.mask =
1244 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask =
1245 theme->iconify_mask;
1246 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1247 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1248 theme->menu_bullet_mask;
1249 theme->a_disabled_focused_max->texture[0].data.mask.color =
1250 theme->a_disabled_focused_close->texture[0].data.mask.color =
1251 theme->a_disabled_focused_desk->texture[0].data.mask.color =
1252 theme->a_disabled_focused_shade->texture[0].data.mask.color =
1253 theme->a_disabled_focused_iconify->texture[0].data.mask.color =
1254 theme->titlebut_disabled_focused_color;
1255 theme->a_disabled_unfocused_max->texture[0].data.mask.color =
1256 theme->a_disabled_unfocused_close->texture[0].data.mask.color =
1257 theme->a_disabled_unfocused_desk->texture[0].data.mask.color =
1258 theme->a_disabled_unfocused_shade->texture[0].data.mask.color =
1259 theme->a_disabled_unfocused_iconify->texture[0].data.mask.color =
1260 theme->titlebut_disabled_unfocused_color;
1261 theme->a_hover_focused_max->texture[0].data.mask.color =
1262 theme->a_hover_focused_close->texture[0].data.mask.color =
1263 theme->a_hover_focused_desk->texture[0].data.mask.color =
1264 theme->a_hover_focused_shade->texture[0].data.mask.color =
1265 theme->a_hover_focused_iconify->texture[0].data.mask.color =
1266 theme->titlebut_hover_focused_color;
1267 theme->a_hover_unfocused_max->texture[0].data.mask.color =
1268 theme->a_hover_unfocused_close->texture[0].data.mask.color =
1269 theme->a_hover_unfocused_desk->texture[0].data.mask.color =
1270 theme->a_hover_unfocused_shade->texture[0].data.mask.color =
1271 theme->a_hover_unfocused_iconify->texture[0].data.mask.color =
1272 theme->titlebut_hover_unfocused_color;
1273 theme->a_toggled_hover_focused_max->texture[0].data.mask.color =
1274 theme->a_toggled_hover_focused_desk->texture[0].data.mask.color =
1275 theme->a_toggled_hover_focused_shade->texture[0].data.mask.color =
1276 theme->titlebut_toggled_hover_focused_color;
1277 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.color =
1278 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.color =
1279 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.color =
1280 theme->titlebut_toggled_hover_unfocused_color;
1281 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.color =
1282 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.color =
1283 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.color =
1284 theme->titlebut_toggled_focused_unpressed_color;
1285 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.color =
1286 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.color =
1287 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.color=
1288 theme->titlebut_toggled_unfocused_unpressed_color;
1289 theme->a_toggled_focused_pressed_max->texture[0].data.mask.color =
1290 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.color =
1291 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.color =
1292 theme->titlebut_toggled_focused_pressed_color;
1293 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.color =
1294 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.color =
1295 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.color =
1296 theme->titlebut_toggled_unfocused_pressed_color;
1297 theme->a_focused_unpressed_max->texture[0].data.mask.color =
1298 theme->a_focused_unpressed_close->texture[0].data.mask.color =
1299 theme->a_focused_unpressed_desk->texture[0].data.mask.color =
1300 theme->a_focused_unpressed_shade->texture[0].data.mask.color =
1301 theme->a_focused_unpressed_iconify->texture[0].data.mask.color =
1302 theme->titlebut_focused_unpressed_color;
1303 theme->a_focused_pressed_max->texture[0].data.mask.color =
1304 theme->a_focused_pressed_close->texture[0].data.mask.color =
1305 theme->a_focused_pressed_desk->texture[0].data.mask.color =
1306 theme->a_focused_pressed_shade->texture[0].data.mask.color =
1307 theme->a_focused_pressed_iconify->texture[0].data.mask.color =
1308 theme->titlebut_focused_pressed_color;
1309 theme->a_unfocused_unpressed_max->texture[0].data.mask.color =
1310 theme->a_unfocused_unpressed_close->texture[0].data.mask.color =
1311 theme->a_unfocused_unpressed_desk->texture[0].data.mask.color =
1312 theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
1313 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
1314 theme->titlebut_unfocused_unpressed_color;
1315 theme->a_unfocused_pressed_max->texture[0].data.mask.color =
1316 theme->a_unfocused_pressed_close->texture[0].data.mask.color =
1317 theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
1318 theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
1319 theme->a_unfocused_pressed_iconify->texture[0].data.mask.color =
1320 theme->titlebut_unfocused_pressed_color;
1321 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1322 theme->menu_color;
1323 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1324 theme->menu_selected_color;
1325
1326 g_free(path);
1327 XrmDestroyDatabase(db);
1328
1329 /* set the font heights */
1330 theme->win_font_height = RrFontHeight
1331 (theme->win_font_focused,
1332 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1333 theme->win_font_height =
1334 MAX(theme->win_font_height,
1335 RrFontHeight
1336 (theme->win_font_focused,
1337 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1338 theme->menu_title_font_height = RrFontHeight
1339 (theme->menu_title_font,
1340 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1341 theme->menu_font_height = RrFontHeight
1342 (theme->menu_font,
1343 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1344
1345 /* calculate some last extents */
1346 {
1347 gint ft, fb, fl, fr, ut, ub, ul, ur;
1348
1349 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1350 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1351 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1352 theme->label_height += theme->label_height % 2;
1353
1354 /* this would be nice I think, since padding.width can now be 0,
1355 but it breaks frame.c horribly and I don't feel like fixing that
1356 right now, so if anyone complains, here is how to keep text from
1357 going over the title's bevel/border with a padding.width of 0 and a
1358 bevelless/borderless label
1359 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1360 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1361 theme->title_height = theme->label_height +
1362 MAX(MAX(theme->padding * 2, ft + fb),
1363 MAX(theme->padding * 2, ut + ub));
1364 */
1365 theme->title_height = theme->label_height + theme->paddingy * 2;
1366
1367 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1368 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1369 theme->menu_title_height = theme->menu_title_label_height +
1370 theme->paddingy * 2;
1371 }
1372 theme->button_size = theme->label_height - 2;
1373 theme->grip_width = 25;
1374
1375 return theme;
1376 }
1377
1378 void RrThemeFree(RrTheme *theme)
1379 {
1380 if (theme) {
1381 g_free(theme->name);
1382
1383 RrColorFree(theme->menu_border_color);
1384 RrColorFree(theme->osd_border_color);
1385 RrColorFree(theme->frame_focused_border_color);
1386 RrColorFree(theme->frame_unfocused_border_color);
1387 RrColorFree(theme->title_separator_focused_color);
1388 RrColorFree(theme->title_separator_unfocused_color);
1389 RrColorFree(theme->cb_unfocused_color);
1390 RrColorFree(theme->cb_focused_color);
1391 RrColorFree(theme->title_focused_color);
1392 RrColorFree(theme->title_unfocused_color);
1393 RrColorFree(theme->titlebut_disabled_focused_color);
1394 RrColorFree(theme->titlebut_disabled_unfocused_color);
1395 RrColorFree(theme->titlebut_hover_focused_color);
1396 RrColorFree(theme->titlebut_hover_unfocused_color);
1397 RrColorFree(theme->titlebut_toggled_hover_focused_color);
1398 RrColorFree(theme->titlebut_toggled_hover_unfocused_color);
1399 RrColorFree(theme->titlebut_toggled_focused_pressed_color);
1400 RrColorFree(theme->titlebut_toggled_unfocused_pressed_color);
1401 RrColorFree(theme->titlebut_toggled_focused_unpressed_color);
1402 RrColorFree(theme->titlebut_toggled_unfocused_unpressed_color);
1403 RrColorFree(theme->titlebut_focused_pressed_color);
1404 RrColorFree(theme->titlebut_unfocused_pressed_color);
1405 RrColorFree(theme->titlebut_focused_unpressed_color);
1406 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1407 RrColorFree(theme->menu_title_color);
1408 RrColorFree(theme->menu_color);
1409 RrColorFree(theme->menu_selected_color);
1410 RrColorFree(theme->menu_disabled_color);
1411 RrColorFree(theme->menu_disabled_selected_color);
1412 RrColorFree(theme->title_focused_shadow_color);
1413 RrColorFree(theme->title_unfocused_shadow_color);
1414 RrColorFree(theme->osd_color);
1415 RrColorFree(theme->osd_shadow_color);
1416 RrColorFree(theme->menu_title_shadow_color);
1417 RrColorFree(theme->menu_text_normal_shadow_color);
1418 RrColorFree(theme->menu_text_selected_shadow_color);
1419 RrColorFree(theme->menu_text_disabled_shadow_color);
1420 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1421
1422 g_free(theme->def_win_icon);
1423
1424 RrPixmapMaskFree(theme->max_mask);
1425 RrPixmapMaskFree(theme->max_toggled_mask);
1426 RrPixmapMaskFree(theme->max_toggled_hover_mask);
1427 RrPixmapMaskFree(theme->max_toggled_pressed_mask);
1428 RrPixmapMaskFree(theme->max_disabled_mask);
1429 RrPixmapMaskFree(theme->max_hover_mask);
1430 RrPixmapMaskFree(theme->max_pressed_mask);
1431 RrPixmapMaskFree(theme->desk_mask);
1432 RrPixmapMaskFree(theme->desk_toggled_mask);
1433 RrPixmapMaskFree(theme->desk_toggled_hover_mask);
1434 RrPixmapMaskFree(theme->desk_toggled_pressed_mask);
1435 RrPixmapMaskFree(theme->desk_disabled_mask);
1436 RrPixmapMaskFree(theme->desk_hover_mask);
1437 RrPixmapMaskFree(theme->desk_pressed_mask);
1438 RrPixmapMaskFree(theme->shade_mask);
1439 RrPixmapMaskFree(theme->shade_toggled_mask);
1440 RrPixmapMaskFree(theme->shade_toggled_hover_mask);
1441 RrPixmapMaskFree(theme->shade_toggled_pressed_mask);
1442 RrPixmapMaskFree(theme->shade_disabled_mask);
1443 RrPixmapMaskFree(theme->shade_hover_mask);
1444 RrPixmapMaskFree(theme->shade_pressed_mask);
1445 RrPixmapMaskFree(theme->iconify_mask);
1446 RrPixmapMaskFree(theme->iconify_disabled_mask);
1447 RrPixmapMaskFree(theme->iconify_hover_mask);
1448 RrPixmapMaskFree(theme->iconify_pressed_mask);
1449 RrPixmapMaskFree(theme->close_mask);
1450 RrPixmapMaskFree(theme->close_disabled_mask);
1451 RrPixmapMaskFree(theme->close_hover_mask);
1452 RrPixmapMaskFree(theme->close_pressed_mask);
1453 RrPixmapMaskFree(theme->menu_bullet_mask);
1454
1455 RrFontClose(theme->win_font_focused);
1456 RrFontClose(theme->win_font_unfocused);
1457 RrFontClose(theme->menu_title_font);
1458 RrFontClose(theme->menu_font);
1459 RrFontClose(theme->osd_font);
1460
1461 RrAppearanceFree(theme->a_disabled_focused_max);
1462 RrAppearanceFree(theme->a_disabled_unfocused_max);
1463 RrAppearanceFree(theme->a_hover_focused_max);
1464 RrAppearanceFree(theme->a_hover_unfocused_max);
1465 RrAppearanceFree(theme->a_toggled_hover_focused_max);
1466 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
1467 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
1468 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
1469 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
1470 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
1471 RrAppearanceFree(theme->a_focused_unpressed_max);
1472 RrAppearanceFree(theme->a_focused_pressed_max);
1473 RrAppearanceFree(theme->a_unfocused_unpressed_max);
1474 RrAppearanceFree(theme->a_unfocused_pressed_max);
1475 RrAppearanceFree(theme->a_disabled_focused_close);
1476 RrAppearanceFree(theme->a_disabled_unfocused_close);
1477 RrAppearanceFree(theme->a_hover_focused_close);
1478 RrAppearanceFree(theme->a_hover_unfocused_close);
1479 RrAppearanceFree(theme->a_focused_unpressed_close);
1480 RrAppearanceFree(theme->a_focused_pressed_close);
1481 RrAppearanceFree(theme->a_unfocused_unpressed_close);
1482 RrAppearanceFree(theme->a_unfocused_pressed_close);
1483 RrAppearanceFree(theme->a_disabled_focused_desk);
1484 RrAppearanceFree(theme->a_disabled_unfocused_desk);
1485 RrAppearanceFree(theme->a_hover_focused_desk);
1486 RrAppearanceFree(theme->a_hover_unfocused_desk);
1487 RrAppearanceFree(theme->a_toggled_hover_focused_desk);
1488 RrAppearanceFree(theme->a_toggled_hover_unfocused_desk);
1489 RrAppearanceFree(theme->a_toggled_focused_unpressed_desk);
1490 RrAppearanceFree(theme->a_toggled_focused_pressed_desk);
1491 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_desk);
1492 RrAppearanceFree(theme->a_toggled_unfocused_pressed_desk);
1493 RrAppearanceFree(theme->a_focused_unpressed_desk);
1494 RrAppearanceFree(theme->a_focused_pressed_desk);
1495 RrAppearanceFree(theme->a_unfocused_unpressed_desk);
1496 RrAppearanceFree(theme->a_unfocused_pressed_desk);
1497 RrAppearanceFree(theme->a_disabled_focused_shade);
1498 RrAppearanceFree(theme->a_disabled_unfocused_shade);
1499 RrAppearanceFree(theme->a_hover_focused_shade);
1500 RrAppearanceFree(theme->a_hover_unfocused_shade);
1501 RrAppearanceFree(theme->a_toggled_hover_focused_shade);
1502 RrAppearanceFree(theme->a_toggled_hover_unfocused_shade);
1503 RrAppearanceFree(theme->a_toggled_focused_unpressed_shade);
1504 RrAppearanceFree(theme->a_toggled_focused_pressed_shade);
1505 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_shade);
1506 RrAppearanceFree(theme->a_toggled_unfocused_pressed_shade);
1507 RrAppearanceFree(theme->a_focused_unpressed_shade);
1508 RrAppearanceFree(theme->a_focused_pressed_shade);
1509 RrAppearanceFree(theme->a_unfocused_unpressed_shade);
1510 RrAppearanceFree(theme->a_unfocused_pressed_shade);
1511 RrAppearanceFree(theme->a_disabled_focused_iconify);
1512 RrAppearanceFree(theme->a_disabled_unfocused_iconify);
1513 RrAppearanceFree(theme->a_hover_focused_iconify);
1514 RrAppearanceFree(theme->a_hover_unfocused_iconify);
1515 RrAppearanceFree(theme->a_focused_unpressed_iconify);
1516 RrAppearanceFree(theme->a_focused_pressed_iconify);
1517 RrAppearanceFree(theme->a_unfocused_unpressed_iconify);
1518 RrAppearanceFree(theme->a_unfocused_pressed_iconify);
1519 RrAppearanceFree(theme->a_focused_grip);
1520 RrAppearanceFree(theme->a_unfocused_grip);
1521 RrAppearanceFree(theme->a_focused_title);
1522 RrAppearanceFree(theme->a_unfocused_title);
1523 RrAppearanceFree(theme->a_focused_label);
1524 RrAppearanceFree(theme->a_unfocused_label);
1525 RrAppearanceFree(theme->a_icon);
1526 RrAppearanceFree(theme->a_focused_handle);
1527 RrAppearanceFree(theme->a_unfocused_handle);
1528 RrAppearanceFree(theme->a_menu);
1529 RrAppearanceFree(theme->a_menu_title);
1530 RrAppearanceFree(theme->a_menu_text_title);
1531 RrAppearanceFree(theme->a_menu_normal);
1532 RrAppearanceFree(theme->a_menu_selected);
1533 RrAppearanceFree(theme->a_menu_disabled);
1534 RrAppearanceFree(theme->a_menu_disabled_selected);
1535 RrAppearanceFree(theme->a_menu_text_normal);
1536 RrAppearanceFree(theme->a_menu_text_selected);
1537 RrAppearanceFree(theme->a_menu_text_disabled);
1538 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1539 RrAppearanceFree(theme->a_menu_bullet_normal);
1540 RrAppearanceFree(theme->a_menu_bullet_selected);
1541 RrAppearanceFree(theme->a_clear);
1542 RrAppearanceFree(theme->a_clear_tex);
1543 RrAppearanceFree(theme->osd_hilite_bg);
1544 RrAppearanceFree(theme->osd_hilite_fg);
1545 RrAppearanceFree(theme->osd_hilite_label);
1546 RrAppearanceFree(theme->osd_unhilite_fg);
1547
1548 g_free(theme);
1549 }
1550 }
1551
1552 static XrmDatabase loaddb(const gchar *name, gchar **path)
1553 {
1554 GSList *it;
1555 XrmDatabase db = NULL;
1556 gchar *s;
1557
1558 if (name[0] == '/') {
1559 s = g_build_filename(name, "openbox-3", "themerc", NULL);
1560 if ((db = XrmGetFileDatabase(s)))
1561 *path = g_path_get_dirname(s);
1562 g_free(s);
1563 } else {
1564 /* XXX backwards compatibility, remove me sometime later */
1565 s = g_build_filename(g_get_home_dir(), ".themes", name,
1566 "openbox-3", "themerc", NULL);
1567 if ((db = XrmGetFileDatabase(s)))
1568 *path = g_path_get_dirname(s);
1569 g_free(s);
1570
1571 for (it = parse_xdg_data_dir_paths(); !db && it;
1572 it = g_slist_next(it))
1573 {
1574 s = g_build_filename(it->data, "themes", name,
1575 "openbox-3", "themerc", NULL);
1576 if ((db = XrmGetFileDatabase(s)))
1577 *path = g_path_get_dirname(s);
1578 g_free(s);
1579 }
1580 }
1581
1582 if (db == NULL) {
1583 s = g_build_filename(name, "themerc", NULL);
1584 if ((db = XrmGetFileDatabase(s)))
1585 *path = g_path_get_dirname(s);
1586 g_free(s);
1587 }
1588
1589 return db;
1590 }
1591
1592 static gchar *create_class_name(const gchar *rname)
1593 {
1594 gchar *rclass = g_strdup(rname);
1595 gchar *p = rclass;
1596
1597 while (TRUE) {
1598 *p = toupper(*p);
1599 p = strchr(p+1, '.');
1600 if (p == NULL) break;
1601 ++p;
1602 if (*p == '\0') break;
1603 }
1604 return rclass;
1605 }
1606
1607 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1608 {
1609 gboolean ret = FALSE;
1610 gchar *rclass = create_class_name(rname);
1611 gchar *rettype, *end;
1612 XrmValue retvalue;
1613
1614 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1615 retvalue.addr != NULL) {
1616 *value = (gint)strtol(retvalue.addr, &end, 10);
1617 if (end != retvalue.addr)
1618 ret = TRUE;
1619 }
1620
1621 g_free(rclass);
1622 return ret;
1623 }
1624
1625 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1626 {
1627 gboolean ret = FALSE;
1628 gchar *rclass = create_class_name(rname);
1629 gchar *rettype;
1630 XrmValue retvalue;
1631
1632 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1633 retvalue.addr != NULL) {
1634 *value = retvalue.addr;
1635 ret = TRUE;
1636 }
1637
1638 g_free(rclass);
1639 return ret;
1640 }
1641
1642 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1643 const gchar *rname, RrColor **value)
1644 {
1645 gboolean ret = FALSE;
1646 gchar *rclass = create_class_name(rname);
1647 gchar *rettype;
1648 XrmValue retvalue;
1649
1650 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1651 retvalue.addr != NULL) {
1652 RrColor *c = RrColorParse(inst, retvalue.addr);
1653 if (c != NULL) {
1654 *value = c;
1655 ret = TRUE;
1656 }
1657 }
1658
1659 g_free(rclass);
1660 return ret;
1661 }
1662
1663 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1664 RrTheme *theme, const gchar *maskname,
1665 RrPixmapMask **value)
1666 {
1667 gboolean ret = FALSE;
1668 gchar *s;
1669 gint hx, hy; /* ignored */
1670 guint w, h;
1671 guchar *b;
1672
1673 s = g_build_filename(path, maskname, NULL);
1674 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1675 ret = TRUE;
1676 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1677 XFree(b);
1678 }
1679 g_free(s);
1680
1681 return ret;
1682 }
1683
1684 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1685 RrReliefType *relief, RrBevelType *bevel,
1686 gboolean *interlaced, gboolean *border,
1687 gboolean allow_trans)
1688 {
1689 gchar *t;
1690
1691 /* convert to all lowercase */
1692 for (t = tex; *t != '\0'; ++t)
1693 *t = g_ascii_tolower(*t);
1694
1695 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1696 *grad = RR_SURFACE_PARENTREL;
1697 } else {
1698 if (strstr(tex, "gradient") != NULL) {
1699 if (strstr(tex, "crossdiagonal") != NULL)
1700 *grad = RR_SURFACE_CROSS_DIAGONAL;
1701 else if (strstr(tex, "pyramid") != NULL)
1702 *grad = RR_SURFACE_PYRAMID;
1703 else if (strstr(tex, "mirrorhorizontal") != NULL)
1704 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1705 else if (strstr(tex, "horizontal") != NULL)
1706 *grad = RR_SURFACE_HORIZONTAL;
1707 else if (strstr(tex, "splitvertical") != NULL)
1708 *grad = RR_SURFACE_SPLIT_VERTICAL;
1709 else if (strstr(tex, "vertical") != NULL)
1710 *grad = RR_SURFACE_VERTICAL;
1711 else
1712 *grad = RR_SURFACE_DIAGONAL;
1713 } else {
1714 *grad = RR_SURFACE_SOLID;
1715 }
1716 }
1717
1718 if (strstr(tex, "sunken") != NULL)
1719 *relief = RR_RELIEF_SUNKEN;
1720 else if (strstr(tex, "flat") != NULL)
1721 *relief = RR_RELIEF_FLAT;
1722 else if (strstr(tex, "raised") != NULL)
1723 *relief = RR_RELIEF_RAISED;
1724 else
1725 *relief = (*grad == RR_SURFACE_PARENTREL) ?
1726 RR_RELIEF_FLAT : RR_RELIEF_RAISED;
1727
1728 *border = FALSE;
1729 if (*relief == RR_RELIEF_FLAT) {
1730 if (strstr(tex, "border") != NULL)
1731 *border = TRUE;
1732 } else {
1733 if (strstr(tex, "bevel2") != NULL)
1734 *bevel = RR_BEVEL_2;
1735 else
1736 *bevel = RR_BEVEL_1;
1737 }
1738
1739 if (strstr(tex, "interlaced") != NULL)
1740 *interlaced = TRUE;
1741 else
1742 *interlaced = FALSE;
1743 }
1744
1745
1746 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1747 const gchar *rname, RrAppearance *value,
1748 gboolean allow_trans)
1749 {
1750 gboolean ret = FALSE;
1751 gchar *rclass = create_class_name(rname);
1752 gchar *cname, *ctoname, *bcname, *icname, *hname, *sname;
1753 gchar *csplitname, *ctosplitname;
1754 gchar *rettype;
1755 XrmValue retvalue;
1756 gint i;
1757
1758 cname = g_strconcat(rname, ".color", NULL);
1759 ctoname = g_strconcat(rname, ".colorTo", NULL);
1760 bcname = g_strconcat(rname, ".border.color", NULL);
1761 icname = g_strconcat(rname, ".interlace.color", NULL);
1762 hname = g_strconcat(rname, ".highlight", NULL);
1763 sname = g_strconcat(rname, ".shadow", NULL);
1764 csplitname = g_strconcat(rname, ".color.splitTo", NULL);
1765 ctosplitname = g_strconcat(rname, ".colorTo.splitTo", NULL);
1766
1767 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1768 retvalue.addr != NULL) {
1769 parse_appearance(retvalue.addr,
1770 &value->surface.grad,
1771 &value->surface.relief,
1772 &value->surface.bevel,
1773 &value->surface.interlaced,
1774 &value->surface.border,
1775 allow_trans);
1776 if (!read_color(db, inst, cname, &value->surface.primary))
1777 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1778 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1779 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1780 if (value->surface.border)
1781 if (!read_color(db, inst, bcname,
1782 &value->surface.border_color))
1783 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1784 if (value->surface.interlaced)
1785 if (!read_color(db, inst, icname,
1786 &value->surface.interlace_color))
1787 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1788 if (read_int(db, hname, &i) && i >= 0)
1789 value->surface.bevel_light_adjust = i;
1790 if (read_int(db, sname, &i) && i >= 0 && i <= 256)
1791 value->surface.bevel_dark_adjust = i;
1792
1793 if (value->surface.grad == RR_SURFACE_SPLIT_VERTICAL) {
1794 gint r, g, b;
1795
1796 if (!read_color(db, inst, csplitname,
1797 &value->surface.split_primary))
1798 {
1799 r = value->surface.primary->r;
1800 r += r >> 2;
1801 g = value->surface.primary->g;
1802 g += g >> 2;
1803 b = value->surface.primary->b;
1804 b += b >> 2;
1805 if (r > 0xFF) r = 0xFF;
1806 if (g > 0xFF) g = 0xFF;
1807 if (b > 0xFF) b = 0xFF;
1808 value->surface.split_primary = RrColorNew(inst, r, g, b);
1809 }
1810
1811 if (!read_color(db, inst, ctosplitname,
1812 &value->surface.split_secondary))
1813 {
1814 r = value->surface.secondary->r;
1815 r += r >> 4;
1816 g = value->surface.secondary->g;
1817 g += g >> 4;
1818 b = value->surface.secondary->b;
1819 b += b >> 4;
1820 if (r > 0xFF) r = 0xFF;
1821 if (g > 0xFF) g = 0xFF;
1822 if (b > 0xFF) b = 0xFF;
1823 value->surface.split_secondary = RrColorNew(inst, r, g, b);
1824 }
1825 }
1826
1827 ret = TRUE;
1828 }
1829
1830 g_free(ctosplitname);
1831 g_free(csplitname);
1832 g_free(sname);
1833 g_free(hname);
1834 g_free(icname);
1835 g_free(bcname);
1836 g_free(ctoname);
1837 g_free(cname);
1838 g_free(rclass);
1839 return ret;
1840 }
1841
1842 static int parse_inline_number(const char *p)
1843 {
1844 int neg = 1;
1845 int res = 0;
1846 if (*p == '-') {
1847 neg = -1;
1848 ++p;
1849 }
1850 for (; isdigit(*p); ++p)
1851 res = res * 10 + *p - '0';
1852 res *= neg;
1853 return res;
1854 }
1855
1856 static void set_default_appearance(RrAppearance *a)
1857 {
1858 a->surface.grad = RR_SURFACE_SOLID;
1859 a->surface.relief = RR_RELIEF_FLAT;
1860 a->surface.bevel = RR_BEVEL_1;
1861 a->surface.interlaced = FALSE;
1862 a->surface.border = FALSE;
1863 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1864 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
1865 }
1866
1867 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1868 an RrTextureRGBA. */
1869 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
1870 {
1871 RrPixel32 *im, *p;
1872 gint i;
1873
1874 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
1875
1876 for (i = 0; i < width * height; ++i) {
1877 guchar a = ((*p >> 24) & 0xff);
1878 guchar b = ((*p >> 16) & 0xff);
1879 guchar g = ((*p >> 8) & 0xff);
1880 guchar r = ((*p >> 0) & 0xff);
1881
1882 *p = ((r << RrDefaultRedOffset) +
1883 (g << RrDefaultGreenOffset) +
1884 (b << RrDefaultBlueOffset) +
1885 (a << RrDefaultAlphaOffset));
1886 p++;
1887 }
1888
1889 return im;
1890 }
This page took 0.131698 seconds and 3 git commands to generate.