added contrib/ directory, updated WPrefs and wmsetbg for smoothed
[wmaker-crm.git] / src / dialog.c
blobb8c1b218d6acc2ab7faa62f945ed54891891aca7
1 /* dialog.c - dialog windows for internal use
2 *
3 * Window Maker window manager
4 *
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 * Copyright (c) 1999 Dan Pascu
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 * USA.
24 #include "wconfig.h"
26 #include <X11/Xlib.h>
27 #include <X11/Xutil.h>
28 #include <X11/keysym.h>
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <unistd.h>
33 #include <string.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <dirent.h>
37 #include <limits.h>
39 #include <signal.h>
40 #ifdef __FreeBSD__
41 #include <sys/signal.h>
42 #endif
45 #ifndef PATH_MAX
46 #define PATH_MAX DEFAULT_PATH_MAX
47 #endif
49 #include "WindowMaker.h"
50 #include "GNUstep.h"
51 #include "screen.h"
52 #include "dialog.h"
53 #include "funcs.h"
54 #include "stacking.h"
55 #include "framewin.h"
56 #include "window.h"
57 #include "actions.h"
58 #include "defaults.h"
61 extern WPreferences wPreferences;
65 int
66 wMessageDialog(WScreen *scr, char *title, char *message,
67 char *defBtn, char *altBtn, char *othBtn)
69 WMAlertPanel *panel;
70 Window parent;
71 WWindow *wwin;
72 int result;
74 panel = WMCreateAlertPanel(scr->wmscreen, NULL, title, message,
75 defBtn, altBtn, othBtn);
77 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 400, 180, 0, 0, 0);
79 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
81 wwin = wManageInternalWindow(scr, parent, None, NULL,
82 (scr->scr_width - 400)/2,
83 (scr->scr_height - 180)/2, 400, 180);
84 wwin->client_leader = WMWidgetXID(panel->win);
86 WMMapWidget(panel->win);
88 wWindowMap(wwin);
90 while (!panel->done) {
91 XEvent event;
93 WMNextEvent(dpy, &event);
94 WMHandleEvent(&event);
97 result = panel->result;
99 WMUnmapWidget(panel->win);
101 wUnmanageWindow(wwin, False, False);
103 WMDestroyAlertPanel(panel);
105 XDestroyWindow(dpy, parent);
107 return result;
113 wInputDialog(WScreen *scr, char *title, char *message, char **text)
115 WWindow *wwin;
116 Window parent;
117 WMInputPanel *panel;
118 char *result;
121 panel = WMCreateInputPanel(scr->wmscreen, NULL, title, message, *text,
122 _("OK"), _("Cancel"));
125 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 320, 160, 0, 0, 0);
126 XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask);
128 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
130 wwin = wManageInternalWindow(scr, parent, None, NULL,
131 (scr->scr_width - 320)/2,
132 (scr->scr_height - 160)/2, 320, 160);
134 wwin->client_leader = WMWidgetXID(panel->win);
136 WMMapWidget(panel->win);
138 wWindowMap(wwin);
140 while (!panel->done) {
141 XEvent event;
143 WMNextEvent(dpy, &event);
144 WMHandleEvent(&event);
147 if (panel->result == WAPRDefault)
148 result = WMGetTextFieldText(panel->text);
149 else
150 result = NULL;
152 wUnmanageWindow(wwin, False, False);
154 WMDestroyInputPanel(panel);
156 XDestroyWindow(dpy, parent);
158 if (result==NULL)
159 return False;
160 else {
161 if (*text)
162 free(*text);
163 *text = result;
165 return True;
171 *****************************************************************
172 * Icon Selection Panel
173 *****************************************************************
176 typedef struct IconPanel {
178 WScreen *scr;
180 WMWindow *win;
182 WMLabel *dirLabel;
183 WMLabel *iconLabel;
185 WMList *dirList;
186 WMList *iconList;
188 WMLabel *iconView;
190 WMLabel *fileLabel;
191 WMTextField *fileField;
193 WMButton *okButton;
194 WMButton *cancelButton;
195 #if 0
196 WMButton *chooseButton;
197 #endif
198 short done;
199 short result;
200 } IconPanel;
204 static void
205 listPixmaps(WScreen *scr, WMList *lPtr, char *path)
207 struct dirent *dentry;
208 DIR *dir;
209 char pbuf[PATH_MAX+16];
210 char *apath;
212 apath = wexpandpath(path);
213 dir = opendir(apath);
215 if (!dir) {
216 char *msg;
217 char *tmp;
218 tmp = _("Could not open directory ");
219 msg = wmalloc(strlen(tmp)+strlen(path)+6);
220 strcpy(msg, tmp);
221 strcat(msg, path);
223 wMessageDialog(scr, _("Error"), msg, _("OK"), NULL, NULL);
224 free(msg);
225 free(apath);
226 return;
229 /* list contents in the column */
230 while ((dentry = readdir(dir))) {
231 struct stat statb;
233 if (strcmp(dentry->d_name, ".")==0 ||
234 strcmp(dentry->d_name, "..")==0)
235 continue;
237 strcpy(pbuf, apath);
238 strcat(pbuf, "/");
239 strcat(pbuf, dentry->d_name);
241 if (stat(pbuf, &statb)<0)
242 continue;
244 if (statb.st_mode & (S_IRUSR|S_IRGRP|S_IROTH)
245 && statb.st_mode & (S_IFREG|S_IFLNK)) {
246 WMAddSortedListItem(lPtr, dentry->d_name);
250 closedir(dir);
251 free(apath);
256 static void
257 setViewedImage(IconPanel *panel, char *file)
259 WMPixmap *pixmap;
260 RColor color;
262 color.red = 0xae;
263 color.green = 0xaa;
264 color.blue = 0xae;
265 color.alpha = 0;
266 pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win),
267 file, &color);
268 if (!pixmap) {
269 char *msg;
270 char *tmp;
272 WMSetButtonEnabled(panel->okButton, False);
274 tmp = _("Could not load image file ");
275 msg = wmalloc(strlen(tmp)+strlen(file)+6);
276 strcpy(msg, tmp);
277 strcat(msg, file);
279 wMessageDialog(panel->scr, _("Error"), msg, _("OK"), NULL, NULL);
280 free(msg);
282 WMSetLabelImage(panel->iconView, NULL);
283 } else {
284 WMSetButtonEnabled(panel->okButton, True);
286 WMSetLabelImage(panel->iconView, pixmap);
287 WMReleasePixmap(pixmap);
292 static void
293 listCallback(void *self, void *data)
295 WMList *lPtr = (WMList*)self;
296 IconPanel *panel = (IconPanel*)data;
297 char *path;
299 if (lPtr==panel->dirList) {
300 path = WMGetListSelectedItem(lPtr)->text;
302 WMSetTextFieldText(panel->fileField, path);
304 WMSetLabelImage(panel->iconView, NULL);
306 WMSetButtonEnabled(panel->okButton, False);
308 WMClearList(panel->iconList);
309 listPixmaps(panel->scr, panel->iconList, path);
310 } else {
311 char *tmp, *iconFile;
313 path = WMGetListSelectedItem(panel->dirList)->text;
314 tmp = wexpandpath(path);
316 iconFile = WMGetListSelectedItem(panel->iconList)->text;
318 path = wmalloc(strlen(tmp)+strlen(iconFile)+4);
319 strcpy(path, tmp);
320 strcat(path, "/");
321 strcat(path, iconFile);
322 free(tmp);
323 WMSetTextFieldText(panel->fileField, path);
324 setViewedImage(panel, path);
325 free(path);
330 static void
331 listIconPaths(WMList *lPtr)
333 char *paths;
334 char *path;
336 paths = wstrdup(wPreferences.icon_path);
338 path = strtok(paths, ":");
340 do {
341 char *tmp;
343 tmp = wexpandpath(path);
344 /* do not sort, because the order implies the order of
345 * directories searched */
346 if (access(tmp, X_OK)==0)
347 WMAddListItem(lPtr, path);
348 free(tmp);
349 } while ((path=strtok(NULL, ":"))!=NULL);
351 free(paths);
356 static void
357 buttonCallback(void *self, void *clientData)
359 WMButton *bPtr = (WMButton*)self;
360 IconPanel *panel = (IconPanel*)clientData;
363 if (bPtr==panel->okButton) {
364 panel->done = True;
365 panel->result = True;
366 } else if (bPtr==panel->cancelButton) {
367 panel->done = True;
368 panel->result = False;
370 #if 0
371 else if (bPtr==panel->chooseButton) {
372 WMOpenPanel *op;
374 op = WMCreateOpenPanel(WMWidgetScreen(bPtr));
376 if (WMRunModalFilePanelForDirectory(op, NULL, "/usr/local", NULL, NULL)) {
377 char *path;
378 path = WMGetFilePanelFile(op);
379 WMSetTextFieldText(panel->fileField, path);
380 setViewedImage(panel, path);
381 free(path);
383 WMDestroyFilePanel(op);
385 #endif
389 Bool
390 wIconChooserDialog(WScreen *scr, char **file, char *instance, char *class)
392 WWindow *wwin;
393 Window parent;
394 IconPanel *panel;
395 WMColor *color;
396 WMFont *boldFont;
398 panel = wmalloc(sizeof(IconPanel));
399 memset(panel, 0, sizeof(IconPanel));
401 panel->scr = scr;
403 panel->win = WMCreateWindow(scr->wmscreen, "iconChooser");
404 WMResizeWidget(panel->win, 450, 280);
406 boldFont = WMBoldSystemFontOfSize(scr->wmscreen, 12);
408 panel->dirLabel = WMCreateLabel(panel->win);
409 WMResizeWidget(panel->dirLabel, 200, 20);
410 WMMoveWidget(panel->dirLabel, 10, 7);
411 WMSetLabelText(panel->dirLabel, _("Directories"));
412 WMSetLabelFont(panel->dirLabel, boldFont);
413 WMSetLabelTextAlignment(panel->dirLabel, WACenter);
415 WMSetLabelRelief(panel->dirLabel, WRSunken);
417 panel->iconLabel = WMCreateLabel(panel->win);
418 WMResizeWidget(panel->iconLabel, 140, 20);
419 WMMoveWidget(panel->iconLabel, 215, 7);
420 WMSetLabelText(panel->iconLabel, _("Icons"));
421 WMSetLabelFont(panel->iconLabel, boldFont);
422 WMSetLabelTextAlignment(panel->iconLabel, WACenter);
424 WMReleaseFont(boldFont);
426 color = WMWhiteColor(scr->wmscreen);
427 WMSetLabelTextColor(panel->dirLabel, color);
428 WMSetLabelTextColor(panel->iconLabel, color);
429 WMReleaseColor(color);
431 color = WMDarkGrayColor(scr->wmscreen);
432 WMSetWidgetBackgroundColor(panel->iconLabel, color);
433 WMSetWidgetBackgroundColor(panel->dirLabel, color);
434 WMReleaseColor(color);
436 WMSetLabelRelief(panel->iconLabel, WRSunken);
438 panel->dirList = WMCreateList(panel->win);
439 WMResizeWidget(panel->dirList, 200, 170);
440 WMMoveWidget(panel->dirList, 10, 30);
441 WMSetListAction(panel->dirList, listCallback, panel);
443 panel->iconList = WMCreateList(panel->win);
444 WMResizeWidget(panel->iconList, 140, 170);
445 WMMoveWidget(panel->iconList, 215, 30);
446 WMSetListAction(panel->iconList, listCallback, panel);
448 panel->iconView = WMCreateLabel(panel->win);
449 WMResizeWidget(panel->iconView, 75, 75);
450 WMMoveWidget(panel->iconView, 365, 60);
451 WMSetLabelImagePosition(panel->iconView, WIPImageOnly);
452 WMSetLabelRelief(panel->iconView, WRSunken);
454 panel->fileLabel = WMCreateLabel(panel->win);
455 WMResizeWidget(panel->fileLabel, 80, 20);
456 WMMoveWidget(panel->fileLabel, 10, 210);
457 WMSetLabelText(panel->fileLabel, _("File Name:"));
459 panel->fileField = WMCreateTextField(panel->win);
460 WMResizeWidget(panel->fileField, 345, 20);
461 WMMoveWidget(panel->fileField, 95, 210);
462 WMSetTextFieldEditable(panel->fileField, False);
464 panel->okButton = WMCreateCommandButton(panel->win);
465 WMResizeWidget(panel->okButton, 80, 26);
466 WMMoveWidget(panel->okButton, 360, 240);
467 WMSetButtonText(panel->okButton, _("OK"));
468 WMSetButtonEnabled(panel->okButton, False);
469 WMSetButtonAction(panel->okButton, buttonCallback, panel);
471 panel->cancelButton = WMCreateCommandButton(panel->win);
472 WMResizeWidget(panel->cancelButton, 80, 26);
473 WMMoveWidget(panel->cancelButton, 270, 240);
474 WMSetButtonText(panel->cancelButton, _("Cancel"));
475 WMSetButtonAction(panel->cancelButton, buttonCallback, panel);
476 #if 0
477 panel->chooseButton = WMCreateCommandButton(panel->win);
478 WMResizeWidget(panel->chooseButton, 110, 26);
479 WMMoveWidget(panel->chooseButton, 150, 240);
480 WMSetButtonText(panel->chooseButton, _("Choose File"));
481 WMSetButtonAction(panel->chooseButton, buttonCallback, panel);
482 #endif
483 WMRealizeWidget(panel->win);
484 WMMapSubwidgets(panel->win);
486 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 450, 280, 0, 0, 0);
488 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
491 char *tmp;
493 tmp = malloc((instance ? strlen(instance) : 0)
494 + (class ? strlen(class) : 0) + 32);
496 if (tmp && (instance || class))
497 sprintf(tmp, "%s [%s.%s]", _("Icon Chooser"), instance, class);
498 else
499 strcpy(tmp, _("Icon Chooser"));
501 wwin = wManageInternalWindow(scr, parent, None, tmp,
502 (scr->scr_width - 450)/2,
503 (scr->scr_height - 280)/2, 450, 280);
504 free(tmp);
507 /* put icon paths in the list */
508 listIconPaths(panel->dirList);
510 WMMapWidget(panel->win);
512 wWindowMap(wwin);
514 while (!panel->done) {
515 XEvent event;
517 WMNextEvent(dpy, &event);
518 WMHandleEvent(&event);
521 if (panel->result) {
522 char *defaultPath, *wantedPath;
524 /* check if the file the user selected is not the one that
525 * would be loaded by default with the current search path */
526 *file = WMGetListSelectedItem(panel->iconList)->text;
527 if ((*file)[0]==0) {
528 free(*file);
529 *file = NULL;
530 } else {
531 defaultPath = FindImage(wPreferences.icon_path, *file);
532 wantedPath = WMGetTextFieldText(panel->fileField);
533 /* if the file is not the default, use full path */
534 if (strcmp(wantedPath, defaultPath)!=0) {
535 *file = wantedPath;
536 } else {
537 *file = wstrdup(*file);
538 free(wantedPath);
540 free(defaultPath);
542 } else {
543 *file = NULL;
546 WMUnmapWidget(panel->win);
548 WMDestroyWidget(panel->win);
550 wUnmanageWindow(wwin, False, False);
552 free(panel);
554 XDestroyWindow(dpy, parent);
556 return panel->result;
561 ***********************************************************************
562 * Info Panel
563 ***********************************************************************
567 typedef struct {
568 WScreen *scr;
570 WWindow *wwin;
572 WMWindow *win;
574 WMLabel *logoL;
575 WMLabel *name1L;
576 WMLabel *name2L;
578 WMLabel *versionL;
580 WMLabel *infoL;
582 WMLabel *copyrL;
584 #ifdef SILLYNESS
585 WMHandlerID timer;
586 int cycle;
587 RImage *icon;
588 RImage *pic;
589 WMPixmap *oldPix;
590 char *str;
591 int x;
592 #endif
593 } InfoPanel;
597 #define COPYRIGHT_TEXT \
598 "Copyright \xa9 1997~1999 Alfredo K. Kojima <kojima@windowmaker.org>\n"\
599 "Copyright \xa9 1998,1999 Dan Pascu <dan@windowmaker.org>"
603 static InfoPanel *thePanel = NULL;
605 static void
606 destroyInfoPanel(WCoreWindow *foo, void *data, XEvent *event)
608 #ifdef SILLYNESS
609 if (thePanel->timer) {
610 WMDeleteTimerHandler(thePanel->timer);
612 if (thePanel->oldPix) {
613 WMReleasePixmap(thePanel->oldPix);
615 if (thePanel->icon) {
616 RDestroyImage(thePanel->icon);
618 if (thePanel->pic) {
619 RDestroyImage(thePanel->pic);
621 #endif /* SILLYNESS */
622 WMUnmapWidget(thePanel);
624 wUnmanageWindow(thePanel->wwin, False, False);
626 WMDestroyWidget(thePanel->win);
628 free(thePanel);
630 thePanel = NULL;
634 WMPixmap*
635 renderText(WMScreen *scr, char *text, char *font, RColor *from, RColor *to)
637 WMPixmap *wpix = NULL;
638 Pixmap grad = None;
639 Pixmap mask = None;
640 RContext *rc = WMScreenRContext(scr);
641 XFontStruct *f = NULL;
642 int w, h;
643 GC gc = None;
645 f = XLoadQueryFont(dpy, font);
646 if (!f)
647 return NULL;
649 w = XTextWidth(f, text, strlen(text));
650 h = f->ascent+f->descent;
652 mask = XCreatePixmap(dpy, rc->drawable, w, h, 1);
653 gc = XCreateGC(dpy, mask, 0, NULL);
654 XSetForeground(dpy, gc, 0);
655 XSetFont(dpy, gc, f->fid);
656 XFillRectangle(dpy, mask, gc, 0, 0, w, h);
658 XSetForeground(dpy, gc, 1);
659 XDrawString(dpy, mask, gc, 0, f->ascent, text, strlen(text));
660 XSetLineAttributes(dpy, gc, 3, LineSolid, CapRound, JoinMiter);
661 XDrawLine(dpy, mask, gc, 0, h-2, w, h-2);
663 grad = XCreatePixmap(dpy, rc->drawable, w, h, rc->depth);
665 WMColor *color;
667 color = WMBlackColor(scr);
668 XFillRectangle(dpy, grad, WMColorGC(color), 0, 0, w, h);
669 WMReleaseColor(color);
672 wpix = WMCreatePixmapFromXPixmaps(scr, grad, mask, w, h, rc->depth);
674 if (gc)
675 XFreeGC(dpy, gc);
676 XFreeFont(dpy, f);
678 return wpix;
681 #ifdef SILLYNESS
683 extern WMPixmap *DoXThing();
684 extern Bool InitXThing();
686 static void
687 logoPushCallback(void *data)
689 InfoPanel *panel = (InfoPanel*)data;
690 char buffer[512];
691 int i;
692 int len;
693 static int jingobeu[] = {
694 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
695 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
696 329, 150, 392, 150, 261, 150, 293, 150, 329, 400, -1, 400, 0
698 static int c = 0;
700 if (panel->x) {
701 XKeyboardControl kc;
703 if (panel->x > 0) {
704 if(jingobeu[panel->x-1]==0){panel->x=-1;}else if(jingobeu[panel->x
705 -1]<0){panel->x++;c=jingobeu[panel->x-1]/50;panel->x++;}else if(c==0){
706 kc.bell_pitch=jingobeu[panel->x-1];panel->x++;kc.bell_percent=50;c=
707 jingobeu[panel->x-1]/50;kc.bell_duration=jingobeu[panel->x-1];panel->x++;
708 XChangeKeyboardControl(dpy,KBBellPitch|KBBellDuration|KBBellPercent,&kc);
709 XBell(dpy,50);XFlush(dpy);}else{c--;}}
710 if (!(panel->cycle % 4)) {
711 WMPixmap *p;
713 p = DoXThing(panel->wwin);
714 WMSetLabelImage(panel->logoL, p);
716 } else if (panel->cycle < 30) {
717 RImage *image;
718 WMPixmap *pix;
720 image = RCloneImage(panel->icon);
721 RCombineImagesWithOpaqueness(image, panel->pic, panel->cycle*255/30);
722 pix = WMCreatePixmapFromRImage(panel->scr->wmscreen, image, 128);
723 RDestroyImage(image);
724 WMSetLabelImage(panel->logoL, pix);
725 WMReleasePixmap(pix);
728 i = panel->cycle%200;
730 len = strlen(panel->str);
732 strncpy(buffer, panel->str, i<len ? i : len);
733 if (i >= len)
734 memset(&buffer[len], ' ', i-len);
736 strncpy(buffer, panel->str, i<len ? i : len);
737 if (i >= len)
738 memset(&buffer[len], ' ', i-len);
739 buffer[i]=0;
740 WMSetLabelText(panel->versionL, buffer);
742 panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
743 panel->cycle++;
747 static void
748 handleLogoPush(XEvent *event, void *data)
750 InfoPanel *panel = (InfoPanel*)data;
751 static int broken = 0;
752 static int clicks = 0;
753 static char *pic_data[] = {
754 "45 45 57 1",
755 " c None",
756 ". c #000000",
757 "X c #383C00",
758 "o c #515500",
759 "O c #616100",
760 "+ c #616900",
761 "@ c #696D00",
762 "# c #697100",
763 "$ c #495100",
764 "% c #202800",
765 "& c #969600",
766 "* c #CFCF00",
767 "= c #D7DB00",
768 "- c #D7D700",
769 "; c #C7CB00",
770 ": c #A6AA00",
771 "> c #494900",
772 ", c #8E8E00",
773 "< c #DFE700",
774 "1 c #F7FF00",
775 "2 c #FFFF00",
776 "3 c #E7EB00",
777 "4 c #B6B600",
778 "5 c #595900",
779 "6 c #717500",
780 "7 c #AEB200",
781 "8 c #CFD300",
782 "9 c #E7EF00",
783 "0 c #EFF300",
784 "q c #9EA200",
785 "w c #F7FB00",
786 "e c #F7F700",
787 "r c #BEBE00",
788 "t c #8E9200",
789 "y c #EFF700",
790 "u c #969A00",
791 "i c #414500",
792 "p c #595D00",
793 "a c #E7E700",
794 "s c #C7C700",
795 "d c #797D00",
796 "f c #BEC300",
797 "g c #DFE300",
798 "h c #868600",
799 "j c #EFEF00",
800 "k c #9E9E00",
801 "l c #616500",
802 "z c #DFDF00",
803 "x c #868A00",
804 "c c #969200",
805 "v c #B6BA00",
806 "b c #A6A600",
807 "n c #8E8A00",
808 "m c #717100",
809 "M c #AEAE00",
810 "N c #AEAA00",
811 "B c #868200",
812 " ............... ",
813 " ....XoO+@##+O$%.... ",
814 " ...%X&*========-;;:o... ",
815 " ...>.>,<122222222222134@... ",
816 " ..>5678912222222222222220q%.. ",
817 " ..$.&-w2222222222222222222er>.. ",
818 " ..O.t31222222222222222222222y4>.. ",
819 " ...O5u3222222222222222222222222yri... ",
820 " ..>p&a22222222222222222222222222wso.. ",
821 " ..ids91222222222222222222222222222wfi.. ",
822 " ..X.7w222222wgs-w2222222213=g0222222<hi.. ",
823 " ..Xuj2222222<@X5=222222229k@l:022222y4i.. ",
824 " .Xdz22222222*X%.s22222222axo%$-222222<c>.. ",
825 " ..o7y22222222v...r222222223hX.i82222221si.. ",
826 "..io*222222222&...u22222222yt..%*22222220:%. ",
827 "..>k02222222227...f222222222v..X=222222229t. ",
828 "..dz12222222220ui:y2222222223d%qw222222221g. ",
829 ".%vw222222222221y2222222222219*y2222222222wd.",
830 ".X;2222222222222222222222222222222222222222b.",
831 ".i*2222222222222222222222222222222222222222v.",
832 ".i*2222222222222222222222222222222222222222;.",
833 ".i*22222222222222222222222222222222222222228.",
834 ".>*2222222222222222222222222222222222222222=.",
835 ".i*22222222222222222222222222222222222222228.",
836 ".i*2222222222222222222222222222222222222222;.",
837 ".X*222222222222222222222222222222we12222222r.",
838 ".Xs12222222w3aw22222222222222222y8s0222222wk.",
839 ".Xq02222222a,na22222222222222222zm6zwy2222gi.",
840 "..>*22222y<:Xcj22222222222222222-o$k;;02228..",
841 "..i7y2220rhX.:y22222222222222222jtiXd,a220,..",
842 " .X@z222a,do%kj2222222222222222wMX5q;gw228%..",
843 " ..58222wagsh6ry222222222222221;>Of0w222y:...",
844 " ...:e2222218mdz22222222222222a&$vw222220@...",
845 " ...O-122222y:.u02222222222229q$uj222221r... ",
846 " ..%&a1222223&573w2222222219NOxz122221z>... ",
847 " ...t3222221-l$nr8ay1222yzbo,=12222w-5... ",
848 " ..X:022222w-k+>o,7s**s7xOn=12221<f5... ",
849 " ..o:9222221j8:&Bl>>>>ihv<12221=dX... ",
850 " ..Xb9122222109g-****;<y22221zn%... ",
851 " ..X&801222222222222222222w-h.... ",
852 " ...o:=022222222222222221=lX... ",
853 " ..X@:;3w2222222222210fO... ",
854 " ...XX&v8<30000003-N@... ",
855 " .....XmnbN:q&Bo.... ",
856 " ............ "};
857 static char *msgs[] = {
858 "Sloppy focus is a *?#@",
859 "Repent! Sloppy focus users will burn in hell!!!",
860 "Have a nice day!"
864 clicks++;
865 if (!panel->timer && !broken && clicks > 0) {
866 char *file;
867 char *path;
869 panel->x = 0;
870 clicks = 0;
871 if (!panel->icon) {
872 file = wDefaultGetIconFile(panel->scr, "Logo", "WMPanel", False);
873 if (!file) {
874 broken = 1;
875 return;
878 path = FindImage(wPreferences.icon_path, file);
879 if (!path) {
880 broken = 1;
881 return;
884 panel->icon = RLoadImage(panel->scr->rcontext, path, 0);
885 free(path);
886 if (!panel->icon) {
887 broken = 1;
888 return;
891 if (!panel->pic) {
892 panel->pic = RGetImageFromXPMData(panel->scr->rcontext, pic_data);
893 if (!panel->pic || panel->icon->width!=panel->pic->width
894 || panel->icon->height!=panel->pic->height) {
895 broken = 1;
896 RDestroyImage(panel->icon);
897 panel->icon = NULL;
898 if (panel->pic) {
899 RDestroyImage(panel->pic);
900 panel->pic = NULL;
902 return;
906 RColor color;
907 color.red = 0xae;
908 color.green = 0xaa;
909 color.blue = 0xae;
910 color.alpha = 255;
911 RCombineImageWithColor(panel->icon, &color);
912 RCombineImageWithColor(panel->pic, &color);
916 panel->str = msgs[rand()%(sizeof(msgs)/sizeof(char*))];
918 panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
919 panel->cycle = 0;
920 panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL));
921 } else if (panel->timer) {
922 char version[20];
924 panel->x = 0;
925 clicks = 0;
926 WMSetLabelImage(panel->logoL, panel->oldPix);
927 WMReleasePixmap(panel->oldPix);
928 panel->oldPix = NULL;
930 WMDeleteTimerHandler(panel->timer);
931 panel->timer = NULL;
933 sprintf(version, "Version %s", VERSION);
934 WMSetLabelText(panel->versionL, version);
938 XEvent ev;
939 while (XCheckTypedWindowEvent(dpy, WMWidgetXID(panel->versionL),
940 ButtonPress, &ev));
943 #endif /* SILLYNESS */
946 void
947 wShowInfoPanel(WScreen *scr)
949 InfoPanel *panel;
950 WMPixmap *logo;
951 WMSize size;
952 WMFont *font;
953 char version[32];
954 char buffer[512];
955 Window parent;
956 WWindow *wwin;
957 RColor color1, color2;
958 char **strl;
959 int i;
960 char *visuals[] = {
961 "StaticGray",
962 "GrayScale",
963 "StaticColor",
964 "PseudoColor",
965 "TrueColor",
966 "DirectColor"
970 if (thePanel) {
971 if (thePanel->scr == scr) {
972 wRaiseFrame(thePanel->wwin->frame->core);
973 wSetFocusTo(scr, thePanel->wwin);
975 return;
978 panel = wmalloc(sizeof(InfoPanel));
979 memset(panel, 0, sizeof(InfoPanel));
981 panel->scr = scr;
983 panel->win = WMCreateWindow(scr->wmscreen, "info");
984 WMResizeWidget(panel->win, 382, 230);
986 logo = WMGetApplicationIconImage(scr->wmscreen);
987 if (logo) {
988 size = WMGetPixmapSize(logo);
989 panel->logoL = WMCreateLabel(panel->win);
990 WMResizeWidget(panel->logoL, 64, 64);
991 WMMoveWidget(panel->logoL, 30, 20);
992 WMSetLabelImagePosition(panel->logoL, WIPImageOnly);
993 WMSetLabelImage(panel->logoL, logo);
994 #ifdef SILLYNESS
995 WMCreateEventHandler(WMWidgetView(panel->logoL), ButtonPressMask,
996 handleLogoPush, panel);
997 #endif
1000 panel->name1L = WMCreateLabel(panel->win);
1001 WMResizeWidget(panel->name1L, 240, 30);
1002 WMMoveWidget(panel->name1L, 100, 30);
1003 color1.red = 0;
1004 color1.green = 0;
1005 color1.blue = 0;
1006 color2.red = 0x50;
1007 color2.green = 0x50;
1008 color2.blue = 0x70;
1009 logo = renderText(scr->wmscreen, "GNU Window Maker",
1010 "-*-utopia-*-r-*-*-25-*", &color1, &color2);
1011 if (logo) {
1012 WMSetLabelImagePosition(panel->name1L, WIPImageOnly);
1013 WMSetLabelImage(panel->name1L, logo);
1014 WMReleasePixmap(logo);
1015 } else {
1016 font = WMBoldSystemFontOfSize(scr->wmscreen, 20);
1017 if (font) {
1018 WMSetLabelFont(panel->name1L, font);
1019 WMReleaseFont(font);
1021 WMSetLabelTextAlignment(panel->name1L, WACenter);
1022 WMSetLabelText(panel->name1L, "GNU Window Maker");
1025 panel->name2L = WMCreateLabel(panel->win);
1026 WMResizeWidget(panel->name2L, 240, 24);
1027 WMMoveWidget(panel->name2L, 100, 60);
1028 font = WMBoldSystemFontOfSize(scr->wmscreen, 18);
1029 if (font) {
1030 WMSetLabelFont(panel->name2L, font);
1031 WMReleaseFont(font);
1032 font = NULL;
1034 WMSetLabelTextAlignment(panel->name2L, WACenter);
1035 WMSetLabelText(panel->name2L, "Window Manager for X");
1038 sprintf(version, "Version %s", VERSION);
1039 panel->versionL = WMCreateLabel(panel->win);
1040 WMResizeWidget(panel->versionL, 310, 16);
1041 WMMoveWidget(panel->versionL, 30, 95);
1042 WMSetLabelTextAlignment(panel->versionL, WARight);
1043 WMSetLabelText(panel->versionL, version);
1044 WMSetLabelWraps(panel->versionL, False);
1046 panel->copyrL = WMCreateLabel(panel->win);
1047 WMResizeWidget(panel->copyrL, 340, 40);
1048 WMMoveWidget(panel->copyrL, 15, 185);
1049 WMSetLabelTextAlignment(panel->copyrL, WALeft);
1050 WMSetLabelText(panel->copyrL, COPYRIGHT_TEXT);
1051 /* we want the (c) character in the helvetica font */
1052 font = WMCreateFontInDefaultEncoding(scr->wmscreen, HELVETICA10_FONT);
1053 if (font) {
1054 WMSetLabelFont(panel->copyrL, font);
1057 switch (scr->w_depth) {
1058 case 15:
1059 strcpy(version, "32 thousand");
1060 break;
1061 case 16:
1062 strcpy(version, "64 thousand");
1063 break;
1064 case 24:
1065 case 32:
1066 strcpy(version, "16 million");
1067 break;
1068 default:
1069 sprintf(version, "%d", 1<<scr->w_depth);
1070 break;
1073 sprintf(buffer, "Using visual 0x%x: %s %ibpp (%s colors)\n",
1074 (unsigned)scr->w_visual->visualid,
1075 visuals[scr->w_visual->class], scr->w_depth, version);
1077 strcat(buffer, "Supported image formats: ");
1078 strl = RSupportedFileFormats();
1079 for (i=0; strl[i]!=NULL; i++) {
1080 strcat(buffer, strl[i]);
1081 strcat(buffer, " ");
1084 strcat(buffer, "\nAdditional Support For: ");
1086 char *list[8];
1087 char buf[80];
1088 int j = 0;
1090 #ifdef MWM_HINTS
1091 list[j++] = "MWM";
1092 #endif
1093 #ifdef KWM_HINTS
1094 list[j++] = "KDE";
1095 #endif
1096 #ifdef GNOME_STUFF
1097 list[j++] = "GNOME";
1098 #endif
1099 #ifdef OLWM_HINTS
1100 list[j++] = "OLWM";
1101 #endif
1102 #ifdef WMSOUND
1103 list[j++] = "Sound";
1104 #endif
1106 buf[0] = 0;
1107 for (i = 0; i < j; i++) {
1108 if (i > 0) {
1109 if (i == j - 1)
1110 strcat(buf, " and ");
1111 else
1112 strcat(buf, ", ");
1114 strcat(buf, list[i]);
1116 strcat(buffer, buf);
1120 panel->infoL = WMCreateLabel(panel->win);
1121 WMResizeWidget(panel->infoL, 350, 75);
1122 WMMoveWidget(panel->infoL, 15, 115);
1123 WMSetLabelText(panel->infoL, buffer);
1124 if (font) {
1125 WMSetLabelFont(panel->infoL, font);
1126 WMReleaseFont(font);
1130 WMRealizeWidget(panel->win);
1131 WMMapSubwidgets(panel->win);
1133 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 382, 230, 0, 0, 0);
1135 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1137 WMMapWidget(panel->win);
1139 wwin = wManageInternalWindow(scr, parent, None, "Info",
1140 (scr->scr_width - 382)/2,
1141 (scr->scr_height - 230)/2, 382, 230);
1143 WSETUFLAG(wwin, no_closable, 0);
1144 WSETUFLAG(wwin, no_close_button, 0);
1145 wWindowUpdateButtonImages(wwin);
1146 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1147 wwin->frame->on_click_right = destroyInfoPanel;
1149 wWindowMap(wwin);
1151 panel->wwin = wwin;
1153 thePanel = panel;
1154 #ifdef SILLYNESS
1155 if (InitXThing(panel->scr)) {
1156 panel->timer = WMAddTimerHandler(100, logoPushCallback, panel);
1157 panel->cycle = 0;
1158 panel->x = 1;
1159 panel->str = "Merry Christmas!";
1160 panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL));
1162 #endif
1167 ***********************************************************************
1168 * Legal Panel
1169 ***********************************************************************
1172 typedef struct {
1173 WScreen *scr;
1175 WWindow *wwin;
1177 WMWindow *win;
1179 WMLabel *licenseL;
1180 } LegalPanel;
1184 #define LICENSE_TEXT \
1185 " Window Maker is free software; you can redistribute it and/or modify "\
1186 "it under the terms of the GNU General Public License as published "\
1187 "by the Free Software Foundation; either version 2 of the License, "\
1188 "or (at your option) any later version.\n\n\n"\
1189 " Window Maker is distributed in the hope that it will be useful, but "\
1190 "WITHOUT ANY WARRANTY; without even the implied warranty of "\
1191 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU "\
1192 "General Public License for more details.\n\n\n"\
1193 " You should have received a copy of the GNU General Public License "\
1194 "along with this program; if not, write to the Free Software "\
1195 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA "\
1196 "02111-1307, USA."
1199 static LegalPanel *legalPanel = NULL;
1201 static void
1202 destroyLegalPanel(WCoreWindow *foo, void *data, XEvent *event)
1204 WMUnmapWidget(legalPanel->win);
1206 WMDestroyWidget(legalPanel->win);
1208 wUnmanageWindow(legalPanel->wwin, False, False);
1210 free(legalPanel);
1212 legalPanel = NULL;
1216 void
1217 wShowLegalPanel(WScreen *scr)
1219 LegalPanel *panel;
1220 Window parent;
1221 WWindow *wwin;
1223 if (legalPanel) {
1224 if (legalPanel->scr == scr) {
1225 wRaiseFrame(legalPanel->wwin->frame->core);
1226 wSetFocusTo(scr, legalPanel->wwin);
1228 return;
1231 panel = wmalloc(sizeof(LegalPanel));
1233 panel->scr = scr;
1235 panel->win = WMCreateWindow(scr->wmscreen, "legal");
1236 WMResizeWidget(panel->win, 420, 250);
1239 panel->licenseL = WMCreateLabel(panel->win);
1240 WMResizeWidget(panel->licenseL, 400, 230);
1241 WMMoveWidget(panel->licenseL, 10, 10);
1242 WMSetLabelTextAlignment(panel->licenseL, WALeft);
1243 WMSetLabelText(panel->licenseL, LICENSE_TEXT);
1244 WMSetLabelRelief(panel->licenseL, WRGroove);
1246 WMRealizeWidget(panel->win);
1247 WMMapSubwidgets(panel->win);
1249 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 420, 250, 0, 0, 0);
1251 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1253 wwin = wManageInternalWindow(scr, parent, None, "Legal",
1254 (scr->scr_width - 420)/2,
1255 (scr->scr_height - 250)/2, 420, 250);
1257 WSETUFLAG(wwin, no_closable, 0);
1258 WSETUFLAG(wwin, no_close_button, 0);
1259 wWindowUpdateButtonImages(wwin);
1260 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1261 wwin->frame->on_click_right = destroyLegalPanel;
1263 panel->wwin = wwin;
1265 WMMapWidget(panel->win);
1267 wWindowMap(wwin);
1269 legalPanel = panel;
1274 ***********************************************************************
1275 * Crashing Dialog Panel
1276 ***********************************************************************
1279 extern WDDomain *WDWindowAttributes;
1282 typedef struct _CrashPanel {
1283 WMWindow *win; /* main window */
1285 WMLabel *iconL; /* application icon */
1286 WMLabel *nameL; /* title of panel */
1288 WMFrame *sepF; /* separator frame */
1290 WMLabel *noteL; /* Title of note */
1291 WMLabel *note2L; /* body of note with what happened */
1293 WMFrame *whatF; /* "what to do next" frame */
1294 WMPopUpButton *whatP; /* action selection popup button */
1296 WMButton *okB; /* ok button */
1298 Bool done; /* if finished with this dialog */
1299 int action; /* what to do after */
1301 KeyCode retKey;
1303 } CrashPanel;
1306 static void
1307 handleKeyPress(XEvent *event, void *clientData)
1309 CrashPanel *panel = (CrashPanel*)clientData;
1311 if (event->xkey.keycode == panel->retKey) {
1312 WMPerformButtonClick(panel->okB);
1317 static void
1318 okButtonCallback(void *self, void *clientData)
1320 CrashPanel *panel = (CrashPanel*)clientData;
1322 panel->done = True;
1326 static void
1327 setCrashAction(void *self, void *clientData)
1329 WMPopUpButton *pop = (WMPopUpButton*)self;
1330 CrashPanel *panel = (CrashPanel*)clientData;
1332 panel->action = WMGetPopUpButtonSelectedItem(pop);
1336 static WMPixmap*
1337 getWindowMakerIconImage(WMScreen *scr)
1339 proplist_t dict, key, option, value=NULL;
1340 WMPixmap *pix=NULL;
1341 char *path;
1343 PLSetStringCmpHook(NULL);
1345 key = PLMakeString("Logo.WMPanel");
1346 option = PLMakeString("Icon");
1348 dict = PLGetDictionaryEntry(WDWindowAttributes->dictionary, key);
1350 if (dict) {
1351 value = PLGetDictionaryEntry(dict, option);
1354 PLRelease(key);
1355 PLRelease(option);
1357 PLSetStringCmpHook(StringCompareHook);
1359 if (value && PLIsString(value)) {
1360 path = FindImage(wPreferences.icon_path, PLGetString(value));
1362 if (path) {
1363 RImage *image;
1365 image = RLoadImage(WMScreenRContext(scr), path, 0);
1366 if (image) {
1367 pix = WMCreatePixmapFromRImage(scr, image, 0);
1368 RDestroyImage(image);
1370 free(path);
1374 return pix;
1378 #define PWIDTH 295
1379 #define PHEIGHT 345
1383 wShowCrashingDialogPanel(int whatSig)
1385 CrashPanel *panel;
1386 WMScreen *scr;
1387 WMFont *font;
1388 WMPixmap *logo;
1389 int screen_no, scr_width, scr_height;
1390 int action;
1391 char buf[256];
1393 panel = wmalloc(sizeof(CrashPanel));
1394 memset(panel, 0, sizeof(CrashPanel));
1396 screen_no = DefaultScreen(dpy);
1397 scr_width = WidthOfScreen(ScreenOfDisplay(dpy, screen_no));
1398 scr_height = HeightOfScreen(ScreenOfDisplay(dpy, screen_no));
1400 scr = WMCreateScreen(dpy, screen_no);
1401 if (!scr) {
1402 wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
1403 return WMAbort;
1406 panel->retKey = XKeysymToKeycode(dpy, XK_Return);
1408 panel->win = WMCreateWindow(scr, "crashingDialog");
1409 WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
1410 WMMoveWidget(panel->win, (scr_width - PWIDTH)/2, (scr_height - PHEIGHT)/2);
1412 logo = getWindowMakerIconImage(scr);
1413 if (logo) {
1414 panel->iconL = WMCreateLabel(panel->win);
1415 WMResizeWidget(panel->iconL, 64, 64);
1416 WMMoveWidget(panel->iconL, 10, 10);
1417 WMSetLabelImagePosition(panel->iconL, WIPImageOnly);
1418 WMSetLabelImage(panel->iconL, logo);
1421 panel->nameL = WMCreateLabel(panel->win);
1422 WMResizeWidget(panel->nameL, 190, 18);
1423 WMMoveWidget(panel->nameL, 80, 35);
1424 WMSetLabelTextAlignment(panel->nameL, WALeft);
1425 font = WMBoldSystemFontOfSize(scr, 18);
1426 WMSetLabelFont(panel->nameL, font);
1427 WMReleaseFont(font);
1428 WMSetLabelText(panel->nameL, _("Fatal error"));
1430 panel->sepF = WMCreateFrame(panel->win);
1431 WMResizeWidget(panel->sepF, PWIDTH+4, 2);
1432 WMMoveWidget(panel->sepF, -2, 80);
1434 panel->noteL = WMCreateLabel(panel->win);
1435 WMResizeWidget(panel->noteL, PWIDTH-20, 40);
1436 WMMoveWidget(panel->noteL, 10, 90);
1437 WMSetLabelTextAlignment(panel->noteL, WAJustified);
1438 #ifdef SYS_SIGLIST_DECLARED
1439 sprintf(buf, _("Window Maker received signal %i\n(%s)."),
1440 whatSig, sys_siglist[whatSig]);
1441 #else
1442 sprintf(buf, _("Window Maker received signal %i."), whatSig);
1443 #endif
1444 WMSetLabelText(panel->noteL, buf);
1446 panel->note2L = WMCreateLabel(panel->win);
1447 WMResizeWidget(panel->note2L, PWIDTH-20, 100);
1448 WMMoveWidget(panel->note2L, 10, 130);
1449 WMSetLabelTextAlignment(panel->note2L, WALeft);
1450 WMSetLabelText(panel->note2L,
1451 _(" This fatal error occured probably due to a bug."
1452 " Please fill the included BUGFORM and "
1453 "report it to bugs@windowmaker.org."));
1456 panel->whatF = WMCreateFrame(panel->win);
1457 WMResizeWidget(panel->whatF, PWIDTH-20, 50);
1458 WMMoveWidget(panel->whatF, 10, 240);
1459 WMSetFrameTitle(panel->whatF, _("What do you want to do now?"));
1461 panel->whatP = WMCreatePopUpButton(panel->whatF);
1462 WMResizeWidget(panel->whatP, PWIDTH-20-70, 20);
1463 WMMoveWidget(panel->whatP, 35, 20);
1464 WMSetPopUpButtonPullsDown(panel->whatP, False);
1465 WMSetPopUpButtonText(panel->whatP, _("Select action"));
1466 WMAddPopUpButtonItem(panel->whatP, _("Abort and leave a core file"));
1467 WMAddPopUpButtonItem(panel->whatP, _("Restart Window Maker"));
1468 WMAddPopUpButtonItem(panel->whatP, _("Start alternate window manager"));
1469 WMSetPopUpButtonAction(panel->whatP, setCrashAction, panel);
1470 WMSetPopUpButtonSelectedItem(panel->whatP, WMRestart);
1471 panel->action = WMRestart;
1473 WMMapSubwidgets(panel->whatF);
1475 panel->okB = WMCreateCommandButton(panel->win);
1476 WMResizeWidget(panel->okB, 80, 26);
1477 WMMoveWidget(panel->okB, 205, 309);
1478 WMSetButtonText(panel->okB, _("OK"));
1479 WMSetButtonImage(panel->okB, WMGetSystemPixmap(scr, WSIReturnArrow));
1480 WMSetButtonAltImage(panel->okB, WMGetSystemPixmap(scr, WSIHighlightedReturnArrow));
1481 WMSetButtonImagePosition(panel->okB, WIPRight);
1482 WMSetButtonAction(panel->okB, okButtonCallback, panel);
1484 panel->done = 0;
1486 WMCreateEventHandler(WMWidgetView(panel->win), KeyPressMask,
1487 handleKeyPress, panel);
1489 WMRealizeWidget(panel->win);
1490 WMMapSubwidgets(panel->win);
1492 WMMapWidget(panel->win);
1494 XSetInputFocus(dpy, WMWidgetXID(panel->win), RevertToParent, CurrentTime);
1496 while (!panel->done) {
1497 XEvent event;
1499 WMNextEvent(dpy, &event);
1500 WMHandleEvent(&event);
1503 action = panel->action;
1505 WMUnmapWidget(panel->win);
1506 WMDestroyWidget(panel->win);
1507 free(panel);
1509 return action;
1515 /*****************************************************************************
1516 * About GNUstep Panel
1517 *****************************************************************************/
1520 static void
1521 drawGNUstepLogo(Display *dpy, Drawable d, int width, int height,
1522 unsigned long blackPixel, unsigned long whitePixel)
1524 GC gc;
1525 XGCValues gcv;
1526 XRectangle rects[3];
1528 gcv.foreground = blackPixel;
1529 gc = XCreateGC(dpy, d, GCForeground, &gcv);
1531 XFillArc(dpy, d, gc, width/45, height/45,
1532 width - 2*width/45, height - 2*height/45, 0, 360*64);
1534 rects[0].x = 0;
1535 rects[0].y = 37*height/45;
1536 rects[0].width = width/3;
1537 rects[0].height = height - rects[0].y;
1539 rects[1].x = rects[0].width;
1540 rects[1].y = height/2;
1541 rects[1].width = width - 2*width/3;
1542 rects[1].height = height - rects[1].y;
1544 rects[2].x = 2*width/3;
1545 rects[2].y = height - 37*height/45;
1546 rects[2].width = width/3;
1547 rects[2].height = height - rects[2].y;
1549 XSetClipRectangles(dpy, gc, 0, 0, rects, 3, Unsorted);
1550 XFillRectangle(dpy, d, gc, 0, 0, width, height);
1552 XSetForeground(dpy, gc, whitePixel);
1553 XFillArc(dpy, d, gc, width/45, height/45,
1554 width - 2*width/45, height - 2*height/45, 0, 360*64);
1556 XFreeGC(dpy, gc);
1561 #define GNUSTEP_TEXT \
1562 "Window Maker is part of the GNUstep project.\n"\
1563 "The GNUstep project aims to create a free\n"\
1564 "implementation of the OpenStep(tm) specification\n"\
1565 "which is a object-oriented framework for\n"\
1566 "creating advanced graphical, multi-platform\n"\
1567 "applications. Aditionally, a development and\n"\
1568 "user desktop enviroment will be created on top\n"\
1569 "of the framework. For more information about\n"\
1570 "GNUstep, please visit: www.gnustep.org"
1573 typedef struct {
1574 WScreen *scr;
1576 WWindow *wwin;
1578 WMWindow *win;
1580 WMLabel *gstepL;
1581 WMLabel *textL;
1582 } GNUstepPanel;
1585 static GNUstepPanel *gnustepPanel = NULL;
1587 static void
1588 destroyGNUstepPanel(WCoreWindow *foo, void *data, XEvent *event)
1590 WMUnmapWidget(gnustepPanel->win);
1592 WMDestroyWidget(gnustepPanel->win);
1594 wUnmanageWindow(gnustepPanel->wwin, False, False);
1596 free(gnustepPanel);
1598 gnustepPanel = NULL;
1602 void
1603 wShowGNUstepPanel(WScreen *scr)
1605 GNUstepPanel *panel;
1606 Window parent;
1607 WWindow *wwin;
1608 WMPixmap *pixmap;
1609 WMColor *color;
1611 if (gnustepPanel) {
1612 if (gnustepPanel->scr == scr) {
1613 wRaiseFrame(gnustepPanel->wwin->frame->core);
1614 wSetFocusTo(scr, gnustepPanel->wwin);
1616 return;
1619 panel = wmalloc(sizeof(GNUstepPanel));
1621 panel->scr = scr;
1623 panel->win = WMCreateWindow(scr->wmscreen, "About GNUstep");
1624 WMResizeWidget(panel->win, 325, 200);
1626 pixmap = WMCreatePixmap(scr->wmscreen, 130, 130,
1627 WMScreenDepth(scr->wmscreen), True);
1629 color = WMCreateNamedColor(scr->wmscreen, "gray50", True);
1631 drawGNUstepLogo(dpy, WMGetPixmapXID(pixmap), 130, 130,
1632 WMColorPixel(color), scr->white_pixel);
1634 WMReleaseColor(color);
1636 drawGNUstepLogo(dpy, WMGetPixmapMaskXID(pixmap), 130, 130, 1, 1);
1638 panel->gstepL = WMCreateLabel(panel->win);
1639 WMResizeWidget(panel->gstepL, 285, 64);
1640 WMMoveWidget(panel->gstepL, 20, 0);
1641 WMSetLabelTextAlignment(panel->gstepL, WARight);
1642 WMSetLabelText(panel->gstepL, "GNUstep");
1644 WMFont *font = WMBoldSystemFontOfSize(scr->wmscreen, 24);
1646 WMSetLabelFont(panel->gstepL, font);
1647 WMReleaseFont(font);
1650 panel->textL = WMCreateLabel(panel->win);
1651 WMResizeWidget(panel->textL, 275, 130);
1652 WMMoveWidget(panel->textL, 30, 50);
1653 WMSetLabelTextAlignment(panel->textL, WARight);
1654 WMSetLabelImagePosition(panel->textL, WIPOverlaps);
1655 WMSetLabelText(panel->textL, GNUSTEP_TEXT);
1656 WMSetLabelImage(panel->textL, pixmap);
1658 WMReleasePixmap(pixmap);
1660 WMRealizeWidget(panel->win);
1661 WMMapSubwidgets(panel->win);
1663 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 325, 200, 0, 0, 0);
1665 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1667 wwin = wManageInternalWindow(scr, parent, None, "About GNUstep",
1668 (scr->scr_width - 325)/2,
1669 (scr->scr_height - 200)/2, 325, 200);
1671 WSETUFLAG(wwin, no_closable, 0);
1672 WSETUFLAG(wwin, no_close_button, 0);
1673 wWindowUpdateButtonImages(wwin);
1674 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1675 wwin->frame->on_click_right = destroyGNUstepPanel;
1677 panel->wwin = wwin;
1679 WMMapWidget(panel->win);
1681 wWindowMap(wwin);
1683 gnustepPanel = panel;