many bug fixes, finished some delegate code, updated menu file bug from EXEC
[wmaker-crm.git] / src / dialog.c
blob2cbf0f9385e9dd6822bb39903dc08eb9d1459be5
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 WMSetButtonEnabled(panel->okButton, False);
271 WMSetLabelText(panel->iconView, _("Could not load image file "));
273 WMSetLabelImage(panel->iconView, NULL);
274 } else {
275 WMSetButtonEnabled(panel->okButton, True);
277 WMSetLabelText(panel->iconView, NULL);
278 WMSetLabelImage(panel->iconView, pixmap);
279 WMReleasePixmap(pixmap);
284 static void
285 listCallback(void *self, void *data)
287 WMList *lPtr = (WMList*)self;
288 IconPanel *panel = (IconPanel*)data;
289 char *path;
291 if (lPtr==panel->dirList) {
292 path = WMGetListSelectedItem(lPtr)->text;
294 WMSetTextFieldText(panel->fileField, path);
296 WMSetLabelImage(panel->iconView, NULL);
298 WMSetButtonEnabled(panel->okButton, False);
300 WMClearList(panel->iconList);
301 listPixmaps(panel->scr, panel->iconList, path);
302 } else {
303 char *tmp, *iconFile;
305 path = WMGetListSelectedItem(panel->dirList)->text;
306 tmp = wexpandpath(path);
308 iconFile = WMGetListSelectedItem(panel->iconList)->text;
310 path = wmalloc(strlen(tmp)+strlen(iconFile)+4);
311 strcpy(path, tmp);
312 strcat(path, "/");
313 strcat(path, iconFile);
314 free(tmp);
315 WMSetTextFieldText(panel->fileField, path);
316 setViewedImage(panel, path);
317 free(path);
322 static void
323 listIconPaths(WMList *lPtr)
325 char *paths;
326 char *path;
328 paths = wstrdup(wPreferences.icon_path);
330 path = strtok(paths, ":");
332 do {
333 char *tmp;
335 tmp = wexpandpath(path);
336 /* do not sort, because the order implies the order of
337 * directories searched */
338 if (access(tmp, X_OK)==0)
339 WMAddListItem(lPtr, path);
340 free(tmp);
341 } while ((path=strtok(NULL, ":"))!=NULL);
343 free(paths);
348 static void
349 buttonCallback(void *self, void *clientData)
351 WMButton *bPtr = (WMButton*)self;
352 IconPanel *panel = (IconPanel*)clientData;
355 if (bPtr==panel->okButton) {
356 panel->done = True;
357 panel->result = True;
358 } else if (bPtr==panel->cancelButton) {
359 panel->done = True;
360 panel->result = False;
362 #if 0
363 else if (bPtr==panel->chooseButton) {
364 WMOpenPanel *op;
366 op = WMCreateOpenPanel(WMWidgetScreen(bPtr));
368 if (WMRunModalFilePanelForDirectory(op, NULL, "/usr/local", NULL, NULL)) {
369 char *path;
370 path = WMGetFilePanelFile(op);
371 WMSetTextFieldText(panel->fileField, path);
372 setViewedImage(panel, path);
373 free(path);
375 WMDestroyFilePanel(op);
377 #endif
381 Bool
382 wIconChooserDialog(WScreen *scr, char **file, char *instance, char *class)
384 WWindow *wwin;
385 Window parent;
386 IconPanel *panel;
387 WMColor *color;
388 WMFont *boldFont;
390 panel = wmalloc(sizeof(IconPanel));
391 memset(panel, 0, sizeof(IconPanel));
393 panel->scr = scr;
395 panel->win = WMCreateWindow(scr->wmscreen, "iconChooser");
396 WMResizeWidget(panel->win, 450, 280);
398 boldFont = WMBoldSystemFontOfSize(scr->wmscreen, 12);
400 panel->dirLabel = WMCreateLabel(panel->win);
401 WMResizeWidget(panel->dirLabel, 200, 20);
402 WMMoveWidget(panel->dirLabel, 10, 7);
403 WMSetLabelText(panel->dirLabel, _("Directories"));
404 WMSetLabelFont(panel->dirLabel, boldFont);
405 WMSetLabelTextAlignment(panel->dirLabel, WACenter);
407 WMSetLabelRelief(panel->dirLabel, WRSunken);
409 panel->iconLabel = WMCreateLabel(panel->win);
410 WMResizeWidget(panel->iconLabel, 140, 20);
411 WMMoveWidget(panel->iconLabel, 215, 7);
412 WMSetLabelText(panel->iconLabel, _("Icons"));
413 WMSetLabelFont(panel->iconLabel, boldFont);
414 WMSetLabelTextAlignment(panel->iconLabel, WACenter);
416 WMReleaseFont(boldFont);
418 color = WMWhiteColor(scr->wmscreen);
419 WMSetLabelTextColor(panel->dirLabel, color);
420 WMSetLabelTextColor(panel->iconLabel, color);
421 WMReleaseColor(color);
423 color = WMDarkGrayColor(scr->wmscreen);
424 WMSetWidgetBackgroundColor(panel->iconLabel, color);
425 WMSetWidgetBackgroundColor(panel->dirLabel, color);
426 WMReleaseColor(color);
428 WMSetLabelRelief(panel->iconLabel, WRSunken);
430 panel->dirList = WMCreateList(panel->win);
431 WMResizeWidget(panel->dirList, 200, 170);
432 WMMoveWidget(panel->dirList, 10, 30);
433 WMSetListAction(panel->dirList, listCallback, panel);
435 panel->iconList = WMCreateList(panel->win);
436 WMResizeWidget(panel->iconList, 140, 170);
437 WMMoveWidget(panel->iconList, 215, 30);
438 WMSetListAction(panel->iconList, listCallback, panel);
440 panel->iconView = WMCreateLabel(panel->win);
441 WMResizeWidget(panel->iconView, 75, 75);
442 WMMoveWidget(panel->iconView, 365, 60);
443 WMSetLabelImagePosition(panel->iconView, WIPOverlaps);
444 WMSetLabelRelief(panel->iconView, WRSunken);
445 WMSetLabelTextAlignment(panel->iconView, WACenter);
447 panel->fileLabel = WMCreateLabel(panel->win);
448 WMResizeWidget(panel->fileLabel, 80, 20);
449 WMMoveWidget(panel->fileLabel, 10, 210);
450 WMSetLabelText(panel->fileLabel, _("File Name:"));
452 panel->fileField = WMCreateTextField(panel->win);
453 WMResizeWidget(panel->fileField, 345, 20);
454 WMMoveWidget(panel->fileField, 95, 210);
455 WMSetTextFieldEditable(panel->fileField, False);
457 panel->okButton = WMCreateCommandButton(panel->win);
458 WMResizeWidget(panel->okButton, 80, 26);
459 WMMoveWidget(panel->okButton, 360, 240);
460 WMSetButtonText(panel->okButton, _("OK"));
461 WMSetButtonEnabled(panel->okButton, False);
462 WMSetButtonAction(panel->okButton, buttonCallback, panel);
464 panel->cancelButton = WMCreateCommandButton(panel->win);
465 WMResizeWidget(panel->cancelButton, 80, 26);
466 WMMoveWidget(panel->cancelButton, 270, 240);
467 WMSetButtonText(panel->cancelButton, _("Cancel"));
468 WMSetButtonAction(panel->cancelButton, buttonCallback, panel);
469 #if 0
470 panel->chooseButton = WMCreateCommandButton(panel->win);
471 WMResizeWidget(panel->chooseButton, 110, 26);
472 WMMoveWidget(panel->chooseButton, 150, 240);
473 WMSetButtonText(panel->chooseButton, _("Choose File"));
474 WMSetButtonAction(panel->chooseButton, buttonCallback, panel);
475 #endif
476 WMRealizeWidget(panel->win);
477 WMMapSubwidgets(panel->win);
479 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 450, 280, 0, 0, 0);
481 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
484 char *tmp;
486 tmp = malloc((instance ? strlen(instance) : 0)
487 + (class ? strlen(class) : 0) + 32);
489 if (tmp && (instance || class))
490 sprintf(tmp, "%s [%s.%s]", _("Icon Chooser"), instance, class);
491 else
492 strcpy(tmp, _("Icon Chooser"));
494 wwin = wManageInternalWindow(scr, parent, None, tmp,
495 (scr->scr_width - 450)/2,
496 (scr->scr_height - 280)/2, 450, 280);
497 free(tmp);
500 /* put icon paths in the list */
501 listIconPaths(panel->dirList);
503 WMMapWidget(panel->win);
505 wWindowMap(wwin);
507 while (!panel->done) {
508 XEvent event;
510 WMNextEvent(dpy, &event);
511 WMHandleEvent(&event);
514 if (panel->result) {
515 char *defaultPath, *wantedPath;
517 /* check if the file the user selected is not the one that
518 * would be loaded by default with the current search path */
519 *file = WMGetListSelectedItem(panel->iconList)->text;
520 if ((*file)[0]==0) {
521 free(*file);
522 *file = NULL;
523 } else {
524 defaultPath = FindImage(wPreferences.icon_path, *file);
525 wantedPath = WMGetTextFieldText(panel->fileField);
526 /* if the file is not the default, use full path */
527 if (strcmp(wantedPath, defaultPath)!=0) {
528 *file = wantedPath;
529 } else {
530 *file = wstrdup(*file);
531 free(wantedPath);
533 free(defaultPath);
535 } else {
536 *file = NULL;
539 WMUnmapWidget(panel->win);
541 WMDestroyWidget(panel->win);
543 wUnmanageWindow(wwin, False, False);
545 free(panel);
547 XDestroyWindow(dpy, parent);
549 return panel->result;
554 ***********************************************************************
555 * Info Panel
556 ***********************************************************************
560 typedef struct {
561 WScreen *scr;
563 WWindow *wwin;
565 WMWindow *win;
567 WMLabel *logoL;
568 WMLabel *name1L;
569 WMLabel *name2L;
571 WMLabel *versionL;
573 WMLabel *infoL;
575 WMLabel *copyrL;
577 #ifdef SILLYNESS
578 WMHandlerID timer;
579 int cycle;
580 RImage *icon;
581 RImage *pic;
582 WMPixmap *oldPix;
583 char *str;
584 int x;
585 #endif
586 } InfoPanel;
590 #define COPYRIGHT_TEXT \
591 "Copyright \xa9 1997~1999 Alfredo K. Kojima <kojima@windowmaker.org>\n"\
592 "Copyright \xa9 1998,1999 Dan Pascu <dan@windowmaker.org>"
596 static InfoPanel *thePanel = NULL;
598 static void
599 destroyInfoPanel(WCoreWindow *foo, void *data, XEvent *event)
601 #ifdef SILLYNESS
602 if (thePanel->timer) {
603 WMDeleteTimerHandler(thePanel->timer);
605 if (thePanel->oldPix) {
606 WMReleasePixmap(thePanel->oldPix);
608 if (thePanel->icon) {
609 RDestroyImage(thePanel->icon);
611 if (thePanel->pic) {
612 RDestroyImage(thePanel->pic);
614 #endif /* SILLYNESS */
615 WMUnmapWidget(thePanel);
617 wUnmanageWindow(thePanel->wwin, False, False);
619 WMDestroyWidget(thePanel->win);
621 free(thePanel);
623 thePanel = NULL;
627 WMPixmap*
628 renderText(WMScreen *scr, char *text, char *font, RColor *from, RColor *to)
630 WMPixmap *wpix = NULL;
631 Pixmap grad = None;
632 Pixmap mask = None;
633 RContext *rc = WMScreenRContext(scr);
634 XFontStruct *f = NULL;
635 int w, h;
636 GC gc = None;
638 f = XLoadQueryFont(dpy, font);
639 if (!f)
640 return NULL;
642 w = XTextWidth(f, text, strlen(text));
643 h = f->ascent+f->descent;
645 mask = XCreatePixmap(dpy, rc->drawable, w, h, 1);
646 gc = XCreateGC(dpy, mask, 0, NULL);
647 XSetForeground(dpy, gc, 0);
648 XSetFont(dpy, gc, f->fid);
649 XFillRectangle(dpy, mask, gc, 0, 0, w, h);
651 XSetForeground(dpy, gc, 1);
652 XDrawString(dpy, mask, gc, 0, f->ascent, text, strlen(text));
653 XSetLineAttributes(dpy, gc, 3, LineSolid, CapRound, JoinMiter);
654 XDrawLine(dpy, mask, gc, 0, h-2, w, h-2);
656 grad = XCreatePixmap(dpy, rc->drawable, w, h, rc->depth);
658 WMColor *color;
660 color = WMBlackColor(scr);
661 XFillRectangle(dpy, grad, WMColorGC(color), 0, 0, w, h);
662 WMReleaseColor(color);
665 wpix = WMCreatePixmapFromXPixmaps(scr, grad, mask, w, h, rc->depth);
667 if (gc)
668 XFreeGC(dpy, gc);
669 XFreeFont(dpy, f);
671 return wpix;
674 #ifdef SILLYNESS
676 extern WMPixmap *DoXThing();
677 extern Bool InitXThing();
679 static void
680 logoPushCallback(void *data)
682 InfoPanel *panel = (InfoPanel*)data;
683 char buffer[512];
684 int i;
685 int len;
686 static int jingobeu[] = {
687 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
688 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
689 329, 150, 392, 150, 261, 150, 293, 150, 329, 400, -1, 400, 0
691 static int c = 0;
693 if (panel->x) {
694 XKeyboardControl kc;
696 if (panel->x > 0) {
697 if(jingobeu[panel->x-1]==0){panel->x=-1;}else if(jingobeu[panel->x
698 -1]<0){panel->x++;c=jingobeu[panel->x-1]/50;panel->x++;}else if(c==0){
699 kc.bell_pitch=jingobeu[panel->x-1];panel->x++;kc.bell_percent=50;c=
700 jingobeu[panel->x-1]/50;kc.bell_duration=jingobeu[panel->x-1];panel->x++;
701 XChangeKeyboardControl(dpy,KBBellPitch|KBBellDuration|KBBellPercent,&kc);
702 XBell(dpy,50);XFlush(dpy);}else{c--;}}
703 if (!(panel->cycle % 4)) {
704 WMPixmap *p;
706 p = DoXThing(panel->wwin);
707 WMSetLabelImage(panel->logoL, p);
709 } else if (panel->cycle < 30) {
710 RImage *image;
711 WMPixmap *pix;
713 image = RCloneImage(panel->icon);
714 RCombineImagesWithOpaqueness(image, panel->pic, panel->cycle*255/30);
715 pix = WMCreatePixmapFromRImage(panel->scr->wmscreen, image, 128);
716 RDestroyImage(image);
717 WMSetLabelImage(panel->logoL, pix);
718 WMReleasePixmap(pix);
721 i = panel->cycle%200;
723 len = strlen(panel->str);
725 strncpy(buffer, panel->str, i<len ? i : len);
726 if (i >= len)
727 memset(&buffer[len], ' ', i-len);
729 strncpy(buffer, panel->str, i<len ? i : len);
730 if (i >= len)
731 memset(&buffer[len], ' ', i-len);
732 buffer[i]=0;
733 WMSetLabelText(panel->versionL, buffer);
735 panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
736 panel->cycle++;
740 static void
741 handleLogoPush(XEvent *event, void *data)
743 InfoPanel *panel = (InfoPanel*)data;
744 static int broken = 0;
745 static int clicks = 0;
746 static char *pic_data[] = {
747 "45 45 57 1",
748 " c None",
749 ". c #000000",
750 "X c #383C00",
751 "o c #515500",
752 "O c #616100",
753 "+ c #616900",
754 "@ c #696D00",
755 "# c #697100",
756 "$ c #495100",
757 "% c #202800",
758 "& c #969600",
759 "* c #CFCF00",
760 "= c #D7DB00",
761 "- c #D7D700",
762 "; c #C7CB00",
763 ": c #A6AA00",
764 "> c #494900",
765 ", c #8E8E00",
766 "< c #DFE700",
767 "1 c #F7FF00",
768 "2 c #FFFF00",
769 "3 c #E7EB00",
770 "4 c #B6B600",
771 "5 c #595900",
772 "6 c #717500",
773 "7 c #AEB200",
774 "8 c #CFD300",
775 "9 c #E7EF00",
776 "0 c #EFF300",
777 "q c #9EA200",
778 "w c #F7FB00",
779 "e c #F7F700",
780 "r c #BEBE00",
781 "t c #8E9200",
782 "y c #EFF700",
783 "u c #969A00",
784 "i c #414500",
785 "p c #595D00",
786 "a c #E7E700",
787 "s c #C7C700",
788 "d c #797D00",
789 "f c #BEC300",
790 "g c #DFE300",
791 "h c #868600",
792 "j c #EFEF00",
793 "k c #9E9E00",
794 "l c #616500",
795 "z c #DFDF00",
796 "x c #868A00",
797 "c c #969200",
798 "v c #B6BA00",
799 "b c #A6A600",
800 "n c #8E8A00",
801 "m c #717100",
802 "M c #AEAE00",
803 "N c #AEAA00",
804 "B c #868200",
805 " ............... ",
806 " ....XoO+@##+O$%.... ",
807 " ...%X&*========-;;:o... ",
808 " ...>.>,<122222222222134@... ",
809 " ..>5678912222222222222220q%.. ",
810 " ..$.&-w2222222222222222222er>.. ",
811 " ..O.t31222222222222222222222y4>.. ",
812 " ...O5u3222222222222222222222222yri... ",
813 " ..>p&a22222222222222222222222222wso.. ",
814 " ..ids91222222222222222222222222222wfi.. ",
815 " ..X.7w222222wgs-w2222222213=g0222222<hi.. ",
816 " ..Xuj2222222<@X5=222222229k@l:022222y4i.. ",
817 " .Xdz22222222*X%.s22222222axo%$-222222<c>.. ",
818 " ..o7y22222222v...r222222223hX.i82222221si.. ",
819 "..io*222222222&...u22222222yt..%*22222220:%. ",
820 "..>k02222222227...f222222222v..X=222222229t. ",
821 "..dz12222222220ui:y2222222223d%qw222222221g. ",
822 ".%vw222222222221y2222222222219*y2222222222wd.",
823 ".X;2222222222222222222222222222222222222222b.",
824 ".i*2222222222222222222222222222222222222222v.",
825 ".i*2222222222222222222222222222222222222222;.",
826 ".i*22222222222222222222222222222222222222228.",
827 ".>*2222222222222222222222222222222222222222=.",
828 ".i*22222222222222222222222222222222222222228.",
829 ".i*2222222222222222222222222222222222222222;.",
830 ".X*222222222222222222222222222222we12222222r.",
831 ".Xs12222222w3aw22222222222222222y8s0222222wk.",
832 ".Xq02222222a,na22222222222222222zm6zwy2222gi.",
833 "..>*22222y<:Xcj22222222222222222-o$k;;02228..",
834 "..i7y2220rhX.:y22222222222222222jtiXd,a220,..",
835 " .X@z222a,do%kj2222222222222222wMX5q;gw228%..",
836 " ..58222wagsh6ry222222222222221;>Of0w222y:...",
837 " ...:e2222218mdz22222222222222a&$vw222220@...",
838 " ...O-122222y:.u02222222222229q$uj222221r... ",
839 " ..%&a1222223&573w2222222219NOxz122221z>... ",
840 " ...t3222221-l$nr8ay1222yzbo,=12222w-5... ",
841 " ..X:022222w-k+>o,7s**s7xOn=12221<f5... ",
842 " ..o:9222221j8:&Bl>>>>ihv<12221=dX... ",
843 " ..Xb9122222109g-****;<y22221zn%... ",
844 " ..X&801222222222222222222w-h.... ",
845 " ...o:=022222222222222221=lX... ",
846 " ..X@:;3w2222222222210fO... ",
847 " ...XX&v8<30000003-N@... ",
848 " .....XmnbN:q&Bo.... ",
849 " ............ "};
850 static char *msgs[] = {
851 "Sloppy focus is a *?#@",
852 "Repent! Sloppy focus users will burn in hell!!!",
853 "Have a nice day!"
857 clicks++;
858 if (!panel->timer && !broken && clicks > 0) {
859 char *file;
860 char *path;
862 panel->x = 0;
863 clicks = 0;
864 if (!panel->icon) {
865 file = wDefaultGetIconFile(panel->scr, "Logo", "WMPanel", False);
866 if (!file) {
867 broken = 1;
868 return;
871 path = FindImage(wPreferences.icon_path, file);
872 if (!path) {
873 broken = 1;
874 return;
877 panel->icon = RLoadImage(panel->scr->rcontext, path, 0);
878 free(path);
879 if (!panel->icon) {
880 broken = 1;
881 return;
884 if (!panel->pic) {
885 panel->pic = RGetImageFromXPMData(panel->scr->rcontext, pic_data);
886 if (!panel->pic || panel->icon->width!=panel->pic->width
887 || panel->icon->height!=panel->pic->height) {
888 broken = 1;
889 RDestroyImage(panel->icon);
890 panel->icon = NULL;
891 if (panel->pic) {
892 RDestroyImage(panel->pic);
893 panel->pic = NULL;
895 return;
899 RColor color;
900 color.red = 0xae;
901 color.green = 0xaa;
902 color.blue = 0xae;
903 color.alpha = 255;
904 RCombineImageWithColor(panel->icon, &color);
905 RCombineImageWithColor(panel->pic, &color);
909 panel->str = msgs[rand()%(sizeof(msgs)/sizeof(char*))];
911 panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
912 panel->cycle = 0;
913 panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL));
914 } else if (panel->timer) {
915 char version[20];
917 panel->x = 0;
918 clicks = 0;
919 WMSetLabelImage(panel->logoL, panel->oldPix);
920 WMReleasePixmap(panel->oldPix);
921 panel->oldPix = NULL;
923 WMDeleteTimerHandler(panel->timer);
924 panel->timer = NULL;
926 sprintf(version, "Version %s", VERSION);
927 WMSetLabelText(panel->versionL, version);
931 XEvent ev;
932 while (XCheckTypedWindowEvent(dpy, WMWidgetXID(panel->versionL),
933 ButtonPress, &ev));
936 #endif /* SILLYNESS */
939 void
940 wShowInfoPanel(WScreen *scr)
942 InfoPanel *panel;
943 WMPixmap *logo;
944 WMSize size;
945 WMFont *font;
946 char version[32];
947 char buffer[512];
948 Window parent;
949 WWindow *wwin;
950 RColor color1, color2;
951 char **strl;
952 int i;
953 char *visuals[] = {
954 "StaticGray",
955 "GrayScale",
956 "StaticColor",
957 "PseudoColor",
958 "TrueColor",
959 "DirectColor"
963 if (thePanel) {
964 if (thePanel->scr == scr) {
965 wRaiseFrame(thePanel->wwin->frame->core);
966 wSetFocusTo(scr, thePanel->wwin);
968 return;
971 panel = wmalloc(sizeof(InfoPanel));
972 memset(panel, 0, sizeof(InfoPanel));
974 panel->scr = scr;
976 panel->win = WMCreateWindow(scr->wmscreen, "info");
977 WMResizeWidget(panel->win, 382, 230);
979 logo = WMGetApplicationIconImage(scr->wmscreen);
980 if (logo) {
981 size = WMGetPixmapSize(logo);
982 panel->logoL = WMCreateLabel(panel->win);
983 WMResizeWidget(panel->logoL, 64, 64);
984 WMMoveWidget(panel->logoL, 30, 20);
985 WMSetLabelImagePosition(panel->logoL, WIPImageOnly);
986 WMSetLabelImage(panel->logoL, logo);
987 #ifdef SILLYNESS
988 WMCreateEventHandler(WMWidgetView(panel->logoL), ButtonPressMask,
989 handleLogoPush, panel);
990 #endif
993 panel->name1L = WMCreateLabel(panel->win);
994 WMResizeWidget(panel->name1L, 240, 30);
995 WMMoveWidget(panel->name1L, 100, 30);
996 color1.red = 0;
997 color1.green = 0;
998 color1.blue = 0;
999 color2.red = 0x50;
1000 color2.green = 0x50;
1001 color2.blue = 0x70;
1002 logo = renderText(scr->wmscreen, "GNU Window Maker",
1003 "-*-utopia-*-r-*-*-25-*", &color1, &color2);
1004 if (logo) {
1005 WMSetLabelImagePosition(panel->name1L, WIPImageOnly);
1006 WMSetLabelImage(panel->name1L, logo);
1007 WMReleasePixmap(logo);
1008 } else {
1009 font = WMBoldSystemFontOfSize(scr->wmscreen, 20);
1010 if (font) {
1011 WMSetLabelFont(panel->name1L, font);
1012 WMReleaseFont(font);
1014 WMSetLabelTextAlignment(panel->name1L, WACenter);
1015 WMSetLabelText(panel->name1L, "GNU Window Maker");
1018 panel->name2L = WMCreateLabel(panel->win);
1019 WMResizeWidget(panel->name2L, 240, 24);
1020 WMMoveWidget(panel->name2L, 100, 60);
1021 font = WMBoldSystemFontOfSize(scr->wmscreen, 18);
1022 if (font) {
1023 WMSetLabelFont(panel->name2L, font);
1024 WMReleaseFont(font);
1025 font = NULL;
1027 WMSetLabelTextAlignment(panel->name2L, WACenter);
1028 WMSetLabelText(panel->name2L, "Window Manager for X");
1031 sprintf(version, "Version %s", VERSION);
1032 panel->versionL = WMCreateLabel(panel->win);
1033 WMResizeWidget(panel->versionL, 310, 16);
1034 WMMoveWidget(panel->versionL, 30, 95);
1035 WMSetLabelTextAlignment(panel->versionL, WARight);
1036 WMSetLabelText(panel->versionL, version);
1037 WMSetLabelWraps(panel->versionL, False);
1039 panel->copyrL = WMCreateLabel(panel->win);
1040 WMResizeWidget(panel->copyrL, 340, 40);
1041 WMMoveWidget(panel->copyrL, 15, 185);
1042 WMSetLabelTextAlignment(panel->copyrL, WALeft);
1043 WMSetLabelText(panel->copyrL, COPYRIGHT_TEXT);
1044 /* we want the (c) character in the helvetica font */
1045 font = WMCreateFontInDefaultEncoding(scr->wmscreen, HELVETICA10_FONT);
1046 if (font) {
1047 WMSetLabelFont(panel->copyrL, font);
1050 switch (scr->w_depth) {
1051 case 15:
1052 strcpy(version, "32 thousand");
1053 break;
1054 case 16:
1055 strcpy(version, "64 thousand");
1056 break;
1057 case 24:
1058 case 32:
1059 strcpy(version, "16 million");
1060 break;
1061 default:
1062 sprintf(version, "%d", 1<<scr->w_depth);
1063 break;
1066 sprintf(buffer, "Using visual 0x%x: %s %ibpp (%s colors)\n",
1067 (unsigned)scr->w_visual->visualid,
1068 visuals[scr->w_visual->class], scr->w_depth, version);
1070 strcat(buffer, "Supported image formats: ");
1071 strl = RSupportedFileFormats();
1072 for (i=0; strl[i]!=NULL; i++) {
1073 strcat(buffer, strl[i]);
1074 strcat(buffer, " ");
1077 strcat(buffer, "\nAdditional Support For: ");
1079 char *list[8];
1080 char buf[80];
1081 int j = 0;
1083 #ifdef MWM_HINTS
1084 list[j++] = "MWM";
1085 #endif
1086 #ifdef KWM_HINTS
1087 list[j++] = "KDE";
1088 #endif
1089 #ifdef GNOME_STUFF
1090 list[j++] = "GNOME";
1091 #endif
1092 #ifdef OLWM_HINTS
1093 list[j++] = "OLWM";
1094 #endif
1095 #ifdef WMSOUND
1096 list[j++] = "Sound";
1097 #endif
1099 buf[0] = 0;
1100 for (i = 0; i < j; i++) {
1101 if (i > 0) {
1102 if (i == j - 1)
1103 strcat(buf, " and ");
1104 else
1105 strcat(buf, ", ");
1107 strcat(buf, list[i]);
1109 strcat(buffer, buf);
1113 panel->infoL = WMCreateLabel(panel->win);
1114 WMResizeWidget(panel->infoL, 350, 75);
1115 WMMoveWidget(panel->infoL, 15, 115);
1116 WMSetLabelText(panel->infoL, buffer);
1117 if (font) {
1118 WMSetLabelFont(panel->infoL, font);
1119 WMReleaseFont(font);
1123 WMRealizeWidget(panel->win);
1124 WMMapSubwidgets(panel->win);
1126 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 382, 230, 0, 0, 0);
1128 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1130 WMMapWidget(panel->win);
1132 wwin = wManageInternalWindow(scr, parent, None, "Info",
1133 (scr->scr_width - 382)/2,
1134 (scr->scr_height - 230)/2, 382, 230);
1136 WSETUFLAG(wwin, no_closable, 0);
1137 WSETUFLAG(wwin, no_close_button, 0);
1138 #ifdef XKB_BUTTON_HINT
1139 wFrameWindowHideButton(wwin->frame, WFF_LANGUAGE_BUTTON);
1140 #endif
1141 wWindowUpdateButtonImages(wwin);
1142 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1143 wwin->frame->on_click_right = destroyInfoPanel;
1145 wWindowMap(wwin);
1147 panel->wwin = wwin;
1149 thePanel = panel;
1150 #ifdef SILLYNESS
1151 if (InitXThing(panel->scr)) {
1152 panel->timer = WMAddTimerHandler(100, logoPushCallback, panel);
1153 panel->cycle = 0;
1154 panel->x = 1;
1155 panel->str = "Merry Christmas!";
1156 panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL));
1158 #endif
1163 ***********************************************************************
1164 * Legal Panel
1165 ***********************************************************************
1168 typedef struct {
1169 WScreen *scr;
1171 WWindow *wwin;
1173 WMWindow *win;
1175 WMLabel *licenseL;
1176 } LegalPanel;
1180 #define LICENSE_TEXT \
1181 " Window Maker is free software; you can redistribute it and/or modify "\
1182 "it under the terms of the GNU General Public License as published "\
1183 "by the Free Software Foundation; either version 2 of the License, "\
1184 "or (at your option) any later version.\n\n\n"\
1185 " Window Maker is distributed in the hope that it will be useful, but "\
1186 "WITHOUT ANY WARRANTY; without even the implied warranty of "\
1187 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU "\
1188 "General Public License for more details.\n\n\n"\
1189 " You should have received a copy of the GNU General Public License "\
1190 "along with this program; if not, write to the Free Software "\
1191 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA "\
1192 "02111-1307, USA."
1195 static LegalPanel *legalPanel = NULL;
1197 static void
1198 destroyLegalPanel(WCoreWindow *foo, void *data, XEvent *event)
1200 WMUnmapWidget(legalPanel->win);
1202 WMDestroyWidget(legalPanel->win);
1204 wUnmanageWindow(legalPanel->wwin, False, False);
1206 free(legalPanel);
1208 legalPanel = NULL;
1212 void
1213 wShowLegalPanel(WScreen *scr)
1215 LegalPanel *panel;
1216 Window parent;
1217 WWindow *wwin;
1219 if (legalPanel) {
1220 if (legalPanel->scr == scr) {
1221 wRaiseFrame(legalPanel->wwin->frame->core);
1222 wSetFocusTo(scr, legalPanel->wwin);
1224 return;
1227 panel = wmalloc(sizeof(LegalPanel));
1229 panel->scr = scr;
1231 panel->win = WMCreateWindow(scr->wmscreen, "legal");
1232 WMResizeWidget(panel->win, 420, 250);
1235 panel->licenseL = WMCreateLabel(panel->win);
1236 WMResizeWidget(panel->licenseL, 400, 230);
1237 WMMoveWidget(panel->licenseL, 10, 10);
1238 WMSetLabelTextAlignment(panel->licenseL, WALeft);
1239 WMSetLabelText(panel->licenseL, LICENSE_TEXT);
1240 WMSetLabelRelief(panel->licenseL, WRGroove);
1242 WMRealizeWidget(panel->win);
1243 WMMapSubwidgets(panel->win);
1245 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 420, 250, 0, 0, 0);
1247 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1249 wwin = wManageInternalWindow(scr, parent, None, "Legal",
1250 (scr->scr_width - 420)/2,
1251 (scr->scr_height - 250)/2, 420, 250);
1253 WSETUFLAG(wwin, no_closable, 0);
1254 WSETUFLAG(wwin, no_close_button, 0);
1255 wWindowUpdateButtonImages(wwin);
1256 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1257 #ifdef XKB_BUTTON_HINT
1258 wFrameWindowHideButton(wwin->frame, WFF_LANGUAGE_BUTTON);
1259 #endif
1260 wwin->frame->on_click_right = destroyLegalPanel;
1262 panel->wwin = wwin;
1264 WMMapWidget(panel->win);
1266 wWindowMap(wwin);
1268 legalPanel = panel;
1273 ***********************************************************************
1274 * Crashing Dialog Panel
1275 ***********************************************************************
1278 extern WDDomain *WDWindowAttributes;
1281 typedef struct _CrashPanel {
1282 WMWindow *win; /* main window */
1284 WMLabel *iconL; /* application icon */
1285 WMLabel *nameL; /* title of panel */
1287 WMFrame *sepF; /* separator frame */
1289 WMLabel *noteL; /* Title of note */
1290 WMLabel *note2L; /* body of note with what happened */
1292 WMFrame *whatF; /* "what to do next" frame */
1293 WMPopUpButton *whatP; /* action selection popup button */
1295 WMButton *okB; /* ok button */
1297 Bool done; /* if finished with this dialog */
1298 int action; /* what to do after */
1300 KeyCode retKey;
1302 } CrashPanel;
1305 static void
1306 handleKeyPress(XEvent *event, void *clientData)
1308 CrashPanel *panel = (CrashPanel*)clientData;
1310 if (event->xkey.keycode == panel->retKey) {
1311 WMPerformButtonClick(panel->okB);
1316 static void
1317 okButtonCallback(void *self, void *clientData)
1319 CrashPanel *panel = (CrashPanel*)clientData;
1321 panel->done = True;
1325 static void
1326 setCrashAction(void *self, void *clientData)
1328 WMPopUpButton *pop = (WMPopUpButton*)self;
1329 CrashPanel *panel = (CrashPanel*)clientData;
1331 panel->action = WMGetPopUpButtonSelectedItem(pop);
1335 static WMPixmap*
1336 getWindowMakerIconImage(WMScreen *scr)
1338 proplist_t dict, key, option, value=NULL;
1339 WMPixmap *pix=NULL;
1340 char *path;
1342 PLSetStringCmpHook(NULL);
1344 key = PLMakeString("Logo.WMPanel");
1345 option = PLMakeString("Icon");
1347 dict = PLGetDictionaryEntry(WDWindowAttributes->dictionary, key);
1349 if (dict) {
1350 value = PLGetDictionaryEntry(dict, option);
1353 PLRelease(key);
1354 PLRelease(option);
1356 PLSetStringCmpHook(StringCompareHook);
1358 if (value && PLIsString(value)) {
1359 path = FindImage(wPreferences.icon_path, PLGetString(value));
1361 if (path) {
1362 RImage *image;
1364 image = RLoadImage(WMScreenRContext(scr), path, 0);
1365 if (image) {
1366 pix = WMCreatePixmapFromRImage(scr, image, 0);
1367 RDestroyImage(image);
1369 free(path);
1373 return pix;
1377 #define PWIDTH 295
1378 #define PHEIGHT 345
1382 wShowCrashingDialogPanel(int whatSig)
1384 CrashPanel *panel;
1385 WMScreen *scr;
1386 WMFont *font;
1387 WMPixmap *logo;
1388 int screen_no, scr_width, scr_height;
1389 int action;
1390 char buf[256];
1392 panel = wmalloc(sizeof(CrashPanel));
1393 memset(panel, 0, sizeof(CrashPanel));
1395 screen_no = DefaultScreen(dpy);
1396 scr_width = WidthOfScreen(ScreenOfDisplay(dpy, screen_no));
1397 scr_height = HeightOfScreen(ScreenOfDisplay(dpy, screen_no));
1399 scr = WMCreateScreen(dpy, screen_no);
1400 if (!scr) {
1401 wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
1402 return WMAbort;
1405 panel->retKey = XKeysymToKeycode(dpy, XK_Return);
1407 panel->win = WMCreateWindow(scr, "crashingDialog");
1408 WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
1409 WMMoveWidget(panel->win, (scr_width - PWIDTH)/2, (scr_height - PHEIGHT)/2);
1411 logo = getWindowMakerIconImage(scr);
1412 if (logo) {
1413 panel->iconL = WMCreateLabel(panel->win);
1414 WMResizeWidget(panel->iconL, 64, 64);
1415 WMMoveWidget(panel->iconL, 10, 10);
1416 WMSetLabelImagePosition(panel->iconL, WIPImageOnly);
1417 WMSetLabelImage(panel->iconL, logo);
1420 panel->nameL = WMCreateLabel(panel->win);
1421 WMResizeWidget(panel->nameL, 190, 18);
1422 WMMoveWidget(panel->nameL, 80, 35);
1423 WMSetLabelTextAlignment(panel->nameL, WALeft);
1424 font = WMBoldSystemFontOfSize(scr, 18);
1425 WMSetLabelFont(panel->nameL, font);
1426 WMReleaseFont(font);
1427 WMSetLabelText(panel->nameL, _("Fatal error"));
1429 panel->sepF = WMCreateFrame(panel->win);
1430 WMResizeWidget(panel->sepF, PWIDTH+4, 2);
1431 WMMoveWidget(panel->sepF, -2, 80);
1433 panel->noteL = WMCreateLabel(panel->win);
1434 WMResizeWidget(panel->noteL, PWIDTH-20, 40);
1435 WMMoveWidget(panel->noteL, 10, 90);
1436 WMSetLabelTextAlignment(panel->noteL, WAJustified);
1437 #ifdef SYS_SIGLIST_DECLARED
1438 sprintf(buf, _("Window Maker received signal %i\n(%s)."),
1439 whatSig, sys_siglist[whatSig]);
1440 #else
1441 sprintf(buf, _("Window Maker received signal %i."), whatSig);
1442 #endif
1443 WMSetLabelText(panel->noteL, buf);
1445 panel->note2L = WMCreateLabel(panel->win);
1446 WMResizeWidget(panel->note2L, PWIDTH-20, 100);
1447 WMMoveWidget(panel->note2L, 10, 130);
1448 WMSetLabelTextAlignment(panel->note2L, WALeft);
1449 WMSetLabelText(panel->note2L,
1450 _(" This fatal error occured probably due to a bug."
1451 " Please fill the included BUGFORM and "
1452 "report it to bugs@windowmaker.org."));
1455 panel->whatF = WMCreateFrame(panel->win);
1456 WMResizeWidget(panel->whatF, PWIDTH-20, 50);
1457 WMMoveWidget(panel->whatF, 10, 240);
1458 WMSetFrameTitle(panel->whatF, _("What do you want to do now?"));
1460 panel->whatP = WMCreatePopUpButton(panel->whatF);
1461 WMResizeWidget(panel->whatP, PWIDTH-20-70, 20);
1462 WMMoveWidget(panel->whatP, 35, 20);
1463 WMSetPopUpButtonPullsDown(panel->whatP, False);
1464 WMSetPopUpButtonText(panel->whatP, _("Select action"));
1465 WMAddPopUpButtonItem(panel->whatP, _("Abort and leave a core file"));
1466 WMAddPopUpButtonItem(panel->whatP, _("Restart Window Maker"));
1467 WMAddPopUpButtonItem(panel->whatP, _("Start alternate window manager"));
1468 WMSetPopUpButtonAction(panel->whatP, setCrashAction, panel);
1469 WMSetPopUpButtonSelectedItem(panel->whatP, WMRestart);
1470 panel->action = WMRestart;
1472 WMMapSubwidgets(panel->whatF);
1474 panel->okB = WMCreateCommandButton(panel->win);
1475 WMResizeWidget(panel->okB, 80, 26);
1476 WMMoveWidget(panel->okB, 205, 309);
1477 WMSetButtonText(panel->okB, _("OK"));
1478 WMSetButtonImage(panel->okB, WMGetSystemPixmap(scr, WSIReturnArrow));
1479 WMSetButtonAltImage(panel->okB, WMGetSystemPixmap(scr, WSIHighlightedReturnArrow));
1480 WMSetButtonImagePosition(panel->okB, WIPRight);
1481 WMSetButtonAction(panel->okB, okButtonCallback, panel);
1483 panel->done = 0;
1485 WMCreateEventHandler(WMWidgetView(panel->win), KeyPressMask,
1486 handleKeyPress, panel);
1488 WMRealizeWidget(panel->win);
1489 WMMapSubwidgets(panel->win);
1491 WMMapWidget(panel->win);
1493 XSetInputFocus(dpy, WMWidgetXID(panel->win), RevertToParent, CurrentTime);
1495 while (!panel->done) {
1496 XEvent event;
1498 WMNextEvent(dpy, &event);
1499 WMHandleEvent(&event);
1502 action = panel->action;
1504 WMUnmapWidget(panel->win);
1505 WMDestroyWidget(panel->win);
1506 free(panel);
1508 return action;
1514 /*****************************************************************************
1515 * About GNUstep Panel
1516 *****************************************************************************/
1519 static void
1520 drawGNUstepLogo(Display *dpy, Drawable d, int width, int height,
1521 unsigned long blackPixel, unsigned long whitePixel)
1523 GC gc;
1524 XGCValues gcv;
1525 XRectangle rects[3];
1527 gcv.foreground = blackPixel;
1528 gc = XCreateGC(dpy, d, GCForeground, &gcv);
1530 XFillArc(dpy, d, gc, width/45, height/45,
1531 width - 2*width/45, height - 2*height/45, 0, 360*64);
1533 rects[0].x = 0;
1534 rects[0].y = 37*height/45;
1535 rects[0].width = width/3;
1536 rects[0].height = height - rects[0].y;
1538 rects[1].x = rects[0].width;
1539 rects[1].y = height/2;
1540 rects[1].width = width - 2*width/3;
1541 rects[1].height = height - rects[1].y;
1543 rects[2].x = 2*width/3;
1544 rects[2].y = height - 37*height/45;
1545 rects[2].width = width/3;
1546 rects[2].height = height - rects[2].y;
1548 XSetClipRectangles(dpy, gc, 0, 0, rects, 3, Unsorted);
1549 XFillRectangle(dpy, d, gc, 0, 0, width, height);
1551 XSetForeground(dpy, gc, whitePixel);
1552 XFillArc(dpy, d, gc, width/45, height/45,
1553 width - 2*width/45, height - 2*height/45, 0, 360*64);
1555 XFreeGC(dpy, gc);
1560 #define GNUSTEP_TEXT \
1561 "Window Maker is part of the GNUstep project.\n"\
1562 "The GNUstep project aims to create a free\n"\
1563 "implementation of the OpenStep(tm) specification\n"\
1564 "which is a object-oriented framework for\n"\
1565 "creating advanced graphical, multi-platform\n"\
1566 "applications. Aditionally, a development and\n"\
1567 "user desktop enviroment will be created on top\n"\
1568 "of the framework. For more information about\n"\
1569 "GNUstep, please visit: www.gnustep.org"
1572 typedef struct {
1573 WScreen *scr;
1575 WWindow *wwin;
1577 WMWindow *win;
1579 WMLabel *gstepL;
1580 WMLabel *textL;
1581 } GNUstepPanel;
1584 static GNUstepPanel *gnustepPanel = NULL;
1586 static void
1587 destroyGNUstepPanel(WCoreWindow *foo, void *data, XEvent *event)
1589 WMUnmapWidget(gnustepPanel->win);
1591 WMDestroyWidget(gnustepPanel->win);
1593 wUnmanageWindow(gnustepPanel->wwin, False, False);
1595 free(gnustepPanel);
1597 gnustepPanel = NULL;
1601 void
1602 wShowGNUstepPanel(WScreen *scr)
1604 GNUstepPanel *panel;
1605 Window parent;
1606 WWindow *wwin;
1607 WMPixmap *pixmap;
1608 WMColor *color;
1610 if (gnustepPanel) {
1611 if (gnustepPanel->scr == scr) {
1612 wRaiseFrame(gnustepPanel->wwin->frame->core);
1613 wSetFocusTo(scr, gnustepPanel->wwin);
1615 return;
1618 panel = wmalloc(sizeof(GNUstepPanel));
1620 panel->scr = scr;
1622 panel->win = WMCreateWindow(scr->wmscreen, "About GNUstep");
1623 WMResizeWidget(panel->win, 325, 200);
1625 pixmap = WMCreatePixmap(scr->wmscreen, 130, 130,
1626 WMScreenDepth(scr->wmscreen), True);
1628 color = WMCreateNamedColor(scr->wmscreen, "gray50", True);
1630 drawGNUstepLogo(dpy, WMGetPixmapXID(pixmap), 130, 130,
1631 WMColorPixel(color), scr->white_pixel);
1633 WMReleaseColor(color);
1635 XSetForeground(dpy, scr->mono_gc, 0);
1636 XFillRectangle(dpy, WMGetPixmapMaskXID(pixmap), scr->mono_gc, 0, 0,
1637 130, 130);
1638 drawGNUstepLogo(dpy, WMGetPixmapMaskXID(pixmap), 130, 130, 1, 1);
1640 panel->gstepL = WMCreateLabel(panel->win);
1641 WMResizeWidget(panel->gstepL, 285, 64);
1642 WMMoveWidget(panel->gstepL, 20, 0);
1643 WMSetLabelTextAlignment(panel->gstepL, WARight);
1644 WMSetLabelText(panel->gstepL, "GNUstep");
1646 WMFont *font = WMBoldSystemFontOfSize(scr->wmscreen, 24);
1648 WMSetLabelFont(panel->gstepL, font);
1649 WMReleaseFont(font);
1652 panel->textL = WMCreateLabel(panel->win);
1653 WMResizeWidget(panel->textL, 275, 130);
1654 WMMoveWidget(panel->textL, 30, 50);
1655 WMSetLabelTextAlignment(panel->textL, WARight);
1656 WMSetLabelImagePosition(panel->textL, WIPOverlaps);
1657 WMSetLabelText(panel->textL, GNUSTEP_TEXT);
1658 WMSetLabelImage(panel->textL, pixmap);
1660 WMReleasePixmap(pixmap);
1662 WMRealizeWidget(panel->win);
1663 WMMapSubwidgets(panel->win);
1665 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 325, 200, 0, 0, 0);
1667 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1669 wwin = wManageInternalWindow(scr, parent, None, "About GNUstep",
1670 (scr->scr_width - 325)/2,
1671 (scr->scr_height - 200)/2, 325, 200);
1673 WSETUFLAG(wwin, no_closable, 0);
1674 WSETUFLAG(wwin, no_close_button, 0);
1675 wWindowUpdateButtonImages(wwin);
1676 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1677 #ifdef XKB_BUTTON_HINT
1678 wFrameWindowHideButton(wwin->frame, WFF_LANGUAGE_BUTTON);
1679 #endif
1680 wwin->frame->on_click_right = destroyGNUstepPanel;
1682 panel->wwin = wwin;
1684 WMMapWidget(panel->win);
1686 wWindowMap(wwin);
1688 gnustepPanel = panel;