fix overflow bug, try2
[wmaker-crm.git] / WPrefs.app / Appearance.c
blob1db9b4fcc4fcb1d7ebb5ff847d408dac26c29abe
1 /* Apperance.c- color/texture for titlebar etc.
2 *
3 * WPrefs - Window Maker Preferences Program
4 *
5 * Copyright (c) 1999-2002 Alfredo K. Kojima
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.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 * USA.
24 #include "WPrefs.h"
26 #include <unistd.h>
27 #include <errno.h>
28 #include <ctype.h>
29 #include <time.h>
30 #include <sys/stat.h>
31 #include <sys/types.h>
32 #include <fcntl.h>
33 #include <unistd.h>
38 #include "TexturePanel.h"
40 typedef struct _Panel {
41 WMBox *box;
42 char *sectionName;
44 char *description;
46 CallbackRec callbacks;
48 WMWidget *parent;
50 WMLabel *prevL;
53 WMTabView *tabv;
55 /* texture list */
56 WMFrame *texF;
57 WMList *texLs;
59 WMPopUpButton *secP;
61 WMButton *newB;
62 WMButton *editB;
63 WMButton *ripB;
64 WMButton *delB;
66 /* text color */
67 WMFrame *colF;
69 WMPopUpButton *colP;
70 WMColor *colors[14];
72 WMColorWell *colW;
74 WMColorWell *sampW[24];
76 /* options */
77 WMFrame *optF;
79 WMFrame *mstyF;
80 WMButton *mstyB[3];
82 WMFrame *taliF;
83 WMButton *taliB[3];
85 /* root bg */
86 WMFrame *bgF;
88 WMLabel *bgprevL;
89 WMButton *selbgB;
91 WMPopUpButton *modeB[3];
93 /* */
95 int textureIndex[8];
97 WMFont *smallFont;
98 WMFont *normalFont;
99 WMFont *boldFont;
101 TexturePanel *texturePanel;
103 WMPixmap *onLed;
104 WMPixmap *offLed;
105 WMPixmap *hand;
107 int oldsection;
108 int oldcsection;
110 char oldTabItem;
112 char menuStyle;
114 char titleAlignment;
116 Pixmap preview;
118 char *fprefix;
119 } _Panel;
122 typedef struct {
123 char *title;
124 char *texture;
125 WMPropList *prop;
126 Pixmap preview;
128 char *path;
130 char selectedFor;
131 unsigned current:1;
132 unsigned ispixmap:1;
133 } TextureListItem;
135 static void updateColorPreviewBox(_Panel *panel, int elements);
137 static void showData(_Panel *panel);
139 static void changePage(WMWidget *w, void *data);
141 static void changeColorPage(WMWidget *w, void *data);
143 static void OpenExtractPanelFor(_Panel *panel, char *path);
147 static void changedTabItem(struct WMTabViewDelegate *self, WMTabView *tabView,
148 WMTabViewItem *item);
152 static WMTabViewDelegate tabviewDelegate = {
153 NULL,
154 NULL, /* didChangeNumberOfItems */
155 changedTabItem, /* didSelectItem */
156 NULL, /* shouldSelectItem */
157 NULL /* willSelectItem */
161 #define ICON_FILE "appearance"
163 #define TNEW_FILE "tnew"
164 #define TDEL_FILE "tdel"
165 #define TEDIT_FILE "tedit"
166 #define TEXTR_FILE "textr"
168 #define MSTYLE1_FILE "msty1"
169 #define MSTYLE2_FILE "msty2"
170 #define MSTYLE3_FILE "msty3"
173 /* XPM */
174 static char * blueled_xpm[] = {
175 "8 8 17 1",
176 " c None",
177 ". c #020204",
178 "+ c #16B6FC",
179 "@ c #176AFC",
180 "# c #163AFC",
181 "$ c #72D2FC",
182 "% c #224CF4",
183 "& c #76D6FC",
184 "* c #16AAFC",
185 "= c #CEE9FC",
186 "- c #229EFC",
187 "; c #164CFC",
188 "> c #FAFEFC",
189 ", c #2482FC",
190 "' c #1652FC",
191 ") c #1E76FC",
192 "! c #1A60FC",
193 " .... ",
194 " .=>-@. ",
195 ".=>$@@'.",
196 ".=$@!;;.",
197 ".!@*+!#.",
198 ".#'*+*,.",
199 " .@)@,. ",
200 " .... "};
203 /* XPM */
204 static char *blueled2_xpm[] = {
205 /* width height num_colors chars_per_pixel */
206 " 8 8 17 1",
207 /* colors */
208 ". c None",
209 "# c #090909",
210 "a c #4b63a4",
211 "b c #011578",
212 "c c #264194",
213 "d c #04338c",
214 "e c #989dac",
215 "f c #011a7c",
216 "g c #465c9c",
217 "h c #03278a",
218 "i c #6175ac",
219 "j c #011e74",
220 "k c #043a90",
221 "l c #042f94",
222 "m c #0933a4",
223 "n c #022184",
224 "o c #012998",
225 /* pixels */
226 "..####..",
227 ".#aimn#.",
228 "#aechnf#",
229 "#gchnjf#",
230 "#jndknb#",
231 "#bjdddl#",
232 ".#nono#.",
233 "..####.."
237 /* XPM */
238 static char * hand_xpm[] = {
239 "22 21 19 1",
240 " c None",
241 ". c #030305",
242 "+ c #7F7F7E",
243 "@ c #B5B5B6",
244 "# c #C5C5C6",
245 "$ c #969697",
246 "% c #FDFDFB",
247 "& c #F2F2F4",
248 "* c #E5E5E4",
249 "= c #ECECEC",
250 "- c #DCDCDC",
251 "; c #D2D2D0",
252 "> c #101010",
253 ", c #767674",
254 "' c #676767",
255 ") c #535355",
256 "! c #323234",
257 "~ c #3E3C56",
258 "{ c #333147",
259 " ",
260 " ..... ",
261 " ..+@##$. ",
262 " .%%%&@.......... ",
263 " .%*%%&#%%%%%%%%%$. ",
264 " .*#%%%%%%%%%&&&&==. ",
265 " .-%%%%%%%%%=*-;;;#$. ",
266 " .-%%%%%%%%&..>..... ",
267 " >-%%%%%%%%%*#+. ",
268 " >-%%%%%%%%%*@,. ",
269 " >#%%%%%%%%%*@'. ",
270 " >$&&%%%%%%=... ",
271 " .+@@;=&%%&;$,> ",
272 " .',$@####$+). ",
273 " .!',+$++,'. ",
274 " ..>>>>>. ",
275 " ",
276 " ~~{{{~~ ",
277 " {{{{{{{{{{{ ",
278 " ~~{{{~~ ",
279 " "};
283 static char *sampleColors[] = {
284 "black",
285 "#292929",
286 "#525252",
287 "#848484",
288 "#adadad",
289 "#d6d6d6",
290 "white",
291 "#d6d68c",
292 "#d6a57b",
293 "#8cd68c",
294 "#8cd6ce",
295 "#d68c8c",
296 "#8c9cd6",
297 "#bd86d6",
298 "#d68cbd",
299 "#d64a4a",
300 "#4a5ad6",
301 "#4ad6ce",
302 "#4ad65a",
303 "#ced64a",
304 "#d6844a",
305 "#8ad631",
306 "#ce29c6",
307 "#ce2973",
308 "black"
312 static char *textureOptions[] = {
313 "FTitleBack", "(solid, black)", "[Focused]",
314 "UTitleBack", "(solid, gray)", "[Unfocused]",
315 "PTitleBack", "(solid, \"#616161\")", "[Owner of Focused]",
316 "ResizebarBack", "(solid, gray)", "[Resizebar]",
317 "MenuTitleBack", "(solid, black)", "[Menu Title]",
318 "MenuTextBack", "(solid, gray)", "[Menu Item]",
319 "IconBack", "(solid, gray)", "[Icon]"
323 #define RESIZEBAR_BEVEL -1
324 #define MENU_BEVEL -2
326 #define TEXPREV_WIDTH 40
327 #define TEXPREV_HEIGHT 24
330 #define MSTYLE_NORMAL 0
331 #define MSTYLE_SINGLE 1
332 #define MSTYLE_FLAT 2
335 #define FTITLE_COL (1<<0)
336 #define UTITLE_COL (1<<1)
337 #define OTITLE_COL (1<<2)
338 #define MTITLE_COL (1<<3)
339 #define MITEM_COL (1<<4)
340 #define MDISAB_COL (1<<5)
341 #define MHIGH_COL (1<<6)
342 #define MHIGHT_COL (1<<7)
343 #define ICONT_COL (1<<8)
344 #define ICONB_COL (1<<9)
345 #define CLIP_COL (1<<10)
346 #define CCLIP_COL (1<<11)
349 static char *colorOptions[] = {
350 "FTitleColor", "white",
351 "UTitleColor", "black",
352 "PTitleColor", "white",
353 "MenuTitleColor", "white",
354 "MenuTextColor", "black",
355 "MenuDisabledColor", "#616161",
356 "HighlightColor", "white",
357 "HighlightTextColor", "black",
358 "IconTitleColor", "white",
359 "IconTitleBack", "black",
360 "ClipTitleColor", "black",
361 "CClipTitleColor", "#454045"
367 static WMRect previewPositions[] = {
368 #define PFOCUSED 0
369 {{30,10},{190, 20}},
370 #define PUNFOCUSED 1
371 {{30,40},{190,20}},
372 #define POWNER 2
373 {{30,70},{190,20}},
374 #define PRESIZEBAR 3
375 {{30,100},{190,9}},
376 #define PMTITLE 4
377 {{30,120},{90,20}},
378 #define PMITEM 5
379 {{30,140},{90,20*4}},
380 #define PICON 6
381 {{155,130},{64,64}}
383 #define EVERYTHING 0xff
386 static WMRect previewColorPositions[] = {
387 {{30,10},{190, 20}},
388 {{30,40},{190,20}},
389 {{30,70},{190,20}},
390 {{30,120},{90,20}},
391 {{30,140},{90,20}},
392 {{30,160},{90,20}},
393 {{30,180},{90,20}},
394 {{30,200},{90,20}},
395 {{155,130},{64,64}},
396 {{155,130},{64,64}},
397 {{155,130},{64,64}},
398 {{155,130},{64,64}}
403 static void
404 str2rcolor(RContext *rc, char *name, RColor *color)
406 XColor xcolor;
408 XParseColor(rc->dpy, rc->cmap, name, &xcolor);
410 color->alpha = 255;
411 color->red = xcolor.red >> 8;
412 color->green = xcolor.green >> 8;
413 color->blue = xcolor.blue >> 8;
417 static void
418 dumpRImage(char *path, RImage *image)
420 FILE *f;
421 int channels = (image->format == RRGBAFormat ? 4 : 3);
423 f = fopen(path, "wb");
424 if (!f) {
425 wsyserror(path);
426 return;
428 fprintf(f, "%02x%02x%1x", image->width, image->height, channels);
430 fwrite(image->data, 1, image->width * image->height * channels, f);
432 if (fclose(f) < 0) {
433 wsyserror(path);
439 static int
440 isPixmap(WMPropList *prop)
442 WMPropList *p;
443 char *s;
445 p = WMGetFromPLArray(prop, 0);
446 s = WMGetFromPLString(p);
447 if (strcasecmp(&s[1], "pixmap")==0)
448 return 1;
449 else
450 return 0;
454 /**********************************************************************/
456 static void
457 drawResizebarBevel(RImage *img)
459 RColor light;
460 RColor dark;
461 RColor black;
462 int width = img->width;
463 int height = img->height;
464 int cwidth = 28;
466 black.alpha = 255;
467 black.red = black.green = black.blue = 0;
469 light.alpha = 0;
470 light.red = light.green = light.blue = 80;
472 dark.alpha = 0;
473 dark.red = dark.green = dark.blue = 40;
475 ROperateLine(img, RSubtractOperation, 0, 0, width-1, 0, &dark);
476 ROperateLine(img, RAddOperation, 0, 1, width-1, 1, &light);
478 ROperateLine(img, RSubtractOperation, cwidth, 2, cwidth, height-1, &dark);
479 ROperateLine(img, RAddOperation, cwidth+1, 2, cwidth+1, height-1, &light);
481 ROperateLine(img, RSubtractOperation, width-cwidth-2, 2, width-cwidth-2,
482 height-1, &dark);
483 ROperateLine(img, RAddOperation, width-cwidth-1, 2, width-cwidth-1,
484 height-1, &light);
486 RDrawLine(img, 0, height-1, width-1, height-1, &black);
487 RDrawLine(img, 0, 0, 0, height-1, &black);
488 RDrawLine(img, width-1, 0, width-1, height-1, &black);
492 static void
493 drawMenuBevel(RImage *img)
495 RColor light, dark, mid;
496 int i;
497 int iheight = img->height / 4;
499 light.alpha = 0;
500 light.red = light.green = light.blue = 80;
502 dark.alpha = 255;
503 dark.red = dark.green = dark.blue = 0;
505 mid.alpha = 0;
506 mid.red = mid.green = mid.blue = 40;
508 for (i = 1; i < 4; i++) {
509 ROperateLine(img, RSubtractOperation, 0, i*iheight-2,
510 img->width-1, i*iheight-2, &mid);
512 RDrawLine(img, 0, i*iheight-1, img->width-1, i*iheight-1, &dark);
514 ROperateLine(img, RAddOperation, 1, i*iheight,
515 img->width-2, i*iheight, &light);
520 static Pixmap
521 renderTexture(WMScreen *scr, WMPropList *texture, int width, int height,
522 char *path, int border)
524 char *type;
525 RImage *image = NULL;
526 Pixmap pixmap;
527 RContext *rc = WMScreenRContext(scr);
528 char *str;
529 RColor rcolor;
532 type = WMGetFromPLString(WMGetFromPLArray(texture, 0));
534 if (strcasecmp(type, "solid")==0) {
536 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
538 str2rcolor(rc, str, &rcolor);
540 image = RCreateImage(width, height, False);
541 RClearImage(image, &rcolor);
542 } else if (strcasecmp(type, "igradient")==0) {
543 int t1, t2;
544 RColor c1[2], c2[2];
546 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
547 str2rcolor(rc, str, &c1[0]);
548 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
549 str2rcolor(rc, str, &c1[1]);
550 str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
551 t1 = atoi(str);
553 str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
554 str2rcolor(rc, str, &c2[0]);
555 str = WMGetFromPLString(WMGetFromPLArray(texture, 5));
556 str2rcolor(rc, str, &c2[1]);
557 str = WMGetFromPLString(WMGetFromPLArray(texture, 6));
558 t2 = atoi(str);
560 image = RRenderInterwovenGradient(width, height, c1, t1, c2, t2);
561 } else if (strcasecmp(&type[1], "gradient")==0) {
562 int style;
563 RColor rcolor2;
565 switch (toupper(type[0])) {
566 case 'V':
567 style = RVerticalGradient;
568 break;
569 case 'H':
570 style = RHorizontalGradient;
571 break;
572 default:
573 case 'D':
574 style = RDiagonalGradient;
575 break;
578 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
579 str2rcolor(rc, str, &rcolor);
580 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
581 str2rcolor(rc, str, &rcolor2);
583 image = RRenderGradient(width, height, &rcolor, &rcolor2, style);
584 } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='T') {
585 int style;
586 RColor rcolor2;
587 int i;
588 RImage *grad, *timage;
589 char *path;
591 switch (toupper(type[1])) {
592 case 'V':
593 style = RVerticalGradient;
594 break;
595 case 'H':
596 style = RHorizontalGradient;
597 break;
598 default:
599 case 'D':
600 style = RDiagonalGradient;
601 break;
604 str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
605 str2rcolor(rc, str, &rcolor);
606 str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
607 str2rcolor(rc, str, &rcolor2);
609 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
611 if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL)
612 timage = RLoadImage(rc, path, 0);
614 if (!path || !timage) {
615 wwarning("could not load file '%s': %s", path,
616 RMessageForError(RErrorCode));
617 } else {
618 grad = RRenderGradient(width, height, &rcolor, &rcolor2, style);
620 image = RMakeTiledImage(timage, width, height);
621 RReleaseImage(timage);
623 i = atoi(WMGetFromPLString(WMGetFromPLArray(texture, 2)));
625 RCombineImagesWithOpaqueness(image, grad, i);
626 RReleaseImage(grad);
628 } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='M') {
629 int style;
630 RColor **colors;
631 int i, j;
633 switch (toupper(type[1])) {
634 case 'V':
635 style = RVerticalGradient;
636 break;
637 case 'H':
638 style = RHorizontalGradient;
639 break;
640 default:
641 case 'D':
642 style = RDiagonalGradient;
643 break;
646 j = WMGetPropListItemCount(texture);
648 if (j > 0) {
649 colors = wmalloc(j * sizeof(RColor*));
651 for (i = 2; i < j; i++) {
652 str = WMGetFromPLString(WMGetFromPLArray(texture, i));
653 colors[i-2] = wmalloc(sizeof(RColor));
654 str2rcolor(rc, str, colors[i-2]);
656 colors[i-2] = NULL;
658 image = RRenderMultiGradient(width, height, colors, style);
660 for (i = 0; colors[i]!=NULL; i++)
661 wfree(colors[i]);
662 wfree(colors);
664 } else if (strcasecmp(&type[1], "pixmap")==0) {
665 RImage *timage = NULL;
666 char *path;
667 RColor color;
669 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
671 if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL)
672 timage = RLoadImage(rc, path, 0);
674 if (!path || !timage) {
675 wwarning("could not load file '%s': %s", path ? path : str,
676 RMessageForError(RErrorCode));
677 } else {
678 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
679 str2rcolor(rc, str, &color);
681 switch (toupper(type[0])) {
682 case 'T':
683 image = RMakeTiledImage(timage, width, height);
684 RReleaseImage(timage);
685 timage = image;
686 break;
687 case 'C':
688 image = RMakeCenteredImage(timage, width, height, &color);
689 RReleaseImage(timage);
690 timage = image;
691 break;
692 case 'S':
693 case 'M':
694 image = RScaleImage(timage, width, height);
695 RReleaseImage(timage);
696 timage = image;
697 break;
701 wfree(path);
704 if (!image)
705 return None;
707 if (path) {
708 dumpRImage(path, image);
711 if (border < 0) {
712 if (border == RESIZEBAR_BEVEL) {
713 drawResizebarBevel(image);
714 } else if (border == MENU_BEVEL) {
715 drawMenuBevel(image);
716 RBevelImage(image, RBEV_RAISED2);
718 } else if (border) {
719 RBevelImage(image, border);
722 RConvertImage(rc, image, &pixmap);
723 RReleaseImage(image);
725 return pixmap;
729 static Pixmap
730 renderMenu(_Panel *panel, WMPropList *texture, int width, int iheight)
732 WMScreen *scr = WMWidgetScreen(panel->parent);
733 Display *dpy = WMScreenDisplay(scr);
734 Pixmap pix, tmp;
735 GC gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
736 int i;
738 switch (panel->menuStyle) {
739 case MSTYLE_NORMAL:
740 tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2);
742 pix = XCreatePixmap(dpy, tmp, width, iheight*4, WMScreenDepth(scr));
743 for (i = 0; i < 4; i++) {
744 XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight, 0, iheight*i);
746 XFreePixmap(dpy, tmp);
747 break;
748 case MSTYLE_SINGLE:
749 pix = renderTexture(scr, texture, width, iheight*4, NULL, MENU_BEVEL);
750 break;
751 case MSTYLE_FLAT:
752 pix = renderTexture(scr, texture, width, iheight*4, NULL, RBEV_RAISED2);
753 break;
755 XFreeGC(dpy, gc);
757 return pix;
761 static void
762 renderPreview(_Panel *panel, GC gc, int part, int relief)
764 WMListItem *item;
765 TextureListItem *titem;
766 Pixmap pix;
767 WMScreen *scr = WMWidgetScreen(panel->box);
769 item = WMGetListItem(panel->texLs, panel->textureIndex[part]);
770 titem = (TextureListItem*)item->clientData;
772 pix = renderTexture(scr, titem->prop,
773 previewPositions[part].size.width,
774 previewPositions[part].size.height,
775 NULL, relief);
777 XCopyArea(WMScreenDisplay(scr), pix, panel->preview, gc, 0, 0,
778 previewPositions[part].size.width,
779 previewPositions[part].size.height,
780 previewPositions[part].pos.x,
781 previewPositions[part].pos.y);
783 XFreePixmap(WMScreenDisplay(scr), pix);
787 static void
788 updatePreviewBox(_Panel *panel, int elements)
790 WMScreen *scr = WMWidgetScreen(panel->parent);
791 Display *dpy = WMScreenDisplay(scr);
792 /* RContext *rc = WMScreenRContext(scr);*/
793 int refresh = 0;
794 Pixmap pix;
795 GC gc;
796 int colorUpdate = 0;
797 WMColor *black = WMBlackColor(scr);
799 gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
802 if (panel->preview == None) {
803 WMColor *color;
805 panel->preview = XCreatePixmap(dpy, WMWidgetXID(panel->parent),
806 240-4, 215-4, WMScreenDepth(scr));
808 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
809 XFillRectangle(dpy, panel->preview, WMColorGC(color),
810 0, 0, 240-4, 215-4);
811 WMReleaseColor(color);
813 refresh = -1;
817 if (elements & (1<<PFOCUSED)) {
818 renderPreview(panel, gc, PFOCUSED, RBEV_RAISED2);
819 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
820 previewPositions[PFOCUSED].pos.x-1,
821 previewPositions[PFOCUSED].pos.y-1,
822 previewPositions[PFOCUSED].size.width,
823 previewPositions[PFOCUSED].size.height);
824 colorUpdate |= FTITLE_COL;
826 if (elements & (1<<PUNFOCUSED)) {
827 renderPreview(panel, gc, PUNFOCUSED, RBEV_RAISED2);
828 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
829 previewPositions[PUNFOCUSED].pos.x-1,
830 previewPositions[PUNFOCUSED].pos.y-1,
831 previewPositions[PUNFOCUSED].size.width,
832 previewPositions[PUNFOCUSED].size.height);
833 colorUpdate |= UTITLE_COL;
835 if (elements & (1<<POWNER)) {
836 renderPreview(panel, gc, POWNER, RBEV_RAISED2);
837 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
838 previewPositions[POWNER].pos.x-1,
839 previewPositions[POWNER].pos.y-1,
840 previewPositions[POWNER].size.width,
841 previewPositions[POWNER].size.height);
842 colorUpdate |= OTITLE_COL;
844 if (elements & (1<<PRESIZEBAR)) {
845 renderPreview(panel, gc, PRESIZEBAR, RESIZEBAR_BEVEL);
847 if (elements & (1<<PMTITLE)) {
848 renderPreview(panel, gc, PMTITLE, RBEV_RAISED2);
849 colorUpdate |= MTITLE_COL;
851 if (elements & (1<<PMITEM)) {
852 WMListItem *item;
853 TextureListItem *titem;
855 item = WMGetListItem(panel->texLs, panel->textureIndex[5]);
856 titem = (TextureListItem*)item->clientData;
858 pix = renderMenu(panel, titem->prop,
859 previewPositions[PMITEM].size.width,
860 previewPositions[PMITEM].size.height/4);
862 XCopyArea(dpy, pix, panel->preview, gc, 0, 0,
863 previewPositions[PMITEM].size.width,
864 previewPositions[PMITEM].size.height,
865 previewPositions[PMITEM].pos.x,
866 previewPositions[PMITEM].pos.y);
868 XFreePixmap(dpy, pix);
870 colorUpdate |= MITEM_COL|MDISAB_COL|MHIGH_COL|MHIGHT_COL;
872 if (elements & (1<<PMITEM|1<<PMTITLE)) {
873 XDrawLine(dpy, panel->preview, gc, 29, 120, 29, 120+20*4+20);
874 XDrawLine(dpy, panel->preview, gc, 29, 119, 119, 119);
876 if (elements & (1<<PICON)) {
877 WMListItem *item;
878 TextureListItem *titem;
880 item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
881 titem = (TextureListItem*)item->clientData;
883 renderPreview(panel, gc, PICON,
884 titem->ispixmap ? 0 : RBEV_RAISED3);
886 colorUpdate |= ICONT_COL|ICONB_COL|CLIP_COL|CCLIP_COL;
888 if (refresh < 0) {
889 WMPixmap *p;
891 p = WMCreatePixmapFromXPixmaps(scr, panel->preview, None,
892 240-4, 215-4, WMScreenDepth(scr));
894 WMSetLabelImage(panel->prevL, p);
895 WMReleasePixmap(p);
897 if (colorUpdate)
898 updateColorPreviewBox(panel, colorUpdate);
899 } else {
900 if (colorUpdate)
901 updateColorPreviewBox(panel, colorUpdate);
902 else
903 WMRedisplayWidget(panel->prevL);
906 XFreeGC(dpy, gc);
907 WMReleaseColor(black);
913 static void
914 cancelNewTexture(void *data)
916 _Panel *panel = (_Panel*)data;
918 HideTexturePanel(panel->texturePanel);
924 static char*
925 makeFileName(char *prefix)
927 char *fname;
929 fname = wstrdup(prefix);
931 while (access(fname, F_OK)==0) {
932 char buf[30];
934 wfree(fname);
935 sprintf(buf, "%08lx.cache", time(NULL));
936 fname = wstrconcat(prefix, buf);
939 return fname;
945 static void
946 okNewTexture(void *data)
948 _Panel *panel = (_Panel*)data;
949 WMListItem *item;
950 char *name;
951 char *str;
952 WMPropList *prop;
953 TextureListItem *titem;
954 WMScreen *scr = WMWidgetScreen(panel->parent);
956 titem = wmalloc(sizeof(TextureListItem));
957 memset(titem, 0, sizeof(TextureListItem));
959 HideTexturePanel(panel->texturePanel);
961 name = GetTexturePanelTextureName(panel->texturePanel);
963 prop = GetTexturePanelTexture(panel->texturePanel);
965 str = WMGetPropListDescription(prop, False);
967 titem->title = name;
968 titem->prop = prop;
969 titem->texture = str;
970 titem->selectedFor = 0;
972 titem->ispixmap = isPixmap(prop);
974 titem->path = makeFileName(panel->fprefix);
975 titem->preview = renderTexture(scr, prop, TEXPREV_WIDTH, TEXPREV_HEIGHT,
976 titem->path, 0);
978 item = WMAddListItem(panel->texLs, "");
979 item->clientData = titem;
981 WMSetListPosition(panel->texLs, WMGetListNumberOfRows(panel->texLs));
985 static void
986 okEditTexture(void *data)
988 _Panel *panel = (_Panel*)data;
989 WMListItem *item;
990 char *name;
991 char *str;
992 WMPropList *prop;
993 TextureListItem *titem;
995 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
996 titem = (TextureListItem*)item->clientData;
998 HideTexturePanel(panel->texturePanel);
1000 if (titem->current) {
1001 name = GetTexturePanelTextureName(panel->texturePanel);
1003 wfree(titem->title);
1004 titem->title = name;
1007 prop = GetTexturePanelTexture(panel->texturePanel);
1009 str = WMGetPropListDescription(prop, False);
1011 WMReleasePropList(titem->prop);
1012 titem->prop = prop;
1014 titem->ispixmap = isPixmap(prop);
1016 wfree(titem->texture);
1017 titem->texture = str;
1019 XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel->texLs)), titem->preview);
1020 titem->preview = renderTexture(WMWidgetScreen(panel->texLs), titem->prop,
1021 TEXPREV_WIDTH, TEXPREV_HEIGHT,
1022 titem->path, 0);
1024 WMRedisplayWidget(panel->texLs);
1026 if (titem->selectedFor)
1027 updatePreviewBox(panel, titem->selectedFor);
1029 changePage(panel->secP, panel);
1034 static void
1035 editTexture(WMWidget *w, void *data)
1037 _Panel *panel = (_Panel*)data;
1038 WMListItem *item;
1039 TextureListItem *titem;
1041 item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
1042 titem = (TextureListItem*)item->clientData;
1044 SetTexturePanelPixmapPath(panel->texturePanel,
1045 GetObjectForKey("PixmapPath"));
1047 SetTexturePanelTexture(panel->texturePanel, titem->title, titem->prop);
1049 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
1050 SetTexturePanelOkAction(panel->texturePanel, okEditTexture, panel);
1052 ShowTexturePanel(panel->texturePanel);
1057 static void
1058 newTexture(WMWidget *w, void *data)
1060 _Panel *panel = (_Panel*)data;
1062 SetTexturePanelPixmapPath(panel->texturePanel,
1063 GetObjectForKey("PixmapPath"));
1065 SetTexturePanelTexture(panel->texturePanel, "New Texture", NULL);
1067 SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
1069 SetTexturePanelOkAction(panel->texturePanel, okNewTexture, panel);
1071 ShowTexturePanel(panel->texturePanel);
1076 static void
1077 deleteTexture(WMWidget *w, void *data)
1079 _Panel *panel = (_Panel*)data;
1080 WMListItem *item;
1081 TextureListItem *titem;
1082 int row;
1083 int section;
1085 section = WMGetPopUpButtonSelectedItem(panel->secP);
1086 row = WMGetListSelectedItemRow(panel->texLs);
1087 item = WMGetListItem(panel->texLs, row);
1088 titem = (TextureListItem*)item->clientData;
1090 if (titem->selectedFor & (1 << section)) {
1091 TextureListItem *titem2;
1093 panel->textureIndex[section] = section;
1094 item = WMGetListItem(panel->texLs, section);
1095 titem2 = (TextureListItem*)item->clientData;
1096 titem2->selectedFor |= 1 << section;
1099 wfree(titem->title);
1100 wfree(titem->texture);
1101 WMReleasePropList(titem->prop);
1102 if (titem->path) {
1103 if (remove(titem->path) < 0 && errno != ENOENT) {
1104 wsyserror("could not remove file %s", titem->path);
1106 wfree(titem->path);
1109 wfree(titem);
1111 WMRemoveListItem(panel->texLs, row);
1112 WMSetButtonEnabled(panel->delB, False);
1118 static void
1119 extractTexture(WMWidget *w, void *data)
1121 _Panel *panel = (_Panel*)data;
1122 char *path;
1123 WMOpenPanel *opanel;
1124 WMScreen *scr = WMWidgetScreen(w);
1126 opanel = WMGetOpenPanel(scr);
1127 WMSetFilePanelCanChooseDirectories(opanel, False);
1128 WMSetFilePanelCanChooseFiles(opanel, True);
1130 if (WMRunModalFilePanelForDirectory(opanel, panel->parent, wgethomedir(),
1131 _("Select File"), NULL)) {
1132 path = WMGetFilePanelFileName(opanel);
1134 OpenExtractPanelFor(panel, path);
1136 wfree(path);
1141 static void
1142 changePage(WMWidget *w, void *data)
1144 _Panel *panel = (_Panel*)data;
1145 int section;
1146 WMListItem *item;
1147 TextureListItem *titem;
1148 WMScreen *scr = WMWidgetScreen(panel->box);
1149 RContext *rc = WMScreenRContext(scr);
1150 static WMPoint positions[] = {
1151 {5, 10},
1152 {5, 40},
1153 {5, 70},
1154 {5, 100},
1155 {5, 120},
1156 {5, 160},
1157 {130, 150}
1160 if (w) {
1161 section = WMGetPopUpButtonSelectedItem(panel->secP);
1163 WMSelectListItem(panel->texLs, panel->textureIndex[section]);
1165 WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2);
1167 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
1169 titem = (TextureListItem*)item->clientData;
1172 WMColor *color;
1174 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
1175 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
1176 positions[panel->oldsection].x,
1177 positions[panel->oldsection].y, 22, 22);
1178 WMReleaseColor(color);
1180 if (w) {
1181 panel->oldsection = section;
1182 WMDrawPixmap(panel->hand, panel->preview, positions[section].x,
1183 positions[section].y);
1185 WMRedisplayWidget(panel->prevL);
1190 static void
1191 previewClick(XEvent *event, void *clientData)
1193 _Panel *panel = (_Panel*)clientData;
1194 int i;
1196 switch (panel->oldTabItem) {
1197 case 0:
1198 for (i = 0; i < sizeof(previewPositions)/sizeof(WMRect); i++) {
1199 if (event->xbutton.x >= previewPositions[i].pos.x
1200 && event->xbutton.y >= previewPositions[i].pos.y
1201 && event->xbutton.x < previewPositions[i].pos.x
1202 + previewPositions[i].size.width
1203 && event->xbutton.y < previewPositions[i].pos.y
1204 + previewPositions[i].size.height) {
1206 WMSetPopUpButtonSelectedItem(panel->secP, i);
1207 changePage(panel->secP, panel);
1208 return;
1211 break;
1212 case 1:
1213 for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->colP); i++) {
1214 if (event->xbutton.x >= previewColorPositions[i].pos.x
1215 && event->xbutton.y >= previewColorPositions[i].pos.y
1216 && event->xbutton.x < previewColorPositions[i].pos.x
1217 + previewColorPositions[i].size.width
1218 && event->xbutton.y < previewColorPositions[i].pos.y
1219 + previewColorPositions[i].size.height) {
1221 /* yuck kluge */
1222 if (i == 7)
1223 i = 4;
1225 WMSetPopUpButtonSelectedItem(panel->colP, i);
1226 changeColorPage(panel->colP, panel);
1227 return;
1230 break;
1235 static void
1236 textureClick(WMWidget *w, void *data)
1238 _Panel *panel = (_Panel*)data;
1239 int i;
1240 WMListItem *item;
1241 TextureListItem *titem;
1243 i = WMGetListSelectedItemRow(panel->texLs);
1245 item = WMGetListItem(panel->texLs, i);
1247 titem = (TextureListItem*)item->clientData;
1249 if (titem->current) {
1250 WMSetButtonEnabled(panel->delB, False);
1251 } else {
1252 WMSetButtonEnabled(panel->delB, True);
1258 static void
1259 textureDoubleClick(WMWidget *w, void *data)
1261 _Panel *panel = (_Panel*)data;
1262 int i, section;
1263 WMListItem *item;
1264 TextureListItem *titem;
1266 /* unselect old texture */
1267 section = WMGetPopUpButtonSelectedItem(panel->secP);
1269 item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
1270 titem = (TextureListItem*)item->clientData;
1271 titem->selectedFor &= ~(1 << section);
1273 /* select new texture */
1274 i = WMGetListSelectedItemRow(panel->texLs);
1276 item = WMGetListItem(panel->texLs, i);
1278 titem = (TextureListItem*)item->clientData;
1280 titem->selectedFor |= 1<<section;
1282 panel->textureIndex[section] = i;
1284 WMRedisplayWidget(panel->texLs);
1286 updatePreviewBox(panel, 1<<section);
1291 static void
1292 paintListItem(WMList *lPtr, int index, Drawable d, char *text, int state,
1293 WMRect *rect)
1295 _Panel *panel = (_Panel*)WMGetHangedData(lPtr);
1296 WMScreen *scr = WMWidgetScreen(lPtr);
1297 int width, height, x, y;
1298 Display *dpy = WMScreenDisplay(scr);
1299 WMColor *back = (state & WLDSSelected) ? WMWhiteColor(scr) : WMGrayColor(scr);
1300 WMListItem *item;
1301 WMColor *black = WMBlackColor(scr);
1302 TextureListItem *titem;
1304 item = WMGetListItem(lPtr, index);
1305 titem = (TextureListItem*)item->clientData;
1306 if (!titem) {
1307 WMReleaseColor(back);
1308 WMReleaseColor(black);
1309 return;
1312 width = rect->size.width;
1313 height = rect->size.height;
1314 x = rect->pos.x;
1315 y = rect->pos.y;
1317 XFillRectangle(dpy, d, WMColorGC(back), x, y, width, height);
1319 if (titem->preview)
1320 XCopyArea(dpy, titem->preview, d, WMColorGC(black), 0, 0,
1321 TEXPREV_WIDTH, TEXPREV_HEIGHT, x + 5, y + 5);
1323 if ((1 << WMGetPopUpButtonSelectedItem(panel->secP)) & titem->selectedFor)
1324 WMDrawPixmap(panel->onLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1325 else if (titem->selectedFor)
1326 WMDrawPixmap(panel->offLed, d, x + TEXPREV_WIDTH + 10, y + 6);
1328 WMDrawString(scr, d, black, panel->boldFont,
1329 x + TEXPREV_WIDTH + 22, y + 2, titem->title,
1330 strlen(titem->title));
1332 WMDrawString(scr, d, black, panel->smallFont,
1333 x + TEXPREV_WIDTH + 14, y + 18, titem->texture,
1334 strlen(titem->texture));
1337 WMReleaseColor(back);
1338 WMReleaseColor(black);
1343 static Pixmap
1344 loadRImage(WMScreen *scr, char *path)
1346 FILE *f;
1347 RImage *image;
1348 int w, h, d;
1349 Pixmap pixmap;
1351 f = fopen(path, "rb");
1352 if (!f)
1353 return None;
1355 fscanf(f, "%02x%02x%1x", &w, &h, &d);
1357 image = RCreateImage(w, h, d == 4);
1358 fread(image->data, 1, w*h*d, f);
1359 fclose(f);
1361 RConvertImage(WMScreenRContext(scr), image, &pixmap);
1362 RReleaseImage(image);
1364 return pixmap;
1369 static void
1370 fillTextureList(WMList *lPtr)
1372 WMPropList *textureList;
1373 WMPropList *texture;
1374 WMUserDefaults *udb = WMGetStandardUserDefaults();
1375 TextureListItem *titem;
1376 WMScreen *scr = WMWidgetScreen(lPtr);
1377 int i;
1379 textureList = WMGetUDObjectForKey(udb, "TextureList");
1380 if (!textureList)
1381 return;
1383 for (i = 0; i < WMGetPropListItemCount(textureList); i++) {
1384 WMListItem *item;
1386 texture = WMGetFromPLArray(textureList, i);
1388 titem = wmalloc(sizeof(TextureListItem));
1389 memset(titem, 0, sizeof(TextureListItem));
1391 titem->title = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 0)));
1392 titem->prop = WMRetainPropList(WMGetFromPLArray(texture, 1));
1393 titem->texture = WMGetPropListDescription(titem->prop, False);
1394 titem->selectedFor = 0;
1395 titem->path = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 2)));
1397 titem->preview = loadRImage(scr, titem->path);
1398 if (!titem->preview) {
1399 titem->preview = renderTexture(scr, titem->prop, TEXPREV_WIDTH,
1400 TEXPREV_HEIGHT, NULL, 0);
1402 item = WMAddListItem(lPtr, "");
1403 item->clientData = titem;
1408 static void
1409 fillColorList(_Panel *panel)
1411 WMColor *color;
1412 WMPropList *list;
1413 WMUserDefaults *udb = WMGetStandardUserDefaults();
1414 WMScreen *scr = WMWidgetScreen(panel->box);
1415 int i;
1417 list = WMGetUDObjectForKey(udb, "ColorList");
1418 if (!list) {
1419 for (i = 0; i < 24; i++) {
1420 color = WMCreateNamedColor(scr, sampleColors[i], False);
1421 if (!color)
1422 continue;
1423 WMSetColorWellColor(panel->sampW[i], color);
1424 WMReleaseColor(color);
1426 } else {
1427 WMPropList *c;
1429 for (i = 0; i < WMIN(24, WMGetPropListItemCount(list)); i++) {
1430 c = WMGetFromPLArray(list, i);
1431 if (!c || !WMIsPLString(c))
1432 continue;
1433 color = WMCreateNamedColor(scr, WMGetFromPLString(c), False);
1434 if (!color)
1435 continue;
1436 WMSetColorWellColor(panel->sampW[i], color);
1437 WMReleaseColor(color);
1443 /*************************************************************************/
1446 static void
1447 changeColorPage(WMWidget *w, void *data)
1449 _Panel *panel = (_Panel*)data;
1450 int section;
1451 WMScreen *scr = WMWidgetScreen(panel->box);
1452 RContext *rc = WMScreenRContext(scr);
1453 static WMPoint positions[] = {
1454 {5, 10},
1455 {5, 40},
1456 {5, 70},
1457 {5, 120},
1458 {5, 140},
1459 {5, 160},
1460 {5, 180},
1461 {5, 180},
1462 {130, 140},
1463 {130, 140},
1464 {130, 140},
1465 {130, 140}
1468 if (panel->preview) {
1469 WMColor *color;
1471 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
1472 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
1473 positions[panel->oldcsection].x,
1474 positions[panel->oldcsection].y, 22, 22);
1475 WMReleaseColor(color);
1477 if (w) {
1478 section = WMGetPopUpButtonSelectedItem(panel->colP);
1480 panel->oldcsection = section;
1481 if (panel->preview)
1482 WMDrawPixmap(panel->hand, panel->preview, positions[section].x,
1483 positions[section].y);
1485 section = WMGetPopUpButtonSelectedItem(panel->colP);
1487 WMSetColorWellColor(panel->colW, panel->colors[section]);
1489 WMRedisplayWidget(panel->prevL);
1493 static void
1494 paintText(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
1495 int x, int y, int w, int h, WMAlignment align, char *text)
1497 int l = strlen(text);
1499 switch (align) {
1500 case WALeft:
1501 x += 5;
1502 break;
1503 case WARight:
1504 x += w - 5 - WMWidthOfString(font, text, l);
1505 break;
1506 default:
1507 case WACenter:
1508 x += (w - WMWidthOfString(font, text, l))/2;
1509 break;
1511 WMDrawString(scr, d, color, font, x, y + (h - WMFontHeight(font))/2,
1512 text, l);
1517 static void
1518 updateColorPreviewBox(_Panel *panel, int elements)
1520 WMScreen *scr = WMWidgetScreen(panel->box);
1521 WMPixmap *pixmap;
1522 Pixmap d;
1524 pixmap = WMGetLabelImage(panel->prevL);
1525 d = WMGetPixmapXID(pixmap);
1527 if (elements & FTITLE_COL) {
1528 paintText(scr, d, panel->colors[0], panel->boldFont, 30, 10, 190, 20,
1529 panel->titleAlignment, _("Focused Window"));
1531 if (elements & UTITLE_COL) {
1532 paintText(scr, d, panel->colors[1], panel->boldFont, 30, 40, 190, 20,
1533 panel->titleAlignment, _("Unfocused Window"));
1535 if (elements & OTITLE_COL) {
1536 paintText(scr, d, panel->colors[2], panel->boldFont, 30, 70, 190, 20,
1537 panel->titleAlignment, _("Owner of Focused Window"));
1539 if (elements & MTITLE_COL) {
1540 paintText(scr, d, panel->colors[3], panel->boldFont, 30, 120, 90, 20,
1541 WALeft, _("Menu Title"));
1543 if (elements & MITEM_COL) {
1544 paintText(scr, d, panel->colors[4], panel->normalFont, 30, 140, 90, 20,
1545 WALeft, _("Normal Item"));
1546 paintText(scr, d, panel->colors[4], panel->normalFont, 30, 200, 90, 20,
1547 WALeft, _("Normal Item"));
1549 if (elements & MDISAB_COL) {
1550 paintText(scr, d, panel->colors[5], panel->normalFont, 30, 160, 90, 20,
1551 WALeft, _("Disabled Item"));
1553 if (elements & MHIGH_COL) {
1554 XFillRectangle(WMScreenDisplay(scr), d, WMColorGC(panel->colors[6]),
1555 31, 181, 87, 17);
1556 elements |= MHIGHT_COL;
1558 if (elements & MHIGHT_COL) {
1559 paintText(scr, d, panel->colors[7], panel->normalFont, 30, 180, 90, 20,
1560 WALeft, _("Highlighted"));
1563 if (elements & ICONT_COL) {
1564 WRITE(_("Focused Window"), panel->colors[8], panel->boldFont,
1565 155, 130, 64);
1567 if (elements & ICONB_COL) {
1568 WRITE(_("Focused Window"), panel->colors[9], panel->boldFont,
1569 0, 0, 30);
1571 if (elements & CLIP_COL) {
1572 WRITE(_("Focused Window"), panel->colors[10], panel->boldFont,
1573 0, 0, 30);
1575 if (elements & CCLIP_COL) {
1576 WRITE(_("Focused Window"), panel->colors[11], panel->boldFont,
1577 0, 0, 30);
1580 WMRedisplayWidget(panel->prevL);
1584 static void
1585 colorWellObserver(void *self, WMNotification *n)
1587 _Panel *panel = (_Panel*)self;
1588 int p;
1590 p = WMGetPopUpButtonSelectedItem(panel->colP);
1592 WMReleaseColor(panel->colors[p]);
1594 panel->colors[p] = WMRetainColor(WMGetColorWellColor(panel->colW));
1596 updateColorPreviewBox(panel, 1<<p);
1600 static void
1601 changedTabItem(struct WMTabViewDelegate *self, WMTabView *tabView,
1602 WMTabViewItem *item)
1604 _Panel *panel = self->data;
1605 int i;
1607 i = WMGetTabViewItemIdentifier(item);
1608 switch (i) {
1609 case 0:
1610 switch (panel->oldTabItem) {
1611 case 1:
1612 changeColorPage(NULL, panel);
1613 break;
1615 changePage(panel->secP, panel);
1616 break;
1617 case 1:
1618 switch (panel->oldTabItem) {
1619 case 0:
1620 changePage(NULL, panel);
1621 break;
1623 changeColorPage(panel->colP, panel);
1624 break;
1625 case 3:
1626 switch (panel->oldTabItem) {
1627 case 0:
1628 changePage(NULL, panel);
1629 break;
1630 case 1:
1631 changeColorPage(NULL, panel);
1632 break;
1634 break;
1637 panel->oldTabItem = i;
1641 /*************************************************************************/
1643 static void
1644 menuStyleCallback(WMWidget *self, void *data)
1646 _Panel *panel = (_Panel*)data;
1648 if (self == panel->mstyB[0]) {
1649 panel->menuStyle = MSTYLE_NORMAL;
1650 updatePreviewBox(panel, 1<<PMITEM);
1652 } else if (self == panel->mstyB[1]) {
1653 panel->menuStyle = MSTYLE_SINGLE;
1654 updatePreviewBox(panel, 1<<PMITEM);
1656 } else if (self == panel->mstyB[2]) {
1657 panel->menuStyle = MSTYLE_FLAT;
1658 updatePreviewBox(panel, 1<<PMITEM);
1663 static void
1664 titleAlignCallback(WMWidget *self, void *data)
1666 _Panel *panel = (_Panel*)data;
1668 if (self == panel->taliB[0]) {
1669 panel->titleAlignment = WALeft;
1670 updatePreviewBox(panel, 1<<PFOCUSED|1<<PUNFOCUSED|1<<POWNER);
1672 } else if (self == panel->taliB[1]) {
1673 panel->titleAlignment = WACenter;
1674 updatePreviewBox(panel, 1<<PFOCUSED|1<<PUNFOCUSED|1<<POWNER);
1676 } else if (self == panel->taliB[2]) {
1677 panel->titleAlignment = WARight;
1678 updatePreviewBox(panel, 1<<PFOCUSED|1<<PUNFOCUSED|1<<POWNER);
1683 static void
1684 createPanel(Panel *p)
1686 _Panel *panel = (_Panel*)p;
1687 WMFont *font;
1688 WMScreen *scr = WMWidgetScreen(panel->parent);
1689 WMTabViewItem *item;
1690 int i;
1691 char *tmp;
1692 Bool ok = True;
1694 panel->fprefix = wstrconcat(wusergnusteppath(), "/.AppInfo");
1696 if (access(panel->fprefix, F_OK)!=0) {
1697 if (mkdir(panel->fprefix, 0755) < 0) {
1698 wsyserror(panel->fprefix);
1699 ok = False;
1702 if (ok) {
1703 tmp = wstrconcat(panel->fprefix, "/WPrefs/");
1704 wfree(panel->fprefix);
1705 panel->fprefix = tmp;
1706 if (access(panel->fprefix, F_OK)!=0) {
1707 if (mkdir(panel->fprefix, 0755) < 0) {
1708 wsyserror(panel->fprefix);
1713 panel->smallFont = WMSystemFontOfSize(scr, 10);
1714 panel->normalFont = WMSystemFontOfSize(scr, 12);
1715 panel->boldFont = WMBoldSystemFontOfSize(scr, 12);
1717 panel->onLed = WMCreatePixmapFromXPMData(scr, blueled_xpm);
1718 panel->offLed = WMCreatePixmapFromXPMData(scr, blueled2_xpm);
1719 panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm);
1721 panel->box = WMCreateBox(panel->parent);
1722 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
1724 /* preview box */
1725 panel->prevL = WMCreateLabel(panel->box);
1726 WMResizeWidget(panel->prevL, 240, FRAME_HEIGHT - 20);
1727 WMMoveWidget(panel->prevL, 15, 10);
1728 WMSetLabelRelief(panel->prevL, WRSunken);
1729 WMSetLabelImagePosition(panel->prevL, WIPImageOnly);
1731 WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask,
1732 previewClick, panel);
1735 /* tabview */
1737 tabviewDelegate.data = panel;
1739 panel->tabv = WMCreateTabView(panel->box);
1740 WMResizeWidget(panel->tabv, 245, FRAME_HEIGHT - 20);
1741 WMMoveWidget(panel->tabv, 265, 10);
1742 WMSetTabViewDelegate(panel->tabv, &tabviewDelegate);
1744 /*** texture list ***/
1746 panel->texF = WMCreateFrame(panel->box);
1747 WMSetFrameRelief(panel->texF, WRFlat);
1749 item = WMCreateTabViewItemWithIdentifier(0);
1750 WMSetTabViewItemView(item, WMWidgetView(panel->texF));
1751 WMSetTabViewItemLabel(item, _("Texture"));
1753 WMAddItemInTabView(panel->tabv, item);
1756 panel->secP = WMCreatePopUpButton(panel->texF);
1757 WMResizeWidget(panel->secP, 228, 20);
1758 WMMoveWidget(panel->secP, 7, 7);
1759 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window"));
1760 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Unfocused Windows"));
1761 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window's Owner"));
1762 WMAddPopUpButtonItem(panel->secP, _("Window Resizebar"));
1763 WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus"));
1764 WMAddPopUpButtonItem(panel->secP, _("Menu Items"));
1765 WMAddPopUpButtonItem(panel->secP, _("Icon Background"));
1766 /* WMAddPopUpButtonItem(panel->secP, _("Workspace Backgrounds"));
1768 WMSetPopUpButtonSelectedItem(panel->secP, 0);
1769 WMSetPopUpButtonAction(panel->secP, changePage, panel);
1771 panel->texLs = WMCreateList(panel->texF);
1772 WMResizeWidget(panel->texLs, 165, 155);
1773 WMMoveWidget(panel->texLs, 70, 33);
1774 WMSetListUserDrawItemHeight(panel->texLs, 35);
1775 WMSetListUserDrawProc(panel->texLs, paintListItem);
1776 WMHangData(panel->texLs, panel);
1777 WMSetListAction(panel->texLs, textureClick, panel);
1778 WMSetListDoubleAction(panel->texLs, textureDoubleClick, panel);
1780 WMSetBalloonTextForView(_("Double click in the texture you want to use\n"
1781 "for the selected item."),
1782 WMWidgetView(panel->texLs));
1784 /* command buttons */
1786 font = WMSystemFontOfSize(scr, 10);
1789 panel->newB = WMCreateCommandButton(panel->texF);
1790 WMResizeWidget(panel->newB, 57, 39);
1791 WMMoveWidget(panel->newB, 7, 33);
1792 WMSetButtonFont(panel->newB, font);
1793 WMSetButtonImagePosition(panel->newB, WIPAbove);
1794 WMSetButtonText(panel->newB, _("New"));
1795 WMSetButtonAction(panel->newB, newTexture, panel);
1796 SetButtonAlphaImage(scr, panel->newB, TNEW_FILE, NULL, NULL);
1798 WMSetBalloonTextForView(_("Create a new texture."),
1799 WMWidgetView(panel->newB));
1801 panel->ripB = WMCreateCommandButton(panel->texF);
1802 WMResizeWidget(panel->ripB, 57, 39);
1803 WMMoveWidget(panel->ripB, 7, 72);
1804 WMSetButtonFont(panel->ripB, font);
1805 WMSetButtonImagePosition(panel->ripB, WIPAbove);
1806 WMSetButtonText(panel->ripB, _("Extract..."));
1807 WMSetButtonAction(panel->ripB, extractTexture, panel);
1808 SetButtonAlphaImage(scr, panel->ripB, TEXTR_FILE, NULL, NULL);
1810 WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."),
1811 WMWidgetView(panel->ripB));
1813 WMSetButtonEnabled(panel->ripB, False);
1815 panel->editB = WMCreateCommandButton(panel->texF);
1816 WMResizeWidget(panel->editB, 57, 39);
1817 WMMoveWidget(panel->editB, 7, 111);
1818 WMSetButtonFont(panel->editB, font);
1819 WMSetButtonImagePosition(panel->editB, WIPAbove);
1820 WMSetButtonText(panel->editB, _("Edit"));
1821 SetButtonAlphaImage(scr, panel->editB, TEDIT_FILE, NULL, NULL);
1822 WMSetButtonAction(panel->editB, editTexture, panel);
1823 WMSetBalloonTextForView(_("Edit the highlighted texture."),
1824 WMWidgetView(panel->editB));
1826 panel->delB = WMCreateCommandButton(panel->texF);
1827 WMResizeWidget(panel->delB, 57, 38);
1828 WMMoveWidget(panel->delB, 7, 150);
1829 WMSetButtonFont(panel->delB, font);
1830 WMSetButtonImagePosition(panel->delB, WIPAbove);
1831 WMSetButtonText(panel->delB, _("Delete"));
1832 SetButtonAlphaImage(scr, panel->delB, TDEL_FILE, NULL, NULL);
1833 WMSetButtonEnabled(panel->delB, False);
1834 WMSetButtonAction(panel->delB, deleteTexture, panel);
1835 WMSetBalloonTextForView(_("Delete the highlighted texture."),
1836 WMWidgetView(panel->delB));
1838 WMReleaseFont(font);
1840 WMMapSubwidgets(panel->texF);
1842 /*** colors ***/
1843 panel->colF = WMCreateFrame(panel->box);
1844 WMSetFrameRelief(panel->colF, WRFlat);
1846 item = WMCreateTabViewItemWithIdentifier(1);
1847 WMSetTabViewItemView(item, WMWidgetView(panel->colF));
1848 WMSetTabViewItemLabel(item, _("Color"));
1850 WMAddItemInTabView(panel->tabv, item);
1852 panel->colP = WMCreatePopUpButton(panel->colF);
1853 WMResizeWidget(panel->colP, 228, 20);
1854 WMMoveWidget(panel->colP, 7, 7);
1855 WMAddPopUpButtonItem(panel->colP, _("Focused Window Title"));
1856 WMAddPopUpButtonItem(panel->colP, _("Unfocused Window Title"));
1857 WMAddPopUpButtonItem(panel->colP, _("Owner of Focused Window Title"));
1858 WMAddPopUpButtonItem(panel->colP, _("Menu Title"));
1859 WMAddPopUpButtonItem(panel->colP, _("Menu Item Text"));
1860 WMAddPopUpButtonItem(panel->colP, _("Disabled Menu Item Text"));
1861 WMAddPopUpButtonItem(panel->colP, _("Menu Highlight Color"));
1862 WMAddPopUpButtonItem(panel->colP, _("Highlighted Menu Text Color"));
1864 WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title"));
1865 WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title Back"));
1866 WMAddPopUpButtonItem(panel->colP, _("Clip Title"));
1867 WMAddPopUpButtonItem(panel->colP, _("Collapsed Clip Title"));
1870 WMSetPopUpButtonSelectedItem(panel->colP, 0);
1872 WMSetPopUpButtonAction(panel->colP, changeColorPage, panel);
1875 panel->colW = WMCreateColorWell(panel->colF);
1876 WMResizeWidget(panel->colW, 65, 50);
1877 WMMoveWidget(panel->colW, 30, 75);
1878 WMAddNotificationObserver(colorWellObserver, panel,
1879 WMColorWellDidChangeNotification, panel->colW);
1881 for (i = 0; i < 4; i++) {
1882 int j;
1883 for (j = 0; j < 6; j++) {
1884 panel->sampW[i+j*4] = WMCreateColorWell(panel->colF);
1885 WMResizeWidget(panel->sampW[i+j*4], 22, 22);
1886 WMMoveWidget(panel->sampW[i+j*4], 130 + i*22, 40 + j*22);
1887 WSetColorWellBordered(panel->sampW[i+j*4], False);
1891 WMMapSubwidgets(panel->colF);
1893 #ifdef unfinished
1894 /*** root bg ***/
1896 panel->bgF = WMCreateFrame(panel->box);
1897 WMSetFrameRelief(panel->bgF, WRFlat);
1899 item = WMCreateTabViewItemWithIdentifier(2);
1900 WMSetTabViewItemView(item, WMWidgetView(panel->bgF));
1901 WMSetTabViewItemLabel(item, _("Background"));
1903 WMAddItemInTabView(panel->tabv, item);
1905 panel->bgprevL = WMCreateLabel(panel->bgF);
1906 WMResizeWidget(panel->bgprevL, 230, 155);
1907 WMMoveWidget(panel->bgprevL, 5, 5);
1908 WMSetLabelRelief(panel->bgprevL, WRSunken);
1910 panel->selbgB = WMCreateCommandButton(panel->bgF);
1911 WMMoveWidget(panel->selbgB, 5, 165);
1912 WMResizeWidget(panel->selbgB, 100, 24);
1913 WMSetButtonText(panel->selbgB, _("Browse..."));
1918 WMMapSubwidgets(panel->bgF);
1919 #endif /* unfinished */
1920 /*** options ***/
1921 panel->optF = WMCreateFrame(panel->box);
1922 WMSetFrameRelief(panel->optF, WRFlat);
1924 item = WMCreateTabViewItemWithIdentifier(3);
1925 WMSetTabViewItemView(item, WMWidgetView(panel->optF));
1926 WMSetTabViewItemLabel(item, _("Options"));
1928 WMAddItemInTabView(panel->tabv, item);
1930 panel->mstyF = WMCreateFrame(panel->optF);
1931 WMResizeWidget(panel->mstyF, 215, 85);
1932 WMMoveWidget(panel->mstyF, 15, 10);
1933 WMSetFrameTitle(panel->mstyF, _("Menu Style"));
1935 for (i = 0; i < 3; i++) {
1936 WMPixmap *icon;
1937 char *path;
1939 panel->mstyB[i] = WMCreateButton(panel->mstyF, WBTOnOff);
1940 WMResizeWidget(panel->mstyB[i], 54, 54);
1941 WMMoveWidget(panel->mstyB[i], 15 + i*65, 20);
1942 WMSetButtonImagePosition(panel->mstyB[i], WIPImageOnly);
1943 WMSetButtonAction(panel->mstyB[i], menuStyleCallback, panel);
1944 switch (i) {
1945 case 0:
1946 path = LocateImage(MSTYLE1_FILE);
1947 break;
1948 case 1:
1949 path = LocateImage(MSTYLE2_FILE);
1950 break;
1951 case 2:
1952 path = LocateImage(MSTYLE3_FILE);
1953 break;
1955 if (path) {
1956 icon = WMCreatePixmapFromFile(scr, path);
1957 if (icon) {
1958 WMSetButtonImage(panel->mstyB[i], icon);
1959 WMReleasePixmap(icon);
1960 } else {
1961 wwarning(_("could not load icon file %s"), path);
1963 wfree(path);
1966 WMGroupButtons(panel->mstyB[0], panel->mstyB[1]);
1967 WMGroupButtons(panel->mstyB[0], panel->mstyB[2]);
1969 WMMapSubwidgets(panel->mstyF);
1972 panel->taliF = WMCreateFrame(panel->optF);
1973 WMResizeWidget(panel->taliF, 110, 80);
1974 WMMoveWidget(panel->taliF, 15, 100);
1975 WMSetFrameTitle(panel->taliF, _("Title Alignment"));
1977 for (i = 0; i < 3; i++) {
1978 panel->taliB[i] = WMCreateRadioButton(panel->taliF);
1979 WMSetButtonAction(panel->taliB[i], titleAlignCallback, panel);
1980 switch (i) {
1981 case 0:
1982 WMSetButtonText(panel->taliB[i], _("Left"));
1983 break;
1984 case 1:
1985 WMSetButtonText(panel->taliB[i], _("Center"));
1986 break;
1987 case 2:
1988 WMSetButtonText(panel->taliB[i], _("Right"));
1989 break;
1991 WMResizeWidget(panel->taliB[i], 90, 18);
1992 WMMoveWidget(panel->taliB[i], 10, 15 + 20*i);
1994 WMGroupButtons(panel->taliB[0], panel->taliB[1]);
1995 WMGroupButtons(panel->taliB[0], panel->taliB[2]);
1997 WMMapSubwidgets(panel->taliF);
1999 WMMapSubwidgets(panel->optF);
2001 /**/
2003 WMRealizeWidget(panel->box);
2004 WMMapSubwidgets(panel->box);
2006 WMSetPopUpButtonSelectedItem(panel->secP, 0);
2008 showData(panel);
2010 changePage(panel->secP, panel);
2012 fillTextureList(panel->texLs);
2014 fillColorList(panel);
2016 panel->texturePanel = CreateTexturePanel(panel->parent);
2021 static void
2022 setupTextureFor(WMList *list, char *key, char *defValue, char *title,
2023 int index)
2025 WMListItem *item;
2026 TextureListItem *titem;
2028 titem = wmalloc(sizeof(TextureListItem));
2029 memset(titem, 0, sizeof(TextureListItem));
2031 titem->title = wstrdup(title);
2032 titem->prop = GetObjectForKey(key);
2033 if (!titem->prop || !WMIsPLArray(titem->prop)) {
2034 /* Maybe also give a error message to stderr that the entry is bad? */
2035 titem->prop = WMCreatePropListFromDescription(defValue);
2036 } else {
2037 WMRetainPropList(titem->prop);
2039 titem->texture = WMGetPropListDescription((WMPropList*)titem->prop, False);
2040 titem->current = 1;
2041 titem->selectedFor = 1<<index;
2043 titem->ispixmap = isPixmap(titem->prop);
2045 titem->preview = renderTexture(WMWidgetScreen(list), titem->prop,
2046 TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0);
2048 item = WMAddListItem(list, "");
2049 item->clientData = titem;
2054 static void
2055 showData(_Panel *panel)
2057 int i;
2058 char *str;
2060 str = GetStringForKey("MenuStyle");
2061 if (str && strcasecmp(str, "flat")==0) {
2062 panel->menuStyle = MSTYLE_FLAT;
2063 } else if (str && strcasecmp(str, "singletexture")==0) {
2064 panel->menuStyle = MSTYLE_SINGLE;
2065 } else {
2066 panel->menuStyle = MSTYLE_NORMAL;
2069 str = GetStringForKey("TitleJustify");
2070 if (str && strcasecmp(str, "left")==0) {
2071 panel->titleAlignment = WALeft;
2072 } else if (str && strcasecmp(str, "right")==0) {
2073 panel->titleAlignment = WARight;
2074 } else {
2075 panel->titleAlignment = WACenter;
2078 for (i = 0; i < sizeof(colorOptions)/(2*sizeof(char*)); i++) {
2079 WMColor *color;
2081 str = GetStringForKey(colorOptions[i*2]);
2082 if (!str)
2083 str = colorOptions[i*2+1];
2085 if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) {
2086 color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False);
2089 panel->colors[i] = color;
2091 changeColorPage(panel->colP, panel);
2093 for (i = 0; i < sizeof(textureOptions)/(3*sizeof(char*)); i++) {
2094 setupTextureFor(panel->texLs, textureOptions[i*3],
2095 textureOptions[i*3+1], textureOptions[i*3+2], i);
2096 panel->textureIndex[i] = i;
2098 updatePreviewBox(panel, EVERYTHING);
2100 WMSetButtonSelected(panel->mstyB[panel->menuStyle], True);
2101 WMSetButtonSelected(panel->taliB[panel->titleAlignment], True);
2105 static void
2106 storeData(_Panel *panel)
2108 TextureListItem *titem;
2109 WMListItem *item;
2110 int i;
2112 for (i = 0; i < sizeof(textureOptions)/(sizeof(char*)*3); i++) {
2113 item = WMGetListItem(panel->texLs, panel->textureIndex[i]);
2114 titem = (TextureListItem*)item->clientData;
2115 SetObjectForKey(titem->prop, textureOptions[i*3]);
2118 for (i = 0; i < 8; i++) {
2119 char *str;
2121 str = WMGetColorRGBDescription(panel->colors[i]);
2123 if (str) {
2124 SetStringForKey(str, colorOptions[i*2]);
2125 wfree(str);
2129 switch (panel->menuStyle) {
2130 case MSTYLE_SINGLE:
2131 SetStringForKey("singletexture", "MenuStyle");
2132 break;
2133 case MSTYLE_FLAT:
2134 SetStringForKey("flat", "MenuStyle");
2135 break;
2136 default:
2137 case MSTYLE_NORMAL:
2138 SetStringForKey("normal", "MenuStyle");
2139 break;
2141 switch (panel->titleAlignment) {
2142 case WALeft:
2143 SetStringForKey("left", "TitleJustify");
2144 break;
2145 case WARight:
2146 SetStringForKey("right", "TitleJustify");
2147 break;
2148 default:
2149 case WACenter:
2150 SetStringForKey("center", "TitleJustify");
2151 break;
2156 static void
2157 prepareForClose(_Panel *panel)
2159 WMPropList *textureList;
2160 WMPropList *texture;
2161 TextureListItem *titem;
2162 WMListItem *item;
2163 WMUserDefaults *udb = WMGetStandardUserDefaults();
2164 int i;
2166 textureList = WMCreatePLArray(NULL, NULL);
2168 /* store list of textures */
2169 for (i = 7; i < WMGetListNumberOfRows(panel->texLs); i++) {
2170 item = WMGetListItem(panel->texLs, i);
2171 titem = (TextureListItem*)item->clientData;
2173 texture = WMCreatePLArray(WMCreatePLString(titem->title),
2174 WMRetainPropList(titem->prop),
2175 WMCreatePLString(titem->path),
2176 NULL);
2178 WMAddToPLArray(textureList, texture);
2181 WMSetUDObjectForKey(udb, textureList, "TextureList");
2182 WMReleasePropList(textureList);
2184 /* store list of colors */
2185 textureList = WMCreatePLArray(NULL, NULL);
2186 for (i = 0; i < 24; i++) {
2187 WMColor *color;
2188 char *str;
2190 color = WMGetColorWellColor(panel->sampW[i]);
2192 str = WMGetColorRGBDescription(color);
2193 WMAddToPLArray(textureList, WMCreatePLString(str));
2194 wfree(str);
2196 WMSetUDObjectForKey(udb, textureList, "ColorList");
2197 WMReleasePropList(textureList);
2199 WMSynchronizeUserDefaults(udb);
2204 Panel*
2205 InitAppearance(WMScreen *scr, WMWindow *win)
2207 _Panel *panel;
2209 panel = wmalloc(sizeof(_Panel));
2210 memset(panel, 0, sizeof(_Panel));
2212 panel->sectionName = _("Appearance Preferences");
2214 panel->description = _("Background texture configuration for windows,\n"
2215 "menus and icons.");
2217 panel->parent = win;
2219 panel->callbacks.createWidgets = createPanel;
2220 panel->callbacks.updateDomain = storeData;
2221 panel->callbacks.prepareForClose = prepareForClose;
2223 AddSection(panel, ICON_FILE);
2225 return panel;
2230 /****************************************************************************/
2234 typedef struct ExtractPanel {
2235 WMWindow *win;
2237 WMLabel *label;
2238 WMList *list;
2240 WMButton *closeB;
2241 WMButton *extrB;
2242 } ExtractPanel;
2246 static void
2247 OpenExtractPanelFor(_Panel *panel, char *path)
2249 ExtractPanel *epanel;
2250 WMColor *color;
2251 WMFont *font;
2252 WMScreen *scr = WMWidgetScreen(panel->parent);
2254 epanel = wmalloc(sizeof(ExtractPanel));
2255 epanel->win = WMCreatePanelWithStyleForWindow(panel->parent, "extract",
2256 WMTitledWindowMask
2257 |WMClosableWindowMask);
2258 WMResizeWidget(epanel->win, 245, 250);
2259 WMSetWindowTitle(epanel->win, _("Extract Texture"));
2261 epanel->label = WMCreateLabel(epanel->win);
2262 WMResizeWidget(epanel->label, 225, 18);
2263 WMMoveWidget(epanel->label, 10, 10);
2264 WMSetLabelTextAlignment(epanel->label, WACenter);
2265 WMSetLabelRelief(epanel->label, WRSunken);
2267 color = WMDarkGrayColor(scr);
2268 WMSetWidgetBackgroundColor(epanel->label, color);
2269 WMReleaseColor(color);
2271 color = WMWhiteColor(scr);
2272 WMSetLabelTextColor(epanel->label, color);
2273 WMReleaseColor(color);
2275 font = WMBoldSystemFontOfSize(scr, 12);
2276 WMSetLabelFont(epanel->label, font);
2277 WMReleaseFont(font);
2279 WMSetLabelText(epanel->label, _("Textures"));
2281 epanel->list = WMCreateList(epanel->win);
2282 WMResizeWidget(epanel->list, 225, 165);
2283 WMMoveWidget(epanel->list, 10, 30);
2287 epanel->closeB = WMCreateCommandButton(epanel->win);
2288 WMResizeWidget(epanel->closeB, 74, 24);
2289 WMMoveWidget(epanel->closeB, 165, 215);
2290 WMSetButtonText(epanel->closeB, _("Close"));
2292 epanel->extrB = WMCreateCommandButton(epanel->win);
2293 WMResizeWidget(epanel->extrB, 74, 24);
2294 WMMoveWidget(epanel->extrB, 80, 215);
2295 WMSetButtonText(epanel->extrB, _("Extract"));
2297 WMMapSubwidgets(epanel->win);
2300 /* take textures from file */
2304 WMRealizeWidget(epanel->win);
2306 WMMapWidget(epanel->win);