move the themes
[dana/openbox.git] / engines / openbox / obtheme.c
1 #include "obengine.h"
2 #include "kernel/openbox.h"
3 #include "kernel/config.h"
4
5 #include <glib.h>
6 #include <X11/Xlib.h>
7 #include <X11/Xresource.h>
8 #ifdef HAVE_STDLIB_H
9 #  include <stdlib.h>
10 #endif
11 #ifdef HAVE_CTYPE_H
12 #  include <ctype.h>
13 #endif
14 #ifdef HAVE_STRING_H
15 #  include <string.h>
16 #endif
17
18 static XrmDatabase loaddb(char *theme)
19 {
20     XrmDatabase db;
21
22     db = XrmGetFileDatabase(theme);
23     if (db == NULL) {
24         char *s = g_build_filename(g_get_home_dir(), ".openbox", "themes",
25                                    "openbox", theme, NULL);
26         db = XrmGetFileDatabase(s);
27         g_free(s);
28     }
29     if (db == NULL) {
30         char *s = g_build_filename(THEMEDIR, theme, NULL);
31         db = XrmGetFileDatabase(s);
32         g_free(s);
33     }
34     return db;
35 }
36
37 static char *create_class_name(char *rname)
38 {
39     char *rclass = g_strdup(rname);
40     char *p = rclass;
41
42     while (TRUE) {
43         *p = toupper(*p);
44         p = strchr(p+1, '.');
45         if (p == NULL) break;
46         ++p;
47         if (*p == '\0') break;
48     }
49     return rclass;
50 }
51
52 static gboolean read_int(XrmDatabase db, char *rname, int *value)
53 {
54     gboolean ret = FALSE;
55     char *rclass = create_class_name(rname);
56     char *rettype, *end;
57     XrmValue retvalue;
58   
59     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
60         retvalue.addr != NULL) {
61         *value = (int)strtol(retvalue.addr, &end, 10);
62         if (end != retvalue.addr)
63             ret = TRUE;
64     }
65
66     g_free(rclass);
67     return ret;
68 }
69
70 static gboolean read_string(XrmDatabase db, char *rname, char **value)
71 {
72     gboolean ret = FALSE;
73     char *rclass = create_class_name(rname);
74     char *rettype;
75     XrmValue retvalue;
76   
77     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
78         retvalue.addr != NULL) {
79         *value = g_strdup(retvalue.addr);
80         ret = TRUE;
81     }
82
83     g_free(rclass);
84     return ret;
85 }
86
87 static gboolean read_color(XrmDatabase db, char *rname, color_rgb **value)
88 {
89     gboolean ret = FALSE;
90     char *rclass = create_class_name(rname);
91     char *rettype;
92     XrmValue retvalue;
93   
94     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
95         retvalue.addr != NULL) {
96         color_rgb *c = color_parse(retvalue.addr);
97         if (c != NULL) {
98             *value = c;
99             ret = TRUE;
100         }
101     }
102
103     g_free(rclass);
104     return ret;
105 }
106
107 static gboolean read_mask(XrmDatabase db, char *rname, pixmap_mask **value)
108 {
109     gboolean ret = FALSE;
110     char *rclass = create_class_name(rname);
111     char *rettype;
112     char *s;
113     char *button_dir;
114     XrmValue retvalue;
115     int hx, hy; /* ignored */
116     unsigned int w, h;
117     unsigned char *b;
118   
119     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
120         retvalue.addr != NULL) {
121
122         button_dir = g_strdup_printf("%s_buttons", config_engine_theme);
123
124         s = g_build_filename(g_get_home_dir(), ".openbox", "themes",
125                              "openbox", button_dir, retvalue.addr, NULL);
126
127         if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess)
128             ret = TRUE;
129         else {
130             g_free(s);
131             s = g_build_filename(THEMEDIR, button_dir, retvalue.addr, NULL);
132         
133             if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) 
134                 ret = TRUE;
135             else {
136                 char *themename;
137
138                 g_free(s);
139                 themename = g_path_get_basename(config_engine_theme);
140                 s = g_strdup_printf("%s/%s_buttons/%s", config_engine_theme,
141                                     themename, retvalue.addr);
142                 g_free(themename);
143                 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) ==
144                     BitmapSuccess) 
145                     ret = TRUE;
146                 else
147                     g_message("Unable to find bitmap '%s'", retvalue.addr);
148             }
149         }
150
151         if (ret) {
152             *value = pixmap_mask_new(w, h, (char*)b);
153             XFree(b);
154         }
155       
156         g_free(s);
157         g_free(button_dir);
158     }
159
160     g_free(rclass);
161     return ret;
162 }
163
164 static void parse_appearance(char *tex, SurfaceColorType *grad,
165                              ReliefType *relief, BevelType *bevel,
166                              gboolean *interlaced, gboolean *border)
167 {
168     char *t;
169
170     /* convert to all lowercase */
171     for (t = tex; *t != '\0'; ++t)
172         *t = g_ascii_tolower(*t);
173
174     if (strstr(tex, "parentrelative") != NULL) {
175         *grad = Background_ParentRelative;
176     } else {
177         if (strstr(tex, "gradient") != NULL) {
178             if (strstr(tex, "crossdiagonal") != NULL)
179                 *grad = Background_CrossDiagonal;
180             else if (strstr(tex, "rectangle") != NULL)
181                 *grad = Background_Rectangle;
182             else if (strstr(tex, "pyramid") != NULL)
183                 *grad = Background_Pyramid;
184             else if (strstr(tex, "pipecross") != NULL)
185                 *grad = Background_PipeCross;
186             else if (strstr(tex, "elliptic") != NULL)
187                 *grad = Background_Elliptic;
188             else if (strstr(tex, "horizontal") != NULL)
189                 *grad = Background_Horizontal;
190             else if (strstr(tex, "vertical") != NULL)
191                 *grad = Background_Vertical;
192             else
193                 *grad = Background_Diagonal;
194         } else {
195             *grad = Background_Solid;
196         }
197
198         if (strstr(tex, "sunken") != NULL)
199             *relief = Sunken;
200         else if (strstr(tex, "flat") != NULL)
201             *relief = Flat;
202         else
203             *relief = Raised;
204         
205         *border = FALSE;
206         if (*relief == Flat) {
207             if (strstr(tex, "border") != NULL)
208                 *border = TRUE;
209         } else {
210             if (strstr(tex, "bevel2") != NULL)
211                 *bevel = Bevel2;
212             else
213                 *bevel = Bevel1;
214         }
215
216         if (strstr(tex, "interlaced") != NULL)
217             *interlaced = TRUE;
218         else
219             *interlaced = FALSE;
220     }
221 }
222
223
224 static gboolean read_appearance(XrmDatabase db, char *rname, Appearance *value)
225 {
226     gboolean ret = FALSE;
227     char *rclass = create_class_name(rname), *cname, *ctoname, *bcname;
228     char *rettype;
229     XrmValue retvalue;
230
231     cname = g_strconcat(rname, ".color", NULL);
232     ctoname = g_strconcat(rname, ".colorTo", NULL);
233     bcname = g_strconcat(rname, ".borderColor", NULL);
234
235     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
236         retvalue.addr != NULL) {
237         parse_appearance(retvalue.addr,
238                          &value->surface.data.planar.grad,
239                          &value->surface.data.planar.relief,
240                          &value->surface.data.planar.bevel,
241                          &value->surface.data.planar.interlaced,
242                          &value->surface.data.planar.border);
243         if (!read_color(db, cname, &value->surface.data.planar.primary))
244             value->surface.data.planar.primary = color_new(0, 0, 0);
245         if (!read_color(db, ctoname, &value->surface.data.planar.secondary))
246             value->surface.data.planar.secondary = color_new(0, 0, 0);
247         if (value->surface.data.planar.border)
248             if (!read_color(db, bcname,
249                             &value->surface.data.planar.border_color))
250                 value->surface.data.planar.border_color = color_new(0, 0, 0);
251         ret = TRUE;
252     }
253
254     g_free(bcname);
255     g_free(ctoname);
256     g_free(cname);
257     g_free(rclass);
258     return ret;
259 }
260
261 static void set_default_appearance(Appearance *a)
262 {
263     a->surface.data.planar.grad = Background_Solid;
264     a->surface.data.planar.relief = Flat;
265     a->surface.data.planar.bevel = Bevel1;
266     a->surface.data.planar.interlaced = FALSE;
267     a->surface.data.planar.border = FALSE;
268     a->surface.data.planar.primary = color_new(0, 0, 0);
269     a->surface.data.planar.secondary = color_new(0, 0, 0);
270 }
271
272 gboolean obtheme_load()
273 {
274     XrmDatabase db = NULL;
275     Justify winjust;
276     char *winjuststr;
277
278     if (config_engine_theme) {
279         db = loaddb(config_engine_theme);
280         if (db == NULL) {
281             g_warning("Failed to load the theme '%s'", config_engine_theme);
282             g_message("Falling back to the default: '%s'", DEFAULT_THEME);
283         }
284     }
285     if (db == NULL) {
286         db = loaddb(DEFAULT_THEME);
287         if (db == NULL) {
288             g_warning("Failed to load the theme '%s'.", DEFAULT_THEME);
289             return FALSE;
290         }
291         /* set it to what was loaded */
292         g_free(config_engine_theme);
293         config_engine_theme = g_strdup(DEFAULT_THEME);
294     }
295
296     /* load the font, not from the theme file tho, its in the config */
297
298     ob_s_winfont = font_open(config_engine_font);
299     ob_s_winfont_height = font_height(ob_s_winfont, config_engine_shadow,
300                                       config_engine_shadow_offset);
301
302     winjust = Justify_Left;
303     if (read_string(db, "window.justify", &winjuststr)) {
304         if (!g_ascii_strcasecmp(winjuststr, "right"))
305             winjust = Justify_Right;
306         else if (!g_ascii_strcasecmp(winjuststr, "center"))
307             winjust = Justify_Center;
308         g_free(winjuststr);
309     }
310
311     if (!read_int(db, "handleWidth", &ob_s_handle_height) ||
312         ob_s_handle_height < 0 || ob_s_handle_height > 100)
313         ob_s_handle_height = 6;
314     if (!read_int(db, "bevelWidth", &ob_s_bevel) ||
315         ob_s_bevel <= 0 || ob_s_bevel > 100) ob_s_bevel = 3;
316     if (!read_int(db, "borderWidth", &ob_s_bwidth) ||
317         ob_s_bwidth < 0 || ob_s_bwidth > 100) ob_s_bwidth = 1;
318     if (!read_int(db, "frameWidth", &ob_s_cbwidth) ||
319         ob_s_cbwidth < 0 || ob_s_cbwidth > 100) ob_s_cbwidth = ob_s_bevel;
320
321     if (!read_color(db, "borderColor", &ob_s_b_color))
322         ob_s_b_color = color_new(0, 0, 0);
323     if (!read_color(db, "window.frame.focusColor", &ob_s_cb_focused_color))
324         ob_s_cb_focused_color = color_new(0xff, 0xff, 0xff);
325     if (!read_color(db, "window.frame.unfocusColor", &ob_s_cb_unfocused_color))
326         ob_s_cb_unfocused_color = color_new(0xff, 0xff, 0xff);
327     if (!read_color(db, "window.label.focus.textColor",
328                     &ob_s_title_focused_color))
329         ob_s_title_focused_color = color_new(0x0, 0x0, 0x0);
330     if (!read_color(db, "window.label.unfocus.textColor",
331                     &ob_s_title_unfocused_color))
332         ob_s_title_unfocused_color = color_new(0xff, 0xff, 0xff);
333     if (!read_color(db, "window.button.focus.picColor",
334                     &ob_s_titlebut_focused_color))
335         ob_s_titlebut_focused_color = color_new(0, 0, 0);
336     if (!read_color(db, "window.button.unfocus.picColor",
337                     &ob_s_titlebut_unfocused_color))
338         ob_s_titlebut_unfocused_color = color_new(0xff, 0xff, 0xff);
339
340     if (read_mask(db, "window.button.max.mask", &ob_s_max_unset_mask)) {
341         if (!read_mask(db, "window.button.max.toggled.mask",
342                        &ob_s_max_set_mask)) {
343             ob_s_max_set_mask = pixmap_mask_copy(ob_s_max_unset_mask);
344         }
345     } else {
346         {
347             char data[] = { 0x7f, 0x7f, 0x7f, 0x41, 0x41, 0x41, 0x7f };
348             ob_s_max_unset_mask = pixmap_mask_new(7, 7, data);
349         }
350         {
351             char data[] = { 0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
352             ob_s_max_set_mask = pixmap_mask_new(7, 7, data);
353         }
354     }
355
356     if (!read_mask(db, "window.button.icon.mask",
357                    &ob_s_iconify_mask)) {
358         char data[] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x7f };
359         ob_s_iconify_mask = pixmap_mask_new(7, 7, data);
360     }
361
362     if (read_mask(db, "window.button.stick.mask",
363                    &ob_s_desk_unset_mask)) {
364         if (!read_mask(db, "window.button.stick.toggled.mask",
365                        &ob_s_desk_set_mask)) {
366             ob_s_desk_set_mask =
367                 pixmap_mask_copy(ob_s_desk_unset_mask);
368         }
369     } else {
370         {
371             char data[] = { 0x63, 0x63, 0x00, 0x00, 0x00, 0x63, 0x63 };
372             ob_s_desk_unset_mask = pixmap_mask_new(7, 7, data);
373         }
374         {
375             char data[] = { 0x00, 0x36, 0x36, 0x08, 0x36, 0x36, 0x00 };
376             ob_s_desk_set_mask = pixmap_mask_new(7, 7, data);
377         }
378     }
379
380     if (read_mask(db, "window.button.shade.mask",
381                    &ob_s_shade_unset_mask)) {
382         if (!read_mask(db, "window.button.shade.toggled.mask",
383                        &ob_s_shade_set_mask)) {
384             ob_s_shade_set_mask =
385                 pixmap_mask_copy(ob_s_shade_unset_mask);
386         }
387     } else {
388         {
389             char data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00 };
390             ob_s_shade_unset_mask = pixmap_mask_new(7, 7, data);
391         }
392         {
393             char data[] = { 0x7f, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x7f };
394             ob_s_shade_set_mask = pixmap_mask_new(7, 7, data);
395         }
396     }
397
398     if (!read_mask(db, "window.button.close.mask",
399                    &ob_s_close_mask)) {
400         char data[] = { 0x63, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x63 };
401         ob_s_close_mask = pixmap_mask_new(7, 7, data);
402     }        
403
404     /* read the decoration textures */
405     if (!read_appearance(db, "window.title.focus", ob_a_focused_title))
406         set_default_appearance(ob_a_focused_title);
407     if (!read_appearance(db, "window.title.unfocus", ob_a_unfocused_title))
408         set_default_appearance(ob_a_unfocused_title);
409     if (!read_appearance(db, "window.label.focus", ob_a_focused_label))
410         set_default_appearance(ob_a_focused_label);
411     if (!read_appearance(db, "window.label.unfocus", ob_a_unfocused_label))
412         set_default_appearance(ob_a_unfocused_label);
413     if (!read_appearance(db, "window.handle.focus", ob_a_focused_handle))
414         set_default_appearance(ob_a_focused_handle);
415     if (!read_appearance(db, "window.handle.unfocus", ob_a_unfocused_handle))
416         set_default_appearance(ob_a_unfocused_handle);
417     if (!read_appearance(db, "window.grip.focus", ob_a_focused_grip))
418         set_default_appearance(ob_a_focused_grip);
419     if (!read_appearance(db, "window.grip.unfocus", ob_a_unfocused_grip))
420         set_default_appearance(ob_a_unfocused_grip);
421
422     /* read the appearances for rendering non-decorations. these cannot be
423        parent-relative */
424     if (ob_a_focused_label->surface.data.planar.grad !=
425         Background_ParentRelative) {
426         if (!read_appearance(db, "window.label.focus", ob_app_hilite_label))
427             set_default_appearance(ob_app_hilite_label);
428     } else {
429         if (!read_appearance(db, "window.title.focus", ob_app_hilite_label))
430             set_default_appearance(ob_app_hilite_label);
431     }
432     if (ob_a_unfocused_label->surface.data.planar.grad !=
433         Background_ParentRelative) {
434         if (!read_appearance(db, "window.label.unfocus",ob_app_unhilite_label))
435             set_default_appearance(ob_app_unhilite_label);
436     } else {
437         if (!read_appearance(db, "window.title.unfocus",ob_app_unhilite_label))
438             set_default_appearance(ob_app_unhilite_label);
439     }
440
441     /* read buttons textures */
442     if (!read_appearance(db, "window.button.pressed.focus",
443                          ob_a_focused_pressed_max))
444         if (!read_appearance(db, "window.button.pressed",
445                              ob_a_focused_pressed_max))
446             set_default_appearance(ob_a_focused_pressed_max);
447     if (!read_appearance(db, "window.button.pressed.unfocus",
448                          ob_a_unfocused_pressed_max))
449         if (!read_appearance(db, "window.button.pressed",
450                              ob_a_unfocused_pressed_max))
451             set_default_appearance(ob_a_unfocused_pressed_max);
452     if (!read_appearance(db, "window.button.focus",
453                          ob_a_focused_unpressed_max))
454         set_default_appearance(ob_a_focused_unpressed_max);
455     if (!read_appearance(db, "window.button.unfocus",
456                          ob_a_unfocused_unpressed_max))
457         set_default_appearance(ob_a_unfocused_unpressed_max);
458
459     ob_a_unfocused_unpressed_close =
460         appearance_copy(ob_a_unfocused_unpressed_max);
461     ob_a_unfocused_pressed_close = appearance_copy(ob_a_unfocused_pressed_max);
462     ob_a_focused_unpressed_close = appearance_copy(ob_a_focused_unpressed_max);
463     ob_a_focused_pressed_close = appearance_copy(ob_a_focused_pressed_max);
464     ob_a_unfocused_unpressed_desk =
465         appearance_copy(ob_a_unfocused_unpressed_max);
466     ob_a_unfocused_pressed_desk = appearance_copy(ob_a_unfocused_pressed_max);
467     ob_a_unfocused_pressed_set_desk =
468         appearance_copy(ob_a_unfocused_pressed_max);
469     ob_a_focused_unpressed_desk = appearance_copy(ob_a_focused_unpressed_max);
470     ob_a_focused_pressed_desk = appearance_copy(ob_a_focused_pressed_max);
471     ob_a_focused_pressed_set_desk = appearance_copy(ob_a_focused_pressed_max);
472     ob_a_unfocused_unpressed_shade =
473         appearance_copy(ob_a_unfocused_unpressed_max);
474     ob_a_unfocused_pressed_shade = appearance_copy(ob_a_unfocused_pressed_max);
475     ob_a_unfocused_pressed_set_shade =
476         appearance_copy(ob_a_unfocused_pressed_max);
477     ob_a_focused_unpressed_shade = appearance_copy(ob_a_focused_unpressed_max);
478     ob_a_focused_pressed_shade = appearance_copy(ob_a_focused_pressed_max);
479     ob_a_focused_pressed_set_shade = appearance_copy(ob_a_focused_pressed_max);
480     ob_a_unfocused_unpressed_iconify =
481         appearance_copy(ob_a_unfocused_unpressed_max);
482     ob_a_unfocused_pressed_iconify =
483         appearance_copy(ob_a_unfocused_pressed_max);
484     ob_a_focused_unpressed_iconify =
485         appearance_copy(ob_a_focused_unpressed_max);
486     ob_a_focused_pressed_iconify = appearance_copy(ob_a_focused_pressed_max);
487     ob_a_unfocused_pressed_set_max =
488         appearance_copy(ob_a_unfocused_pressed_max);
489     ob_a_focused_pressed_set_max = appearance_copy(ob_a_focused_pressed_max);
490
491     ob_a_icon->surface.data.planar.grad = Background_ParentRelative;
492
493     /* set up the textures */
494     ob_a_focused_label->texture[0].type = Text;
495     ob_a_focused_label->texture[0].data.text.justify = winjust;
496     ob_a_focused_label->texture[0].data.text.font = ob_s_winfont;
497     ob_a_focused_label->texture[0].data.text.shadow = config_engine_shadow;
498     ob_a_focused_label->texture[0].data.text.offset =
499         config_engine_shadow_offset;
500     ob_a_focused_label->texture[0].data.text.tint = config_engine_shadow_tint;
501     ob_a_focused_label->texture[0].data.text.color = ob_s_title_focused_color;
502     ob_app_hilite_label->texture[0].type = Text;
503     ob_app_hilite_label->texture[0].data.text.justify = winjust;
504     ob_app_hilite_label->texture[0].data.text.font = ob_s_winfont;
505     ob_app_hilite_label->texture[0].data.text.shadow = config_engine_shadow;
506     ob_app_hilite_label->texture[0].data.text.offset =
507         config_engine_shadow_offset;
508     ob_app_hilite_label->texture[0].data.text.tint = config_engine_shadow_tint;
509     ob_app_hilite_label->texture[0].data.text.color = ob_s_title_focused_color;
510
511     ob_a_unfocused_label->texture[0].type = Text;
512     ob_a_unfocused_label->texture[0].data.text.justify = winjust;
513     ob_a_unfocused_label->texture[0].data.text.font = ob_s_winfont;
514     ob_a_unfocused_label->texture[0].data.text.shadow = config_engine_shadow;
515     ob_a_unfocused_label->texture[0].data.text.offset =
516         config_engine_shadow_offset;
517     ob_a_unfocused_label->texture[0].data.text.tint =config_engine_shadow_tint;
518     ob_a_unfocused_label->texture[0].data.text.color =
519         ob_s_title_unfocused_color;
520     ob_app_unhilite_label->texture[0].type = Text;
521     ob_app_unhilite_label->texture[0].data.text.justify = winjust;
522     ob_app_unhilite_label->texture[0].data.text.font = ob_s_winfont;
523     ob_app_unhilite_label->texture[0].data.text.shadow = config_engine_shadow;
524     ob_app_unhilite_label->texture[0].data.text.offset =
525         config_engine_shadow_offset;
526     ob_app_unhilite_label->texture[0].data.text.tint =
527         config_engine_shadow_tint;
528     ob_app_unhilite_label->texture[0].data.text.color =
529         ob_s_title_unfocused_color;
530
531     ob_a_focused_unpressed_max->texture[0].type = 
532         ob_a_focused_pressed_max->texture[0].type = 
533         ob_a_focused_pressed_set_max->texture[0].type =  
534         ob_a_unfocused_unpressed_max->texture[0].type = 
535         ob_a_unfocused_pressed_max->texture[0].type = 
536         ob_a_unfocused_pressed_set_max->texture[0].type = 
537         ob_a_focused_unpressed_close->texture[0].type = 
538         ob_a_focused_pressed_close->texture[0].type = 
539         ob_a_unfocused_unpressed_close->texture[0].type = 
540         ob_a_unfocused_pressed_close->texture[0].type = 
541         ob_a_focused_unpressed_desk->texture[0].type = 
542         ob_a_focused_pressed_desk->texture[0].type = 
543         ob_a_focused_pressed_set_desk->texture[0].type = 
544         ob_a_unfocused_unpressed_desk->texture[0].type = 
545         ob_a_unfocused_pressed_desk->texture[0].type = 
546         ob_a_unfocused_pressed_set_desk->texture[0].type = 
547         ob_a_focused_unpressed_shade->texture[0].type = 
548         ob_a_focused_pressed_shade->texture[0].type = 
549         ob_a_focused_pressed_set_shade->texture[0].type = 
550         ob_a_unfocused_unpressed_shade->texture[0].type = 
551         ob_a_unfocused_pressed_shade->texture[0].type = 
552         ob_a_unfocused_pressed_set_shade->texture[0].type = 
553         ob_a_focused_unpressed_iconify->texture[0].type = 
554         ob_a_focused_pressed_iconify->texture[0].type = 
555         ob_a_unfocused_unpressed_iconify->texture[0].type = 
556         ob_a_unfocused_pressed_iconify->texture[0].type = Bitmask;
557     ob_a_focused_unpressed_max->texture[0].data.mask.mask = 
558         ob_a_unfocused_unpressed_max->texture[0].data.mask.mask = 
559         ob_a_focused_pressed_max->texture[0].data.mask.mask = 
560         ob_a_unfocused_pressed_max->texture[0].data.mask.mask =
561         ob_s_max_unset_mask;
562     ob_a_focused_pressed_set_max->texture[0].data.mask.mask = 
563         ob_a_unfocused_pressed_set_max->texture[0].data.mask.mask =
564         ob_s_max_set_mask;
565     ob_a_focused_pressed_close->texture[0].data.mask.mask = 
566         ob_a_unfocused_pressed_close->texture[0].data.mask.mask =
567         ob_a_focused_unpressed_close->texture[0].data.mask.mask = 
568         ob_a_unfocused_unpressed_close->texture[0].data.mask.mask =
569         ob_s_close_mask;
570     ob_a_focused_unpressed_desk->texture[0].data.mask.mask = 
571         ob_a_unfocused_unpressed_desk->texture[0].data.mask.mask = 
572         ob_a_focused_pressed_desk->texture[0].data.mask.mask = 
573         ob_a_unfocused_pressed_desk->texture[0].data.mask.mask =
574         ob_s_desk_unset_mask;
575     ob_a_focused_pressed_set_desk->texture[0].data.mask.mask = 
576         ob_a_unfocused_pressed_set_desk->texture[0].data.mask.mask =
577         ob_s_desk_set_mask;
578     ob_a_focused_unpressed_shade->texture[0].data.mask.mask = 
579         ob_a_unfocused_unpressed_shade->texture[0].data.mask.mask = 
580         ob_a_focused_pressed_shade->texture[0].data.mask.mask = 
581         ob_a_unfocused_pressed_shade->texture[0].data.mask.mask =
582         ob_s_shade_unset_mask;
583     ob_a_focused_pressed_set_shade->texture[0].data.mask.mask = 
584         ob_a_unfocused_pressed_set_shade->texture[0].data.mask.mask =
585         ob_s_shade_set_mask;
586     ob_a_focused_unpressed_iconify->texture[0].data.mask.mask = 
587         ob_a_unfocused_unpressed_iconify->texture[0].data.mask.mask = 
588         ob_a_focused_pressed_iconify->texture[0].data.mask.mask = 
589         ob_a_unfocused_pressed_iconify->texture[0].data.mask.mask =
590         ob_s_iconify_mask;
591     ob_a_focused_unpressed_max->texture[0].data.mask.color = 
592         ob_a_focused_pressed_max->texture[0].data.mask.color = 
593         ob_a_focused_pressed_set_max->texture[0].data.mask.color = 
594         ob_a_focused_unpressed_close->texture[0].data.mask.color = 
595         ob_a_focused_pressed_close->texture[0].data.mask.color = 
596         ob_a_focused_unpressed_desk->texture[0].data.mask.color = 
597         ob_a_focused_pressed_desk->texture[0].data.mask.color = 
598         ob_a_focused_pressed_set_desk->texture[0].data.mask.color = 
599         ob_a_focused_unpressed_shade->texture[0].data.mask.color = 
600         ob_a_focused_pressed_shade->texture[0].data.mask.color = 
601         ob_a_focused_pressed_set_shade->texture[0].data.mask.color = 
602         ob_a_focused_unpressed_iconify->texture[0].data.mask.color = 
603         ob_a_focused_pressed_iconify->texture[0].data.mask.color =
604         ob_s_titlebut_focused_color;
605     ob_a_unfocused_unpressed_max->texture[0].data.mask.color = 
606         ob_a_unfocused_pressed_max->texture[0].data.mask.color = 
607         ob_a_unfocused_pressed_set_max->texture[0].data.mask.color = 
608         ob_a_unfocused_unpressed_close->texture[0].data.mask.color = 
609         ob_a_unfocused_pressed_close->texture[0].data.mask.color = 
610         ob_a_unfocused_unpressed_desk->texture[0].data.mask.color = 
611         ob_a_unfocused_pressed_desk->texture[0].data.mask.color = 
612         ob_a_unfocused_pressed_set_desk->texture[0].data.mask.color = 
613         ob_a_unfocused_unpressed_shade->texture[0].data.mask.color = 
614         ob_a_unfocused_pressed_shade->texture[0].data.mask.color = 
615         ob_a_unfocused_pressed_set_shade->texture[0].data.mask.color = 
616         ob_a_unfocused_unpressed_iconify->texture[0].data.mask.color = 
617         ob_a_unfocused_pressed_iconify->texture[0].data.mask.color =
618         ob_s_titlebut_unfocused_color;
619
620     XrmDestroyDatabase(db);
621     return TRUE;
622 }
623
624