1 /* dialog.c - dialog windows for internal use
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 * Copyright (c) 1999 Dan Pascu
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,
27 #include <X11/Xutil.h>
28 #include <X11/keysym.h>
34 #include <sys/types.h>
45 #include <sys/signal.h>
50 #define PATH_MAX DEFAULT_PATH_MAX
53 #include "WindowMaker.h"
65 extern WPreferences wPreferences
;
70 wMessageDialog(WScreen
*scr
, char *title
, char *message
,
71 char *defBtn
, char *altBtn
, char *othBtn
)
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
);
94 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
96 result
= panel
->result
;
98 WMUnmapWidget(panel
->win
);
100 wUnmanageWindow(wwin
, False
, False
);
102 WMDestroyAlertPanel(panel
);
104 XDestroyWindow(dpy
, parent
);
111 toggleSaveSession(WMWidget
*w
, void *data
)
113 wPreferences
.save_session_on_exit
= WMGetButtonSelected((WMButton
*) w
);
118 wExitDialog(WScreen
*scr
, char *title
, char *message
,
119 char *defBtn
, char *altBtn
, char *othBtn
)
122 WMButton
*saveSessionBtn
;
127 panel
= WMCreateAlertPanel(scr
->wmscreen
, NULL
, title
, message
,
128 defBtn
, altBtn
, othBtn
);
130 /* add save session button */
131 saveSessionBtn
= WMCreateSwitchButton(panel
->hbox
);
132 WMSetButtonAction(saveSessionBtn
, toggleSaveSession
, NULL
);
133 WMAddBoxSubview(panel
->hbox
, WMWidgetView(saveSessionBtn
),
134 False
, True
, 200, 0, 0);
135 WMSetButtonText(saveSessionBtn
, _("Save workspace state"));
136 WMSetButtonSelected(saveSessionBtn
, wPreferences
.save_session_on_exit
);
137 WMRealizeWidget(saveSessionBtn
);
138 WMMapWidget(saveSessionBtn
);
140 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 400, 180, 0, 0, 0);
142 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
144 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
,
145 (scr
->scr_width
- 400)/2,
146 (scr
->scr_height
- 180)/2, 400, 180);
147 wwin
->client_leader
= WMWidgetXID(panel
->win
);
149 WMMapWidget(panel
->win
);
153 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
155 result
= panel
->result
;
157 WMUnmapWidget(panel
->win
);
159 wUnmanageWindow(wwin
, False
, False
);
161 WMDestroyAlertPanel(panel
);
163 XDestroyWindow(dpy
, parent
);
170 wInputDialog(WScreen
*scr
, char *title
, char *message
, char **text
)
178 panel
= WMCreateInputPanel(scr
->wmscreen
, NULL
, title
, message
, *text
,
179 _("OK"), _("Cancel"));
182 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 320, 160, 0, 0, 0);
183 XSelectInput(dpy
, parent
, KeyPressMask
|KeyReleaseMask
);
185 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
187 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
,
188 (scr
->scr_width
- 320)/2,
189 (scr
->scr_height
- 160)/2, 320, 160);
191 wwin
->client_leader
= WMWidgetXID(panel
->win
);
193 WMMapWidget(panel
->win
);
197 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
199 if (panel
->result
== WAPRDefault
)
200 result
= WMGetTextFieldText(panel
->text
);
204 wUnmanageWindow(wwin
, False
, False
);
206 WMDestroyInputPanel(panel
);
208 XDestroyWindow(dpy
, parent
);
223 *****************************************************************
224 * Icon Selection Panel
225 *****************************************************************
228 typedef struct IconPanel
{
241 WMButton
*previewButton
;
246 WMTextField
*fileField
;
249 WMButton
*cancelButton
;
251 WMButton
*chooseButton
;
261 listPixmaps(WScreen
*scr
, WMList
*lPtr
, char *path
)
263 struct dirent
*dentry
;
265 char pbuf
[PATH_MAX
+16];
267 IconPanel
*panel
= WMGetHangedData(lPtr
);
269 panel
->preview
= False
;
271 apath
= wexpandpath(path
);
272 dir
= opendir(apath
);
277 tmp
= _("Could not open directory ");
278 msg
= wmalloc(strlen(tmp
)+strlen(path
)+6);
282 wMessageDialog(scr
, _("Error"), msg
, _("OK"), NULL
, NULL
);
288 /* list contents in the column */
289 while ((dentry
= readdir(dir
))) {
292 if (strcmp(dentry
->d_name
, ".")==0 ||
293 strcmp(dentry
->d_name
, "..")==0)
298 strcat(pbuf
, dentry
->d_name
);
300 if (stat(pbuf
, &statb
)<0)
303 if (statb
.st_mode
& (S_IRUSR
|S_IRGRP
|S_IROTH
)
304 && statb
.st_mode
& (S_IFREG
|S_IFLNK
)) {
305 WMAddListItem(lPtr
, dentry
->d_name
);
308 WMSortListItems(lPtr
);
312 panel
->preview
= True
;
318 setViewedImage(IconPanel
*panel
, char *file
)
327 pixmap
= WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel
->win
),
330 WMSetButtonEnabled(panel
->okButton
, False
);
332 WMSetLabelText(panel
->iconView
, _("Could not load image file "));
334 WMSetLabelImage(panel
->iconView
, NULL
);
336 WMSetButtonEnabled(panel
->okButton
, True
);
338 WMSetLabelText(panel
->iconView
, NULL
);
339 WMSetLabelImage(panel
->iconView
, pixmap
);
340 WMReleasePixmap(pixmap
);
346 listCallback(void *self
, void *data
)
348 WMList
*lPtr
= (WMList
*)self
;
349 IconPanel
*panel
= (IconPanel
*)data
;
352 if (lPtr
==panel
->dirList
) {
353 WMListItem
*item
= WMGetListSelectedItem(lPtr
);
359 WMSetTextFieldText(panel
->fileField
, path
);
361 WMSetLabelImage(panel
->iconView
, NULL
);
363 WMSetButtonEnabled(panel
->okButton
, False
);
365 WMClearList(panel
->iconList
);
366 listPixmaps(panel
->scr
, panel
->iconList
, path
);
368 char *tmp
, *iconFile
;
369 WMListItem
*item
= WMGetListSelectedItem(panel
->dirList
);
374 tmp
= wexpandpath(path
);
376 item
= WMGetListSelectedItem(panel
->iconList
);
379 iconFile
= item
->text
;
381 path
= wmalloc(strlen(tmp
)+strlen(iconFile
)+4);
384 strcat(path
, iconFile
);
386 WMSetTextFieldText(panel
->fileField
, path
);
387 setViewedImage(panel
, path
);
394 listIconPaths(WMList
*lPtr
)
399 paths
= wstrdup(wPreferences
.icon_path
);
401 path
= strtok(paths
, ":");
406 tmp
= wexpandpath(path
);
407 /* do not sort, because the order implies the order of
408 * directories searched */
409 if (access(tmp
, X_OK
)==0)
410 WMAddListItem(lPtr
, path
);
412 } while ((path
=strtok(NULL
, ":"))!=NULL
);
419 drawIconProc(WMList
*lPtr
, int index
, Drawable d
, char *text
,
420 int state
, WMRect
*rect
)
422 IconPanel
*panel
= WMGetHangedData(lPtr
);
423 GC gc
= panel
->scr
->draw_gc
;
424 GC copygc
= panel
->scr
->copy_gc
;
425 char *file
, *dirfile
;
430 WMScreen
*wmscr
= WMWidgetScreen(panel
->win
);
434 if(!panel
->preview
) return;
436 width
= rect
->size
.width
;
438 blackcolor
= WMBlackColor(wmscr
);
439 whitecolor
= WMWhiteColor(wmscr
);
441 dirfile
= wexpandpath(WMGetListSelectedItem(panel
->dirList
)->text
);
443 int len
= strlen(dirfile
)+strlen(text
)+4;
445 snprintf(file
, len
, "%s/%s", dirfile
, text
);
449 if ((state
& WLDSSelected
) != 0) {
450 color
.red
= color
.green
= color
.blue
= 0xff;
453 color
.red
= color
.blue
= 0xae;
454 color
.green
= 0xaa; color
.alpha
= 0;
456 pixmap
= WMCreateBlendedPixmapFromFile(wmscr
, file
, &color
);
460 WMRemoveListItem(lPtr
, index
);
464 XClearArea(dpy
, d
, rect
->pos
.x
, rect
->pos
.y
, width
, rect
->size
.height
,
466 XSetClipMask(dpy
, gc
, None
);
468 XDrawRectangle(dpy, d, WMColorGC(whitecolor), rect->pos.x + 5,
469 rect->pos.y +5, width - 10, 54);
471 XDrawLine(dpy
, d
, WMColorGC(whitecolor
), rect
->pos
.x
,
472 rect
->pos
.y
+rect
->size
.height
-1, rect
->pos
.x
+width
,
473 rect
->pos
.y
+rect
->size
.height
-1);
476 if (state
&WLDSSelected
) {
477 XFillRectangle(dpy
, d
, WMColorGC(whitecolor
), rect
->pos
.x
,
478 rect
->pos
.y
, width
, rect
->size
.height
);
481 size
= WMGetPixmapSize(pixmap
);
483 XSetClipMask(dpy
, copygc
, WMGetPixmapMaskXID(pixmap
));
484 XSetClipOrigin(dpy
, copygc
, rect
->pos
.x
+ (width
-size
.width
)/2,
486 XCopyArea(dpy
, WMGetPixmapXID(pixmap
), d
, copygc
, 0, 0,
487 size
.width
>100?100:size
.width
, size
.height
>64?64:size
.height
,
488 rect
->pos
.x
+ (width
-size
.width
)/2, rect
->pos
.y
+2);
492 int fheight
= WMFontHeight(panel
->normalfont
);
493 int tlen
= strlen(text
);
494 int twidth
= WMWidthOfString(panel
->normalfont
, text
, tlen
);
497 ofx
= rect
->pos
.x
+ (width
- twidth
)/2;
498 ofy
= rect
->pos
.y
+ 64 - fheight
;
502 WMDrawString(wmscr
, d
, WMColorGC(whitecolor
),
503 panel
->normalfont
, ofx
+i
, ofy
+j
,
506 WMDrawString(wmscr
, d
, WMColorGC(blackcolor
), panel
->normalfont
,
507 ofx
, ofy
, text
, tlen
);
510 WMReleasePixmap(pixmap
);
511 /* I hope it is better to do not use cache / on my box it is fast nuff */
514 WMReleaseColor(blackcolor
);
515 WMReleaseColor(whitecolor
);
520 buttonCallback(void *self
, void *clientData
)
522 WMButton
*bPtr
= (WMButton
*)self
;
523 IconPanel
*panel
= (IconPanel
*)clientData
;
526 if (bPtr
==panel
->okButton
) {
528 panel
->result
= True
;
529 } else if (bPtr
==panel
->cancelButton
) {
531 panel
->result
= False
;
532 } else if (bPtr
==panel
->previewButton
) {
533 /**** Previewer ****/
534 WMSetButtonEnabled(bPtr
, False
);
535 WMSetListUserDrawItemHeight(panel
->iconList
, 68);
536 WMSetListUserDrawProc(panel
->iconList
, drawIconProc
);
537 WMRedisplayWidget(panel
->iconList
);
538 /* for draw proc to access screen/gc */
539 /*** end preview ***/
542 else if (bPtr
==panel
->chooseButton
) {
545 op
= WMCreateOpenPanel(WMWidgetScreen(bPtr
));
547 if (WMRunModalFilePanelForDirectory(op
, NULL
, "/usr/local", NULL
, NULL
)) {
549 path
= WMGetFilePanelFile(op
);
550 WMSetTextFieldText(panel
->fileField
, path
);
551 setViewedImage(panel
, path
);
554 WMDestroyFilePanel(op
);
561 keyPressHandler(XEvent
*event
, void *data
)
563 IconPanel
*panel
= (IconPanel
*)data
;
572 if (event
->type
== KeyRelease
)
576 count
= XLookupString(&event
->xkey
, buffer
, sizeof(buffer
), &ksym
, NULL
);
579 iidx
= WMGetListSelectedItemRow(panel
->iconList
);
580 didx
= WMGetListSelectedItemRow(panel
->dirList
);
588 list
= panel
->iconList
;
591 if (iidx
< WMGetListNumberOfRows(panel
->iconList
) - 1)
595 list
= panel
->iconList
;
599 list
= panel
->iconList
;
602 item
= WMGetListNumberOfRows(panel
->iconList
) - 1;
603 list
= panel
->iconList
;
606 if (didx
< WMGetListNumberOfRows(panel
->dirList
) - 1)
610 list
= panel
->dirList
;
617 list
= panel
->dirList
;
620 WMPerformButtonClick(panel
->okButton
);
623 WMPerformButtonClick(panel
->cancelButton
);
628 WMSelectListItem(list
, item
);
629 WMSetListPosition(list
, item
- 5);
630 listCallback(list
, panel
);
637 wIconChooserDialog(WScreen
*scr
, char **file
, char *instance
, char *class)
645 panel
= wmalloc(sizeof(IconPanel
));
646 memset(panel
, 0, sizeof(IconPanel
));
650 panel
->win
= WMCreateWindow(scr
->wmscreen
, "iconChooser");
651 WMResizeWidget(panel
->win
, 450, 280);
653 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
|KeyReleaseMask
,
654 keyPressHandler
, panel
);
657 boldFont
= WMBoldSystemFontOfSize(scr
->wmscreen
, 12);
658 panel
->normalfont
= WMSystemFontOfSize(WMWidgetScreen(panel
->win
), 12);
660 panel
->dirLabel
= WMCreateLabel(panel
->win
);
661 WMResizeWidget(panel
->dirLabel
, 200, 20);
662 WMMoveWidget(panel
->dirLabel
, 10, 7);
663 WMSetLabelText(panel
->dirLabel
, _("Directories"));
664 WMSetLabelFont(panel
->dirLabel
, boldFont
);
665 WMSetLabelTextAlignment(panel
->dirLabel
, WACenter
);
667 WMSetLabelRelief(panel
->dirLabel
, WRSunken
);
669 panel
->iconLabel
= WMCreateLabel(panel
->win
);
670 WMResizeWidget(panel
->iconLabel
, 140, 20);
671 WMMoveWidget(panel
->iconLabel
, 215, 7);
672 WMSetLabelText(panel
->iconLabel
, _("Icons"));
673 WMSetLabelFont(panel
->iconLabel
, boldFont
);
674 WMSetLabelTextAlignment(panel
->iconLabel
, WACenter
);
676 WMReleaseFont(boldFont
);
678 color
= WMWhiteColor(scr
->wmscreen
);
679 WMSetLabelTextColor(panel
->dirLabel
, color
);
680 WMSetLabelTextColor(panel
->iconLabel
, color
);
681 WMReleaseColor(color
);
683 color
= WMDarkGrayColor(scr
->wmscreen
);
684 WMSetWidgetBackgroundColor(panel
->iconLabel
, color
);
685 WMSetWidgetBackgroundColor(panel
->dirLabel
, color
);
686 WMReleaseColor(color
);
688 WMSetLabelRelief(panel
->iconLabel
, WRSunken
);
690 panel
->dirList
= WMCreateList(panel
->win
);
691 WMResizeWidget(panel
->dirList
, 200, 170);
692 WMMoveWidget(panel
->dirList
, 10, 30);
693 WMSetListAction(panel
->dirList
, listCallback
, panel
);
695 panel
->iconList
= WMCreateList(panel
->win
);
696 WMResizeWidget(panel
->iconList
, 140, 170);
697 WMMoveWidget(panel
->iconList
, 215, 30);
698 WMSetListAction(panel
->iconList
, listCallback
, panel
);
700 WMHangData(panel
->iconList
,panel
);
702 panel
->previewButton
= WMCreateCommandButton(panel
->win
);
703 WMResizeWidget(panel
->previewButton
, 75, 26);
704 WMMoveWidget(panel
->previewButton
, 365, 130);
705 WMSetButtonText(panel
->previewButton
, _("Preview"));
706 WMSetButtonAction(panel
->previewButton
, buttonCallback
, panel
);
708 panel
->iconView
= WMCreateLabel(panel
->win
);
709 WMResizeWidget(panel
->iconView
, 75, 75);
710 WMMoveWidget(panel
->iconView
, 365, 40);
711 WMSetLabelImagePosition(panel
->iconView
, WIPOverlaps
);
712 WMSetLabelRelief(panel
->iconView
, WRSunken
);
713 WMSetLabelTextAlignment(panel
->iconView
, WACenter
);
715 panel
->fileLabel
= WMCreateLabel(panel
->win
);
716 WMResizeWidget(panel
->fileLabel
, 80, 20);
717 WMMoveWidget(panel
->fileLabel
, 10, 210);
718 WMSetLabelText(panel
->fileLabel
, _("File Name:"));
720 panel
->fileField
= WMCreateTextField(panel
->win
);
721 WMSetViewNextResponder(WMWidgetView(panel
->fileField
), WMWidgetView(panel
->win
));
722 WMResizeWidget(panel
->fileField
, 345, 20);
723 WMMoveWidget(panel
->fileField
, 95, 210);
724 WMSetTextFieldEditable(panel
->fileField
, False
);
726 panel
->okButton
= WMCreateCommandButton(panel
->win
);
727 WMResizeWidget(panel
->okButton
, 80, 26);
728 WMMoveWidget(panel
->okButton
, 360, 240);
729 WMSetButtonText(panel
->okButton
, _("OK"));
730 WMSetButtonEnabled(panel
->okButton
, False
);
731 WMSetButtonAction(panel
->okButton
, buttonCallback
, panel
);
733 panel
->cancelButton
= WMCreateCommandButton(panel
->win
);
734 WMResizeWidget(panel
->cancelButton
, 80, 26);
735 WMMoveWidget(panel
->cancelButton
, 270, 240);
736 WMSetButtonText(panel
->cancelButton
, _("Cancel"));
737 WMSetButtonAction(panel
->cancelButton
, buttonCallback
, panel
);
739 panel
->chooseButton
= WMCreateCommandButton(panel
->win
);
740 WMResizeWidget(panel
->chooseButton
, 110, 26);
741 WMMoveWidget(panel
->chooseButton
, 150, 240);
742 WMSetButtonText(panel
->chooseButton
, _("Choose File"));
743 WMSetButtonAction(panel
->chooseButton
, buttonCallback
, panel
);
745 WMRealizeWidget(panel
->win
);
746 WMMapSubwidgets(panel
->win
);
748 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 450, 280, 0, 0, 0);
750 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
754 int len
= (instance
? strlen(instance
) : 0)
755 + (class ? strlen(class) : 0) + 32;
759 if (tmp
&& (instance
|| class))
760 snprintf(tmp
, len
, "%s [%s.%s]", _("Icon Chooser"), instance
, class);
762 strcpy(tmp
, _("Icon Chooser"));
764 wwin
= wManageInternalWindow(scr
, parent
, None
, tmp
,
765 (scr
->scr_width
- 450)/2,
766 (scr
->scr_height
- 280)/2, 450, 280);
770 /* put icon paths in the list */
771 listIconPaths(panel
->dirList
);
773 WMMapWidget(panel
->win
);
777 while (!panel
->done
) {
780 WMNextEvent(dpy
, &event
);
781 WMHandleEvent(&event
);
785 char *defaultPath
, *wantedPath
;
787 /* check if the file the user selected is not the one that
788 * would be loaded by default with the current search path */
789 *file
= WMGetListSelectedItem(panel
->iconList
)->text
;
794 defaultPath
= FindImage(wPreferences
.icon_path
, *file
);
795 wantedPath
= WMGetTextFieldText(panel
->fileField
);
796 /* if the file is not the default, use full path */
797 if (strcmp(wantedPath
, defaultPath
)!=0) {
800 *file
= wstrdup(*file
);
809 WMReleaseFont(panel
->normalfont
);
811 WMUnmapWidget(panel
->win
);
813 WMDestroyWidget(panel
->win
);
815 wUnmanageWindow(wwin
, False
, False
);
819 XDestroyWindow(dpy
, parent
);
821 return panel
->result
;
826 ***********************************************************************
828 ***********************************************************************
863 #define COPYRIGHT_TEXT \
864 "Copyright \xa9 1997~2001 Alfredo K. Kojima <kojima@windowmaker.org>\n"\
865 "Copyright \xa9 1998~2001 Dan Pascu <dan@windowmaker.org>"
869 static InfoPanel
*thePanel
= NULL
;
872 destroyInfoPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
875 if (thePanel
->timer
) {
876 WMDeleteTimerHandler(thePanel
->timer
);
878 if (thePanel
->oldPix
) {
879 WMReleasePixmap(thePanel
->oldPix
);
881 if (thePanel
->oldFont
) {
882 WMReleaseFont(thePanel
->oldFont
);
884 if (thePanel
->icon
) {
885 RReleaseImage(thePanel
->icon
);
888 RReleaseImage(thePanel
->pic
);
890 #endif /* SILLYNESS */
891 WMUnmapWidget(thePanel
);
893 wUnmanageWindow(thePanel
->wwin
, False
, False
);
895 WMDestroyWidget(thePanel
->win
);
904 renderText(WMScreen
*scr
, char *text
, char *font
, RColor
*from
, RColor
*to
)
906 WMPixmap
*wpix
= NULL
;
909 RContext
*rc
= WMScreenRContext(scr
);
910 XFontStruct
*f
= NULL
;
914 f
= XLoadQueryFont(dpy
, font
);
918 w
= XTextWidth(f
, text
, strlen(text
));
919 h
= f
->ascent
+f
->descent
;
921 mask
= XCreatePixmap(dpy
, rc
->drawable
, w
, h
, 1);
922 gc
= XCreateGC(dpy
, mask
, 0, NULL
);
923 XSetForeground(dpy
, gc
, 0);
924 XSetFont(dpy
, gc
, f
->fid
);
925 XFillRectangle(dpy
, mask
, gc
, 0, 0, w
, h
);
927 XSetForeground(dpy
, gc
, 1);
928 XDrawString(dpy
, mask
, gc
, 0, f
->ascent
, text
, strlen(text
));
929 XSetLineAttributes(dpy
, gc
, 3, LineSolid
, CapRound
, JoinMiter
);
930 XDrawLine(dpy
, mask
, gc
, 0, h
-2, w
, h
-2);
932 grad
= XCreatePixmap(dpy
, rc
->drawable
, w
, h
, rc
->depth
);
936 color
= WMBlackColor(scr
);
937 XFillRectangle(dpy
, grad
, WMColorGC(color
), 0, 0, w
, h
);
938 WMReleaseColor(color
);
941 wpix
= WMCreatePixmapFromXPixmaps(scr
, grad
, mask
, w
, h
, rc
->depth
);
952 extern WMPixmap
*DoXThing();
953 extern Bool
InitXThing();
956 logoPushCallback(void *data
)
958 InfoPanel
*panel
= (InfoPanel
*)data
;
963 static int jingobeu
[] = {
964 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
965 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
966 329, 150, 392, 150, 261, 150, 293, 150, 329, 400, -1, 400, 0
974 if(jingobeu
[panel
->x
-1]==0){panel
->x
=-1;}else if(jingobeu
[panel
->x
975 -1]<0){panel
->x
++;c
=jingobeu
[panel
->x
-1]/50;panel
->x
++;}else if(c
==0){
976 kc
.bell_pitch
=jingobeu
[panel
->x
-1];panel
->x
++;kc
.bell_percent
=50;c
=
977 jingobeu
[panel
->x
-1]/50;kc
.bell_duration
=jingobeu
[panel
->x
-1];panel
->x
++;
978 XChangeKeyboardControl(dpy
,KBBellPitch
|KBBellDuration
|KBBellPercent
,&kc
);
979 XBell(dpy
,50);XFlush(dpy
);}else{c
--;}}
980 if (!(panel
->cycle
% 4)) {
983 p
= DoXThing(panel
->wwin
);
984 WMSetLabelImage(panel
->logoL
, p
);
986 } else if (panel
->cycle
< 30) {
991 gray
.red
= 0xae; gray
.green
= 0xaa;
992 gray
.blue
= 0xae; gray
.alpha
= 0;
994 image
= RScaleImage(panel
->icon
, panel
->pic
->width
, panel
->pic
->height
);
995 RCombineImagesWithOpaqueness(image
, panel
->pic
, panel
->cycle
*255/30);
996 pix
= WMCreateBlendedPixmapFromRImage(panel
->scr
->wmscreen
, image
, &gray
);
997 RReleaseImage(image
);
998 WMSetLabelImage(panel
->logoL
, pix
);
999 WMReleasePixmap(pix
);
1002 /* slow down text a little */
1003 i
= (int)(panel
->cycle
* 50.0/85.0)%200;
1006 len
= strlen(panel
->str
);
1008 strncpy(buffer
, panel
->str
, i
<len
? i
: len
);
1010 memset(&buffer
[len
], ' ', i
-len
);
1012 strncpy(buffer
, panel
->str
, i
<len
? i
: len
);
1014 memset(&buffer
[len
], ' ', i
-len
);
1017 WMSetLabelText(panel
->versionL
, buffer
);
1019 XFlush(WMScreenDisplay(WMWidgetScreen(panel
->versionL
)));
1024 panel
->timer
= WMAddTimerHandler(50, logoPushCallback
, panel
);
1030 handleLogoPush(XEvent
*event
, void *data
)
1032 InfoPanel
*panel
= (InfoPanel
*)data
;
1033 static int broken
= 0;
1034 static int clicks
= 0;
1035 static char *pic_data
[] = {
1094 " ............... ",
1095 " ....XoO+@##+O$%.... ",
1096 " ...%X&*========-;;:o... ",
1097 " ...>.>,<122222222222134@... ",
1098 " ..>5678912222222222222220q%.. ",
1099 " ..$.&-w2222222222222222222er>.. ",
1100 " ..O.t31222222222222222222222y4>.. ",
1101 " ...O5u3222222222222222222222222yri... ",
1102 " ..>p&a22222222222222222222222222wso.. ",
1103 " ..ids91222222222222222222222222222wfi.. ",
1104 " ..X.7w222222wgs-w2222222213=g0222222<hi.. ",
1105 " ..Xuj2222222<@X5=222222229k@l:022222y4i.. ",
1106 " .Xdz22222222*X%.s22222222axo%$-222222<c>.. ",
1107 " ..o7y22222222v...r222222223hX.i82222221si.. ",
1108 "..io*222222222&...u22222222yt..%*22222220:%. ",
1109 "..>k02222222227...f222222222v..X=222222229t. ",
1110 "..dz12222222220ui:y2222222223d%qw222222221g. ",
1111 ".%vw222222222221y2222222222219*y2222222222wd.",
1112 ".X;2222222222222222222222222222222222222222b.",
1113 ".i*2222222222222222222222222222222222222222v.",
1114 ".i*2222222222222222222222222222222222222222;.",
1115 ".i*22222222222222222222222222222222222222228.",
1116 ".>*2222222222222222222222222222222222222222=.",
1117 ".i*22222222222222222222222222222222222222228.",
1118 ".i*2222222222222222222222222222222222222222;.",
1119 ".X*222222222222222222222222222222we12222222r.",
1120 ".Xs12222222w3aw22222222222222222y8s0222222wk.",
1121 ".Xq02222222a,na22222222222222222zm6zwy2222gi.",
1122 "..>*22222y<:Xcj22222222222222222-o$k;;02228..",
1123 "..i7y2220rhX.:y22222222222222222jtiXd,a220,..",
1124 " .X@z222a,do%kj2222222222222222wMX5q;gw228%..",
1125 " ..58222wagsh6ry222222222222221;>Of0w222y:...",
1126 " ...:e2222218mdz22222222222222a&$vw222220@...",
1127 " ...O-122222y:.u02222222222229q$uj222221r... ",
1128 " ..%&a1222223&573w2222222219NOxz122221z>... ",
1129 " ...t3222221-l$nr8ay1222yzbo,=12222w-5... ",
1130 " ..X:022222w-k+>o,7s**s7xOn=12221<f5... ",
1131 " ..o:9222221j8:&Bl>>>>ihv<12221=dX... ",
1132 " ..Xb9122222109g-****;<y22221zn%... ",
1133 " ..X&801222222222222222222w-h.... ",
1134 " ...o:=022222222222222221=lX... ",
1135 " ..X@:;3w2222222222210fO... ",
1136 " ...XX&v8<30000003-N@... ",
1137 " .....XmnbN:q&Bo.... ",
1140 static char *msgs
[] = {
1142 "Focus follow mouse users will burn in hell!!!",
1144 "Hi! My name is bobby...",
1145 "AHH! The neurotic monkeys are after me!",
1147 "HOW ARE YOU GENTLEMEN?",
1149 "SOMEBODY SET UP US THE BOMB",
1150 "ALL YOUR BASE ARE BELONG TO US!",
1151 "Oh My God!!! Larry is back!"
1157 if (!panel
->timer
&& !broken
&& clicks
> 0) {
1163 panel
->icon
= WMGetApplicationIconImage(panel
->scr
->wmscreen
);
1170 color
.red
= 0xae; color
.green
= 0xaa;
1171 color
.blue
= 0xae; color
.alpha
= 0;
1173 panel
->icon
= RCloneImage(panel
->icon
);
1174 RCombineImageWithColor(panel
->icon
, &color
);
1178 panel
->pic
= RGetImageFromXPMData(panel
->scr
->rcontext
, pic_data
);
1181 RReleaseImage(panel
->icon
);
1187 panel
->str
= msgs
[rand()%(sizeof(msgs
)/sizeof(char*))];
1189 panel
->timer
= WMAddTimerHandler(50, logoPushCallback
, panel
);
1191 panel
->oldPix
= WMRetainPixmap(WMGetLabelImage(panel
->logoL
));
1192 /* If we don't use a fixed font, scrolling will be jumpy */
1193 /* Alternatively we can draw text in a pixmap and scroll it smoothly */
1194 if ((panel
->oldFont
= WMGetLabelFont(panel
->versionL
))!=NULL
)
1195 WMRetainFont(panel
->oldFont
);
1196 font
= WMCreateFont(WMWidgetScreen(panel
->versionL
), "-*-fixed-*-*-*-*-14-*-*-*-*-*-*-*");
1198 WMSetLabelFont(panel
->versionL
, font
);
1199 WMReleaseFont(font
);
1201 WMSetLabelText(panel
->versionL
, "");
1202 } else if (panel
->timer
) {
1207 WMSetLabelImage(panel
->logoL
, panel
->oldPix
);
1208 WMReleasePixmap(panel
->oldPix
);
1209 panel
->oldPix
= NULL
;
1211 WMDeleteTimerHandler(panel
->timer
);
1212 panel
->timer
= NULL
;
1214 WMSetLabelFont(panel
->versionL
, panel
->oldFont
);
1215 if (panel
->oldFont
) {
1216 WMReleaseFont(panel
->oldFont
);
1217 panel
->oldFont
= NULL
;
1219 snprintf(version
, sizeof(version
), _("Version %s"), VERSION
);
1220 WMSetLabelText(panel
->versionL
, version
);
1221 XFlush(WMScreenDisplay(WMWidgetScreen(panel
->versionL
)));
1226 while (XCheckTypedWindowEvent(dpy
, WMWidgetXID(panel
->versionL
),
1230 #endif /* SILLYNESS */
1234 wShowInfoPanel(WScreen
*scr
)
1240 char *strbuf
= NULL
;
1244 RColor color1
, color2
;
1258 if (thePanel
->scr
== scr
) {
1259 wRaiseFrame(thePanel
->wwin
->frame
->core
);
1260 wSetFocusTo(scr
, thePanel
->wwin
);
1265 panel
= wmalloc(sizeof(InfoPanel
));
1266 memset(panel
, 0, sizeof(InfoPanel
));
1270 panel
->win
= WMCreateWindow(scr
->wmscreen
, "info");
1271 WMResizeWidget(panel
->win
, 382, 230);
1273 logo
= WMCreateApplicationIconBlendedPixmap(scr
->wmscreen
, (RColor
*)NULL
);
1275 logo
= WMRetainPixmap(WMGetApplicationIconPixmap(scr
->wmscreen
));
1278 size
= WMGetPixmapSize(logo
);
1279 panel
->logoL
= WMCreateLabel(panel
->win
);
1280 WMResizeWidget(panel
->logoL
, 64, 64);
1281 WMMoveWidget(panel
->logoL
, 30, 20);
1282 WMSetLabelImagePosition(panel
->logoL
, WIPImageOnly
);
1283 WMSetLabelImage(panel
->logoL
, logo
);
1285 WMCreateEventHandler(WMWidgetView(panel
->logoL
), ButtonPressMask
,
1286 handleLogoPush
, panel
);
1288 WMReleasePixmap(logo
);
1291 panel
->name1L
= WMCreateLabel(panel
->win
);
1292 WMResizeWidget(panel
->name1L
, 240, 30);
1293 WMMoveWidget(panel
->name1L
, 100, 30);
1298 color2
.green
= 0x50;
1300 logo
= renderText(scr
->wmscreen
, "GNU Window Maker",
1301 "-*-utopia-*-r-*-*-25-*", &color1
, &color2
);
1303 WMSetLabelImagePosition(panel
->name1L
, WIPImageOnly
);
1304 WMSetLabelImage(panel
->name1L
, logo
);
1305 WMReleasePixmap(logo
);
1307 font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 20);
1309 WMSetLabelFont(panel
->name1L
, font
);
1310 WMReleaseFont(font
);
1312 WMSetLabelTextAlignment(panel
->name1L
, WACenter
);
1313 WMSetLabelText(panel
->name1L
, "GNU Window Maker");
1316 panel
->name2L
= WMCreateLabel(panel
->win
);
1317 WMResizeWidget(panel
->name2L
, 240, 24);
1318 WMMoveWidget(panel
->name2L
, 100, 60);
1319 font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 18);
1321 WMSetLabelFont(panel
->name2L
, font
);
1322 WMReleaseFont(font
);
1325 WMSetLabelTextAlignment(panel
->name2L
, WACenter
);
1326 WMSetLabelText(panel
->name2L
, _("Window Manager for X"));
1329 snprintf(buffer
, sizeof(buffer
), _("Version %s"), VERSION
);
1330 panel
->versionL
= WMCreateLabel(panel
->win
);
1331 WMResizeWidget(panel
->versionL
, 310, 16);
1332 WMMoveWidget(panel
->versionL
, 30, 95);
1333 WMSetLabelTextAlignment(panel
->versionL
, WARight
);
1334 WMSetLabelText(panel
->versionL
, buffer
);
1335 WMSetLabelWraps(panel
->versionL
, False
);
1337 panel
->copyrL
= WMCreateLabel(panel
->win
);
1338 WMResizeWidget(panel
->copyrL
, 340, 40);
1339 WMMoveWidget(panel
->copyrL
, 15, 185);
1340 WMSetLabelTextAlignment(panel
->copyrL
, WALeft
);
1341 WMSetLabelText(panel
->copyrL
, COPYRIGHT_TEXT
);
1342 /* we want the (c) character in the helvetica font */
1343 font
= WMCreateNormalFont(scr
->wmscreen
, HELVETICA10_FONT
);
1345 WMSetLabelFont(panel
->copyrL
, font
);
1349 snprintf(buffer
, sizeof(buffer
), _("Using visual 0x%x: %s %ibpp "),
1350 (unsigned)scr
->w_visual
->visualid
,
1351 visuals
[scr
->w_visual
->class], scr
->w_depth
);
1353 strbuf
= wstrappend(strbuf
, buffer
);
1355 switch (scr
->w_depth
) {
1357 strbuf
= wstrappend(strbuf
, _("(32 thousand colors)\n"));
1360 strbuf
= wstrappend(strbuf
, _("(64 thousand colors)\n"));
1364 strbuf
= wstrappend(strbuf
, _("(16 million colors)\n"));
1367 snprintf(buffer
, sizeof(buffer
), _("(%d colors)\n"), 1<<scr
->w_depth
);
1368 strbuf
= wstrappend(strbuf
, buffer
);
1373 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
1375 struct mallinfo ma
= mallinfo();
1376 snprintf(buffer
, sizeof(buffer
),
1377 _("Total allocated memory: %i kB. Total memory in use: %i kB.\n"),
1378 (ma
.arena
+ma
.hblkhd
)/1024, (ma
.uordblks
+ma
.hblkhd
)/1024);
1380 strbuf
= wstrappend(strbuf
, buffer
);
1384 strbuf
= wstrappend(strbuf
, _("Supported image formats: "));
1385 strl
= RSupportedFileFormats();
1386 for (i
=0; strl
[i
]!=NULL
; i
++) {
1387 strbuf
= wstrappend(strbuf
, strl
[i
]);
1388 strbuf
= wstrappend(strbuf
, " ");
1391 strbuf
= wstrappend(strbuf
, _("\nAdditional support for: "));
1404 list
[j
++] = "GNOME";
1411 for (i
= 0; i
< j
; i
++) {
1414 strcat(buf
, _(" and "));
1418 strcat(buf
, list
[i
]);
1420 strbuf
= wstrappend(strbuf
, buf
);
1423 if (wPreferences
.no_sound
) {
1424 strbuf
= wstrappend(strbuf
, _("\nSound disabled"));
1426 strbuf
= wstrappend(strbuf
, _("\nSound enabled"));
1430 panel
->infoL
= WMCreateLabel(panel
->win
);
1431 WMResizeWidget(panel
->infoL
, 350, 75);
1432 WMMoveWidget(panel
->infoL
, 15, 115);
1433 WMSetLabelText(panel
->infoL
, strbuf
);
1435 WMSetLabelFont(panel
->infoL
, font
);
1436 WMReleaseFont(font
);
1441 WMRealizeWidget(panel
->win
);
1442 WMMapSubwidgets(panel
->win
);
1444 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 382, 230, 0, 0, 0);
1446 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1448 WMMapWidget(panel
->win
);
1450 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Info"),
1451 (scr
->scr_width
- 382)/2,
1452 (scr
->scr_height
- 230)/2, 382, 230);
1454 WSETUFLAG(wwin
, no_closable
, 0);
1455 WSETUFLAG(wwin
, no_close_button
, 0);
1456 #ifdef XKB_BUTTON_HINT
1457 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1459 wWindowUpdateButtonImages(wwin
);
1460 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1461 wwin
->frame
->on_click_right
= destroyInfoPanel
;
1469 if (InitXThing(panel
->scr
)) {
1470 panel
->timer
= WMAddTimerHandler(100, logoPushCallback
, panel
);
1473 panel
->str
= _("Merry X'mas!");
1474 panel
->oldPix
= WMRetainPixmap(WMGetLabelImage(panel
->logoL
));
1481 ***********************************************************************
1483 ***********************************************************************
1497 static LegalPanel
*legalPanel
= NULL
;
1500 destroyLegalPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
1502 WMUnmapWidget(legalPanel
->win
);
1504 WMDestroyWidget(legalPanel
->win
);
1506 wUnmanageWindow(legalPanel
->wwin
, False
, False
);
1515 wShowLegalPanel(WScreen
*scr
)
1522 if (legalPanel
->scr
== scr
) {
1523 wRaiseFrame(legalPanel
->wwin
->frame
->core
);
1524 wSetFocusTo(scr
, legalPanel
->wwin
);
1529 panel
= wmalloc(sizeof(LegalPanel
));
1533 panel
->win
= WMCreateWindow(scr
->wmscreen
, "legal");
1534 WMResizeWidget(panel
->win
, 420, 250);
1537 panel
->licenseL
= WMCreateLabel(panel
->win
);
1538 WMSetLabelWraps(panel
->licenseL
, True
);
1539 WMResizeWidget(panel
->licenseL
, 400, 230);
1540 WMMoveWidget(panel
->licenseL
, 10, 10);
1541 WMSetLabelTextAlignment(panel
->licenseL
, WALeft
);
1542 WMSetLabelText(panel
->licenseL
,
1543 _(" Window Maker is free software; you can redistribute it and/or\n"
1544 "modify it under the terms of the GNU General Public License as\n"
1545 "published by the Free Software Foundation; either version 2 of the\n"
1546 "License, or (at your option) any later version.\n\n\n"
1547 " Window Maker is distributed in the hope that it will be useful,\n"
1548 "but WITHOUT ANY WARRANTY; without even the implied warranty\n"
1549 "of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
1550 "See the GNU General Public License for more details.\n\n\n"
1551 " You should have received a copy of the GNU General Public\n"
1552 "License along with this program; if not, write to the Free Software\n"
1553 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA\n"
1554 "02111-1307, USA."));
1555 WMSetLabelRelief(panel
->licenseL
, WRGroove
);
1557 WMRealizeWidget(panel
->win
);
1558 WMMapSubwidgets(panel
->win
);
1560 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 420, 250, 0, 0, 0);
1562 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1564 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Legal"),
1565 (scr
->scr_width
- 420)/2,
1566 (scr
->scr_height
- 250)/2, 420, 250);
1568 WSETUFLAG(wwin
, no_closable
, 0);
1569 WSETUFLAG(wwin
, no_close_button
, 0);
1570 wWindowUpdateButtonImages(wwin
);
1571 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1572 #ifdef XKB_BUTTON_HINT
1573 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1575 wwin
->frame
->on_click_right
= destroyLegalPanel
;
1579 WMMapWidget(panel
->win
);
1588 ***********************************************************************
1589 * Crashing Dialog Panel
1590 ***********************************************************************
1593 extern WDDomain
*WDWindowAttributes
;
1596 typedef struct _CrashPanel
{
1597 WMWindow
*win
; /* main window */
1599 WMLabel
*iconL
; /* application icon */
1600 WMLabel
*nameL
; /* title of panel */
1602 WMFrame
*sepF
; /* separator frame */
1604 WMLabel
*noteL
; /* Title of note */
1605 WMLabel
*note2L
; /* body of note with what happened */
1607 WMFrame
*whatF
; /* "what to do next" frame */
1608 WMPopUpButton
*whatP
; /* action selection popup button */
1610 WMButton
*okB
; /* ok button */
1612 Bool done
; /* if finished with this dialog */
1613 int action
; /* what to do after */
1621 handleKeyPress(XEvent
*event
, void *clientData
)
1623 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1625 if (event
->xkey
.keycode
== panel
->retKey
) {
1626 WMPerformButtonClick(panel
->okB
);
1632 okButtonCallback(void *self
, void *clientData
)
1634 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1641 setCrashAction(void *self
, void *clientData
)
1643 WMPopUpButton
*pop
= (WMPopUpButton
*)self
;
1644 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1646 panel
->action
= WMGetPopUpButtonSelectedItem(pop
);
1651 getWindowMakerIconImage(WMScreen
*scr
)
1653 WMPropList
*dict
, *key
, *option
, *value
=NULL
;
1657 WMPLSetCaseSensitive(True
);
1659 key
= WMCreatePLString("Logo.WMPanel");
1660 option
= WMCreatePLString("Icon");
1662 dict
= WMGetFromPLDictionary(WDWindowAttributes
->dictionary
, key
);
1665 value
= WMGetFromPLDictionary(dict
, option
);
1668 WMReleasePropList(key
);
1669 WMReleasePropList(option
);
1671 WMPLSetCaseSensitive(False
);
1673 if (value
&& WMIsPLString(value
)) {
1674 path
= FindImage(wPreferences
.icon_path
, WMGetFromPLString(value
));
1679 gray
.red
= 0xae; gray
.green
= 0xaa;
1680 gray
.blue
= 0xae; gray
.alpha
= 0;
1682 pix
= WMCreateBlendedPixmapFromFile(scr
, path
, &gray
);
1696 wShowCrashingDialogPanel(int whatSig
)
1702 int screen_no
, scr_width
, scr_height
;
1706 panel
= wmalloc(sizeof(CrashPanel
));
1707 memset(panel
, 0, sizeof(CrashPanel
));
1709 screen_no
= DefaultScreen(dpy
);
1710 scr_width
= WidthOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1711 scr_height
= HeightOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1713 scr
= WMCreateScreen(dpy
, screen_no
);
1715 wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
1719 panel
->retKey
= XKeysymToKeycode(dpy
, XK_Return
);
1721 panel
->win
= WMCreateWindow(scr
, "crashingDialog");
1722 WMResizeWidget(panel
->win
, PWIDTH
, PHEIGHT
);
1723 WMMoveWidget(panel
->win
, (scr_width
- PWIDTH
)/2, (scr_height
- PHEIGHT
)/2);
1725 logo
= getWindowMakerIconImage(scr
);
1727 panel
->iconL
= WMCreateLabel(panel
->win
);
1728 WMResizeWidget(panel
->iconL
, 64, 64);
1729 WMMoveWidget(panel
->iconL
, 10, 10);
1730 WMSetLabelImagePosition(panel
->iconL
, WIPImageOnly
);
1731 WMSetLabelImage(panel
->iconL
, logo
);
1734 panel
->nameL
= WMCreateLabel(panel
->win
);
1735 WMResizeWidget(panel
->nameL
, 190, 18);
1736 WMMoveWidget(panel
->nameL
, 80, 35);
1737 WMSetLabelTextAlignment(panel
->nameL
, WALeft
);
1738 font
= WMBoldSystemFontOfSize(scr
, 18);
1739 WMSetLabelFont(panel
->nameL
, font
);
1740 WMReleaseFont(font
);
1741 WMSetLabelText(panel
->nameL
, _("Fatal error"));
1743 panel
->sepF
= WMCreateFrame(panel
->win
);
1744 WMResizeWidget(panel
->sepF
, PWIDTH
+4, 2);
1745 WMMoveWidget(panel
->sepF
, -2, 80);
1747 panel
->noteL
= WMCreateLabel(panel
->win
);
1748 WMResizeWidget(panel
->noteL
, PWIDTH
-20, 40);
1749 WMMoveWidget(panel
->noteL
, 10, 90);
1750 WMSetLabelTextAlignment(panel
->noteL
, WAJustified
);
1751 #ifdef SYS_SIGLIST_DECLARED
1752 snprintf(buf
, sizeof(buf
), _("Window Maker received signal %i\n(%s)."),
1753 whatSig
, sys_siglist
[whatSig
]);
1755 snprintf(buf
, sizeof(buf
), _("Window Maker received signal %i."), whatSig
);
1757 WMSetLabelText(panel
->noteL
, buf
);
1759 panel
->note2L
= WMCreateLabel(panel
->win
);
1760 WMResizeWidget(panel
->note2L
, PWIDTH
-20, 100);
1761 WMMoveWidget(panel
->note2L
, 10, 130);
1762 WMSetLabelTextAlignment(panel
->note2L
, WALeft
);
1763 WMSetLabelText(panel
->note2L
,
1764 _(" This fatal error occured probably due to a bug."
1765 " Please fill the included BUGFORM and "
1766 "report it to bugs@windowmaker.org."));
1767 WMSetLabelWraps(panel
->note2L
, True
);
1770 panel
->whatF
= WMCreateFrame(panel
->win
);
1771 WMResizeWidget(panel
->whatF
, PWIDTH
-20, 50);
1772 WMMoveWidget(panel
->whatF
, 10, 240);
1773 WMSetFrameTitle(panel
->whatF
, _("What do you want to do now?"));
1775 panel
->whatP
= WMCreatePopUpButton(panel
->whatF
);
1776 WMResizeWidget(panel
->whatP
, PWIDTH
-20-70, 20);
1777 WMMoveWidget(panel
->whatP
, 35, 20);
1778 WMSetPopUpButtonPullsDown(panel
->whatP
, False
);
1779 WMSetPopUpButtonText(panel
->whatP
, _("Select action"));
1780 WMAddPopUpButtonItem(panel
->whatP
, _("Abort and leave a core file"));
1781 WMAddPopUpButtonItem(panel
->whatP
, _("Restart Window Maker"));
1782 WMAddPopUpButtonItem(panel
->whatP
, _("Start alternate window manager"));
1783 WMSetPopUpButtonAction(panel
->whatP
, setCrashAction
, panel
);
1784 WMSetPopUpButtonSelectedItem(panel
->whatP
, WMRestart
);
1785 panel
->action
= WMRestart
;
1787 WMMapSubwidgets(panel
->whatF
);
1789 panel
->okB
= WMCreateCommandButton(panel
->win
);
1790 WMResizeWidget(panel
->okB
, 80, 26);
1791 WMMoveWidget(panel
->okB
, 205, 309);
1792 WMSetButtonText(panel
->okB
, _("OK"));
1793 WMSetButtonImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIReturnArrow
));
1794 WMSetButtonAltImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIHighlightedReturnArrow
));
1795 WMSetButtonImagePosition(panel
->okB
, WIPRight
);
1796 WMSetButtonAction(panel
->okB
, okButtonCallback
, panel
);
1800 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
,
1801 handleKeyPress
, panel
);
1803 WMRealizeWidget(panel
->win
);
1804 WMMapSubwidgets(panel
->win
);
1806 WMMapWidget(panel
->win
);
1808 XSetInputFocus(dpy
, WMWidgetXID(panel
->win
), RevertToParent
, CurrentTime
);
1810 while (!panel
->done
) {
1813 WMNextEvent(dpy
, &event
);
1814 WMHandleEvent(&event
);
1817 action
= panel
->action
;
1819 WMUnmapWidget(panel
->win
);
1820 WMDestroyWidget(panel
->win
);
1829 /*****************************************************************************
1830 * About GNUstep Panel
1831 *****************************************************************************/
1835 drawGNUstepLogo(Display
*dpy
, Drawable d
, int width
, int height
,
1836 unsigned long blackPixel
, unsigned long whitePixel
)
1840 XRectangle rects
[3];
1842 gcv
.foreground
= blackPixel
;
1843 gc
= XCreateGC(dpy
, d
, GCForeground
, &gcv
);
1845 XFillArc(dpy
, d
, gc
, width
/45, height
/45,
1846 width
- 2*width
/45, height
- 2*height
/45, 0, 360*64);
1849 rects
[0].y
= 37*height
/45;
1850 rects
[0].width
= width
/3;
1851 rects
[0].height
= height
- rects
[0].y
;
1853 rects
[1].x
= rects
[0].width
;
1854 rects
[1].y
= height
/2;
1855 rects
[1].width
= width
- 2*width
/3;
1856 rects
[1].height
= height
- rects
[1].y
;
1858 rects
[2].x
= 2*width
/3;
1859 rects
[2].y
= height
- 37*height
/45;
1860 rects
[2].width
= width
/3;
1861 rects
[2].height
= height
- rects
[2].y
;
1863 XSetClipRectangles(dpy
, gc
, 0, 0, rects
, 3, Unsorted
);
1864 XFillRectangle(dpy
, d
, gc
, 0, 0, width
, height
);
1866 XSetForeground(dpy
, gc
, whitePixel
);
1867 XFillArc(dpy
, d
, gc
, width
/45, height
/45,
1868 width
- 2*width
/45, height
- 2*height
/45, 0, 360*64);
1886 static GNUstepPanel
*gnustepPanel
= NULL
;
1889 destroyGNUstepPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
1891 WMUnmapWidget(gnustepPanel
->win
);
1893 WMDestroyWidget(gnustepPanel
->win
);
1895 wUnmanageWindow(gnustepPanel
->wwin
, False
, False
);
1897 wfree(gnustepPanel
);
1899 gnustepPanel
= NULL
;
1904 wShowGNUstepPanel(WScreen
*scr
)
1906 GNUstepPanel
*panel
;
1913 if (gnustepPanel
->scr
== scr
) {
1914 wRaiseFrame(gnustepPanel
->wwin
->frame
->core
);
1915 wSetFocusTo(scr
, gnustepPanel
->wwin
);
1920 panel
= wmalloc(sizeof(GNUstepPanel
));
1924 panel
->win
= WMCreateWindow(scr
->wmscreen
, "About GNUstep");
1925 WMResizeWidget(panel
->win
, 325, 200);
1927 pixmap
= WMCreatePixmap(scr
->wmscreen
, 130, 130,
1928 WMScreenDepth(scr
->wmscreen
), True
);
1930 color
= WMCreateNamedColor(scr
->wmscreen
, "gray50", True
);
1932 drawGNUstepLogo(dpy
, WMGetPixmapXID(pixmap
), 130, 130,
1933 WMColorPixel(color
), scr
->white_pixel
);
1935 WMReleaseColor(color
);
1937 XSetForeground(dpy
, scr
->mono_gc
, 0);
1938 XFillRectangle(dpy
, WMGetPixmapMaskXID(pixmap
), scr
->mono_gc
, 0, 0,
1940 drawGNUstepLogo(dpy
, WMGetPixmapMaskXID(pixmap
), 130, 130, 1, 1);
1942 panel
->gstepL
= WMCreateLabel(panel
->win
);
1943 WMResizeWidget(panel
->gstepL
, 285, 64);
1944 WMMoveWidget(panel
->gstepL
, 20, 0);
1945 WMSetLabelTextAlignment(panel
->gstepL
, WARight
);
1946 WMSetLabelText(panel
->gstepL
, "GNUstep");
1948 WMFont
*font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 24);
1950 WMSetLabelFont(panel
->gstepL
, font
);
1951 WMReleaseFont(font
);
1954 panel
->textL
= WMCreateLabel(panel
->win
);
1955 WMResizeWidget(panel
->textL
, 275, 130);
1956 WMMoveWidget(panel
->textL
, 30, 50);
1957 WMSetLabelTextAlignment(panel
->textL
, WARight
);
1958 WMSetLabelImagePosition(panel
->textL
, WIPOverlaps
);
1959 WMSetLabelText(panel
->textL
,
1960 _("Window Maker is part of the GNUstep project.\n"\
1961 "The GNUstep project aims to create a free\n"\
1962 "implementation of the OpenStep(tm) specification\n"\
1963 "which is a object-oriented framework for\n"\
1964 "creating advanced graphical, multi-platform\n"\
1965 "applications. Additionally, a development and\n"\
1966 "user desktop enviroment will be created on top\n"\
1967 "of the framework. For more information about\n"\
1968 "GNUstep, please visit: www.gnustep.org"));
1969 WMSetLabelImage(panel
->textL
, pixmap
);
1971 WMReleasePixmap(pixmap
);
1973 WMRealizeWidget(panel
->win
);
1974 WMMapSubwidgets(panel
->win
);
1976 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 325, 200, 0, 0, 0);
1978 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1980 wwin
= wManageInternalWindow(scr
, parent
, None
, _("About GNUstep"),
1981 (scr
->scr_width
- 325)/2,
1982 (scr
->scr_height
- 200)/2, 325, 200);
1984 WSETUFLAG(wwin
, no_closable
, 0);
1985 WSETUFLAG(wwin
, no_close_button
, 0);
1986 wWindowUpdateButtonImages(wwin
);
1987 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1988 #ifdef XKB_BUTTON_HINT
1989 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1991 wwin
->frame
->on_click_right
= destroyGNUstepPanel
;
1995 WMMapWidget(panel
->win
);
1999 gnustepPanel
= panel
;