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