memory stats in info panel
[wmaker-crm.git] / src / dialog.c
blobb5e402d4d34265acdfdd00b9f8930500deb34ff5
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 while (!panel->done) {
95 XEvent event;
97 WMNextEvent(dpy, &event);
98 WMHandleEvent(&event);
101 result = panel->result;
103 WMUnmapWidget(panel->win);
105 wUnmanageWindow(wwin, False, False);
107 WMDestroyAlertPanel(panel);
109 XDestroyWindow(dpy, parent);
111 return result;
117 wInputDialog(WScreen *scr, char *title, char *message, char **text)
119 WWindow *wwin;
120 Window parent;
121 WMInputPanel *panel;
122 char *result;
125 panel = WMCreateInputPanel(scr->wmscreen, NULL, title, message, *text,
126 _("OK"), _("Cancel"));
129 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 320, 160, 0, 0, 0);
130 XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask);
132 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
134 wwin = wManageInternalWindow(scr, parent, None, NULL,
135 (scr->scr_width - 320)/2,
136 (scr->scr_height - 160)/2, 320, 160);
138 wwin->client_leader = WMWidgetXID(panel->win);
140 WMMapWidget(panel->win);
142 wWindowMap(wwin);
144 while (!panel->done) {
145 XEvent event;
147 WMNextEvent(dpy, &event);
148 WMHandleEvent(&event);
151 if (panel->result == WAPRDefault)
152 result = WMGetTextFieldText(panel->text);
153 else
154 result = NULL;
156 wUnmanageWindow(wwin, False, False);
158 WMDestroyInputPanel(panel);
160 XDestroyWindow(dpy, parent);
162 if (result==NULL)
163 return False;
164 else {
165 if (*text)
166 free(*text);
167 *text = result;
169 return True;
175 *****************************************************************
176 * Icon Selection Panel
177 *****************************************************************
180 typedef struct IconPanel {
182 WScreen *scr;
184 WMWindow *win;
186 WMLabel *dirLabel;
187 WMLabel *iconLabel;
189 WMList *dirList;
190 WMList *iconList;
191 WMFont *normalfont;
193 WMButton *previewButton;
195 WMLabel *iconView;
197 WMLabel *fileLabel;
198 WMTextField *fileField;
200 WMButton *okButton;
201 WMButton *cancelButton;
202 #if 0
203 WMButton *chooseButton;
204 #endif
205 short done;
206 short result;
207 short preview;
208 } IconPanel;
212 static void
213 listPixmaps(WScreen *scr, WMList *lPtr, char *path)
215 struct dirent *dentry;
216 DIR *dir;
217 char pbuf[PATH_MAX+16];
218 char *apath;
219 IconPanel *panel = WMGetHangedData(lPtr);
221 panel->preview = False;
223 apath = wexpandpath(path);
224 dir = opendir(apath);
226 if (!dir) {
227 char *msg;
228 char *tmp;
229 tmp = _("Could not open directory ");
230 msg = wmalloc(strlen(tmp)+strlen(path)+6);
231 strcpy(msg, tmp);
232 strcat(msg, path);
234 wMessageDialog(scr, _("Error"), msg, _("OK"), NULL, NULL);
235 free(msg);
236 free(apath);
237 return;
240 /* list contents in the column */
241 while ((dentry = readdir(dir))) {
242 struct stat statb;
244 if (strcmp(dentry->d_name, ".")==0 ||
245 strcmp(dentry->d_name, "..")==0)
246 continue;
248 strcpy(pbuf, apath);
249 strcat(pbuf, "/");
250 strcat(pbuf, dentry->d_name);
252 if (stat(pbuf, &statb)<0)
253 continue;
255 if (statb.st_mode & (S_IRUSR|S_IRGRP|S_IROTH)
256 && statb.st_mode & (S_IFREG|S_IFLNK)) {
257 WMAddListItem(lPtr, dentry->d_name);
260 WMSortListItems(lPtr);
262 closedir(dir);
263 free(apath);
264 panel->preview = True;
269 static void
270 setViewedImage(IconPanel *panel, char *file)
272 WMPixmap *pixmap;
273 RColor color;
275 color.red = 0xae;
276 color.green = 0xaa;
277 color.blue = 0xae;
278 color.alpha = 0;
279 pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win),
280 file, &color);
281 if (!pixmap) {
282 WMSetButtonEnabled(panel->okButton, False);
284 WMSetLabelText(panel->iconView, _("Could not load image file "));
286 WMSetLabelImage(panel->iconView, NULL);
287 } else {
288 WMSetButtonEnabled(panel->okButton, True);
290 WMSetLabelText(panel->iconView, NULL);
291 WMSetLabelImage(panel->iconView, pixmap);
292 WMReleasePixmap(pixmap);
297 static void
298 listCallback(void *self, void *data)
300 WMList *lPtr = (WMList*)self;
301 IconPanel *panel = (IconPanel*)data;
302 char *path;
304 if (lPtr==panel->dirList) {
305 path = WMGetListSelectedItem(lPtr)->text;
307 WMSetTextFieldText(panel->fileField, path);
309 WMSetLabelImage(panel->iconView, NULL);
311 WMSetButtonEnabled(panel->okButton, False);
313 WMClearList(panel->iconList);
314 listPixmaps(panel->scr, panel->iconList, path);
315 } else {
316 char *tmp, *iconFile;
318 path = WMGetListSelectedItem(panel->dirList)->text;
319 tmp = wexpandpath(path);
321 iconFile = WMGetListSelectedItem(panel->iconList)->text;
323 path = wmalloc(strlen(tmp)+strlen(iconFile)+4);
324 strcpy(path, tmp);
325 strcat(path, "/");
326 strcat(path, iconFile);
327 free(tmp);
328 WMSetTextFieldText(panel->fileField, path);
329 setViewedImage(panel, path);
330 free(path);
335 static void
336 listIconPaths(WMList *lPtr)
338 char *paths;
339 char *path;
341 paths = wstrdup(wPreferences.icon_path);
343 path = strtok(paths, ":");
345 do {
346 char *tmp;
348 tmp = wexpandpath(path);
349 /* do not sort, because the order implies the order of
350 * directories searched */
351 if (access(tmp, X_OK)==0)
352 WMAddListItem(lPtr, path);
353 free(tmp);
354 } while ((path=strtok(NULL, ":"))!=NULL);
356 free(paths);
360 void
361 drawIconProc(WMList *lPtr, int index, Drawable d, char *text,
362 int state, WMRect *rect)
364 IconPanel *panel = WMGetHangedData(lPtr);
365 GC gc = panel->scr->draw_gc;
366 GC copygc = panel->scr->copy_gc;
367 char *buffer, *dirfile;
368 WMPixmap *pixmap;
369 WMColor *blackcolor;
370 WMColor *whitecolor;
371 WMSize size;
372 WMScreen *wmscr=WMWidgetScreen(panel->win);
373 int width;
375 if(!panel->preview) return;
377 width = rect->size.width;
379 blackcolor = WMBlackColor(wmscr);
380 whitecolor = WMWhiteColor(wmscr);
382 dirfile = wexpandpath(WMGetListSelectedItem(panel->dirList)->text);
383 buffer = wmalloc(strlen(dirfile)+strlen(text)+4);
384 sprintf(buffer, "%s/%s", dirfile, text);
385 free(dirfile);
387 pixmap = WMCreatePixmapFromFile(WMWidgetScreen(panel->win), buffer);
388 free(buffer);
389 if (!pixmap) {
390 WMRemoveListItem(lPtr, index);
391 return;
394 XClearArea(dpy, d, rect->pos.x, rect->pos.y, width, rect->size.height,
395 False);
396 XSetClipMask(dpy, gc, None);
398 XDrawRectangle(dpy, d, WMColorGC(whitecolor), rect->pos.x + 5,
399 rect->pos.y +5, width - 10, 54);
401 XDrawLine(dpy, d, WMColorGC(whitecolor), rect->pos.x,
402 rect->pos.y+rect->size.height-1, rect->pos.x+width,
403 rect->pos.y+rect->size.height-1);
406 if (state&WLDSSelected) {
407 XFillRectangle(dpy, d, WMColorGC(whitecolor), rect->pos.x,
408 rect->pos.y, width, rect->size.height);
411 size = WMGetPixmapSize(pixmap);
413 XSetClipMask(dpy, copygc, WMGetPixmapMaskXID(pixmap));
414 XSetClipOrigin(dpy, copygc, rect->pos.x + (width-size.width)/2,
415 rect->pos.y+2);
416 XCopyArea(dpy, WMGetPixmapXID(pixmap), d, copygc, 0, 0,
417 size.width>100?100:size.width, size.height>64?64:size.height,
418 rect->pos.x + (width-size.width)/2, rect->pos.y+2);
421 int i,j;
422 int fheight = WMFontHeight(panel->normalfont);
423 int tlen = strlen(text);
424 int twidth = WMWidthOfString(panel->normalfont, text, tlen);
425 int ofx, ofy;
427 ofx = rect->pos.x + (width - twidth)/2;
428 ofy = rect->pos.y + 64 - fheight;
430 for(i=-1;i<2;i++)
431 for(j=-1;j<2;j++)
432 WMDrawString(wmscr, d, WMColorGC(whitecolor),
433 panel->normalfont, ofx+i, ofy+j,
434 text, tlen);
436 WMDrawString(wmscr, d, WMColorGC(blackcolor), panel->normalfont,
437 ofx, ofy, text, tlen);
440 WMReleasePixmap(pixmap);
441 /* I hope it is better to do not use cache / on my box it is fast nuff */
442 XFlush(dpy);
444 WMReleaseColor(blackcolor);
445 WMReleaseColor(whitecolor);
449 static void
450 buttonCallback(void *self, void *clientData)
452 WMButton *bPtr = (WMButton*)self;
453 IconPanel *panel = (IconPanel*)clientData;
456 if (bPtr==panel->okButton) {
457 panel->done = True;
458 panel->result = True;
459 } else if (bPtr==panel->cancelButton) {
460 panel->done = True;
461 panel->result = False;
462 } else if (bPtr==panel->previewButton) {
463 /**** Previewer ****/
464 WMSetButtonEnabled(bPtr, False);
465 WMSetListUserDrawItemHeight(panel->iconList, 68);
466 WMSetListUserDrawProc(panel->iconList, drawIconProc);
467 WMRedisplayWidget(panel->iconList);
468 /* for draw proc to access screen/gc */
469 /*** end preview ***/
471 #if 0
472 else if (bPtr==panel->chooseButton) {
473 WMOpenPanel *op;
475 op = WMCreateOpenPanel(WMWidgetScreen(bPtr));
477 if (WMRunModalFilePanelForDirectory(op, NULL, "/usr/local", NULL, NULL)) {
478 char *path;
479 path = WMGetFilePanelFile(op);
480 WMSetTextFieldText(panel->fileField, path);
481 setViewedImage(panel, path);
482 free(path);
484 WMDestroyFilePanel(op);
486 #endif
490 Bool
491 wIconChooserDialog(WScreen *scr, char **file, char *instance, char *class)
493 WWindow *wwin;
494 Window parent;
495 IconPanel *panel;
496 WMColor *color;
497 WMFont *boldFont;
499 panel = wmalloc(sizeof(IconPanel));
500 memset(panel, 0, sizeof(IconPanel));
502 panel->scr = scr;
504 panel->win = WMCreateWindow(scr->wmscreen, "iconChooser");
505 WMResizeWidget(panel->win, 450, 280);
507 boldFont = WMBoldSystemFontOfSize(scr->wmscreen, 12);
508 panel->normalfont = WMSystemFontOfSize(WMWidgetScreen(panel->win), 12);
510 panel->dirLabel = WMCreateLabel(panel->win);
511 WMResizeWidget(panel->dirLabel, 200, 20);
512 WMMoveWidget(panel->dirLabel, 10, 7);
513 WMSetLabelText(panel->dirLabel, _("Directories"));
514 WMSetLabelFont(panel->dirLabel, boldFont);
515 WMSetLabelTextAlignment(panel->dirLabel, WACenter);
517 WMSetLabelRelief(panel->dirLabel, WRSunken);
519 panel->iconLabel = WMCreateLabel(panel->win);
520 WMResizeWidget(panel->iconLabel, 140, 20);
521 WMMoveWidget(panel->iconLabel, 215, 7);
522 WMSetLabelText(panel->iconLabel, _("Icons"));
523 WMSetLabelFont(panel->iconLabel, boldFont);
524 WMSetLabelTextAlignment(panel->iconLabel, WACenter);
526 WMReleaseFont(boldFont);
528 color = WMWhiteColor(scr->wmscreen);
529 WMSetLabelTextColor(panel->dirLabel, color);
530 WMSetLabelTextColor(panel->iconLabel, color);
531 WMReleaseColor(color);
533 color = WMDarkGrayColor(scr->wmscreen);
534 WMSetWidgetBackgroundColor(panel->iconLabel, color);
535 WMSetWidgetBackgroundColor(panel->dirLabel, color);
536 WMReleaseColor(color);
538 WMSetLabelRelief(panel->iconLabel, WRSunken);
540 panel->dirList = WMCreateList(panel->win);
541 WMResizeWidget(panel->dirList, 200, 170);
542 WMMoveWidget(panel->dirList, 10, 30);
543 WMSetListAction(panel->dirList, listCallback, panel);
545 panel->iconList = WMCreateList(panel->win);
546 WMResizeWidget(panel->iconList, 140, 170);
547 WMMoveWidget(panel->iconList, 215, 30);
548 WMSetListAction(panel->iconList, listCallback, panel);
550 WMHangData(panel->iconList,panel);
552 panel->previewButton = WMCreateCommandButton(panel->win);
553 WMResizeWidget(panel->previewButton, 75, 26);
554 WMMoveWidget(panel->previewButton, 365, 130);
555 WMSetButtonText(panel->previewButton, _("Preview"));
556 WMSetButtonAction(panel->previewButton, buttonCallback, panel);
558 panel->iconView = WMCreateLabel(panel->win);
559 WMResizeWidget(panel->iconView, 75, 75);
560 WMMoveWidget(panel->iconView, 365, 40);
561 WMSetLabelImagePosition(panel->iconView, WIPOverlaps);
562 WMSetLabelRelief(panel->iconView, WRSunken);
563 WMSetLabelTextAlignment(panel->iconView, WACenter);
565 panel->fileLabel = WMCreateLabel(panel->win);
566 WMResizeWidget(panel->fileLabel, 80, 20);
567 WMMoveWidget(panel->fileLabel, 10, 210);
568 WMSetLabelText(panel->fileLabel, _("File Name:"));
570 panel->fileField = WMCreateTextField(panel->win);
571 WMResizeWidget(panel->fileField, 345, 20);
572 WMMoveWidget(panel->fileField, 95, 210);
573 WMSetTextFieldEditable(panel->fileField, False);
575 panel->okButton = WMCreateCommandButton(panel->win);
576 WMResizeWidget(panel->okButton, 80, 26);
577 WMMoveWidget(panel->okButton, 360, 240);
578 WMSetButtonText(panel->okButton, _("OK"));
579 WMSetButtonEnabled(panel->okButton, False);
580 WMSetButtonAction(panel->okButton, buttonCallback, panel);
582 panel->cancelButton = WMCreateCommandButton(panel->win);
583 WMResizeWidget(panel->cancelButton, 80, 26);
584 WMMoveWidget(panel->cancelButton, 270, 240);
585 WMSetButtonText(panel->cancelButton, _("Cancel"));
586 WMSetButtonAction(panel->cancelButton, buttonCallback, panel);
587 #if 0
588 panel->chooseButton = WMCreateCommandButton(panel->win);
589 WMResizeWidget(panel->chooseButton, 110, 26);
590 WMMoveWidget(panel->chooseButton, 150, 240);
591 WMSetButtonText(panel->chooseButton, _("Choose File"));
592 WMSetButtonAction(panel->chooseButton, buttonCallback, panel);
593 #endif
594 WMRealizeWidget(panel->win);
595 WMMapSubwidgets(panel->win);
597 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 450, 280, 0, 0, 0);
599 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
602 char *tmp;
604 tmp = wmalloc((instance ? strlen(instance) : 0)
605 + (class ? strlen(class) : 0) + 32);
607 if (tmp && (instance || class))
608 sprintf(tmp, "%s [%s.%s]", _("Icon Chooser"), instance, class);
609 else
610 strcpy(tmp, _("Icon Chooser"));
612 wwin = wManageInternalWindow(scr, parent, None, tmp,
613 (scr->scr_width - 450)/2,
614 (scr->scr_height - 280)/2, 450, 280);
615 free(tmp);
618 /* put icon paths in the list */
619 listIconPaths(panel->dirList);
621 WMMapWidget(panel->win);
623 wWindowMap(wwin);
625 while (!panel->done) {
626 XEvent event;
628 WMNextEvent(dpy, &event);
629 WMHandleEvent(&event);
632 if (panel->result) {
633 char *defaultPath, *wantedPath;
635 /* check if the file the user selected is not the one that
636 * would be loaded by default with the current search path */
637 *file = WMGetListSelectedItem(panel->iconList)->text;
638 if ((*file)[0]==0) {
639 free(*file);
640 *file = NULL;
641 } else {
642 defaultPath = FindImage(wPreferences.icon_path, *file);
643 wantedPath = WMGetTextFieldText(panel->fileField);
644 /* if the file is not the default, use full path */
645 if (strcmp(wantedPath, defaultPath)!=0) {
646 *file = wantedPath;
647 } else {
648 *file = wstrdup(*file);
649 free(wantedPath);
651 free(defaultPath);
653 } else {
654 *file = NULL;
657 WMReleaseFont(panel->normalfont);
659 WMUnmapWidget(panel->win);
661 WMDestroyWidget(panel->win);
663 wUnmanageWindow(wwin, False, False);
665 free(panel);
667 XDestroyWindow(dpy, parent);
669 return panel->result;
674 ***********************************************************************
675 * Info Panel
676 ***********************************************************************
680 typedef struct {
681 WScreen *scr;
683 WWindow *wwin;
685 WMWindow *win;
687 WMLabel *logoL;
688 WMLabel *name1L;
689 WMLabel *name2L;
691 WMLabel *versionL;
693 WMLabel *infoL;
695 WMLabel *copyrL;
697 #ifdef SILLYNESS
698 WMHandlerID timer;
699 int cycle;
700 RImage *icon;
701 RImage *pic;
702 WMPixmap *oldPix;
703 char *str;
704 int x;
705 #endif
706 } InfoPanel;
710 #define COPYRIGHT_TEXT \
711 "Copyright \xa9 1997~2000 Alfredo K. Kojima <kojima@windowmaker.org>\n"\
712 "Copyright \xa9 1998~2000 Dan Pascu <dan@windowmaker.org>"
716 static InfoPanel *thePanel = NULL;
718 static void
719 destroyInfoPanel(WCoreWindow *foo, void *data, XEvent *event)
721 #ifdef SILLYNESS
722 if (thePanel->timer) {
723 WMDeleteTimerHandler(thePanel->timer);
725 if (thePanel->oldPix) {
726 WMReleasePixmap(thePanel->oldPix);
728 if (thePanel->icon) {
729 RDestroyImage(thePanel->icon);
731 if (thePanel->pic) {
732 RDestroyImage(thePanel->pic);
734 #endif /* SILLYNESS */
735 WMUnmapWidget(thePanel);
737 wUnmanageWindow(thePanel->wwin, False, False);
739 WMDestroyWidget(thePanel->win);
741 free(thePanel);
743 thePanel = NULL;
747 WMPixmap*
748 renderText(WMScreen *scr, char *text, char *font, RColor *from, RColor *to)
750 WMPixmap *wpix = NULL;
751 Pixmap grad = None;
752 Pixmap mask = None;
753 RContext *rc = WMScreenRContext(scr);
754 XFontStruct *f = NULL;
755 int w, h;
756 GC gc = None;
758 f = XLoadQueryFont(dpy, font);
759 if (!f)
760 return NULL;
762 w = XTextWidth(f, text, strlen(text));
763 h = f->ascent+f->descent;
765 mask = XCreatePixmap(dpy, rc->drawable, w, h, 1);
766 gc = XCreateGC(dpy, mask, 0, NULL);
767 XSetForeground(dpy, gc, 0);
768 XSetFont(dpy, gc, f->fid);
769 XFillRectangle(dpy, mask, gc, 0, 0, w, h);
771 XSetForeground(dpy, gc, 1);
772 XDrawString(dpy, mask, gc, 0, f->ascent, text, strlen(text));
773 XSetLineAttributes(dpy, gc, 3, LineSolid, CapRound, JoinMiter);
774 XDrawLine(dpy, mask, gc, 0, h-2, w, h-2);
776 grad = XCreatePixmap(dpy, rc->drawable, w, h, rc->depth);
778 WMColor *color;
780 color = WMBlackColor(scr);
781 XFillRectangle(dpy, grad, WMColorGC(color), 0, 0, w, h);
782 WMReleaseColor(color);
785 wpix = WMCreatePixmapFromXPixmaps(scr, grad, mask, w, h, rc->depth);
787 if (gc)
788 XFreeGC(dpy, gc);
789 XFreeFont(dpy, f);
791 return wpix;
794 #ifdef SILLYNESS
796 extern WMPixmap *DoXThing();
797 extern Bool InitXThing();
799 static void
800 logoPushCallback(void *data)
802 InfoPanel *panel = (InfoPanel*)data;
803 char buffer[512];
804 int i;
805 int len;
806 static int jingobeu[] = {
807 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
808 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
809 329, 150, 392, 150, 261, 150, 293, 150, 329, 400, -1, 400, 0
811 static int c = 0;
813 if (panel->x) {
814 XKeyboardControl kc;
816 if (panel->x > 0) {
817 if(jingobeu[panel->x-1]==0){panel->x=-1;}else if(jingobeu[panel->x
818 -1]<0){panel->x++;c=jingobeu[panel->x-1]/50;panel->x++;}else if(c==0){
819 kc.bell_pitch=jingobeu[panel->x-1];panel->x++;kc.bell_percent=50;c=
820 jingobeu[panel->x-1]/50;kc.bell_duration=jingobeu[panel->x-1];panel->x++;
821 XChangeKeyboardControl(dpy,KBBellPitch|KBBellDuration|KBBellPercent,&kc);
822 XBell(dpy,50);XFlush(dpy);}else{c--;}}
823 if (!(panel->cycle % 4)) {
824 WMPixmap *p;
826 p = DoXThing(panel->wwin);
827 WMSetLabelImage(panel->logoL, p);
829 } else if (panel->cycle < 30) {
830 RImage *image;
831 WMPixmap *pix;
833 image = RCloneImage(panel->icon);
834 RCombineImagesWithOpaqueness(image, panel->pic, panel->cycle*255/30);
835 pix = WMCreatePixmapFromRImage(panel->scr->wmscreen, image, 128);
836 RDestroyImage(image);
837 WMSetLabelImage(panel->logoL, pix);
838 WMReleasePixmap(pix);
841 i = panel->cycle%200;
843 len = strlen(panel->str);
845 strncpy(buffer, panel->str, i<len ? i : len);
846 if (i >= len)
847 memset(&buffer[len], ' ', i-len);
849 strncpy(buffer, panel->str, i<len ? i : len);
850 if (i >= len)
851 memset(&buffer[len], ' ', i-len);
852 buffer[i]=0;
853 WMSetLabelText(panel->versionL, buffer);
855 panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
856 panel->cycle++;
860 static void
861 handleLogoPush(XEvent *event, void *data)
863 InfoPanel *panel = (InfoPanel*)data;
864 static int broken = 0;
865 static int clicks = 0;
866 static char *pic_data[] = {
867 "45 45 57 1",
868 " c None",
869 ". c #000000",
870 "X c #383C00",
871 "o c #515500",
872 "O c #616100",
873 "+ c #616900",
874 "@ c #696D00",
875 "# c #697100",
876 "$ c #495100",
877 "% c #202800",
878 "& c #969600",
879 "* c #CFCF00",
880 "= c #D7DB00",
881 "- c #D7D700",
882 "; c #C7CB00",
883 ": c #A6AA00",
884 "> c #494900",
885 ", c #8E8E00",
886 "< c #DFE700",
887 "1 c #F7FF00",
888 "2 c #FFFF00",
889 "3 c #E7EB00",
890 "4 c #B6B600",
891 "5 c #595900",
892 "6 c #717500",
893 "7 c #AEB200",
894 "8 c #CFD300",
895 "9 c #E7EF00",
896 "0 c #EFF300",
897 "q c #9EA200",
898 "w c #F7FB00",
899 "e c #F7F700",
900 "r c #BEBE00",
901 "t c #8E9200",
902 "y c #EFF700",
903 "u c #969A00",
904 "i c #414500",
905 "p c #595D00",
906 "a c #E7E700",
907 "s c #C7C700",
908 "d c #797D00",
909 "f c #BEC300",
910 "g c #DFE300",
911 "h c #868600",
912 "j c #EFEF00",
913 "k c #9E9E00",
914 "l c #616500",
915 "z c #DFDF00",
916 "x c #868A00",
917 "c c #969200",
918 "v c #B6BA00",
919 "b c #A6A600",
920 "n c #8E8A00",
921 "m c #717100",
922 "M c #AEAE00",
923 "N c #AEAA00",
924 "B c #868200",
925 " ............... ",
926 " ....XoO+@##+O$%.... ",
927 " ...%X&*========-;;:o... ",
928 " ...>.>,<122222222222134@... ",
929 " ..>5678912222222222222220q%.. ",
930 " ..$.&-w2222222222222222222er>.. ",
931 " ..O.t31222222222222222222222y4>.. ",
932 " ...O5u3222222222222222222222222yri... ",
933 " ..>p&a22222222222222222222222222wso.. ",
934 " ..ids91222222222222222222222222222wfi.. ",
935 " ..X.7w222222wgs-w2222222213=g0222222<hi.. ",
936 " ..Xuj2222222<@X5=222222229k@l:022222y4i.. ",
937 " .Xdz22222222*X%.s22222222axo%$-222222<c>.. ",
938 " ..o7y22222222v...r222222223hX.i82222221si.. ",
939 "..io*222222222&...u22222222yt..%*22222220:%. ",
940 "..>k02222222227...f222222222v..X=222222229t. ",
941 "..dz12222222220ui:y2222222223d%qw222222221g. ",
942 ".%vw222222222221y2222222222219*y2222222222wd.",
943 ".X;2222222222222222222222222222222222222222b.",
944 ".i*2222222222222222222222222222222222222222v.",
945 ".i*2222222222222222222222222222222222222222;.",
946 ".i*22222222222222222222222222222222222222228.",
947 ".>*2222222222222222222222222222222222222222=.",
948 ".i*22222222222222222222222222222222222222228.",
949 ".i*2222222222222222222222222222222222222222;.",
950 ".X*222222222222222222222222222222we12222222r.",
951 ".Xs12222222w3aw22222222222222222y8s0222222wk.",
952 ".Xq02222222a,na22222222222222222zm6zwy2222gi.",
953 "..>*22222y<:Xcj22222222222222222-o$k;;02228..",
954 "..i7y2220rhX.:y22222222222222222jtiXd,a220,..",
955 " .X@z222a,do%kj2222222222222222wMX5q;gw228%..",
956 " ..58222wagsh6ry222222222222221;>Of0w222y:...",
957 " ...:e2222218mdz22222222222222a&$vw222220@...",
958 " ...O-122222y:.u02222222222229q$uj222221r... ",
959 " ..%&a1222223&573w2222222219NOxz122221z>... ",
960 " ...t3222221-l$nr8ay1222yzbo,=12222w-5... ",
961 " ..X:022222w-k+>o,7s**s7xOn=12221<f5... ",
962 " ..o:9222221j8:&Bl>>>>ihv<12221=dX... ",
963 " ..Xb9122222109g-****;<y22221zn%... ",
964 " ..X&801222222222222222222w-h.... ",
965 " ...o:=022222222222222221=lX... ",
966 " ..X@:;3w2222222222210fO... ",
967 " ...XX&v8<30000003-N@... ",
968 " .....XmnbN:q&Bo.... ",
969 " ............ "};
970 static char *msgs[] = {
971 "Have a nice day!"
975 clicks++;
976 if (!panel->timer && !broken && clicks > 0) {
977 char *file;
978 char *path;
980 panel->x = 0;
981 clicks = 0;
982 if (!panel->icon) {
983 file = wDefaultGetIconFile(panel->scr, "Logo", "WMPanel", False);
984 if (!file) {
985 broken = 1;
986 return;
989 path = FindImage(wPreferences.icon_path, file);
990 if (!path) {
991 broken = 1;
992 return;
995 panel->icon = RLoadImage(panel->scr->rcontext, path, 0);
996 free(path);
997 if (!panel->icon) {
998 broken = 1;
999 return;
1002 if (!panel->pic) {
1003 panel->pic = RGetImageFromXPMData(panel->scr->rcontext, pic_data);
1004 if (!panel->pic || panel->icon->width!=panel->pic->width
1005 || panel->icon->height!=panel->pic->height) {
1006 broken = 1;
1007 RDestroyImage(panel->icon);
1008 panel->icon = NULL;
1009 if (panel->pic) {
1010 RDestroyImage(panel->pic);
1011 panel->pic = NULL;
1013 return;
1017 RColor color;
1018 color.red = 0xae;
1019 color.green = 0xaa;
1020 color.blue = 0xae;
1021 color.alpha = 255;
1022 RCombineImageWithColor(panel->icon, &color);
1023 RCombineImageWithColor(panel->pic, &color);
1027 panel->str = msgs[rand()%(sizeof(msgs)/sizeof(char*))];
1029 panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
1030 panel->cycle = 0;
1031 panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL));
1032 } else if (panel->timer) {
1033 char version[20];
1035 panel->x = 0;
1036 clicks = 0;
1037 WMSetLabelImage(panel->logoL, panel->oldPix);
1038 WMReleasePixmap(panel->oldPix);
1039 panel->oldPix = NULL;
1041 WMDeleteTimerHandler(panel->timer);
1042 panel->timer = NULL;
1044 sprintf(version, "Version %s", VERSION);
1045 WMSetLabelText(panel->versionL, version);
1049 XEvent ev;
1050 while (XCheckTypedWindowEvent(dpy, WMWidgetXID(panel->versionL),
1051 ButtonPress, &ev));
1054 #endif /* SILLYNESS */
1057 void
1058 wShowInfoPanel(WScreen *scr)
1060 InfoPanel *panel;
1061 WMPixmap *logo;
1062 WMSize size;
1063 WMFont *font;
1064 char version[32];
1065 char buffer[512];
1066 Window parent;
1067 WWindow *wwin;
1068 RColor color1, color2;
1069 char **strl;
1070 int i;
1071 char *visuals[] = {
1072 "StaticGray",
1073 "GrayScale",
1074 "StaticColor",
1075 "PseudoColor",
1076 "TrueColor",
1077 "DirectColor"
1081 if (thePanel) {
1082 if (thePanel->scr == scr) {
1083 wRaiseFrame(thePanel->wwin->frame->core);
1084 wSetFocusTo(scr, thePanel->wwin);
1086 return;
1089 panel = wmalloc(sizeof(InfoPanel));
1090 memset(panel, 0, sizeof(InfoPanel));
1092 panel->scr = scr;
1094 panel->win = WMCreateWindow(scr->wmscreen, "info");
1095 WMResizeWidget(panel->win, 382, 230);
1097 logo = WMGetApplicationIconImage(scr->wmscreen);
1098 if (logo) {
1099 size = WMGetPixmapSize(logo);
1100 panel->logoL = WMCreateLabel(panel->win);
1101 WMResizeWidget(panel->logoL, 64, 64);
1102 WMMoveWidget(panel->logoL, 30, 20);
1103 WMSetLabelImagePosition(panel->logoL, WIPImageOnly);
1104 WMSetLabelImage(panel->logoL, logo);
1105 #ifdef SILLYNESS
1106 WMCreateEventHandler(WMWidgetView(panel->logoL), ButtonPressMask,
1107 handleLogoPush, panel);
1108 #endif
1111 panel->name1L = WMCreateLabel(panel->win);
1112 WMResizeWidget(panel->name1L, 240, 30);
1113 WMMoveWidget(panel->name1L, 100, 30);
1114 color1.red = 0;
1115 color1.green = 0;
1116 color1.blue = 0;
1117 color2.red = 0x50;
1118 color2.green = 0x50;
1119 color2.blue = 0x70;
1120 logo = renderText(scr->wmscreen, "GNU Window Maker",
1121 "-*-utopia-*-r-*-*-25-*", &color1, &color2);
1122 if (logo) {
1123 WMSetLabelImagePosition(panel->name1L, WIPImageOnly);
1124 WMSetLabelImage(panel->name1L, logo);
1125 WMReleasePixmap(logo);
1126 } else {
1127 font = WMBoldSystemFontOfSize(scr->wmscreen, 20);
1128 if (font) {
1129 WMSetLabelFont(panel->name1L, font);
1130 WMReleaseFont(font);
1132 WMSetLabelTextAlignment(panel->name1L, WACenter);
1133 WMSetLabelText(panel->name1L, "GNU Window Maker");
1136 panel->name2L = WMCreateLabel(panel->win);
1137 WMResizeWidget(panel->name2L, 240, 24);
1138 WMMoveWidget(panel->name2L, 100, 60);
1139 font = WMBoldSystemFontOfSize(scr->wmscreen, 18);
1140 if (font) {
1141 WMSetLabelFont(panel->name2L, font);
1142 WMReleaseFont(font);
1143 font = NULL;
1145 WMSetLabelTextAlignment(panel->name2L, WACenter);
1146 WMSetLabelText(panel->name2L, "Window Manager for X");
1149 sprintf(version, "Version %s", VERSION);
1150 panel->versionL = WMCreateLabel(panel->win);
1151 WMResizeWidget(panel->versionL, 310, 16);
1152 WMMoveWidget(panel->versionL, 30, 95);
1153 WMSetLabelTextAlignment(panel->versionL, WARight);
1154 WMSetLabelText(panel->versionL, version);
1155 WMSetLabelWraps(panel->versionL, False);
1157 panel->copyrL = WMCreateLabel(panel->win);
1158 WMResizeWidget(panel->copyrL, 340, 40);
1159 WMMoveWidget(panel->copyrL, 15, 185);
1160 WMSetLabelTextAlignment(panel->copyrL, WALeft);
1161 WMSetLabelText(panel->copyrL, COPYRIGHT_TEXT);
1162 /* we want the (c) character in the helvetica font */
1163 font = WMCreateNormalFont(scr->wmscreen, HELVETICA10_FONT);
1164 if (font) {
1165 WMSetLabelFont(panel->copyrL, font);
1168 switch (scr->w_depth) {
1169 case 15:
1170 strcpy(version, "32 thousand");
1171 break;
1172 case 16:
1173 strcpy(version, "64 thousand");
1174 break;
1175 case 24:
1176 case 32:
1177 strcpy(version, "16 million");
1178 break;
1179 default:
1180 sprintf(version, "%d", 1<<scr->w_depth);
1181 break;
1184 sprintf(buffer, "Using visual 0x%x: %s %ibpp (%s colors)\n",
1185 (unsigned)scr->w_visual->visualid,
1186 visuals[scr->w_visual->class], scr->w_depth, version);
1188 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
1190 struct mallinfo ma = mallinfo();
1191 sprintf(buffer+strlen(buffer),
1192 "Total allocated memory: %i kB. Total memory in use: %i kB.\n",
1193 (ma.arena+ma.hblkhd)/1024, (ma.uordblks+ma.hblkhd)/1024);
1196 #endif
1198 strcat(buffer, "Supported image formats: ");
1199 strl = RSupportedFileFormats();
1200 for (i=0; strl[i]!=NULL; i++) {
1201 strcat(buffer, strl[i]);
1202 strcat(buffer, " ");
1205 strcat(buffer, "\nAdditional Support For: ");
1207 char *list[8];
1208 char buf[80];
1209 int j = 0;
1211 #ifdef MWM_HINTS
1212 list[j++] = "MWM";
1213 #endif
1214 #ifdef KWM_HINTS
1215 list[j++] = "KDE";
1216 #endif
1217 #ifdef GNOME_STUFF
1218 list[j++] = "GNOME";
1219 #endif
1220 #ifdef OLWM_HINTS
1221 list[j++] = "OLWM";
1222 #endif
1223 #ifdef WMSOUND
1224 list[j++] = "Sound";
1225 #endif
1227 buf[0] = 0;
1228 for (i = 0; i < j; i++) {
1229 if (i > 0) {
1230 if (i == j - 1)
1231 strcat(buf, " and ");
1232 else
1233 strcat(buf, ", ");
1235 strcat(buf, list[i]);
1237 strcat(buffer, buf);
1241 panel->infoL = WMCreateLabel(panel->win);
1242 WMResizeWidget(panel->infoL, 350, 75);
1243 WMMoveWidget(panel->infoL, 15, 115);
1244 WMSetLabelText(panel->infoL, buffer);
1245 if (font) {
1246 WMSetLabelFont(panel->infoL, font);
1247 WMReleaseFont(font);
1251 WMRealizeWidget(panel->win);
1252 WMMapSubwidgets(panel->win);
1254 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 382, 230, 0, 0, 0);
1256 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1258 WMMapWidget(panel->win);
1260 wwin = wManageInternalWindow(scr, parent, None, "Info",
1261 (scr->scr_width - 382)/2,
1262 (scr->scr_height - 230)/2, 382, 230);
1264 WSETUFLAG(wwin, no_closable, 0);
1265 WSETUFLAG(wwin, no_close_button, 0);
1266 #ifdef XKB_BUTTON_HINT
1267 wFrameWindowHideButton(wwin->frame, WFF_LANGUAGE_BUTTON);
1268 #endif
1269 wWindowUpdateButtonImages(wwin);
1270 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1271 wwin->frame->on_click_right = destroyInfoPanel;
1273 wWindowMap(wwin);
1275 panel->wwin = wwin;
1277 thePanel = panel;
1278 #ifdef SILLYNESS
1279 if (InitXThing(panel->scr)) {
1280 panel->timer = WMAddTimerHandler(100, logoPushCallback, panel);
1281 panel->cycle = 0;
1282 panel->x = 1;
1283 panel->str = "Merry Christmas!";
1284 panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL));
1286 #endif
1291 ***********************************************************************
1292 * Legal Panel
1293 ***********************************************************************
1296 typedef struct {
1297 WScreen *scr;
1299 WWindow *wwin;
1301 WMWindow *win;
1303 WMLabel *licenseL;
1304 } LegalPanel;
1308 #define LICENSE_TEXT \
1309 " Window Maker is free software; you can redistribute it and/or modify "\
1310 "it under the terms of the GNU General Public License as published "\
1311 "by the Free Software Foundation; either version 2 of the License, "\
1312 "or (at your option) any later version.\n\n\n"\
1313 " Window Maker is distributed in the hope that it will be useful, but "\
1314 "WITHOUT ANY WARRANTY; without even the implied warranty of "\
1315 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU "\
1316 "General Public License for more details.\n\n\n"\
1317 " You should have received a copy of the GNU General Public License "\
1318 "along with this program; if not, write to the Free Software "\
1319 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA "\
1320 "02111-1307, USA."
1323 static LegalPanel *legalPanel = NULL;
1325 static void
1326 destroyLegalPanel(WCoreWindow *foo, void *data, XEvent *event)
1328 WMUnmapWidget(legalPanel->win);
1330 WMDestroyWidget(legalPanel->win);
1332 wUnmanageWindow(legalPanel->wwin, False, False);
1334 free(legalPanel);
1336 legalPanel = NULL;
1340 void
1341 wShowLegalPanel(WScreen *scr)
1343 LegalPanel *panel;
1344 Window parent;
1345 WWindow *wwin;
1347 if (legalPanel) {
1348 if (legalPanel->scr == scr) {
1349 wRaiseFrame(legalPanel->wwin->frame->core);
1350 wSetFocusTo(scr, legalPanel->wwin);
1352 return;
1355 panel = wmalloc(sizeof(LegalPanel));
1357 panel->scr = scr;
1359 panel->win = WMCreateWindow(scr->wmscreen, "legal");
1360 WMResizeWidget(panel->win, 420, 250);
1363 panel->licenseL = WMCreateLabel(panel->win);
1364 WMResizeWidget(panel->licenseL, 400, 230);
1365 WMMoveWidget(panel->licenseL, 10, 10);
1366 WMSetLabelTextAlignment(panel->licenseL, WALeft);
1367 WMSetLabelText(panel->licenseL, LICENSE_TEXT);
1368 WMSetLabelRelief(panel->licenseL, WRGroove);
1370 WMRealizeWidget(panel->win);
1371 WMMapSubwidgets(panel->win);
1373 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 420, 250, 0, 0, 0);
1375 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1377 wwin = wManageInternalWindow(scr, parent, None, "Legal",
1378 (scr->scr_width - 420)/2,
1379 (scr->scr_height - 250)/2, 420, 250);
1381 WSETUFLAG(wwin, no_closable, 0);
1382 WSETUFLAG(wwin, no_close_button, 0);
1383 wWindowUpdateButtonImages(wwin);
1384 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1385 #ifdef XKB_BUTTON_HINT
1386 wFrameWindowHideButton(wwin->frame, WFF_LANGUAGE_BUTTON);
1387 #endif
1388 wwin->frame->on_click_right = destroyLegalPanel;
1390 panel->wwin = wwin;
1392 WMMapWidget(panel->win);
1394 wWindowMap(wwin);
1396 legalPanel = panel;
1401 ***********************************************************************
1402 * Crashing Dialog Panel
1403 ***********************************************************************
1406 extern WDDomain *WDWindowAttributes;
1409 typedef struct _CrashPanel {
1410 WMWindow *win; /* main window */
1412 WMLabel *iconL; /* application icon */
1413 WMLabel *nameL; /* title of panel */
1415 WMFrame *sepF; /* separator frame */
1417 WMLabel *noteL; /* Title of note */
1418 WMLabel *note2L; /* body of note with what happened */
1420 WMFrame *whatF; /* "what to do next" frame */
1421 WMPopUpButton *whatP; /* action selection popup button */
1423 WMButton *okB; /* ok button */
1425 Bool done; /* if finished with this dialog */
1426 int action; /* what to do after */
1428 KeyCode retKey;
1430 } CrashPanel;
1433 static void
1434 handleKeyPress(XEvent *event, void *clientData)
1436 CrashPanel *panel = (CrashPanel*)clientData;
1438 if (event->xkey.keycode == panel->retKey) {
1439 WMPerformButtonClick(panel->okB);
1444 static void
1445 okButtonCallback(void *self, void *clientData)
1447 CrashPanel *panel = (CrashPanel*)clientData;
1449 panel->done = True;
1453 static void
1454 setCrashAction(void *self, void *clientData)
1456 WMPopUpButton *pop = (WMPopUpButton*)self;
1457 CrashPanel *panel = (CrashPanel*)clientData;
1459 panel->action = WMGetPopUpButtonSelectedItem(pop);
1463 static WMPixmap*
1464 getWindowMakerIconImage(WMScreen *scr)
1466 proplist_t dict, key, option, value=NULL;
1467 WMPixmap *pix=NULL;
1468 char *path;
1470 PLSetStringCmpHook(NULL);
1472 key = PLMakeString("Logo.WMPanel");
1473 option = PLMakeString("Icon");
1475 dict = PLGetDictionaryEntry(WDWindowAttributes->dictionary, key);
1477 if (dict) {
1478 value = PLGetDictionaryEntry(dict, option);
1481 PLRelease(key);
1482 PLRelease(option);
1484 PLSetStringCmpHook(StringCompareHook);
1486 if (value && PLIsString(value)) {
1487 path = FindImage(wPreferences.icon_path, PLGetString(value));
1489 if (path) {
1490 RImage *image;
1492 image = RLoadImage(WMScreenRContext(scr), path, 0);
1493 if (image) {
1494 pix = WMCreatePixmapFromRImage(scr, image, 0);
1495 RDestroyImage(image);
1497 free(path);
1501 return pix;
1505 #define PWIDTH 295
1506 #define PHEIGHT 345
1510 wShowCrashingDialogPanel(int whatSig)
1512 CrashPanel *panel;
1513 WMScreen *scr;
1514 WMFont *font;
1515 WMPixmap *logo;
1516 int screen_no, scr_width, scr_height;
1517 int action;
1518 char buf[256];
1520 panel = wmalloc(sizeof(CrashPanel));
1521 memset(panel, 0, sizeof(CrashPanel));
1523 screen_no = DefaultScreen(dpy);
1524 scr_width = WidthOfScreen(ScreenOfDisplay(dpy, screen_no));
1525 scr_height = HeightOfScreen(ScreenOfDisplay(dpy, screen_no));
1527 scr = WMCreateScreen(dpy, screen_no);
1528 if (!scr) {
1529 wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
1530 return WMAbort;
1533 panel->retKey = XKeysymToKeycode(dpy, XK_Return);
1535 panel->win = WMCreateWindow(scr, "crashingDialog");
1536 WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
1537 WMMoveWidget(panel->win, (scr_width - PWIDTH)/2, (scr_height - PHEIGHT)/2);
1539 logo = getWindowMakerIconImage(scr);
1540 if (logo) {
1541 panel->iconL = WMCreateLabel(panel->win);
1542 WMResizeWidget(panel->iconL, 64, 64);
1543 WMMoveWidget(panel->iconL, 10, 10);
1544 WMSetLabelImagePosition(panel->iconL, WIPImageOnly);
1545 WMSetLabelImage(panel->iconL, logo);
1548 panel->nameL = WMCreateLabel(panel->win);
1549 WMResizeWidget(panel->nameL, 190, 18);
1550 WMMoveWidget(panel->nameL, 80, 35);
1551 WMSetLabelTextAlignment(panel->nameL, WALeft);
1552 font = WMBoldSystemFontOfSize(scr, 18);
1553 WMSetLabelFont(panel->nameL, font);
1554 WMReleaseFont(font);
1555 WMSetLabelText(panel->nameL, _("Fatal error"));
1557 panel->sepF = WMCreateFrame(panel->win);
1558 WMResizeWidget(panel->sepF, PWIDTH+4, 2);
1559 WMMoveWidget(panel->sepF, -2, 80);
1561 panel->noteL = WMCreateLabel(panel->win);
1562 WMResizeWidget(panel->noteL, PWIDTH-20, 40);
1563 WMMoveWidget(panel->noteL, 10, 90);
1564 WMSetLabelTextAlignment(panel->noteL, WAJustified);
1565 #ifdef SYS_SIGLIST_DECLARED
1566 sprintf(buf, _("Window Maker received signal %i\n(%s)."),
1567 whatSig, sys_siglist[whatSig]);
1568 #else
1569 sprintf(buf, _("Window Maker received signal %i."), whatSig);
1570 #endif
1571 WMSetLabelText(panel->noteL, buf);
1573 panel->note2L = WMCreateLabel(panel->win);
1574 WMResizeWidget(panel->note2L, PWIDTH-20, 100);
1575 WMMoveWidget(panel->note2L, 10, 130);
1576 WMSetLabelTextAlignment(panel->note2L, WALeft);
1577 WMSetLabelText(panel->note2L,
1578 _(" This fatal error occured probably due to a bug."
1579 " Please fill the included BUGFORM and "
1580 "report it to bugs@windowmaker.org."));
1583 panel->whatF = WMCreateFrame(panel->win);
1584 WMResizeWidget(panel->whatF, PWIDTH-20, 50);
1585 WMMoveWidget(panel->whatF, 10, 240);
1586 WMSetFrameTitle(panel->whatF, _("What do you want to do now?"));
1588 panel->whatP = WMCreatePopUpButton(panel->whatF);
1589 WMResizeWidget(panel->whatP, PWIDTH-20-70, 20);
1590 WMMoveWidget(panel->whatP, 35, 20);
1591 WMSetPopUpButtonPullsDown(panel->whatP, False);
1592 WMSetPopUpButtonText(panel->whatP, _("Select action"));
1593 WMAddPopUpButtonItem(panel->whatP, _("Abort and leave a core file"));
1594 WMAddPopUpButtonItem(panel->whatP, _("Restart Window Maker"));
1595 WMAddPopUpButtonItem(panel->whatP, _("Start alternate window manager"));
1596 WMSetPopUpButtonAction(panel->whatP, setCrashAction, panel);
1597 WMSetPopUpButtonSelectedItem(panel->whatP, WMRestart);
1598 panel->action = WMRestart;
1600 WMMapSubwidgets(panel->whatF);
1602 panel->okB = WMCreateCommandButton(panel->win);
1603 WMResizeWidget(panel->okB, 80, 26);
1604 WMMoveWidget(panel->okB, 205, 309);
1605 WMSetButtonText(panel->okB, _("OK"));
1606 WMSetButtonImage(panel->okB, WMGetSystemPixmap(scr, WSIReturnArrow));
1607 WMSetButtonAltImage(panel->okB, WMGetSystemPixmap(scr, WSIHighlightedReturnArrow));
1608 WMSetButtonImagePosition(panel->okB, WIPRight);
1609 WMSetButtonAction(panel->okB, okButtonCallback, panel);
1611 panel->done = 0;
1613 WMCreateEventHandler(WMWidgetView(panel->win), KeyPressMask,
1614 handleKeyPress, panel);
1616 WMRealizeWidget(panel->win);
1617 WMMapSubwidgets(panel->win);
1619 WMMapWidget(panel->win);
1621 XSetInputFocus(dpy, WMWidgetXID(panel->win), RevertToParent, CurrentTime);
1623 while (!panel->done) {
1624 XEvent event;
1626 WMNextEvent(dpy, &event);
1627 WMHandleEvent(&event);
1630 action = panel->action;
1632 WMUnmapWidget(panel->win);
1633 WMDestroyWidget(panel->win);
1634 free(panel);
1636 return action;
1642 /*****************************************************************************
1643 * About GNUstep Panel
1644 *****************************************************************************/
1647 static void
1648 drawGNUstepLogo(Display *dpy, Drawable d, int width, int height,
1649 unsigned long blackPixel, unsigned long whitePixel)
1651 GC gc;
1652 XGCValues gcv;
1653 XRectangle rects[3];
1655 gcv.foreground = blackPixel;
1656 gc = XCreateGC(dpy, d, GCForeground, &gcv);
1658 XFillArc(dpy, d, gc, width/45, height/45,
1659 width - 2*width/45, height - 2*height/45, 0, 360*64);
1661 rects[0].x = 0;
1662 rects[0].y = 37*height/45;
1663 rects[0].width = width/3;
1664 rects[0].height = height - rects[0].y;
1666 rects[1].x = rects[0].width;
1667 rects[1].y = height/2;
1668 rects[1].width = width - 2*width/3;
1669 rects[1].height = height - rects[1].y;
1671 rects[2].x = 2*width/3;
1672 rects[2].y = height - 37*height/45;
1673 rects[2].width = width/3;
1674 rects[2].height = height - rects[2].y;
1676 XSetClipRectangles(dpy, gc, 0, 0, rects, 3, Unsorted);
1677 XFillRectangle(dpy, d, gc, 0, 0, width, height);
1679 XSetForeground(dpy, gc, whitePixel);
1680 XFillArc(dpy, d, gc, width/45, height/45,
1681 width - 2*width/45, height - 2*height/45, 0, 360*64);
1683 XFreeGC(dpy, gc);
1688 #define GNUSTEP_TEXT \
1689 "Window Maker is part of the GNUstep project.\n"\
1690 "The GNUstep project aims to create a free\n"\
1691 "implementation of the OpenStep(tm) specification\n"\
1692 "which is a object-oriented framework for\n"\
1693 "creating advanced graphical, multi-platform\n"\
1694 "applications. Additionally, a development and\n"\
1695 "user desktop enviroment will be created on top\n"\
1696 "of the framework. For more information about\n"\
1697 "GNUstep, please visit: www.gnustep.org"
1700 typedef struct {
1701 WScreen *scr;
1703 WWindow *wwin;
1705 WMWindow *win;
1707 WMLabel *gstepL;
1708 WMLabel *textL;
1709 } GNUstepPanel;
1712 static GNUstepPanel *gnustepPanel = NULL;
1714 static void
1715 destroyGNUstepPanel(WCoreWindow *foo, void *data, XEvent *event)
1717 WMUnmapWidget(gnustepPanel->win);
1719 WMDestroyWidget(gnustepPanel->win);
1721 wUnmanageWindow(gnustepPanel->wwin, False, False);
1723 free(gnustepPanel);
1725 gnustepPanel = NULL;
1729 void
1730 wShowGNUstepPanel(WScreen *scr)
1732 GNUstepPanel *panel;
1733 Window parent;
1734 WWindow *wwin;
1735 WMPixmap *pixmap;
1736 WMColor *color;
1738 if (gnustepPanel) {
1739 if (gnustepPanel->scr == scr) {
1740 wRaiseFrame(gnustepPanel->wwin->frame->core);
1741 wSetFocusTo(scr, gnustepPanel->wwin);
1743 return;
1746 panel = wmalloc(sizeof(GNUstepPanel));
1748 panel->scr = scr;
1750 panel->win = WMCreateWindow(scr->wmscreen, "About GNUstep");
1751 WMResizeWidget(panel->win, 325, 200);
1753 pixmap = WMCreatePixmap(scr->wmscreen, 130, 130,
1754 WMScreenDepth(scr->wmscreen), True);
1756 color = WMCreateNamedColor(scr->wmscreen, "gray50", True);
1758 drawGNUstepLogo(dpy, WMGetPixmapXID(pixmap), 130, 130,
1759 WMColorPixel(color), scr->white_pixel);
1761 WMReleaseColor(color);
1763 XSetForeground(dpy, scr->mono_gc, 0);
1764 XFillRectangle(dpy, WMGetPixmapMaskXID(pixmap), scr->mono_gc, 0, 0,
1765 130, 130);
1766 drawGNUstepLogo(dpy, WMGetPixmapMaskXID(pixmap), 130, 130, 1, 1);
1768 panel->gstepL = WMCreateLabel(panel->win);
1769 WMResizeWidget(panel->gstepL, 285, 64);
1770 WMMoveWidget(panel->gstepL, 20, 0);
1771 WMSetLabelTextAlignment(panel->gstepL, WARight);
1772 WMSetLabelText(panel->gstepL, "GNUstep");
1774 WMFont *font = WMBoldSystemFontOfSize(scr->wmscreen, 24);
1776 WMSetLabelFont(panel->gstepL, font);
1777 WMReleaseFont(font);
1780 panel->textL = WMCreateLabel(panel->win);
1781 WMResizeWidget(panel->textL, 275, 130);
1782 WMMoveWidget(panel->textL, 30, 50);
1783 WMSetLabelTextAlignment(panel->textL, WARight);
1784 WMSetLabelImagePosition(panel->textL, WIPOverlaps);
1785 WMSetLabelText(panel->textL, GNUSTEP_TEXT);
1786 WMSetLabelImage(panel->textL, pixmap);
1788 WMReleasePixmap(pixmap);
1790 WMRealizeWidget(panel->win);
1791 WMMapSubwidgets(panel->win);
1793 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 325, 200, 0, 0, 0);
1795 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1797 wwin = wManageInternalWindow(scr, parent, None, "About GNUstep",
1798 (scr->scr_width - 325)/2,
1799 (scr->scr_height - 200)/2, 325, 200);
1801 WSETUFLAG(wwin, no_closable, 0);
1802 WSETUFLAG(wwin, no_close_button, 0);
1803 wWindowUpdateButtonImages(wwin);
1804 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1805 #ifdef XKB_BUTTON_HINT
1806 wFrameWindowHideButton(wwin->frame, WFF_LANGUAGE_BUTTON);
1807 #endif
1808 wwin->frame->on_click_right = destroyGNUstepPanel;
1810 panel->wwin = wwin;
1812 WMMapWidget(panel->win);
1814 wWindowMap(wwin);
1816 gnustepPanel = panel;