added patch with bugfixes for wings/textfield/panel exit with escape/bag etc
[wmaker-crm.git] / src / dialog.c
bloba1a5bb26fbce69657238ef849c397980dbf16b52
1 /* dialog.c - dialog windows for internal use
2 *
3 * Window Maker window manager
4 *
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 * Copyright (c) 1999 Dan Pascu
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 * USA.
24 #include "wconfig.h"
26 #include <X11/Xlib.h>
27 #include <X11/Xutil.h>
28 #include <X11/keysym.h>
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <unistd.h>
33 #include <string.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <dirent.h>
37 #include <limits.h>
39 #include <signal.h>
40 #ifdef __FreeBSD__
41 #include <sys/signal.h>
42 #endif
45 #ifndef PATH_MAX
46 #define PATH_MAX DEFAULT_PATH_MAX
47 #endif
49 #include "WindowMaker.h"
50 #include "GNUstep.h"
51 #include "screen.h"
52 #include "dialog.h"
53 #include "funcs.h"
54 #include "stacking.h"
55 #include "framewin.h"
56 #include "window.h"
57 #include "actions.h"
58 #include "defaults.h"
61 extern WPreferences wPreferences;
65 int
66 wMessageDialog(WScreen *scr, char *title, char *message,
67 char *defBtn, char *altBtn, char *othBtn)
69 WMAlertPanel *panel;
70 Window parent;
71 WWindow *wwin;
72 int result;
74 panel = WMCreateAlertPanel(scr->wmscreen, NULL, title, message,
75 defBtn, altBtn, othBtn);
77 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 400, 180, 0, 0, 0);
79 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
81 wwin = wManageInternalWindow(scr, parent, None, NULL,
82 (scr->scr_width - 400)/2,
83 (scr->scr_height - 180)/2, 400, 180);
84 wwin->client_leader = WMWidgetXID(panel->win);
86 WMMapWidget(panel->win);
88 wWindowMap(wwin);
90 while (!panel->done) {
91 XEvent event;
93 WMNextEvent(dpy, &event);
94 WMHandleEvent(&event);
97 result = panel->result;
99 WMUnmapWidget(panel->win);
101 wUnmanageWindow(wwin, False, False);
103 WMDestroyAlertPanel(panel);
105 XDestroyWindow(dpy, parent);
107 return result;
113 wInputDialog(WScreen *scr, char *title, char *message, char **text)
115 WWindow *wwin;
116 Window parent;
117 WMInputPanel *panel;
118 char *result;
121 panel = WMCreateInputPanel(scr->wmscreen, NULL, title, message, *text,
122 _("OK"), _("Cancel"));
125 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 320, 160, 0, 0, 0);
126 XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask);
128 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
130 wwin = wManageInternalWindow(scr, parent, None, NULL,
131 (scr->scr_width - 320)/2,
132 (scr->scr_height - 160)/2, 320, 160);
134 wwin->client_leader = WMWidgetXID(panel->win);
136 WMMapWidget(panel->win);
138 wWindowMap(wwin);
140 while (!panel->done) {
141 XEvent event;
143 WMNextEvent(dpy, &event);
144 WMHandleEvent(&event);
147 if (panel->result == WAPRDefault)
148 result = WMGetTextFieldText(panel->text);
149 else
150 result = NULL;
152 wUnmanageWindow(wwin, False, False);
154 WMDestroyInputPanel(panel);
156 XDestroyWindow(dpy, parent);
158 if (result==NULL)
159 return False;
160 else {
161 if (*text)
162 free(*text);
163 *text = result;
165 return True;
171 *****************************************************************
172 * Icon Selection Panel
173 *****************************************************************
176 typedef struct IconPanel {
178 WScreen *scr;
180 WMWindow *win;
182 WMLabel *dirLabel;
183 WMLabel *iconLabel;
185 WMList *dirList;
186 WMList *iconList;
187 WMFont *normalfont;
189 WMButton *previewButton;
191 WMLabel *iconView;
193 WMLabel *fileLabel;
194 WMTextField *fileField;
196 WMButton *okButton;
197 WMButton *cancelButton;
198 #if 0
199 WMButton *chooseButton;
200 #endif
201 short done;
202 short result;
203 short preview;
204 } IconPanel;
208 static void
209 listPixmaps(WScreen *scr, WMList *lPtr, char *path)
211 struct dirent *dentry;
212 DIR *dir;
213 char pbuf[PATH_MAX+16];
214 char *apath;
215 IconPanel *panel = WMGetHangedData(lPtr);
217 panel->preview = False;
219 apath = wexpandpath(path);
220 dir = opendir(apath);
222 if (!dir) {
223 char *msg;
224 char *tmp;
225 tmp = _("Could not open directory ");
226 msg = wmalloc(strlen(tmp)+strlen(path)+6);
227 strcpy(msg, tmp);
228 strcat(msg, path);
230 wMessageDialog(scr, _("Error"), msg, _("OK"), NULL, NULL);
231 free(msg);
232 free(apath);
233 return;
236 /* list contents in the column */
237 while ((dentry = readdir(dir))) {
238 struct stat statb;
240 if (strcmp(dentry->d_name, ".")==0 ||
241 strcmp(dentry->d_name, "..")==0)
242 continue;
244 strcpy(pbuf, apath);
245 strcat(pbuf, "/");
246 strcat(pbuf, dentry->d_name);
248 if (stat(pbuf, &statb)<0)
249 continue;
251 if (statb.st_mode & (S_IRUSR|S_IRGRP|S_IROTH)
252 && statb.st_mode & (S_IFREG|S_IFLNK)) {
253 WMAddSortedListItem(lPtr, dentry->d_name);
257 closedir(dir);
258 free(apath);
259 panel->preview = True;
264 static void
265 setViewedImage(IconPanel *panel, char *file)
267 WMPixmap *pixmap;
268 RColor color;
270 color.red = 0xae;
271 color.green = 0xaa;
272 color.blue = 0xae;
273 color.alpha = 0;
274 pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win),
275 file, &color);
276 if (!pixmap) {
277 WMSetButtonEnabled(panel->okButton, False);
279 WMSetLabelText(panel->iconView, _("Could not load image file "));
281 WMSetLabelImage(panel->iconView, NULL);
282 } else {
283 WMSetButtonEnabled(panel->okButton, True);
285 WMSetLabelText(panel->iconView, NULL);
286 WMSetLabelImage(panel->iconView, pixmap);
287 WMReleasePixmap(pixmap);
292 static void
293 listCallback(void *self, void *data)
295 WMList *lPtr = (WMList*)self;
296 IconPanel *panel = (IconPanel*)data;
297 char *path;
299 if (lPtr==panel->dirList) {
300 path = WMGetListSelectedItem(lPtr)->text;
302 WMSetTextFieldText(panel->fileField, path);
304 WMSetLabelImage(panel->iconView, NULL);
306 WMSetButtonEnabled(panel->okButton, False);
308 WMClearList(panel->iconList);
309 listPixmaps(panel->scr, panel->iconList, path);
310 } else {
311 char *tmp, *iconFile;
313 path = WMGetListSelectedItem(panel->dirList)->text;
314 tmp = wexpandpath(path);
316 iconFile = WMGetListSelectedItem(panel->iconList)->text;
318 path = wmalloc(strlen(tmp)+strlen(iconFile)+4);
319 strcpy(path, tmp);
320 strcat(path, "/");
321 strcat(path, iconFile);
322 free(tmp);
323 WMSetTextFieldText(panel->fileField, path);
324 setViewedImage(panel, path);
325 free(path);
330 static void
331 listIconPaths(WMList *lPtr)
333 char *paths;
334 char *path;
336 paths = wstrdup(wPreferences.icon_path);
338 path = strtok(paths, ":");
340 do {
341 char *tmp;
343 tmp = wexpandpath(path);
344 /* do not sort, because the order implies the order of
345 * directories searched */
346 if (access(tmp, X_OK)==0)
347 WMAddListItem(lPtr, path);
348 free(tmp);
349 } while ((path=strtok(NULL, ":"))!=NULL);
351 free(paths);
355 void
356 drawIconProc(WMList *lPtr, int index, Drawable d, char *text,
357 int state, WMRect *rect)
359 IconPanel *panel = WMGetHangedData(lPtr);
360 GC gc = panel->scr->draw_gc;
361 GC copygc = panel->scr->copy_gc;
362 char *buffer, *dirfile;
363 WMPixmap *pixmap;
364 WMColor *blackcolor;
365 WMColor *whitecolor;
366 WMSize size;
367 WMScreen *wmscr=WMWidgetScreen(panel->win);
368 int width;
370 if(!panel->preview) return;
372 width = rect->size.width;
374 blackcolor = WMBlackColor(wmscr);
375 whitecolor = WMWhiteColor(wmscr);
377 dirfile = WMGetListSelectedItem(panel->dirList)->text;
378 buffer = wmalloc(strlen(dirfile)+strlen(text)+4);
379 sprintf(buffer,"%s/%s" ,dirfile,text);
381 pixmap = WMCreatePixmapFromFile(WMWidgetScreen(panel->win), buffer);
382 free(buffer);
383 if (!pixmap) {
384 WMRemoveListItem(lPtr, index);
385 return;
388 XClearArea(dpy, d, rect->pos.x, rect->pos.y, width, rect->size.height,
389 False);
390 XSetClipMask(dpy, gc, None);
392 XDrawRectangle(dpy, d, WMColorGC(whitecolor), rect->pos.x + 5,
393 rect->pos.y +5, width - 10, 54);
395 XDrawLine(dpy, d, WMColorGC(whitecolor), rect->pos.x,
396 rect->pos.y+rect->size.height-1, rect->pos.x+width,
397 rect->pos.y+rect->size.height-1);
400 if (state&WLDSSelected) {
401 XFillRectangle(dpy, d, WMColorGC(whitecolor), rect->pos.x,
402 rect->pos.y, width, rect->size.height);
405 size = WMGetPixmapSize(pixmap);
407 XSetClipMask(dpy, copygc, WMGetPixmapMaskXID(pixmap));
408 XSetClipOrigin(dpy, copygc, rect->pos.x + (width-size.width)/2,
409 rect->pos.y+2);
410 XCopyArea(dpy, WMGetPixmapXID(pixmap), d, copygc, 0, 0,
411 size.width>100?100:size.width, size.height>64?64:size.height,
412 rect->pos.x + (width-size.width)/2, rect->pos.y+2);
415 int i,j;
416 int fheight = WMFontHeight(panel->normalfont);
417 int tlen = strlen(text);
418 int twidth = WMWidthOfString(panel->normalfont, text, tlen);
419 int ofx, ofy;
421 ofx = rect->pos.x + (width - twidth)/2;
422 ofy = rect->pos.y + 64 - fheight;
424 for(i=-1;i<2;i++)
425 for(j=-1;j<2;j++)
426 WMDrawString(wmscr, d, WMColorGC(whitecolor),
427 panel->normalfont, ofx+i, ofy+j,
428 text, tlen);
430 WMDrawString(wmscr, d, WMColorGC(blackcolor), panel->normalfont,
431 ofx, ofy, text, tlen);
434 WMReleasePixmap(pixmap);
435 /* I hope it is better to do not use cache / on my box it is fast nuff */
436 XFlush(dpy);
438 WMReleaseColor(blackcolor);
439 WMReleaseColor(whitecolor);
443 static void
444 buttonCallback(void *self, void *clientData)
446 WMButton *bPtr = (WMButton*)self;
447 IconPanel *panel = (IconPanel*)clientData;
450 if (bPtr==panel->okButton) {
451 panel->done = True;
452 panel->result = True;
453 } else if (bPtr==panel->cancelButton) {
454 panel->done = True;
455 panel->result = False;
456 } else if (bPtr==panel->previewButton) {
457 /**** Previewer ****/
458 WMSetButtonEnabled(bPtr, False);
459 WMSetListUserDrawItemHeight(panel->iconList, 68);
460 WMSetListUserDrawProc(panel->iconList, drawIconProc);
461 WMRedisplayWidget(panel->iconList);
462 /* for draw proc to access screen/gc */
463 /*** end preview ***/
465 #if 0
466 else if (bPtr==panel->chooseButton) {
467 WMOpenPanel *op;
469 op = WMCreateOpenPanel(WMWidgetScreen(bPtr));
471 if (WMRunModalFilePanelForDirectory(op, NULL, "/usr/local", NULL, NULL)) {
472 char *path;
473 path = WMGetFilePanelFile(op);
474 WMSetTextFieldText(panel->fileField, path);
475 setViewedImage(panel, path);
476 free(path);
478 WMDestroyFilePanel(op);
480 #endif
484 Bool
485 wIconChooserDialog(WScreen *scr, char **file, char *instance, char *class)
487 WWindow *wwin;
488 Window parent;
489 IconPanel *panel;
490 WMColor *color;
491 WMFont *boldFont;
493 panel = wmalloc(sizeof(IconPanel));
494 memset(panel, 0, sizeof(IconPanel));
496 panel->scr = scr;
498 panel->win = WMCreateWindow(scr->wmscreen, "iconChooser");
499 WMResizeWidget(panel->win, 450, 280);
501 boldFont = WMBoldSystemFontOfSize(scr->wmscreen, 12);
502 panel->normalfont = WMSystemFontOfSize(WMWidgetScreen(panel->win), 12);
504 panel->dirLabel = WMCreateLabel(panel->win);
505 WMResizeWidget(panel->dirLabel, 200, 20);
506 WMMoveWidget(panel->dirLabel, 10, 7);
507 WMSetLabelText(panel->dirLabel, _("Directories"));
508 WMSetLabelFont(panel->dirLabel, boldFont);
509 WMSetLabelTextAlignment(panel->dirLabel, WACenter);
511 WMSetLabelRelief(panel->dirLabel, WRSunken);
513 panel->iconLabel = WMCreateLabel(panel->win);
514 WMResizeWidget(panel->iconLabel, 140, 20);
515 WMMoveWidget(panel->iconLabel, 215, 7);
516 WMSetLabelText(panel->iconLabel, _("Icons"));
517 WMSetLabelFont(panel->iconLabel, boldFont);
518 WMSetLabelTextAlignment(panel->iconLabel, WACenter);
520 WMReleaseFont(boldFont);
522 color = WMWhiteColor(scr->wmscreen);
523 WMSetLabelTextColor(panel->dirLabel, color);
524 WMSetLabelTextColor(panel->iconLabel, color);
525 WMReleaseColor(color);
527 color = WMDarkGrayColor(scr->wmscreen);
528 WMSetWidgetBackgroundColor(panel->iconLabel, color);
529 WMSetWidgetBackgroundColor(panel->dirLabel, color);
530 WMReleaseColor(color);
532 WMSetLabelRelief(panel->iconLabel, WRSunken);
534 panel->dirList = WMCreateList(panel->win);
535 WMResizeWidget(panel->dirList, 200, 170);
536 WMMoveWidget(panel->dirList, 10, 30);
537 WMSetListAction(panel->dirList, listCallback, panel);
539 panel->iconList = WMCreateList(panel->win);
540 WMResizeWidget(panel->iconList, 140, 170);
541 WMMoveWidget(panel->iconList, 215, 30);
542 WMSetListAction(panel->iconList, listCallback, panel);
544 WMHangData(panel->iconList,panel);
546 panel->previewButton = WMCreateCommandButton(panel->win);
547 WMResizeWidget(panel->previewButton, 75, 26);
548 WMMoveWidget(panel->previewButton, 365, 130);
549 WMSetButtonText(panel->previewButton, _("Preview"));
550 WMSetButtonAction(panel->previewButton, buttonCallback, panel);
552 panel->iconView = WMCreateLabel(panel->win);
553 WMResizeWidget(panel->iconView, 75, 75);
554 WMMoveWidget(panel->iconView, 365, 40);
555 WMSetLabelImagePosition(panel->iconView, WIPOverlaps);
556 WMSetLabelRelief(panel->iconView, WRSunken);
557 WMSetLabelTextAlignment(panel->iconView, WACenter);
559 panel->fileLabel = WMCreateLabel(panel->win);
560 WMResizeWidget(panel->fileLabel, 80, 20);
561 WMMoveWidget(panel->fileLabel, 10, 210);
562 WMSetLabelText(panel->fileLabel, _("File Name:"));
564 panel->fileField = WMCreateTextField(panel->win);
565 WMResizeWidget(panel->fileField, 345, 20);
566 WMMoveWidget(panel->fileField, 95, 210);
567 WMSetTextFieldEditable(panel->fileField, False);
569 panel->okButton = WMCreateCommandButton(panel->win);
570 WMResizeWidget(panel->okButton, 80, 26);
571 WMMoveWidget(panel->okButton, 360, 240);
572 WMSetButtonText(panel->okButton, _("OK"));
573 WMSetButtonEnabled(panel->okButton, False);
574 WMSetButtonAction(panel->okButton, buttonCallback, panel);
576 panel->cancelButton = WMCreateCommandButton(panel->win);
577 WMResizeWidget(panel->cancelButton, 80, 26);
578 WMMoveWidget(panel->cancelButton, 270, 240);
579 WMSetButtonText(panel->cancelButton, _("Cancel"));
580 WMSetButtonAction(panel->cancelButton, buttonCallback, panel);
581 #if 0
582 panel->chooseButton = WMCreateCommandButton(panel->win);
583 WMResizeWidget(panel->chooseButton, 110, 26);
584 WMMoveWidget(panel->chooseButton, 150, 240);
585 WMSetButtonText(panel->chooseButton, _("Choose File"));
586 WMSetButtonAction(panel->chooseButton, buttonCallback, panel);
587 #endif
588 WMRealizeWidget(panel->win);
589 WMMapSubwidgets(panel->win);
591 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 450, 280, 0, 0, 0);
593 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
596 char *tmp;
598 tmp = wmalloc((instance ? strlen(instance) : 0)
599 + (class ? strlen(class) : 0) + 32);
601 if (tmp && (instance || class))
602 sprintf(tmp, "%s [%s.%s]", _("Icon Chooser"), instance, class);
603 else
604 strcpy(tmp, _("Icon Chooser"));
606 wwin = wManageInternalWindow(scr, parent, None, tmp,
607 (scr->scr_width - 450)/2,
608 (scr->scr_height - 280)/2, 450, 280);
609 free(tmp);
612 /* put icon paths in the list */
613 listIconPaths(panel->dirList);
615 WMMapWidget(panel->win);
617 wWindowMap(wwin);
619 while (!panel->done) {
620 XEvent event;
622 WMNextEvent(dpy, &event);
623 WMHandleEvent(&event);
626 if (panel->result) {
627 char *defaultPath, *wantedPath;
629 /* check if the file the user selected is not the one that
630 * would be loaded by default with the current search path */
631 *file = WMGetListSelectedItem(panel->iconList)->text;
632 if ((*file)[0]==0) {
633 free(*file);
634 *file = NULL;
635 } else {
636 defaultPath = FindImage(wPreferences.icon_path, *file);
637 wantedPath = WMGetTextFieldText(panel->fileField);
638 /* if the file is not the default, use full path */
639 if (strcmp(wantedPath, defaultPath)!=0) {
640 *file = wantedPath;
641 } else {
642 *file = wstrdup(*file);
643 free(wantedPath);
645 free(defaultPath);
647 } else {
648 *file = NULL;
651 WMReleaseFont(panel->normalfont);
653 WMUnmapWidget(panel->win);
655 WMDestroyWidget(panel->win);
657 wUnmanageWindow(wwin, False, False);
659 free(panel);
661 XDestroyWindow(dpy, parent);
663 return panel->result;
668 ***********************************************************************
669 * Info Panel
670 ***********************************************************************
674 typedef struct {
675 WScreen *scr;
677 WWindow *wwin;
679 WMWindow *win;
681 WMLabel *logoL;
682 WMLabel *name1L;
683 WMLabel *name2L;
685 WMLabel *versionL;
687 WMLabel *infoL;
689 WMLabel *copyrL;
691 #ifdef SILLYNESS
692 WMHandlerID timer;
693 int cycle;
694 RImage *icon;
695 RImage *pic;
696 WMPixmap *oldPix;
697 char *str;
698 int x;
699 #endif
700 } InfoPanel;
704 #define COPYRIGHT_TEXT \
705 "Copyright \xa9 1997~1999 Alfredo K. Kojima <kojima@windowmaker.org>\n"\
706 "Copyright \xa9 1998,1999 Dan Pascu <dan@windowmaker.org>"
710 static InfoPanel *thePanel = NULL;
712 static void
713 destroyInfoPanel(WCoreWindow *foo, void *data, XEvent *event)
715 #ifdef SILLYNESS
716 if (thePanel->timer) {
717 WMDeleteTimerHandler(thePanel->timer);
719 if (thePanel->oldPix) {
720 WMReleasePixmap(thePanel->oldPix);
722 if (thePanel->icon) {
723 RDestroyImage(thePanel->icon);
725 if (thePanel->pic) {
726 RDestroyImage(thePanel->pic);
728 #endif /* SILLYNESS */
729 WMUnmapWidget(thePanel);
731 wUnmanageWindow(thePanel->wwin, False, False);
733 WMDestroyWidget(thePanel->win);
735 free(thePanel);
737 thePanel = NULL;
741 WMPixmap*
742 renderText(WMScreen *scr, char *text, char *font, RColor *from, RColor *to)
744 WMPixmap *wpix = NULL;
745 Pixmap grad = None;
746 Pixmap mask = None;
747 RContext *rc = WMScreenRContext(scr);
748 XFontStruct *f = NULL;
749 int w, h;
750 GC gc = None;
752 f = XLoadQueryFont(dpy, font);
753 if (!f)
754 return NULL;
756 w = XTextWidth(f, text, strlen(text));
757 h = f->ascent+f->descent;
759 mask = XCreatePixmap(dpy, rc->drawable, w, h, 1);
760 gc = XCreateGC(dpy, mask, 0, NULL);
761 XSetForeground(dpy, gc, 0);
762 XSetFont(dpy, gc, f->fid);
763 XFillRectangle(dpy, mask, gc, 0, 0, w, h);
765 XSetForeground(dpy, gc, 1);
766 XDrawString(dpy, mask, gc, 0, f->ascent, text, strlen(text));
767 XSetLineAttributes(dpy, gc, 3, LineSolid, CapRound, JoinMiter);
768 XDrawLine(dpy, mask, gc, 0, h-2, w, h-2);
770 grad = XCreatePixmap(dpy, rc->drawable, w, h, rc->depth);
772 WMColor *color;
774 color = WMBlackColor(scr);
775 XFillRectangle(dpy, grad, WMColorGC(color), 0, 0, w, h);
776 WMReleaseColor(color);
779 wpix = WMCreatePixmapFromXPixmaps(scr, grad, mask, w, h, rc->depth);
781 if (gc)
782 XFreeGC(dpy, gc);
783 XFreeFont(dpy, f);
785 return wpix;
788 #ifdef SILLYNESS
790 extern WMPixmap *DoXThing();
791 extern Bool InitXThing();
793 static void
794 logoPushCallback(void *data)
796 InfoPanel *panel = (InfoPanel*)data;
797 char buffer[512];
798 int i;
799 int len;
800 static int jingobeu[] = {
801 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
802 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
803 329, 150, 392, 150, 261, 150, 293, 150, 329, 400, -1, 400, 0
805 static int c = 0;
807 if (panel->x) {
808 XKeyboardControl kc;
810 if (panel->x > 0) {
811 if(jingobeu[panel->x-1]==0){panel->x=-1;}else if(jingobeu[panel->x
812 -1]<0){panel->x++;c=jingobeu[panel->x-1]/50;panel->x++;}else if(c==0){
813 kc.bell_pitch=jingobeu[panel->x-1];panel->x++;kc.bell_percent=50;c=
814 jingobeu[panel->x-1]/50;kc.bell_duration=jingobeu[panel->x-1];panel->x++;
815 XChangeKeyboardControl(dpy,KBBellPitch|KBBellDuration|KBBellPercent,&kc);
816 XBell(dpy,50);XFlush(dpy);}else{c--;}}
817 if (!(panel->cycle % 4)) {
818 WMPixmap *p;
820 p = DoXThing(panel->wwin);
821 WMSetLabelImage(panel->logoL, p);
823 } else if (panel->cycle < 30) {
824 RImage *image;
825 WMPixmap *pix;
827 image = RCloneImage(panel->icon);
828 RCombineImagesWithOpaqueness(image, panel->pic, panel->cycle*255/30);
829 pix = WMCreatePixmapFromRImage(panel->scr->wmscreen, image, 128);
830 RDestroyImage(image);
831 WMSetLabelImage(panel->logoL, pix);
832 WMReleasePixmap(pix);
835 i = panel->cycle%200;
837 len = strlen(panel->str);
839 strncpy(buffer, panel->str, i<len ? i : len);
840 if (i >= len)
841 memset(&buffer[len], ' ', i-len);
843 strncpy(buffer, panel->str, i<len ? i : len);
844 if (i >= len)
845 memset(&buffer[len], ' ', i-len);
846 buffer[i]=0;
847 WMSetLabelText(panel->versionL, buffer);
849 panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
850 panel->cycle++;
854 static void
855 handleLogoPush(XEvent *event, void *data)
857 InfoPanel *panel = (InfoPanel*)data;
858 static int broken = 0;
859 static int clicks = 0;
860 static char *pic_data[] = {
861 "45 45 57 1",
862 " c None",
863 ". c #000000",
864 "X c #383C00",
865 "o c #515500",
866 "O c #616100",
867 "+ c #616900",
868 "@ c #696D00",
869 "# c #697100",
870 "$ c #495100",
871 "% c #202800",
872 "& c #969600",
873 "* c #CFCF00",
874 "= c #D7DB00",
875 "- c #D7D700",
876 "; c #C7CB00",
877 ": c #A6AA00",
878 "> c #494900",
879 ", c #8E8E00",
880 "< c #DFE700",
881 "1 c #F7FF00",
882 "2 c #FFFF00",
883 "3 c #E7EB00",
884 "4 c #B6B600",
885 "5 c #595900",
886 "6 c #717500",
887 "7 c #AEB200",
888 "8 c #CFD300",
889 "9 c #E7EF00",
890 "0 c #EFF300",
891 "q c #9EA200",
892 "w c #F7FB00",
893 "e c #F7F700",
894 "r c #BEBE00",
895 "t c #8E9200",
896 "y c #EFF700",
897 "u c #969A00",
898 "i c #414500",
899 "p c #595D00",
900 "a c #E7E700",
901 "s c #C7C700",
902 "d c #797D00",
903 "f c #BEC300",
904 "g c #DFE300",
905 "h c #868600",
906 "j c #EFEF00",
907 "k c #9E9E00",
908 "l c #616500",
909 "z c #DFDF00",
910 "x c #868A00",
911 "c c #969200",
912 "v c #B6BA00",
913 "b c #A6A600",
914 "n c #8E8A00",
915 "m c #717100",
916 "M c #AEAE00",
917 "N c #AEAA00",
918 "B c #868200",
919 " ............... ",
920 " ....XoO+@##+O$%.... ",
921 " ...%X&*========-;;:o... ",
922 " ...>.>,<122222222222134@... ",
923 " ..>5678912222222222222220q%.. ",
924 " ..$.&-w2222222222222222222er>.. ",
925 " ..O.t31222222222222222222222y4>.. ",
926 " ...O5u3222222222222222222222222yri... ",
927 " ..>p&a22222222222222222222222222wso.. ",
928 " ..ids91222222222222222222222222222wfi.. ",
929 " ..X.7w222222wgs-w2222222213=g0222222<hi.. ",
930 " ..Xuj2222222<@X5=222222229k@l:022222y4i.. ",
931 " .Xdz22222222*X%.s22222222axo%$-222222<c>.. ",
932 " ..o7y22222222v...r222222223hX.i82222221si.. ",
933 "..io*222222222&...u22222222yt..%*22222220:%. ",
934 "..>k02222222227...f222222222v..X=222222229t. ",
935 "..dz12222222220ui:y2222222223d%qw222222221g. ",
936 ".%vw222222222221y2222222222219*y2222222222wd.",
937 ".X;2222222222222222222222222222222222222222b.",
938 ".i*2222222222222222222222222222222222222222v.",
939 ".i*2222222222222222222222222222222222222222;.",
940 ".i*22222222222222222222222222222222222222228.",
941 ".>*2222222222222222222222222222222222222222=.",
942 ".i*22222222222222222222222222222222222222228.",
943 ".i*2222222222222222222222222222222222222222;.",
944 ".X*222222222222222222222222222222we12222222r.",
945 ".Xs12222222w3aw22222222222222222y8s0222222wk.",
946 ".Xq02222222a,na22222222222222222zm6zwy2222gi.",
947 "..>*22222y<:Xcj22222222222222222-o$k;;02228..",
948 "..i7y2220rhX.:y22222222222222222jtiXd,a220,..",
949 " .X@z222a,do%kj2222222222222222wMX5q;gw228%..",
950 " ..58222wagsh6ry222222222222221;>Of0w222y:...",
951 " ...:e2222218mdz22222222222222a&$vw222220@...",
952 " ...O-122222y:.u02222222222229q$uj222221r... ",
953 " ..%&a1222223&573w2222222219NOxz122221z>... ",
954 " ...t3222221-l$nr8ay1222yzbo,=12222w-5... ",
955 " ..X:022222w-k+>o,7s**s7xOn=12221<f5... ",
956 " ..o:9222221j8:&Bl>>>>ihv<12221=dX... ",
957 " ..Xb9122222109g-****;<y22221zn%... ",
958 " ..X&801222222222222222222w-h.... ",
959 " ...o:=022222222222222221=lX... ",
960 " ..X@:;3w2222222222210fO... ",
961 " ...XX&v8<30000003-N@... ",
962 " .....XmnbN:q&Bo.... ",
963 " ............ "};
964 static char *msgs[] = {
965 "Sloppy focus is a *?#@",
966 "Repent! Sloppy focus users will burn in hell!!!",
967 "Have a nice day!"
971 clicks++;
972 if (!panel->timer && !broken && clicks > 0) {
973 char *file;
974 char *path;
976 panel->x = 0;
977 clicks = 0;
978 if (!panel->icon) {
979 file = wDefaultGetIconFile(panel->scr, "Logo", "WMPanel", False);
980 if (!file) {
981 broken = 1;
982 return;
985 path = FindImage(wPreferences.icon_path, file);
986 if (!path) {
987 broken = 1;
988 return;
991 panel->icon = RLoadImage(panel->scr->rcontext, path, 0);
992 free(path);
993 if (!panel->icon) {
994 broken = 1;
995 return;
998 if (!panel->pic) {
999 panel->pic = RGetImageFromXPMData(panel->scr->rcontext, pic_data);
1000 if (!panel->pic || panel->icon->width!=panel->pic->width
1001 || panel->icon->height!=panel->pic->height) {
1002 broken = 1;
1003 RDestroyImage(panel->icon);
1004 panel->icon = NULL;
1005 if (panel->pic) {
1006 RDestroyImage(panel->pic);
1007 panel->pic = NULL;
1009 return;
1013 RColor color;
1014 color.red = 0xae;
1015 color.green = 0xaa;
1016 color.blue = 0xae;
1017 color.alpha = 255;
1018 RCombineImageWithColor(panel->icon, &color);
1019 RCombineImageWithColor(panel->pic, &color);
1023 panel->str = msgs[rand()%(sizeof(msgs)/sizeof(char*))];
1025 panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
1026 panel->cycle = 0;
1027 panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL));
1028 } else if (panel->timer) {
1029 char version[20];
1031 panel->x = 0;
1032 clicks = 0;
1033 WMSetLabelImage(panel->logoL, panel->oldPix);
1034 WMReleasePixmap(panel->oldPix);
1035 panel->oldPix = NULL;
1037 WMDeleteTimerHandler(panel->timer);
1038 panel->timer = NULL;
1040 sprintf(version, "Version %s", VERSION);
1041 WMSetLabelText(panel->versionL, version);
1045 XEvent ev;
1046 while (XCheckTypedWindowEvent(dpy, WMWidgetXID(panel->versionL),
1047 ButtonPress, &ev));
1050 #endif /* SILLYNESS */
1053 void
1054 wShowInfoPanel(WScreen *scr)
1056 InfoPanel *panel;
1057 WMPixmap *logo;
1058 WMSize size;
1059 WMFont *font;
1060 char version[32];
1061 char buffer[512];
1062 Window parent;
1063 WWindow *wwin;
1064 RColor color1, color2;
1065 char **strl;
1066 int i;
1067 char *visuals[] = {
1068 "StaticGray",
1069 "GrayScale",
1070 "StaticColor",
1071 "PseudoColor",
1072 "TrueColor",
1073 "DirectColor"
1077 if (thePanel) {
1078 if (thePanel->scr == scr) {
1079 wRaiseFrame(thePanel->wwin->frame->core);
1080 wSetFocusTo(scr, thePanel->wwin);
1082 return;
1085 panel = wmalloc(sizeof(InfoPanel));
1086 memset(panel, 0, sizeof(InfoPanel));
1088 panel->scr = scr;
1090 panel->win = WMCreateWindow(scr->wmscreen, "info");
1091 WMResizeWidget(panel->win, 382, 230);
1093 logo = WMGetApplicationIconImage(scr->wmscreen);
1094 if (logo) {
1095 size = WMGetPixmapSize(logo);
1096 panel->logoL = WMCreateLabel(panel->win);
1097 WMResizeWidget(panel->logoL, 64, 64);
1098 WMMoveWidget(panel->logoL, 30, 20);
1099 WMSetLabelImagePosition(panel->logoL, WIPImageOnly);
1100 WMSetLabelImage(panel->logoL, logo);
1101 #ifdef SILLYNESS
1102 WMCreateEventHandler(WMWidgetView(panel->logoL), ButtonPressMask,
1103 handleLogoPush, panel);
1104 #endif
1107 panel->name1L = WMCreateLabel(panel->win);
1108 WMResizeWidget(panel->name1L, 240, 30);
1109 WMMoveWidget(panel->name1L, 100, 30);
1110 color1.red = 0;
1111 color1.green = 0;
1112 color1.blue = 0;
1113 color2.red = 0x50;
1114 color2.green = 0x50;
1115 color2.blue = 0x70;
1116 logo = renderText(scr->wmscreen, "GNU Window Maker",
1117 "-*-utopia-*-r-*-*-25-*", &color1, &color2);
1118 if (logo) {
1119 WMSetLabelImagePosition(panel->name1L, WIPImageOnly);
1120 WMSetLabelImage(panel->name1L, logo);
1121 WMReleasePixmap(logo);
1122 } else {
1123 font = WMBoldSystemFontOfSize(scr->wmscreen, 20);
1124 if (font) {
1125 WMSetLabelFont(panel->name1L, font);
1126 WMReleaseFont(font);
1128 WMSetLabelTextAlignment(panel->name1L, WACenter);
1129 WMSetLabelText(panel->name1L, "GNU Window Maker");
1132 panel->name2L = WMCreateLabel(panel->win);
1133 WMResizeWidget(panel->name2L, 240, 24);
1134 WMMoveWidget(panel->name2L, 100, 60);
1135 font = WMBoldSystemFontOfSize(scr->wmscreen, 18);
1136 if (font) {
1137 WMSetLabelFont(panel->name2L, font);
1138 WMReleaseFont(font);
1139 font = NULL;
1141 WMSetLabelTextAlignment(panel->name2L, WACenter);
1142 WMSetLabelText(panel->name2L, "Window Manager for X");
1145 sprintf(version, "Version %s", VERSION);
1146 panel->versionL = WMCreateLabel(panel->win);
1147 WMResizeWidget(panel->versionL, 310, 16);
1148 WMMoveWidget(panel->versionL, 30, 95);
1149 WMSetLabelTextAlignment(panel->versionL, WARight);
1150 WMSetLabelText(panel->versionL, version);
1151 WMSetLabelWraps(panel->versionL, False);
1153 panel->copyrL = WMCreateLabel(panel->win);
1154 WMResizeWidget(panel->copyrL, 340, 40);
1155 WMMoveWidget(panel->copyrL, 15, 185);
1156 WMSetLabelTextAlignment(panel->copyrL, WALeft);
1157 WMSetLabelText(panel->copyrL, COPYRIGHT_TEXT);
1158 /* we want the (c) character in the helvetica font */
1159 font = WMCreateNormalFont(scr->wmscreen, HELVETICA10_FONT);
1160 if (font) {
1161 WMSetLabelFont(panel->copyrL, font);
1164 switch (scr->w_depth) {
1165 case 15:
1166 strcpy(version, "32 thousand");
1167 break;
1168 case 16:
1169 strcpy(version, "64 thousand");
1170 break;
1171 case 24:
1172 case 32:
1173 strcpy(version, "16 million");
1174 break;
1175 default:
1176 sprintf(version, "%d", 1<<scr->w_depth);
1177 break;
1180 sprintf(buffer, "Using visual 0x%x: %s %ibpp (%s colors)\n",
1181 (unsigned)scr->w_visual->visualid,
1182 visuals[scr->w_visual->class], scr->w_depth, version);
1184 strcat(buffer, "Supported image formats: ");
1185 strl = RSupportedFileFormats();
1186 for (i=0; strl[i]!=NULL; i++) {
1187 strcat(buffer, strl[i]);
1188 strcat(buffer, " ");
1191 strcat(buffer, "\nAdditional Support For: ");
1193 char *list[8];
1194 char buf[80];
1195 int j = 0;
1197 #ifdef MWM_HINTS
1198 list[j++] = "MWM";
1199 #endif
1200 #ifdef KWM_HINTS
1201 list[j++] = "KDE";
1202 #endif
1203 #ifdef GNOME_STUFF
1204 list[j++] = "GNOME";
1205 #endif
1206 #ifdef OLWM_HINTS
1207 list[j++] = "OLWM";
1208 #endif
1209 #ifdef WMSOUND
1210 list[j++] = "Sound";
1211 #endif
1213 buf[0] = 0;
1214 for (i = 0; i < j; i++) {
1215 if (i > 0) {
1216 if (i == j - 1)
1217 strcat(buf, " and ");
1218 else
1219 strcat(buf, ", ");
1221 strcat(buf, list[i]);
1223 strcat(buffer, buf);
1227 panel->infoL = WMCreateLabel(panel->win);
1228 WMResizeWidget(panel->infoL, 350, 75);
1229 WMMoveWidget(panel->infoL, 15, 115);
1230 WMSetLabelText(panel->infoL, buffer);
1231 if (font) {
1232 WMSetLabelFont(panel->infoL, font);
1233 WMReleaseFont(font);
1237 WMRealizeWidget(panel->win);
1238 WMMapSubwidgets(panel->win);
1240 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 382, 230, 0, 0, 0);
1242 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1244 WMMapWidget(panel->win);
1246 wwin = wManageInternalWindow(scr, parent, None, "Info",
1247 (scr->scr_width - 382)/2,
1248 (scr->scr_height - 230)/2, 382, 230);
1250 WSETUFLAG(wwin, no_closable, 0);
1251 WSETUFLAG(wwin, no_close_button, 0);
1252 #ifdef XKB_BUTTON_HINT
1253 wFrameWindowHideButton(wwin->frame, WFF_LANGUAGE_BUTTON);
1254 #endif
1255 wWindowUpdateButtonImages(wwin);
1256 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1257 wwin->frame->on_click_right = destroyInfoPanel;
1259 wWindowMap(wwin);
1261 panel->wwin = wwin;
1263 thePanel = panel;
1264 #ifdef SILLYNESS
1265 if (InitXThing(panel->scr)) {
1266 panel->timer = WMAddTimerHandler(100, logoPushCallback, panel);
1267 panel->cycle = 0;
1268 panel->x = 1;
1269 panel->str = "Merry Christmas!";
1270 panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL));
1272 #endif
1277 ***********************************************************************
1278 * Legal Panel
1279 ***********************************************************************
1282 typedef struct {
1283 WScreen *scr;
1285 WWindow *wwin;
1287 WMWindow *win;
1289 WMLabel *licenseL;
1290 } LegalPanel;
1294 #define LICENSE_TEXT \
1295 " Window Maker is free software; you can redistribute it and/or modify "\
1296 "it under the terms of the GNU General Public License as published "\
1297 "by the Free Software Foundation; either version 2 of the License, "\
1298 "or (at your option) any later version.\n\n\n"\
1299 " Window Maker is distributed in the hope that it will be useful, but "\
1300 "WITHOUT ANY WARRANTY; without even the implied warranty of "\
1301 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU "\
1302 "General Public License for more details.\n\n\n"\
1303 " You should have received a copy of the GNU General Public License "\
1304 "along with this program; if not, write to the Free Software "\
1305 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA "\
1306 "02111-1307, USA."
1309 static LegalPanel *legalPanel = NULL;
1311 static void
1312 destroyLegalPanel(WCoreWindow *foo, void *data, XEvent *event)
1314 WMUnmapWidget(legalPanel->win);
1316 WMDestroyWidget(legalPanel->win);
1318 wUnmanageWindow(legalPanel->wwin, False, False);
1320 free(legalPanel);
1322 legalPanel = NULL;
1326 void
1327 wShowLegalPanel(WScreen *scr)
1329 LegalPanel *panel;
1330 Window parent;
1331 WWindow *wwin;
1333 if (legalPanel) {
1334 if (legalPanel->scr == scr) {
1335 wRaiseFrame(legalPanel->wwin->frame->core);
1336 wSetFocusTo(scr, legalPanel->wwin);
1338 return;
1341 panel = wmalloc(sizeof(LegalPanel));
1343 panel->scr = scr;
1345 panel->win = WMCreateWindow(scr->wmscreen, "legal");
1346 WMResizeWidget(panel->win, 420, 250);
1349 panel->licenseL = WMCreateLabel(panel->win);
1350 WMResizeWidget(panel->licenseL, 400, 230);
1351 WMMoveWidget(panel->licenseL, 10, 10);
1352 WMSetLabelTextAlignment(panel->licenseL, WALeft);
1353 WMSetLabelText(panel->licenseL, LICENSE_TEXT);
1354 WMSetLabelRelief(panel->licenseL, WRGroove);
1356 WMRealizeWidget(panel->win);
1357 WMMapSubwidgets(panel->win);
1359 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 420, 250, 0, 0, 0);
1361 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1363 wwin = wManageInternalWindow(scr, parent, None, "Legal",
1364 (scr->scr_width - 420)/2,
1365 (scr->scr_height - 250)/2, 420, 250);
1367 WSETUFLAG(wwin, no_closable, 0);
1368 WSETUFLAG(wwin, no_close_button, 0);
1369 wWindowUpdateButtonImages(wwin);
1370 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1371 #ifdef XKB_BUTTON_HINT
1372 wFrameWindowHideButton(wwin->frame, WFF_LANGUAGE_BUTTON);
1373 #endif
1374 wwin->frame->on_click_right = destroyLegalPanel;
1376 panel->wwin = wwin;
1378 WMMapWidget(panel->win);
1380 wWindowMap(wwin);
1382 legalPanel = panel;
1387 ***********************************************************************
1388 * Crashing Dialog Panel
1389 ***********************************************************************
1392 extern WDDomain *WDWindowAttributes;
1395 typedef struct _CrashPanel {
1396 WMWindow *win; /* main window */
1398 WMLabel *iconL; /* application icon */
1399 WMLabel *nameL; /* title of panel */
1401 WMFrame *sepF; /* separator frame */
1403 WMLabel *noteL; /* Title of note */
1404 WMLabel *note2L; /* body of note with what happened */
1406 WMFrame *whatF; /* "what to do next" frame */
1407 WMPopUpButton *whatP; /* action selection popup button */
1409 WMButton *okB; /* ok button */
1411 Bool done; /* if finished with this dialog */
1412 int action; /* what to do after */
1414 KeyCode retKey;
1416 } CrashPanel;
1419 static void
1420 handleKeyPress(XEvent *event, void *clientData)
1422 CrashPanel *panel = (CrashPanel*)clientData;
1424 if (event->xkey.keycode == panel->retKey) {
1425 WMPerformButtonClick(panel->okB);
1430 static void
1431 okButtonCallback(void *self, void *clientData)
1433 CrashPanel *panel = (CrashPanel*)clientData;
1435 panel->done = True;
1439 static void
1440 setCrashAction(void *self, void *clientData)
1442 WMPopUpButton *pop = (WMPopUpButton*)self;
1443 CrashPanel *panel = (CrashPanel*)clientData;
1445 panel->action = WMGetPopUpButtonSelectedItem(pop);
1449 static WMPixmap*
1450 getWindowMakerIconImage(WMScreen *scr)
1452 proplist_t dict, key, option, value=NULL;
1453 WMPixmap *pix=NULL;
1454 char *path;
1456 PLSetStringCmpHook(NULL);
1458 key = PLMakeString("Logo.WMPanel");
1459 option = PLMakeString("Icon");
1461 dict = PLGetDictionaryEntry(WDWindowAttributes->dictionary, key);
1463 if (dict) {
1464 value = PLGetDictionaryEntry(dict, option);
1467 PLRelease(key);
1468 PLRelease(option);
1470 PLSetStringCmpHook(StringCompareHook);
1472 if (value && PLIsString(value)) {
1473 path = FindImage(wPreferences.icon_path, PLGetString(value));
1475 if (path) {
1476 RImage *image;
1478 image = RLoadImage(WMScreenRContext(scr), path, 0);
1479 if (image) {
1480 pix = WMCreatePixmapFromRImage(scr, image, 0);
1481 RDestroyImage(image);
1483 free(path);
1487 return pix;
1491 #define PWIDTH 295
1492 #define PHEIGHT 345
1496 wShowCrashingDialogPanel(int whatSig)
1498 CrashPanel *panel;
1499 WMScreen *scr;
1500 WMFont *font;
1501 WMPixmap *logo;
1502 int screen_no, scr_width, scr_height;
1503 int action;
1504 char buf[256];
1506 panel = wmalloc(sizeof(CrashPanel));
1507 memset(panel, 0, sizeof(CrashPanel));
1509 screen_no = DefaultScreen(dpy);
1510 scr_width = WidthOfScreen(ScreenOfDisplay(dpy, screen_no));
1511 scr_height = HeightOfScreen(ScreenOfDisplay(dpy, screen_no));
1513 scr = WMCreateScreen(dpy, screen_no);
1514 if (!scr) {
1515 wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
1516 return WMAbort;
1519 panel->retKey = XKeysymToKeycode(dpy, XK_Return);
1521 panel->win = WMCreateWindow(scr, "crashingDialog");
1522 WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
1523 WMMoveWidget(panel->win, (scr_width - PWIDTH)/2, (scr_height - PHEIGHT)/2);
1525 logo = getWindowMakerIconImage(scr);
1526 if (logo) {
1527 panel->iconL = WMCreateLabel(panel->win);
1528 WMResizeWidget(panel->iconL, 64, 64);
1529 WMMoveWidget(panel->iconL, 10, 10);
1530 WMSetLabelImagePosition(panel->iconL, WIPImageOnly);
1531 WMSetLabelImage(panel->iconL, logo);
1534 panel->nameL = WMCreateLabel(panel->win);
1535 WMResizeWidget(panel->nameL, 190, 18);
1536 WMMoveWidget(panel->nameL, 80, 35);
1537 WMSetLabelTextAlignment(panel->nameL, WALeft);
1538 font = WMBoldSystemFontOfSize(scr, 18);
1539 WMSetLabelFont(panel->nameL, font);
1540 WMReleaseFont(font);
1541 WMSetLabelText(panel->nameL, _("Fatal error"));
1543 panel->sepF = WMCreateFrame(panel->win);
1544 WMResizeWidget(panel->sepF, PWIDTH+4, 2);
1545 WMMoveWidget(panel->sepF, -2, 80);
1547 panel->noteL = WMCreateLabel(panel->win);
1548 WMResizeWidget(panel->noteL, PWIDTH-20, 40);
1549 WMMoveWidget(panel->noteL, 10, 90);
1550 WMSetLabelTextAlignment(panel->noteL, WAJustified);
1551 #ifdef SYS_SIGLIST_DECLARED
1552 sprintf(buf, _("Window Maker received signal %i\n(%s)."),
1553 whatSig, sys_siglist[whatSig]);
1554 #else
1555 sprintf(buf, _("Window Maker received signal %i."), whatSig);
1556 #endif
1557 WMSetLabelText(panel->noteL, buf);
1559 panel->note2L = WMCreateLabel(panel->win);
1560 WMResizeWidget(panel->note2L, PWIDTH-20, 100);
1561 WMMoveWidget(panel->note2L, 10, 130);
1562 WMSetLabelTextAlignment(panel->note2L, WALeft);
1563 WMSetLabelText(panel->note2L,
1564 _(" This fatal error occured probably due to a bug."
1565 " Please fill the included BUGFORM and "
1566 "report it to bugs@windowmaker.org."));
1569 panel->whatF = WMCreateFrame(panel->win);
1570 WMResizeWidget(panel->whatF, PWIDTH-20, 50);
1571 WMMoveWidget(panel->whatF, 10, 240);
1572 WMSetFrameTitle(panel->whatF, _("What do you want to do now?"));
1574 panel->whatP = WMCreatePopUpButton(panel->whatF);
1575 WMResizeWidget(panel->whatP, PWIDTH-20-70, 20);
1576 WMMoveWidget(panel->whatP, 35, 20);
1577 WMSetPopUpButtonPullsDown(panel->whatP, False);
1578 WMSetPopUpButtonText(panel->whatP, _("Select action"));
1579 WMAddPopUpButtonItem(panel->whatP, _("Abort and leave a core file"));
1580 WMAddPopUpButtonItem(panel->whatP, _("Restart Window Maker"));
1581 WMAddPopUpButtonItem(panel->whatP, _("Start alternate window manager"));
1582 WMSetPopUpButtonAction(panel->whatP, setCrashAction, panel);
1583 WMSetPopUpButtonSelectedItem(panel->whatP, WMRestart);
1584 panel->action = WMRestart;
1586 WMMapSubwidgets(panel->whatF);
1588 panel->okB = WMCreateCommandButton(panel->win);
1589 WMResizeWidget(panel->okB, 80, 26);
1590 WMMoveWidget(panel->okB, 205, 309);
1591 WMSetButtonText(panel->okB, _("OK"));
1592 WMSetButtonImage(panel->okB, WMGetSystemPixmap(scr, WSIReturnArrow));
1593 WMSetButtonAltImage(panel->okB, WMGetSystemPixmap(scr, WSIHighlightedReturnArrow));
1594 WMSetButtonImagePosition(panel->okB, WIPRight);
1595 WMSetButtonAction(panel->okB, okButtonCallback, panel);
1597 panel->done = 0;
1599 WMCreateEventHandler(WMWidgetView(panel->win), KeyPressMask,
1600 handleKeyPress, panel);
1602 WMRealizeWidget(panel->win);
1603 WMMapSubwidgets(panel->win);
1605 WMMapWidget(panel->win);
1607 XSetInputFocus(dpy, WMWidgetXID(panel->win), RevertToParent, CurrentTime);
1609 while (!panel->done) {
1610 XEvent event;
1612 WMNextEvent(dpy, &event);
1613 WMHandleEvent(&event);
1616 action = panel->action;
1618 WMUnmapWidget(panel->win);
1619 WMDestroyWidget(panel->win);
1620 free(panel);
1622 return action;
1628 /*****************************************************************************
1629 * About GNUstep Panel
1630 *****************************************************************************/
1633 static void
1634 drawGNUstepLogo(Display *dpy, Drawable d, int width, int height,
1635 unsigned long blackPixel, unsigned long whitePixel)
1637 GC gc;
1638 XGCValues gcv;
1639 XRectangle rects[3];
1641 gcv.foreground = blackPixel;
1642 gc = XCreateGC(dpy, d, GCForeground, &gcv);
1644 XFillArc(dpy, d, gc, width/45, height/45,
1645 width - 2*width/45, height - 2*height/45, 0, 360*64);
1647 rects[0].x = 0;
1648 rects[0].y = 37*height/45;
1649 rects[0].width = width/3;
1650 rects[0].height = height - rects[0].y;
1652 rects[1].x = rects[0].width;
1653 rects[1].y = height/2;
1654 rects[1].width = width - 2*width/3;
1655 rects[1].height = height - rects[1].y;
1657 rects[2].x = 2*width/3;
1658 rects[2].y = height - 37*height/45;
1659 rects[2].width = width/3;
1660 rects[2].height = height - rects[2].y;
1662 XSetClipRectangles(dpy, gc, 0, 0, rects, 3, Unsorted);
1663 XFillRectangle(dpy, d, gc, 0, 0, width, height);
1665 XSetForeground(dpy, gc, whitePixel);
1666 XFillArc(dpy, d, gc, width/45, height/45,
1667 width - 2*width/45, height - 2*height/45, 0, 360*64);
1669 XFreeGC(dpy, gc);
1674 #define GNUSTEP_TEXT \
1675 "Window Maker is part of the GNUstep project.\n"\
1676 "The GNUstep project aims to create a free\n"\
1677 "implementation of the OpenStep(tm) specification\n"\
1678 "which is a object-oriented framework for\n"\
1679 "creating advanced graphical, multi-platform\n"\
1680 "applications. Aditionally, a development and\n"\
1681 "user desktop enviroment will be created on top\n"\
1682 "of the framework. For more information about\n"\
1683 "GNUstep, please visit: www.gnustep.org"
1686 typedef struct {
1687 WScreen *scr;
1689 WWindow *wwin;
1691 WMWindow *win;
1693 WMLabel *gstepL;
1694 WMLabel *textL;
1695 } GNUstepPanel;
1698 static GNUstepPanel *gnustepPanel = NULL;
1700 static void
1701 destroyGNUstepPanel(WCoreWindow *foo, void *data, XEvent *event)
1703 WMUnmapWidget(gnustepPanel->win);
1705 WMDestroyWidget(gnustepPanel->win);
1707 wUnmanageWindow(gnustepPanel->wwin, False, False);
1709 free(gnustepPanel);
1711 gnustepPanel = NULL;
1715 void
1716 wShowGNUstepPanel(WScreen *scr)
1718 GNUstepPanel *panel;
1719 Window parent;
1720 WWindow *wwin;
1721 WMPixmap *pixmap;
1722 WMColor *color;
1724 if (gnustepPanel) {
1725 if (gnustepPanel->scr == scr) {
1726 wRaiseFrame(gnustepPanel->wwin->frame->core);
1727 wSetFocusTo(scr, gnustepPanel->wwin);
1729 return;
1732 panel = wmalloc(sizeof(GNUstepPanel));
1734 panel->scr = scr;
1736 panel->win = WMCreateWindow(scr->wmscreen, "About GNUstep");
1737 WMResizeWidget(panel->win, 325, 200);
1739 pixmap = WMCreatePixmap(scr->wmscreen, 130, 130,
1740 WMScreenDepth(scr->wmscreen), True);
1742 color = WMCreateNamedColor(scr->wmscreen, "gray50", True);
1744 drawGNUstepLogo(dpy, WMGetPixmapXID(pixmap), 130, 130,
1745 WMColorPixel(color), scr->white_pixel);
1747 WMReleaseColor(color);
1749 XSetForeground(dpy, scr->mono_gc, 0);
1750 XFillRectangle(dpy, WMGetPixmapMaskXID(pixmap), scr->mono_gc, 0, 0,
1751 130, 130);
1752 drawGNUstepLogo(dpy, WMGetPixmapMaskXID(pixmap), 130, 130, 1, 1);
1754 panel->gstepL = WMCreateLabel(panel->win);
1755 WMResizeWidget(panel->gstepL, 285, 64);
1756 WMMoveWidget(panel->gstepL, 20, 0);
1757 WMSetLabelTextAlignment(panel->gstepL, WARight);
1758 WMSetLabelText(panel->gstepL, "GNUstep");
1760 WMFont *font = WMBoldSystemFontOfSize(scr->wmscreen, 24);
1762 WMSetLabelFont(panel->gstepL, font);
1763 WMReleaseFont(font);
1766 panel->textL = WMCreateLabel(panel->win);
1767 WMResizeWidget(panel->textL, 275, 130);
1768 WMMoveWidget(panel->textL, 30, 50);
1769 WMSetLabelTextAlignment(panel->textL, WARight);
1770 WMSetLabelImagePosition(panel->textL, WIPOverlaps);
1771 WMSetLabelText(panel->textL, GNUSTEP_TEXT);
1772 WMSetLabelImage(panel->textL, pixmap);
1774 WMReleasePixmap(pixmap);
1776 WMRealizeWidget(panel->win);
1777 WMMapSubwidgets(panel->win);
1779 parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, 325, 200, 0, 0, 0);
1781 XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
1783 wwin = wManageInternalWindow(scr, parent, None, "About GNUstep",
1784 (scr->scr_width - 325)/2,
1785 (scr->scr_height - 200)/2, 325, 200);
1787 WSETUFLAG(wwin, no_closable, 0);
1788 WSETUFLAG(wwin, no_close_button, 0);
1789 wWindowUpdateButtonImages(wwin);
1790 wFrameWindowShowButton(wwin->frame, WFF_RIGHT_BUTTON);
1791 #ifdef XKB_BUTTON_HINT
1792 wFrameWindowHideButton(wwin->frame, WFF_LANGUAGE_BUTTON);
1793 #endif
1794 wwin->frame->on_click_right = destroyGNUstepPanel;
1796 panel->wwin = wwin;
1798 WMMapWidget(panel->win);
1800 wWindowMap(wwin);
1802 gnustepPanel = panel;