Fixed non-responding panels in wmaker.
[wmaker-crm.git] / src / dialog.c
blobff00e9465747bbcc3c32bd7f52014561ab2eb361
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 #ifdef HAVE_MALLOC_H
40 #include <malloc.h>
41 #endif
43 #include <signal.h>
44 #ifdef __FreeBSD__
45 #include <sys/signal.h>
46 #endif
49 #ifndef PATH_MAX
50 #define PATH_MAX DEFAULT_PATH_MAX
51 #endif
53 #include "WindowMaker.h"
54 #include "GNUstep.h"
55 #include "screen.h"
56 #include "dialog.h"
57 #include "funcs.h"
58 #include "stacking.h"
59 #include "framewin.h"
60 #include "window.h"
61 #include "actions.h"
62 #include "defaults.h"
65 extern WPreferences wPreferences;
69 int
70 wMessageDialog(WScreen *scr, char *title, char *message,
71 char *defBtn, char *altBtn, char *othBtn)
73 WMAlertPanel *panel;
74 Window parent;
75 WWindow *wwin;
76 int result;
78 panel = WMCreateAlertPanel(scr->wmscreen, NULL, title, message,
79 defBtn, altBtn, othBtn);
81 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 400, 180, 0, 0, 0);
83 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
85 wwin = wManageInternalWindow(scr, parent, None, NULL,
86 (scr->scr_width - 400)/2,
87 (scr->scr_height - 180)/2, 400, 180);
88 wwin->client_leader = WMWidgetXID(panel->win);
90 WMMapWidget(panel->win);
92 wWindowMap(wwin);
94 WMRunModalLoop(WMWidgetScreen(panel->win), WMWidgetView(panel->win));
96 result = panel->result;
98 WMUnmapWidget(panel->win);
100 wUnmanageWindow(wwin, False, False);
102 WMDestroyAlertPanel(panel);
104 XDestroyWindow(dpy, parent);
106 return result;
112 wInputDialog(WScreen *scr, char *title, char *message, char **text)
114 WWindow *wwin;
115 Window parent;
116 WMInputPanel *panel;
117 char *result;
120 panel = WMCreateInputPanel(scr->wmscreen, NULL, title, message, *text,
121 _("OK"), _("Cancel"));
124 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 320, 160, 0, 0, 0);
125 XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask);
127 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
129 wwin = wManageInternalWindow(scr, parent, None, NULL,
130 (scr->scr_width - 320)/2,
131 (scr->scr_height - 160)/2, 320, 160);
133 wwin->client_leader = WMWidgetXID(panel->win);
135 WMMapWidget(panel->win);
137 wWindowMap(wwin);
139 WMRunModalLoop(WMWidgetScreen(panel->win), WMWidgetView(panel->win));
141 if (panel->result == WAPRDefault)
142 result = WMGetTextFieldText(panel->text);
143 else
144 result = NULL;
146 wUnmanageWindow(wwin, False, False);
148 WMDestroyInputPanel(panel);
150 XDestroyWindow(dpy, parent);
152 if (result==NULL)
153 return False;
154 else {
155 if (*text)
156 wfree(*text);
157 *text = result;
159 return True;
165 *****************************************************************
166 * Icon Selection Panel
167 *****************************************************************
170 typedef struct IconPanel {
172 WScreen *scr;
174 WMWindow *win;
176 WMLabel *dirLabel;
177 WMLabel *iconLabel;
179 WMList *dirList;
180 WMList *iconList;
181 WMFont *normalfont;
183 WMButton *previewButton;
185 WMLabel *iconView;
187 WMLabel *fileLabel;
188 WMTextField *fileField;
190 WMButton *okButton;
191 WMButton *cancelButton;
192 #if 0
193 WMButton *chooseButton;
194 #endif
195 short done;
196 short result;
197 short preview;
198 } IconPanel;
202 static void
203 listPixmaps(WScreen *scr, WMList *lPtr, char *path)
205 struct dirent *dentry;
206 DIR *dir;
207 char pbuf[PATH_MAX+16];
208 char *apath;
209 IconPanel *panel = WMGetHangedData(lPtr);
211 panel->preview = False;
213 apath = wexpandpath(path);
214 dir = opendir(apath);
216 if (!dir) {
217 char *msg;
218 char *tmp;
219 tmp = _("Could not open directory ");
220 msg = wmalloc(strlen(tmp)+strlen(path)+6);
221 strcpy(msg, tmp);
222 strcat(msg, path);
224 wMessageDialog(scr, _("Error"), msg, _("OK"), NULL, NULL);
225 wfree(msg);
226 wfree(apath);
227 return;
230 /* list contents in the column */
231 while ((dentry = readdir(dir))) {
232 struct stat statb;
234 if (strcmp(dentry->d_name, ".")==0 ||
235 strcmp(dentry->d_name, "..")==0)
236 continue;
238 strcpy(pbuf, apath);
239 strcat(pbuf, "/");
240 strcat(pbuf, dentry->d_name);
242 if (stat(pbuf, &statb)<0)
243 continue;
245 if (statb.st_mode & (S_IRUSR|S_IRGRP|S_IROTH)
246 && statb.st_mode & (S_IFREG|S_IFLNK)) {
247 WMAddListItem(lPtr, dentry->d_name);
250 WMSortListItems(lPtr);
252 closedir(dir);
253 wfree(apath);
254 panel->preview = True;
259 static void
260 setViewedImage(IconPanel *panel, char *file)
262 WMPixmap *pixmap;
263 RColor color;
265 color.red = 0xae;
266 color.green = 0xaa;
267 color.blue = 0xae;
268 color.alpha = 0;
269 pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win),
270 file, &color);
271 if (!pixmap) {
272 WMSetButtonEnabled(panel->okButton, False);
274 WMSetLabelText(panel->iconView, _("Could not load image file "));
276 WMSetLabelImage(panel->iconView, NULL);
277 } else {
278 WMSetButtonEnabled(panel->okButton, True);
280 WMSetLabelText(panel->iconView, NULL);
281 WMSetLabelImage(panel->iconView, pixmap);
282 WMReleasePixmap(pixmap);
287 static void
288 listCallback(void *self, void *data)
290 WMList *lPtr = (WMList*)self;
291 IconPanel *panel = (IconPanel*)data;
292 char *path;
294 if (lPtr==panel->dirList) {
295 path = WMGetListSelectedItem(lPtr)->text;
297 WMSetTextFieldText(panel->fileField, path);
299 WMSetLabelImage(panel->iconView, NULL);
301 WMSetButtonEnabled(panel->okButton, False);
303 WMClearList(panel->iconList);
304 listPixmaps(panel->scr, panel->iconList, path);
305 } else {
306 char *tmp, *iconFile;
308 path = WMGetListSelectedItem(panel->dirList)->text;
309 tmp = wexpandpath(path);
311 iconFile = WMGetListSelectedItem(panel->iconList)->text;
313 path = wmalloc(strlen(tmp)+strlen(iconFile)+4);
314 strcpy(path, tmp);
315 strcat(path, "/");
316 strcat(path, iconFile);
317 wfree(tmp);
318 WMSetTextFieldText(panel->fileField, path);
319 setViewedImage(panel, path);
320 wfree(path);
325 static void
326 listIconPaths(WMList *lPtr)
328 char *paths;
329 char *path;
331 paths = wstrdup(wPreferences.icon_path);
333 path = strtok(paths, ":");
335 do {
336 char *tmp;
338 tmp = wexpandpath(path);
339 /* do not sort, because the order implies the order of
340 * directories searched */
341 if (access(tmp, X_OK)==0)
342 WMAddListItem(lPtr, path);
343 wfree(tmp);
344 } while ((path=strtok(NULL, ":"))!=NULL);
346 wfree(paths);
350 void
351 drawIconProc(WMList *lPtr, int index, Drawable d, char *text,
352 int state, WMRect *rect)
354 IconPanel *panel = WMGetHangedData(lPtr);
355 GC gc = panel->scr->draw_gc;
356 GC copygc = panel->scr->copy_gc;
357 char *buffer, *dirfile;
358 WMPixmap *pixmap;
359 WMColor *blackcolor;
360 WMColor *whitecolor;
361 WMSize size;
362 WMScreen *wmscr=WMWidgetScreen(panel->win);
363 int width;
365 if(!panel->preview) return;
367 width = rect->size.width;
369 blackcolor = WMBlackColor(wmscr);
370 whitecolor = WMWhiteColor(wmscr);
372 dirfile = wexpandpath(WMGetListSelectedItem(panel->dirList)->text);
373 buffer = wmalloc(strlen(dirfile)+strlen(text)+4);
374 sprintf(buffer, "%s/%s", dirfile, text);
375 wfree(dirfile);
377 pixmap = WMCreatePixmapFromFile(WMWidgetScreen(panel->win), buffer);
378 wfree(buffer);
379 if (!pixmap) {
380 WMRemoveListItem(lPtr, index);
381 return;
384 XClearArea(dpy, d, rect->pos.x, rect->pos.y, width, rect->size.height,
385 False);
386 XSetClipMask(dpy, gc, None);
388 XDrawRectangle(dpy, d, WMColorGC(whitecolor), rect->pos.x + 5,
389 rect->pos.y +5, width - 10, 54);
391 XDrawLine(dpy, d, WMColorGC(whitecolor), rect->pos.x,
392 rect->pos.y+rect->size.height-1, rect->pos.x+width,
393 rect->pos.y+rect->size.height-1);
396 if (state&WLDSSelected) {
397 XFillRectangle(dpy, d, WMColorGC(whitecolor), rect->pos.x,
398 rect->pos.y, width, rect->size.height);
401 size = WMGetPixmapSize(pixmap);
403 XSetClipMask(dpy, copygc, WMGetPixmapMaskXID(pixmap));
404 XSetClipOrigin(dpy, copygc, rect->pos.x + (width-size.width)/2,
405 rect->pos.y+2);
406 XCopyArea(dpy, WMGetPixmapXID(pixmap), d, copygc, 0, 0,
407 size.width>100?100:size.width, size.height>64?64:size.height,
408 rect->pos.x + (width-size.width)/2, rect->pos.y+2);
411 int i,j;
412 int fheight = WMFontHeight(panel->normalfont);
413 int tlen = strlen(text);
414 int twidth = WMWidthOfString(panel->normalfont, text, tlen);
415 int ofx, ofy;
417 ofx = rect->pos.x + (width - twidth)/2;
418 ofy = rect->pos.y + 64 - fheight;
420 for(i=-1;i<2;i++)
421 for(j=-1;j<2;j++)
422 WMDrawString(wmscr, d, WMColorGC(whitecolor),
423 panel->normalfont, ofx+i, ofy+j,
424 text, tlen);
426 WMDrawString(wmscr, d, WMColorGC(blackcolor), panel->normalfont,
427 ofx, ofy, text, tlen);
430 WMReleasePixmap(pixmap);
431 /* I hope it is better to do not use cache / on my box it is fast nuff */
432 XFlush(dpy);
434 WMReleaseColor(blackcolor);
435 WMReleaseColor(whitecolor);
439 static void
440 buttonCallback(void *self, void *clientData)
442 WMButton *bPtr = (WMButton*)self;
443 IconPanel *panel = (IconPanel*)clientData;
446 if (bPtr==panel->okButton) {
447 panel->done = True;
448 panel->result = True;
449 } else if (bPtr==panel->cancelButton) {
450 panel->done = True;
451 panel->result = False;
452 } else if (bPtr==panel->previewButton) {
453 /**** Previewer ****/
454 WMSetButtonEnabled(bPtr, False);
455 WMSetListUserDrawItemHeight(panel->iconList, 68);
456 WMSetListUserDrawProc(panel->iconList, drawIconProc);
457 WMRedisplayWidget(panel->iconList);
458 /* for draw proc to access screen/gc */
459 /*** end preview ***/
461 #if 0
462 else if (bPtr==panel->chooseButton) {
463 WMOpenPanel *op;
465 op = WMCreateOpenPanel(WMWidgetScreen(bPtr));
467 if (WMRunModalFilePanelForDirectory(op, NULL, "/usr/local", NULL, NULL)) {
468 char *path;
469 path = WMGetFilePanelFile(op);
470 WMSetTextFieldText(panel->fileField, path);
471 setViewedImage(panel, path);
472 wfree(path);
474 WMDestroyFilePanel(op);
476 #endif
480 Bool
481 wIconChooserDialog(WScreen *scr, char **file, char *instance, char *class)
483 WWindow *wwin;
484 Window parent;
485 IconPanel *panel;
486 WMColor *color;
487 WMFont *boldFont;
489 panel = wmalloc(sizeof(IconPanel));
490 memset(panel, 0, sizeof(IconPanel));
492 panel->scr = scr;
494 panel->win = WMCreateWindow(scr->wmscreen, "iconChooser");
495 WMResizeWidget(panel->win, 450, 280);
497 boldFont = WMBoldSystemFontOfSize(scr->wmscreen, 12);
498 panel->normalfont = WMSystemFontOfSize(WMWidgetScreen(panel->win), 12);
500 panel->dirLabel = WMCreateLabel(panel->win);
501 WMResizeWidget(panel->dirLabel, 200, 20);
502 WMMoveWidget(panel->dirLabel, 10, 7);
503 WMSetLabelText(panel->dirLabel, _("Directories"));
504 WMSetLabelFont(panel->dirLabel, boldFont);
505 WMSetLabelTextAlignment(panel->dirLabel, WACenter);
507 WMSetLabelRelief(panel->dirLabel, WRSunken);
509 panel->iconLabel = WMCreateLabel(panel->win);
510 WMResizeWidget(panel->iconLabel, 140, 20);
511 WMMoveWidget(panel->iconLabel, 215, 7);
512 WMSetLabelText(panel->iconLabel, _("Icons"));
513 WMSetLabelFont(panel->iconLabel, boldFont);
514 WMSetLabelTextAlignment(panel->iconLabel, WACenter);
516 WMReleaseFont(boldFont);
518 color = WMWhiteColor(scr->wmscreen);
519 WMSetLabelTextColor(panel->dirLabel, color);
520 WMSetLabelTextColor(panel->iconLabel, color);
521 WMReleaseColor(color);
523 color = WMDarkGrayColor(scr->wmscreen);
524 WMSetWidgetBackgroundColor(panel->iconLabel, color);
525 WMSetWidgetBackgroundColor(panel->dirLabel, color);
526 WMReleaseColor(color);
528 WMSetLabelRelief(panel->iconLabel, WRSunken);
530 panel->dirList = WMCreateList(panel->win);
531 WMResizeWidget(panel->dirList, 200, 170);
532 WMMoveWidget(panel->dirList, 10, 30);
533 WMSetListAction(panel->dirList, listCallback, panel);
535 panel->iconList = WMCreateList(panel->win);
536 WMResizeWidget(panel->iconList, 140, 170);
537 WMMoveWidget(panel->iconList, 215, 30);
538 WMSetListAction(panel->iconList, listCallback, panel);
540 WMHangData(panel->iconList,panel);
542 panel->previewButton = WMCreateCommandButton(panel->win);
543 WMResizeWidget(panel->previewButton, 75, 26);
544 WMMoveWidget(panel->previewButton, 365, 130);
545 WMSetButtonText(panel->previewButton, _("Preview"));
546 WMSetButtonAction(panel->previewButton, buttonCallback, panel);
548 panel->iconView = WMCreateLabel(panel->win);
549 WMResizeWidget(panel->iconView, 75, 75);
550 WMMoveWidget(panel->iconView, 365, 40);
551 WMSetLabelImagePosition(panel->iconView, WIPOverlaps);
552 WMSetLabelRelief(panel->iconView, WRSunken);
553 WMSetLabelTextAlignment(panel->iconView, WACenter);
555 panel->fileLabel = WMCreateLabel(panel->win);
556 WMResizeWidget(panel->fileLabel, 80, 20);
557 WMMoveWidget(panel->fileLabel, 10, 210);
558 WMSetLabelText(panel->fileLabel, _("File Name:"));
560 panel->fileField = WMCreateTextField(panel->win);
561 WMResizeWidget(panel->fileField, 345, 20);
562 WMMoveWidget(panel->fileField, 95, 210);
563 WMSetTextFieldEditable(panel->fileField, False);
565 panel->okButton = WMCreateCommandButton(panel->win);
566 WMResizeWidget(panel->okButton, 80, 26);
567 WMMoveWidget(panel->okButton, 360, 240);
568 WMSetButtonText(panel->okButton, _("OK"));
569 WMSetButtonEnabled(panel->okButton, False);
570 WMSetButtonAction(panel->okButton, buttonCallback, panel);
572 panel->cancelButton = WMCreateCommandButton(panel->win);
573 WMResizeWidget(panel->cancelButton, 80, 26);
574 WMMoveWidget(panel->cancelButton, 270, 240);
575 WMSetButtonText(panel->cancelButton, _("Cancel"));
576 WMSetButtonAction(panel->cancelButton, buttonCallback, panel);
577 #if 0
578 panel->chooseButton = WMCreateCommandButton(panel->win);
579 WMResizeWidget(panel->chooseButton, 110, 26);
580 WMMoveWidget(panel->chooseButton, 150, 240);
581 WMSetButtonText(panel->chooseButton, _("Choose File"));
582 WMSetButtonAction(panel->chooseButton, buttonCallback, panel);
583 #endif
584 WMRealizeWidget(panel->win);
585 WMMapSubwidgets(panel->win);
587 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 450, 280, 0, 0, 0);
589 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
592 char *tmp;
594 tmp = wmalloc((instance ? strlen(instance) : 0)
595 + (class ? strlen(class) : 0) + 32);
597 if (tmp && (instance || class))
598 sprintf(tmp, "%s [%s.%s]", _("Icon Chooser"), instance, class);
599 else
600 strcpy(tmp, _("Icon Chooser"));
602 wwin = wManageInternalWindow(scr, parent, None, tmp,
603 (scr->scr_width - 450)/2,
604 (scr->scr_height - 280)/2, 450, 280);
605 wfree(tmp);
608 /* put icon paths in the list */
609 listIconPaths(panel->dirList);
611 WMMapWidget(panel->win);
613 wWindowMap(wwin);
615 while (!panel->done) {
616 XEvent event;
618 WMNextEvent(dpy, &event);
619 WMHandleEvent(&event);
622 if (panel->result) {
623 char *defaultPath, *wantedPath;
625 /* check if the file the user selected is not the one that
626 * would be loaded by default with the current search path */
627 *file = WMGetListSelectedItem(panel->iconList)->text;
628 if ((*file)[0]==0) {
629 wfree(*file);
630 *file = NULL;
631 } else {
632 defaultPath = FindImage(wPreferences.icon_path, *file);
633 wantedPath = WMGetTextFieldText(panel->fileField);
634 /* if the file is not the default, use full path */
635 if (strcmp(wantedPath, defaultPath)!=0) {
636 *file = wantedPath;
637 } else {
638 *file = wstrdup(*file);
639 wfree(wantedPath);
641 wfree(defaultPath);
643 } else {
644 *file = NULL;
647 WMReleaseFont(panel->normalfont);
649 WMUnmapWidget(panel->win);
651 WMDestroyWidget(panel->win);
653 wUnmanageWindow(wwin, False, False);
655 wfree(panel);
657 XDestroyWindow(dpy, parent);
659 return panel->result;
664 ***********************************************************************
665 * Info Panel
666 ***********************************************************************
670 typedef struct {
671 WScreen *scr;
673 WWindow *wwin;
675 WMWindow *win;
677 WMLabel *logoL;
678 WMLabel *name1L;
679 WMLabel *name2L;
681 WMLabel *versionL;
683 WMLabel *infoL;
685 WMLabel *copyrL;
687 #ifdef SILLYNESS
688 WMHandlerID timer;
689 int cycle;
690 RImage *icon;
691 RImage *pic;
692 WMPixmap *oldPix;
693 char *str;
694 int x;
695 #endif
696 } InfoPanel;
700 #define COPYRIGHT_TEXT \
701 "Copyright \xa9 1997~2000 Alfredo K. Kojima <kojima@windowmaker.org>\n"\
702 "Copyright \xa9 1998~2000 Dan Pascu <dan@windowmaker.org>"
706 static InfoPanel *thePanel = NULL;
708 static void
709 destroyInfoPanel(WCoreWindow *foo, void *data, XEvent *event)
711 #ifdef SILLYNESS
712 if (thePanel->timer) {
713 WMDeleteTimerHandler(thePanel->timer);
715 if (thePanel->oldPix) {
716 WMReleasePixmap(thePanel->oldPix);
718 if (thePanel->icon) {
719 RDestroyImage(thePanel->icon);
721 if (thePanel->pic) {
722 RDestroyImage(thePanel->pic);
724 #endif /* SILLYNESS */
725 WMUnmapWidget(thePanel);
727 wUnmanageWindow(thePanel->wwin, False, False);
729 WMDestroyWidget(thePanel->win);
731 wfree(thePanel);
733 thePanel = NULL;
737 WMPixmap*
738 renderText(WMScreen *scr, char *text, char *font, RColor *from, RColor *to)
740 WMPixmap *wpix = NULL;
741 Pixmap grad = None;
742 Pixmap mask = None;
743 RContext *rc = WMScreenRContext(scr);
744 XFontStruct *f = NULL;
745 int w, h;
746 GC gc = None;
748 f = XLoadQueryFont(dpy, font);
749 if (!f)
750 return NULL;
752 w = XTextWidth(f, text, strlen(text));
753 h = f->ascent+f->descent;
755 mask = XCreatePixmap(dpy, rc->drawable, w, h, 1);
756 gc = XCreateGC(dpy, mask, 0, NULL);
757 XSetForeground(dpy, gc, 0);
758 XSetFont(dpy, gc, f->fid);
759 XFillRectangle(dpy, mask, gc, 0, 0, w, h);
761 XSetForeground(dpy, gc, 1);
762 XDrawString(dpy, mask, gc, 0, f->ascent, text, strlen(text));
763 XSetLineAttributes(dpy, gc, 3, LineSolid, CapRound, JoinMiter);
764 XDrawLine(dpy, mask, gc, 0, h-2, w, h-2);
766 grad = XCreatePixmap(dpy, rc->drawable, w, h, rc->depth);
768 WMColor *color;
770 color = WMBlackColor(scr);
771 XFillRectangle(dpy, grad, WMColorGC(color), 0, 0, w, h);
772 WMReleaseColor(color);
775 wpix = WMCreatePixmapFromXPixmaps(scr, grad, mask, w, h, rc->depth);
777 if (gc)
778 XFreeGC(dpy, gc);
779 XFreeFont(dpy, f);
781 return wpix;
784 #ifdef SILLYNESS
786 extern WMPixmap *DoXThing();
787 extern Bool InitXThing();
789 static void
790 logoPushCallback(void *data)
792 InfoPanel *panel = (InfoPanel*)data;
793 char buffer[512];
794 int i;
795 int len;
796 static int jingobeu[] = {
797 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
798 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
799 329, 150, 392, 150, 261, 150, 293, 150, 329, 400, -1, 400, 0
801 static int c = 0;
803 if (panel->x) {
804 XKeyboardControl kc;
806 if (panel->x > 0) {
807 if(jingobeu[panel->x-1]==0){panel->x=-1;}else if(jingobeu[panel->x
808 -1]<0){panel->x++;c=jingobeu[panel->x-1]/50;panel->x++;}else if(c==0){
809 kc.bell_pitch=jingobeu[panel->x-1];panel->x++;kc.bell_percent=50;c=
810 jingobeu[panel->x-1]/50;kc.bell_duration=jingobeu[panel->x-1];panel->x++;
811 XChangeKeyboardControl(dpy,KBBellPitch|KBBellDuration|KBBellPercent,&kc);
812 XBell(dpy,50);XFlush(dpy);}else{c--;}}
813 if (!(panel->cycle % 4)) {
814 WMPixmap *p;
816 p = DoXThing(panel->wwin);
817 WMSetLabelImage(panel->logoL, p);
819 } else if (panel->cycle < 30) {
820 RImage *image;
821 WMPixmap *pix;
823 image = RCloneImage(panel->icon);
824 RCombineImagesWithOpaqueness(image, panel->pic, panel->cycle*255/30);
825 pix = WMCreatePixmapFromRImage(panel->scr->wmscreen, image, 128);
826 RDestroyImage(image);
827 WMSetLabelImage(panel->logoL, pix);
828 WMReleasePixmap(pix);
831 i = panel->cycle%200;
833 len = strlen(panel->str);
835 strncpy(buffer, panel->str, i<len ? i : len);
836 if (i >= len)
837 memset(&buffer[len], ' ', i-len);
839 strncpy(buffer, panel->str, i<len ? i : len);
840 if (i >= len)
841 memset(&buffer[len], ' ', i-len);
842 buffer[i]=0;
843 WMSetLabelText(panel->versionL, buffer);
845 panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
846 panel->cycle++;
850 static void
851 handleLogoPush(XEvent *event, void *data)
853 InfoPanel *panel = (InfoPanel*)data;
854 static int broken = 0;
855 static int clicks = 0;
856 static char *pic_data[] = {
857 "45 45 57 1",
858 " c None",
859 ". c #000000",
860 "X c #383C00",
861 "o c #515500",
862 "O c #616100",
863 "+ c #616900",
864 "@ c #696D00",
865 "# c #697100",
866 "$ c #495100",
867 "% c #202800",
868 "& c #969600",
869 "* c #CFCF00",
870 "= c #D7DB00",
871 "- c #D7D700",
872 "; c #C7CB00",
873 ": c #A6AA00",
874 "> c #494900",
875 ", c #8E8E00",
876 "< c #DFE700",
877 "1 c #F7FF00",
878 "2 c #FFFF00",
879 "3 c #E7EB00",
880 "4 c #B6B600",
881 "5 c #595900",
882 "6 c #717500",
883 "7 c #AEB200",
884 "8 c #CFD300",
885 "9 c #E7EF00",
886 "0 c #EFF300",
887 "q c #9EA200",
888 "w c #F7FB00",
889 "e c #F7F700",
890 "r c #BEBE00",
891 "t c #8E9200",
892 "y c #EFF700",
893 "u c #969A00",
894 "i c #414500",
895 "p c #595D00",
896 "a c #E7E700",
897 "s c #C7C700",
898 "d c #797D00",
899 "f c #BEC300",
900 "g c #DFE300",
901 "h c #868600",
902 "j c #EFEF00",
903 "k c #9E9E00",
904 "l c #616500",
905 "z c #DFDF00",
906 "x c #868A00",
907 "c c #969200",
908 "v c #B6BA00",
909 "b c #A6A600",
910 "n c #8E8A00",
911 "m c #717100",
912 "M c #AEAE00",
913 "N c #AEAA00",
914 "B c #868200",
915 " ............... ",
916 " ....XoO+@##+O$%.... ",
917 " ...%X&*========-;;:o... ",
918 " ...>.>,<122222222222134@... ",
919 " ..>5678912222222222222220q%.. ",
920 " ..$.&-w2222222222222222222er>.. ",
921 " ..O.t31222222222222222222222y4>.. ",
922 " ...O5u3222222222222222222222222yri... ",
923 " ..>p&a22222222222222222222222222wso.. ",
924 " ..ids91222222222222222222222222222wfi.. ",
925 " ..X.7w222222wgs-w2222222213=g0222222<hi.. ",
926 " ..Xuj2222222<@X5=222222229k@l:022222y4i.. ",
927 " .Xdz22222222*X%.s22222222axo%$-222222<c>.. ",
928 " ..o7y22222222v...r222222223hX.i82222221si.. ",
929 "..io*222222222&...u22222222yt..%*22222220:%. ",
930 "..>k02222222227...f222222222v..X=222222229t. ",
931 "..dz12222222220ui:y2222222223d%qw222222221g. ",
932 ".%vw222222222221y2222222222219*y2222222222wd.",
933 ".X;2222222222222222222222222222222222222222b.",
934 ".i*2222222222222222222222222222222222222222v.",
935 ".i*2222222222222222222222222222222222222222;.",
936 ".i*22222222222222222222222222222222222222228.",
937 ".>*2222222222222222222222222222222222222222=.",
938 ".i*22222222222222222222222222222222222222228.",
939 ".i*2222222222222222222222222222222222222222;.",
940 ".X*222222222222222222222222222222we12222222r.",
941 ".Xs12222222w3aw22222222222222222y8s0222222wk.",
942 ".Xq02222222a,na22222222222222222zm6zwy2222gi.",
943 "..>*22222y<:Xcj22222222222222222-o$k;;02228..",
944 "..i7y2220rhX.:y22222222222222222jtiXd,a220,..",
945 " .X@z222a,do%kj2222222222222222wMX5q;gw228%..",
946 " ..58222wagsh6ry222222222222221;>Of0w222y:...",
947 " ...:e2222218mdz22222222222222a&$vw222220@...",
948 " ...O-122222y:.u02222222222229q$uj222221r... ",
949 " ..%&a1222223&573w2222222219NOxz122221z>... ",
950 " ...t3222221-l$nr8ay1222yzbo,=12222w-5... ",
951 " ..X:022222w-k+>o,7s**s7xOn=12221<f5... ",
952 " ..o:9222221j8:&Bl>>>>ihv<12221=dX... ",
953 " ..Xb9122222109g-****;<y22221zn%... ",
954 " ..X&801222222222222222222w-h.... ",
955 " ...o:=022222222222222221=lX... ",
956 " ..X@:;3w2222222222210fO... ",
957 " ...XX&v8<30000003-N@... ",
958 " .....XmnbN:q&Bo.... ",
959 " ............ "};
960 static char *msgs[] = {
961 "Have a nice day!"
965 clicks++;
966 if (!panel->timer && !broken && clicks > 0) {
967 char *file;
968 char *path;
970 panel->x = 0;
971 clicks = 0;
972 if (!panel->icon) {
973 file = wDefaultGetIconFile(panel->scr, "Logo", "WMPanel", False);
974 if (!file) {
975 broken = 1;
976 return;
979 path = FindImage(wPreferences.icon_path, file);
980 if (!path) {
981 broken = 1;
982 return;
985 panel->icon = RLoadImage(panel->scr->rcontext, path, 0);
986 wfree(path);
987 if (!panel->icon) {
988 broken = 1;
989 return;
992 if (!panel->pic) {
993 panel->pic = RGetImageFromXPMData(panel->scr->rcontext, pic_data);
994 if (!panel->pic || panel->icon->width!=panel->pic->width
995 || panel->icon->height!=panel->pic->height) {
996 broken = 1;
997 RDestroyImage(panel->icon);
998 panel->icon = NULL;
999 if (panel->pic) {
1000 RDestroyImage(panel->pic);
1001 panel->pic = NULL;
1003 return;
1007 RColor color;
1008 color.red = 0xae;
1009 color.green = 0xaa;
1010 color.blue = 0xae;
1011 color.alpha = 255;
1012 RCombineImageWithColor(panel->icon, &color);
1013 RCombineImageWithColor(panel->pic, &color);
1017 panel->str = msgs[rand()%(sizeof(msgs)/sizeof(char*))];
1019 panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
1020 panel->cycle = 0;
1021 panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL));
1022 } else if (panel->timer) {
1023 char version[20];
1025 panel->x = 0;
1026 clicks = 0;
1027 WMSetLabelImage(panel->logoL, panel->oldPix);
1028 WMReleasePixmap(panel->oldPix);
1029 panel->oldPix = NULL;
1031 WMDeleteTimerHandler(panel->timer);
1032 panel->timer = NULL;
1034 sprintf(version, "Version %s", VERSION);
1035 WMSetLabelText(panel->versionL, version);
1039 XEvent ev;
1040 while (XCheckTypedWindowEvent(dpy, WMWidgetXID(panel->versionL),
1041 ButtonPress, &ev));
1044 #endif /* SILLYNESS */
1047 void
1048 wShowInfoPanel(WScreen *scr)
1050 InfoPanel *panel;
1051 WMPixmap *logo;
1052 WMSize size;
1053 WMFont *font;
1054 char version[32];
1055 char buffer[512];
1056 Window parent;
1057 WWindow *wwin;
1058 RColor color1, color2;
1059 char **strl;
1060 int i;
1061 char *visuals[] = {
1062 "StaticGray",
1063 "GrayScale",
1064 "StaticColor",
1065 "PseudoColor",
1066 "TrueColor",
1067 "DirectColor"
1071 if (thePanel) {
1072 if (thePanel->scr == scr) {
1073 wRaiseFrame(thePanel->wwin->frame->core);
1074 wSetFocusTo(scr, thePanel->wwin);
1076 return;
1079 panel = wmalloc(sizeof(InfoPanel));
1080 memset(panel, 0, sizeof(InfoPanel));
1082 panel->scr = scr;
1084 panel->win = WMCreateWindow(scr->wmscreen, "info");
1085 WMResizeWidget(panel->win, 382, 230);
1087 logo = WMGetApplicationIconImage(scr->wmscreen);
1088 if (logo) {
1089 size = WMGetPixmapSize(logo);
1090 panel->logoL = WMCreateLabel(panel->win);
1091 WMResizeWidget(panel->logoL, 64, 64);
1092 WMMoveWidget(panel->logoL, 30, 20);
1093 WMSetLabelImagePosition(panel->logoL, WIPImageOnly);
1094 WMSetLabelImage(panel->logoL, logo);
1095 #ifdef SILLYNESS
1096 WMCreateEventHandler(WMWidgetView(panel->logoL), ButtonPressMask,
1097 handleLogoPush, panel);
1098 #endif
1101 panel->name1L = WMCreateLabel(panel->win);
1102 WMResizeWidget(panel->name1L, 240, 30);
1103 WMMoveWidget(panel->name1L, 100, 30);
1104 color1.red = 0;
1105 color1.green = 0;
1106 color1.blue = 0;
1107 color2.red = 0x50;
1108 color2.green = 0x50;
1109 color2.blue = 0x70;
1110 logo = renderText(scr->wmscreen, "GNU Window Maker",
1111 "-*-utopia-*-r-*-*-25-*", &color1, &color2);
1112 if (logo) {
1113 WMSetLabelImagePosition(panel->name1L, WIPImageOnly);
1114 WMSetLabelImage(panel->name1L, logo);
1115 WMReleasePixmap(logo);
1116 } else {
1117 font = WMBoldSystemFontOfSize(scr->wmscreen, 20);
1118 if (font) {
1119 WMSetLabelFont(panel->name1L, font);
1120 WMReleaseFont(font);
1122 WMSetLabelTextAlignment(panel->name1L, WACenter);
1123 WMSetLabelText(panel->name1L, "GNU Window Maker");
1126 panel->name2L = WMCreateLabel(panel->win);
1127 WMResizeWidget(panel->name2L, 240, 24);
1128 WMMoveWidget(panel->name2L, 100, 60);
1129 font = WMBoldSystemFontOfSize(scr->wmscreen, 18);
1130 if (font) {
1131 WMSetLabelFont(panel->name2L, font);
1132 WMReleaseFont(font);
1133 font = NULL;
1135 WMSetLabelTextAlignment(panel->name2L, WACenter);
1136 WMSetLabelText(panel->name2L, "Window Manager for X");
1139 sprintf(version, "Version %s", VERSION);
1140 panel->versionL = WMCreateLabel(panel->win);
1141 WMResizeWidget(panel->versionL, 310, 16);
1142 WMMoveWidget(panel->versionL, 30, 95);
1143 WMSetLabelTextAlignment(panel->versionL, WARight);
1144 WMSetLabelText(panel->versionL, version);
1145 WMSetLabelWraps(panel->versionL, False);
1147 panel->copyrL = WMCreateLabel(panel->win);
1148 WMResizeWidget(panel->copyrL, 340, 40);
1149 WMMoveWidget(panel->copyrL, 15, 185);
1150 WMSetLabelTextAlignment(panel->copyrL, WALeft);
1151 WMSetLabelText(panel->copyrL, COPYRIGHT_TEXT);
1152 /* we want the (c) character in the helvetica font */
1153 font = WMCreateNormalFont(scr->wmscreen, HELVETICA10_FONT);
1154 if (font) {
1155 WMSetLabelFont(panel->copyrL, font);
1158 switch (scr->w_depth) {
1159 case 15:
1160 strcpy(version, "32 thousand");
1161 break;
1162 case 16:
1163 strcpy(version, "64 thousand");
1164 break;
1165 case 24:
1166 case 32:
1167 strcpy(version, "16 million");
1168 break;
1169 default:
1170 sprintf(version, "%d", 1<<scr->w_depth);
1171 break;
1174 sprintf(buffer, "Using visual 0x%x: %s %ibpp (%s colors)\n",
1175 (unsigned)scr->w_visual->visualid,
1176 visuals[scr->w_visual->class], scr->w_depth, version);
1178 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
1180 struct mallinfo ma = mallinfo();
1181 sprintf(buffer+strlen(buffer),
1182 "Total allocated memory: %i kB. Total memory in use: %i kB.\n",
1183 (ma.arena+ma.hblkhd)/1024, (ma.uordblks+ma.hblkhd)/1024);
1186 #endif
1188 strcat(buffer, "Supported image formats: ");
1189 strl = RSupportedFileFormats();
1190 for (i=0; strl[i]!=NULL; i++) {
1191 strcat(buffer, strl[i]);
1192 strcat(buffer, " ");
1195 strcat(buffer, "\nAdditional Support For: ");
1197 char *list[8];
1198 char buf[80];
1199 int j = 0;
1201 #ifdef MWM_HINTS
1202 list[j++] = "MWM";
1203 #endif
1204 #ifdef KWM_HINTS
1205 list[j++] = "KDE";
1206 #endif
1207 #ifdef GNOME_STUFF
1208 list[j++] = "GNOME";
1209 #endif
1210 #ifdef OLWM_HINTS
1211 list[j++] = "OLWM";
1212 #endif
1213 #ifdef WSOUND
1214 list[j++] = "Sound";
1215 #endif
1217 buf[0] = 0;
1218 for (i = 0; i < j; i++) {
1219 if (i > 0) {
1220 if (i == j - 1)
1221 strcat(buf, " and ");
1222 else
1223 strcat(buf, ", ");
1225 strcat(buf, list[i]);
1227 strcat(buffer, buf);
1231 panel->infoL = WMCreateLabel(panel->win);
1232 WMResizeWidget(panel->infoL, 350, 75);
1233 WMMoveWidget(panel->infoL, 15, 115);
1234 WMSetLabelText(panel->infoL, buffer);
1235 if (font) {
1236 WMSetLabelFont(panel->infoL, font);
1237 WMReleaseFont(font);
1241 WMRealizeWidget(panel->win);
1242 WMMapSubwidgets(panel->win);
1244 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 382, 230, 0, 0, 0);
1246 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1248 WMMapWidget(panel->win);
1250 wwin = wManageInternalWindow(scr, parent, None, "Info",
1251 (scr->scr_width - 382)/2,
1252 (scr->scr_height - 230)/2, 382, 230);
1254 WSETUFLAG(wwin, no_closable, 0);
1255 WSETUFLAG(wwin, no_close_button, 0);
1256 #ifdef XKB_BUTTON_HINT
1257 wFrameWindowHideButton(wwin->frame, WFF_LANGUAGE_BUTTON);
1258 #endif
1259 wWindowUpdateButtonImages(wwin);
1260 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1261 wwin->frame->on_click_right = destroyInfoPanel;
1263 wWindowMap(wwin);
1265 panel->wwin = wwin;
1267 thePanel = panel;
1268 #ifdef SILLYNESS
1269 if (InitXThing(panel->scr)) {
1270 panel->timer = WMAddTimerHandler(100, logoPushCallback, panel);
1271 panel->cycle = 0;
1272 panel->x = 1;
1273 panel->str = "Merry Christmas!";
1274 panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL));
1276 #endif
1281 ***********************************************************************
1282 * Legal Panel
1283 ***********************************************************************
1286 typedef struct {
1287 WScreen *scr;
1289 WWindow *wwin;
1291 WMWindow *win;
1293 WMLabel *licenseL;
1294 } LegalPanel;
1298 #define LICENSE_TEXT \
1299 " Window Maker is free software; you can redistribute it and/or modify "\
1300 "it under the terms of the GNU General Public License as published "\
1301 "by the Free Software Foundation; either version 2 of the License, "\
1302 "or (at your option) any later version.\n\n\n"\
1303 " Window Maker is distributed in the hope that it will be useful, but "\
1304 "WITHOUT ANY WARRANTY; without even the implied warranty of "\
1305 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU "\
1306 "General Public License for more details.\n\n\n"\
1307 " You should have received a copy of the GNU General Public License "\
1308 "along with this program; if not, write to the Free Software "\
1309 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA "\
1310 "02111-1307, USA."
1313 static LegalPanel *legalPanel = NULL;
1315 static void
1316 destroyLegalPanel(WCoreWindow *foo, void *data, XEvent *event)
1318 WMUnmapWidget(legalPanel->win);
1320 WMDestroyWidget(legalPanel->win);
1322 wUnmanageWindow(legalPanel->wwin, False, False);
1324 wfree(legalPanel);
1326 legalPanel = NULL;
1330 void
1331 wShowLegalPanel(WScreen *scr)
1333 LegalPanel *panel;
1334 Window parent;
1335 WWindow *wwin;
1337 if (legalPanel) {
1338 if (legalPanel->scr == scr) {
1339 wRaiseFrame(legalPanel->wwin->frame->core);
1340 wSetFocusTo(scr, legalPanel->wwin);
1342 return;
1345 panel = wmalloc(sizeof(LegalPanel));
1347 panel->scr = scr;
1349 panel->win = WMCreateWindow(scr->wmscreen, "legal");
1350 WMResizeWidget(panel->win, 420, 250);
1353 panel->licenseL = WMCreateLabel(panel->win);
1354 WMSetLabelWraps(panel->licenseL, True);
1355 WMResizeWidget(panel->licenseL, 400, 230);
1356 WMMoveWidget(panel->licenseL, 10, 10);
1357 WMSetLabelTextAlignment(panel->licenseL, WALeft);
1358 WMSetLabelText(panel->licenseL, LICENSE_TEXT);
1359 WMSetLabelRelief(panel->licenseL, WRGroove);
1361 WMRealizeWidget(panel->win);
1362 WMMapSubwidgets(panel->win);
1364 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 420, 250, 0, 0, 0);
1366 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1368 wwin = wManageInternalWindow(scr, parent, None, "Legal",
1369 (scr->scr_width - 420)/2,
1370 (scr->scr_height - 250)/2, 420, 250);
1372 WSETUFLAG(wwin, no_closable, 0);
1373 WSETUFLAG(wwin, no_close_button, 0);
1374 wWindowUpdateButtonImages(wwin);
1375 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1376 #ifdef XKB_BUTTON_HINT
1377 wFrameWindowHideButton(wwin->frame, WFF_LANGUAGE_BUTTON);
1378 #endif
1379 wwin->frame->on_click_right = destroyLegalPanel;
1381 panel->wwin = wwin;
1383 WMMapWidget(panel->win);
1385 wWindowMap(wwin);
1387 legalPanel = panel;
1392 ***********************************************************************
1393 * Crashing Dialog Panel
1394 ***********************************************************************
1397 extern WDDomain *WDWindowAttributes;
1400 typedef struct _CrashPanel {
1401 WMWindow *win; /* main window */
1403 WMLabel *iconL; /* application icon */
1404 WMLabel *nameL; /* title of panel */
1406 WMFrame *sepF; /* separator frame */
1408 WMLabel *noteL; /* Title of note */
1409 WMLabel *note2L; /* body of note with what happened */
1411 WMFrame *whatF; /* "what to do next" frame */
1412 WMPopUpButton *whatP; /* action selection popup button */
1414 WMButton *okB; /* ok button */
1416 Bool done; /* if finished with this dialog */
1417 int action; /* what to do after */
1419 KeyCode retKey;
1421 } CrashPanel;
1424 static void
1425 handleKeyPress(XEvent *event, void *clientData)
1427 CrashPanel *panel = (CrashPanel*)clientData;
1429 if (event->xkey.keycode == panel->retKey) {
1430 WMPerformButtonClick(panel->okB);
1435 static void
1436 okButtonCallback(void *self, void *clientData)
1438 CrashPanel *panel = (CrashPanel*)clientData;
1440 panel->done = True;
1444 static void
1445 setCrashAction(void *self, void *clientData)
1447 WMPopUpButton *pop = (WMPopUpButton*)self;
1448 CrashPanel *panel = (CrashPanel*)clientData;
1450 panel->action = WMGetPopUpButtonSelectedItem(pop);
1454 static WMPixmap*
1455 getWindowMakerIconImage(WMScreen *scr)
1457 proplist_t dict, key, option, value=NULL;
1458 WMPixmap *pix=NULL;
1459 char *path;
1461 PLSetStringCmpHook(NULL);
1463 key = PLMakeString("Logo.WMPanel");
1464 option = PLMakeString("Icon");
1466 dict = PLGetDictionaryEntry(WDWindowAttributes->dictionary, key);
1468 if (dict) {
1469 value = PLGetDictionaryEntry(dict, option);
1472 PLRelease(key);
1473 PLRelease(option);
1475 PLSetStringCmpHook(StringCompareHook);
1477 if (value && PLIsString(value)) {
1478 path = FindImage(wPreferences.icon_path, PLGetString(value));
1480 if (path) {
1481 RImage *image;
1483 image = RLoadImage(WMScreenRContext(scr), path, 0);
1484 if (image) {
1485 pix = WMCreatePixmapFromRImage(scr, image, 0);
1486 RDestroyImage(image);
1488 wfree(path);
1492 return pix;
1496 #define PWIDTH 295
1497 #define PHEIGHT 345
1501 wShowCrashingDialogPanel(int whatSig)
1503 CrashPanel *panel;
1504 WMScreen *scr;
1505 WMFont *font;
1506 WMPixmap *logo;
1507 int screen_no, scr_width, scr_height;
1508 int action;
1509 char buf[256];
1511 panel = wmalloc(sizeof(CrashPanel));
1512 memset(panel, 0, sizeof(CrashPanel));
1514 screen_no = DefaultScreen(dpy);
1515 scr_width = WidthOfScreen(ScreenOfDisplay(dpy, screen_no));
1516 scr_height = HeightOfScreen(ScreenOfDisplay(dpy, screen_no));
1518 scr = WMCreateScreen(dpy, screen_no);
1519 if (!scr) {
1520 wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
1521 return WMAbort;
1524 panel->retKey = XKeysymToKeycode(dpy, XK_Return);
1526 panel->win = WMCreateWindow(scr, "crashingDialog");
1527 WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
1528 WMMoveWidget(panel->win, (scr_width - PWIDTH)/2, (scr_height - PHEIGHT)/2);
1530 logo = getWindowMakerIconImage(scr);
1531 if (logo) {
1532 panel->iconL = WMCreateLabel(panel->win);
1533 WMResizeWidget(panel->iconL, 64, 64);
1534 WMMoveWidget(panel->iconL, 10, 10);
1535 WMSetLabelImagePosition(panel->iconL, WIPImageOnly);
1536 WMSetLabelImage(panel->iconL, logo);
1539 panel->nameL = WMCreateLabel(panel->win);
1540 WMResizeWidget(panel->nameL, 190, 18);
1541 WMMoveWidget(panel->nameL, 80, 35);
1542 WMSetLabelTextAlignment(panel->nameL, WALeft);
1543 font = WMBoldSystemFontOfSize(scr, 18);
1544 WMSetLabelFont(panel->nameL, font);
1545 WMReleaseFont(font);
1546 WMSetLabelText(panel->nameL, _("Fatal error"));
1548 panel->sepF = WMCreateFrame(panel->win);
1549 WMResizeWidget(panel->sepF, PWIDTH+4, 2);
1550 WMMoveWidget(panel->sepF, -2, 80);
1552 panel->noteL = WMCreateLabel(panel->win);
1553 WMResizeWidget(panel->noteL, PWIDTH-20, 40);
1554 WMMoveWidget(panel->noteL, 10, 90);
1555 WMSetLabelTextAlignment(panel->noteL, WAJustified);
1556 #ifdef SYS_SIGLIST_DECLARED
1557 sprintf(buf, _("Window Maker received signal %i\n(%s)."),
1558 whatSig, sys_siglist[whatSig]);
1559 #else
1560 sprintf(buf, _("Window Maker received signal %i."), whatSig);
1561 #endif
1562 WMSetLabelText(panel->noteL, buf);
1564 panel->note2L = WMCreateLabel(panel->win);
1565 WMResizeWidget(panel->note2L, PWIDTH-20, 100);
1566 WMMoveWidget(panel->note2L, 10, 130);
1567 WMSetLabelTextAlignment(panel->note2L, WALeft);
1568 WMSetLabelText(panel->note2L,
1569 _(" This fatal error occured probably due to a bug."
1570 " Please fill the included BUGFORM and "
1571 "report it to bugs@windowmaker.org."));
1574 panel->whatF = WMCreateFrame(panel->win);
1575 WMResizeWidget(panel->whatF, PWIDTH-20, 50);
1576 WMMoveWidget(panel->whatF, 10, 240);
1577 WMSetFrameTitle(panel->whatF, _("What do you want to do now?"));
1579 panel->whatP = WMCreatePopUpButton(panel->whatF);
1580 WMResizeWidget(panel->whatP, PWIDTH-20-70, 20);
1581 WMMoveWidget(panel->whatP, 35, 20);
1582 WMSetPopUpButtonPullsDown(panel->whatP, False);
1583 WMSetPopUpButtonText(panel->whatP, _("Select action"));
1584 WMAddPopUpButtonItem(panel->whatP, _("Abort and leave a core file"));
1585 WMAddPopUpButtonItem(panel->whatP, _("Restart Window Maker"));
1586 WMAddPopUpButtonItem(panel->whatP, _("Start alternate window manager"));
1587 WMSetPopUpButtonAction(panel->whatP, setCrashAction, panel);
1588 WMSetPopUpButtonSelectedItem(panel->whatP, WMRestart);
1589 panel->action = WMRestart;
1591 WMMapSubwidgets(panel->whatF);
1593 panel->okB = WMCreateCommandButton(panel->win);
1594 WMResizeWidget(panel->okB, 80, 26);
1595 WMMoveWidget(panel->okB, 205, 309);
1596 WMSetButtonText(panel->okB, _("OK"));
1597 WMSetButtonImage(panel->okB, WMGetSystemPixmap(scr, WSIReturnArrow));
1598 WMSetButtonAltImage(panel->okB, WMGetSystemPixmap(scr, WSIHighlightedReturnArrow));
1599 WMSetButtonImagePosition(panel->okB, WIPRight);
1600 WMSetButtonAction(panel->okB, okButtonCallback, panel);
1602 panel->done = 0;
1604 WMCreateEventHandler(WMWidgetView(panel->win), KeyPressMask,
1605 handleKeyPress, panel);
1607 WMRealizeWidget(panel->win);
1608 WMMapSubwidgets(panel->win);
1610 WMMapWidget(panel->win);
1612 XSetInputFocus(dpy, WMWidgetXID(panel->win), RevertToParent, CurrentTime);
1614 while (!panel->done) {
1615 XEvent event;
1617 WMNextEvent(dpy, &event);
1618 WMHandleEvent(&event);
1621 action = panel->action;
1623 WMUnmapWidget(panel->win);
1624 WMDestroyWidget(panel->win);
1625 wfree(panel);
1627 return action;
1633 /*****************************************************************************
1634 * About GNUstep Panel
1635 *****************************************************************************/
1638 static void
1639 drawGNUstepLogo(Display *dpy, Drawable d, int width, int height,
1640 unsigned long blackPixel, unsigned long whitePixel)
1642 GC gc;
1643 XGCValues gcv;
1644 XRectangle rects[3];
1646 gcv.foreground = blackPixel;
1647 gc = XCreateGC(dpy, d, GCForeground, &gcv);
1649 XFillArc(dpy, d, gc, width/45, height/45,
1650 width - 2*width/45, height - 2*height/45, 0, 360*64);
1652 rects[0].x = 0;
1653 rects[0].y = 37*height/45;
1654 rects[0].width = width/3;
1655 rects[0].height = height - rects[0].y;
1657 rects[1].x = rects[0].width;
1658 rects[1].y = height/2;
1659 rects[1].width = width - 2*width/3;
1660 rects[1].height = height - rects[1].y;
1662 rects[2].x = 2*width/3;
1663 rects[2].y = height - 37*height/45;
1664 rects[2].width = width/3;
1665 rects[2].height = height - rects[2].y;
1667 XSetClipRectangles(dpy, gc, 0, 0, rects, 3, Unsorted);
1668 XFillRectangle(dpy, d, gc, 0, 0, width, height);
1670 XSetForeground(dpy, gc, whitePixel);
1671 XFillArc(dpy, d, gc, width/45, height/45,
1672 width - 2*width/45, height - 2*height/45, 0, 360*64);
1674 XFreeGC(dpy, gc);
1679 #define GNUSTEP_TEXT \
1680 "Window Maker is part of the GNUstep project.\n"\
1681 "The GNUstep project aims to create a free\n"\
1682 "implementation of the OpenStep(tm) specification\n"\
1683 "which is a object-oriented framework for\n"\
1684 "creating advanced graphical, multi-platform\n"\
1685 "applications. Additionally, a development and\n"\
1686 "user desktop enviroment will be created on top\n"\
1687 "of the framework. For more information about\n"\
1688 "GNUstep, please visit: www.gnustep.org"
1691 typedef struct {
1692 WScreen *scr;
1694 WWindow *wwin;
1696 WMWindow *win;
1698 WMLabel *gstepL;
1699 WMLabel *textL;
1700 } GNUstepPanel;
1703 static GNUstepPanel *gnustepPanel = NULL;
1705 static void
1706 destroyGNUstepPanel(WCoreWindow *foo, void *data, XEvent *event)
1708 WMUnmapWidget(gnustepPanel->win);
1710 WMDestroyWidget(gnustepPanel->win);
1712 wUnmanageWindow(gnustepPanel->wwin, False, False);
1714 wfree(gnustepPanel);
1716 gnustepPanel = NULL;
1720 void
1721 wShowGNUstepPanel(WScreen *scr)
1723 GNUstepPanel *panel;
1724 Window parent;
1725 WWindow *wwin;
1726 WMPixmap *pixmap;
1727 WMColor *color;
1729 if (gnustepPanel) {
1730 if (gnustepPanel->scr == scr) {
1731 wRaiseFrame(gnustepPanel->wwin->frame->core);
1732 wSetFocusTo(scr, gnustepPanel->wwin);
1734 return;
1737 panel = wmalloc(sizeof(GNUstepPanel));
1739 panel->scr = scr;
1741 panel->win = WMCreateWindow(scr->wmscreen, "About GNUstep");
1742 WMResizeWidget(panel->win, 325, 200);
1744 pixmap = WMCreatePixmap(scr->wmscreen, 130, 130,
1745 WMScreenDepth(scr->wmscreen), True);
1747 color = WMCreateNamedColor(scr->wmscreen, "gray50", True);
1749 drawGNUstepLogo(dpy, WMGetPixmapXID(pixmap), 130, 130,
1750 WMColorPixel(color), scr->white_pixel);
1752 WMReleaseColor(color);
1754 XSetForeground(dpy, scr->mono_gc, 0);
1755 XFillRectangle(dpy, WMGetPixmapMaskXID(pixmap), scr->mono_gc, 0, 0,
1756 130, 130);
1757 drawGNUstepLogo(dpy, WMGetPixmapMaskXID(pixmap), 130, 130, 1, 1);
1759 panel->gstepL = WMCreateLabel(panel->win);
1760 WMResizeWidget(panel->gstepL, 285, 64);
1761 WMMoveWidget(panel->gstepL, 20, 0);
1762 WMSetLabelTextAlignment(panel->gstepL, WARight);
1763 WMSetLabelText(panel->gstepL, "GNUstep");
1765 WMFont *font = WMBoldSystemFontOfSize(scr->wmscreen, 24);
1767 WMSetLabelFont(panel->gstepL, font);
1768 WMReleaseFont(font);
1771 panel->textL = WMCreateLabel(panel->win);
1772 WMResizeWidget(panel->textL, 275, 130);
1773 WMMoveWidget(panel->textL, 30, 50);
1774 WMSetLabelTextAlignment(panel->textL, WARight);
1775 WMSetLabelImagePosition(panel->textL, WIPOverlaps);
1776 WMSetLabelText(panel->textL, GNUSTEP_TEXT);
1777 WMSetLabelImage(panel->textL, pixmap);
1779 WMReleasePixmap(pixmap);
1781 WMRealizeWidget(panel->win);
1782 WMMapSubwidgets(panel->win);
1784 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 325, 200, 0, 0, 0);
1786 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1788 wwin = wManageInternalWindow(scr, parent, None, "About GNUstep",
1789 (scr->scr_width - 325)/2,
1790 (scr->scr_height - 200)/2, 325, 200);
1792 WSETUFLAG(wwin, no_closable, 0);
1793 WSETUFLAG(wwin, no_close_button, 0);
1794 wWindowUpdateButtonImages(wwin);
1795 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1796 #ifdef XKB_BUTTON_HINT
1797 wFrameWindowHideButton(wwin->frame, WFF_LANGUAGE_BUTTON);
1798 #endif
1799 wwin->frame->on_click_right = destroyGNUstepPanel;
1801 panel->wwin = wwin;
1803 WMMapWidget(panel->win);
1805 wWindowMap(wwin);
1807 gnustepPanel = panel;