1 /* dialog.c - dialog windows for internal use
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * Copyright (c) 1998-2003 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"
67 extern WPreferences wPreferences
;
71 getCenter(WScreen
*scr
, int width
, int height
)
73 return wGetPointToCenterRectInHead(scr
, wGetHeadForPointerLocation(scr
),
79 wMessageDialog(WScreen
*scr
, char *title
, char *message
,
80 char *defBtn
, char *altBtn
, char *othBtn
)
88 panel
= WMCreateAlertPanel(scr
->wmscreen
, NULL
, title
, message
,
89 defBtn
, altBtn
, othBtn
);
91 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 400, 180, 0, 0, 0);
93 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
96 center
= getCenter(scr
, 400, 180);
97 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
,
99 wwin
->client_leader
= WMWidgetXID(panel
->win
);
101 WMMapWidget(panel
->win
);
105 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
107 result
= panel
->result
;
109 WMUnmapWidget(panel
->win
);
111 wUnmanageWindow(wwin
, False
, False
);
113 WMDestroyAlertPanel(panel
);
115 XDestroyWindow(dpy
, parent
);
122 toggleSaveSession(WMWidget
*w
, void *data
)
124 wPreferences
.save_session_on_exit
= WMGetButtonSelected((WMButton
*) w
);
129 wExitDialog(WScreen
*scr
, char *title
, char *message
,
130 char *defBtn
, char *altBtn
, char *othBtn
)
133 WMButton
*saveSessionBtn
;
139 panel
= WMCreateAlertPanel(scr
->wmscreen
, NULL
, title
, message
,
140 defBtn
, altBtn
, othBtn
);
142 /* add save session button */
143 saveSessionBtn
= WMCreateSwitchButton(panel
->hbox
);
144 WMSetButtonAction(saveSessionBtn
, toggleSaveSession
, NULL
);
145 WMAddBoxSubview(panel
->hbox
, WMWidgetView(saveSessionBtn
),
146 False
, True
, 200, 0, 0);
147 WMSetButtonText(saveSessionBtn
, _("Save workspace state"));
148 WMSetButtonSelected(saveSessionBtn
, wPreferences
.save_session_on_exit
);
149 WMRealizeWidget(saveSessionBtn
);
150 WMMapWidget(saveSessionBtn
);
152 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 400, 180, 0, 0, 0);
154 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
156 center
= getCenter(scr
, 400, 180);
157 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
,
158 center
.x
, center
.y
, 400, 180);
160 wwin
->client_leader
= WMWidgetXID(panel
->win
);
162 WMMapWidget(panel
->win
);
166 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
168 result
= panel
->result
;
170 WMUnmapWidget(panel
->win
);
172 wUnmanageWindow(wwin
, False
, False
);
174 WMDestroyAlertPanel(panel
);
176 XDestroyWindow(dpy
, parent
);
183 wInputDialog(WScreen
*scr
, char *title
, char *message
, char **text
)
191 panel
= WMCreateInputPanel(scr
->wmscreen
, NULL
, title
, message
, *text
,
192 _("OK"), _("Cancel"));
195 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 320, 160, 0, 0, 0);
196 XSelectInput(dpy
, parent
, KeyPressMask
|KeyReleaseMask
);
198 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
200 center
= getCenter(scr
, 320, 160);
201 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
,
204 wwin
->client_leader
= WMWidgetXID(panel
->win
);
206 WMMapWidget(panel
->win
);
210 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
212 if (panel
->result
== WAPRDefault
)
213 result
= WMGetTextFieldText(panel
->text
);
217 wUnmanageWindow(wwin
, False
, False
);
219 WMDestroyInputPanel(panel
);
221 XDestroyWindow(dpy
, parent
);
236 *****************************************************************
237 * Icon Selection Panel
238 *****************************************************************
241 typedef struct IconPanel
{
254 WMButton
*previewButton
;
259 WMTextField
*fileField
;
262 WMButton
*cancelButton
;
264 WMButton
*chooseButton
;
274 listPixmaps(WScreen
*scr
, WMList
*lPtr
, char *path
)
276 struct dirent
*dentry
;
278 char pbuf
[PATH_MAX
+16];
280 IconPanel
*panel
= WMGetHangedData(lPtr
);
282 panel
->preview
= False
;
284 apath
= wexpandpath(path
);
285 dir
= opendir(apath
);
290 tmp
= _("Could not open directory ");
291 msg
= wmalloc(strlen(tmp
)+strlen(path
)+6);
295 wMessageDialog(scr
, _("Error"), msg
, _("OK"), NULL
, NULL
);
301 /* list contents in the column */
302 while ((dentry
= readdir(dir
))) {
305 if (strcmp(dentry
->d_name
, ".")==0 ||
306 strcmp(dentry
->d_name
, "..")==0)
311 strcat(pbuf
, dentry
->d_name
);
313 if (stat(pbuf
, &statb
)<0)
316 if (statb
.st_mode
& (S_IRUSR
|S_IRGRP
|S_IROTH
)
317 && statb
.st_mode
& (S_IFREG
|S_IFLNK
)) {
318 WMAddListItem(lPtr
, dentry
->d_name
);
321 WMSortListItems(lPtr
);
325 panel
->preview
= True
;
331 setViewedImage(IconPanel
*panel
, char *file
)
340 pixmap
= WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel
->win
),
343 WMSetButtonEnabled(panel
->okButton
, False
);
345 WMSetLabelText(panel
->iconView
, _("Could not load image file "));
347 WMSetLabelImage(panel
->iconView
, NULL
);
349 WMSetButtonEnabled(panel
->okButton
, True
);
351 WMSetLabelText(panel
->iconView
, NULL
);
352 WMSetLabelImage(panel
->iconView
, pixmap
);
353 WMReleasePixmap(pixmap
);
359 listCallback(void *self
, void *data
)
361 WMList
*lPtr
= (WMList
*)self
;
362 IconPanel
*panel
= (IconPanel
*)data
;
365 if (lPtr
==panel
->dirList
) {
366 WMListItem
*item
= WMGetListSelectedItem(lPtr
);
372 WMSetTextFieldText(panel
->fileField
, path
);
374 WMSetLabelImage(panel
->iconView
, NULL
);
376 WMSetButtonEnabled(panel
->okButton
, False
);
378 WMClearList(panel
->iconList
);
379 listPixmaps(panel
->scr
, panel
->iconList
, path
);
381 char *tmp
, *iconFile
;
382 WMListItem
*item
= WMGetListSelectedItem(panel
->dirList
);
387 tmp
= wexpandpath(path
);
389 item
= WMGetListSelectedItem(panel
->iconList
);
392 iconFile
= item
->text
;
394 path
= wmalloc(strlen(tmp
)+strlen(iconFile
)+4);
397 strcat(path
, iconFile
);
399 WMSetTextFieldText(panel
->fileField
, path
);
400 setViewedImage(panel
, path
);
407 listIconPaths(WMList
*lPtr
)
412 paths
= wstrdup(wPreferences
.icon_path
);
414 path
= strtok(paths
, ":");
419 tmp
= wexpandpath(path
);
420 /* do not sort, because the order implies the order of
421 * directories searched */
422 if (access(tmp
, X_OK
)==0)
423 WMAddListItem(lPtr
, path
);
425 } while ((path
=strtok(NULL
, ":"))!=NULL
);
432 drawIconProc(WMList
*lPtr
, int index
, Drawable d
, char *text
, int state
,
435 IconPanel
*panel
= WMGetHangedData(lPtr
);
436 WScreen
*scr
= panel
->scr
;
437 GC gc
= scr
->draw_gc
;
438 GC copygc
= scr
->copy_gc
;
439 char *file
, *dirfile
;
443 WMScreen
*wmscr
= WMWidgetScreen(panel
->win
);
445 int x
, y
, width
, height
, len
;
447 if(!panel
->preview
) return;
451 width
= rect
->size
.width
;
452 height
= rect
->size
.height
;
454 back
= (state
& WLDSSelected
) ? scr
->white
: scr
->gray
;
456 dirfile
= wexpandpath(WMGetListSelectedItem(panel
->dirList
)->text
);
457 len
= strlen(dirfile
)+strlen(text
)+4;
459 snprintf(file
, len
, "%s/%s", dirfile
, text
);
462 color
.red
= WMRedComponentOfColor(back
) >> 8;
463 color
.green
= WMGreenComponentOfColor(back
) >> 8;
464 color
.blue
= WMBlueComponentOfColor(back
) >> 8;
465 color
.alpha
= WMGetColorAlpha(back
) >> 8;
467 pixmap
= WMCreateBlendedPixmapFromFile(wmscr
, file
, &color
);
471 /*WMRemoveListItem(lPtr, index);*/
475 XFillRectangle(dpy
, d
, WMColorGC(back
), x
, y
, width
, height
);
477 XSetClipMask(dpy
, gc
, None
);
478 /*XDrawRectangle(dpy, d, WMColorGC(white), x+5, y+5, width-10, 54);*/
479 XDrawLine(dpy
, d
, WMColorGC(scr
->white
), x
, y
+height
-1, x
+width
, y
+height
-1);
481 size
= WMGetPixmapSize(pixmap
);
483 XSetClipMask(dpy
, copygc
, WMGetPixmapMaskXID(pixmap
));
484 XSetClipOrigin(dpy
, copygc
, x
+ (width
-size
.width
)/2, y
+2);
485 XCopyArea(dpy
, WMGetPixmapXID(pixmap
), d
, copygc
, 0, 0,
486 size
.width
>100?100:size
.width
, size
.height
>64?64:size
.height
,
487 x
+ (width
-size
.width
)/2, y
+2);
491 int fheight
= WMFontHeight(panel
->normalfont
);
492 int tlen
= strlen(text
);
493 int twidth
= WMWidthOfString(panel
->normalfont
, text
, tlen
);
496 ofx
= x
+ (width
- twidth
)/2;
497 ofy
= y
+ 64 - fheight
;
501 WMDrawString(wmscr
, d
, scr
->white
, panel
->normalfont
,
502 ofx
+i
, ofy
+j
, text
, tlen
);
504 WMDrawString(wmscr
, d
, scr
->black
, panel
->normalfont
, ofx
, ofy
,
508 WMReleasePixmap(pixmap
);
509 /* I hope it is better to do not use cache / on my box it is fast nuff */
515 buttonCallback(void *self
, void *clientData
)
517 WMButton
*bPtr
= (WMButton
*)self
;
518 IconPanel
*panel
= (IconPanel
*)clientData
;
521 if (bPtr
==panel
->okButton
) {
523 panel
->result
= True
;
524 } else if (bPtr
==panel
->cancelButton
) {
526 panel
->result
= False
;
527 } else if (bPtr
==panel
->previewButton
) {
528 /**** Previewer ****/
529 WMSetButtonEnabled(bPtr
, False
);
530 WMSetListUserDrawItemHeight(panel
->iconList
, 68);
531 WMSetListUserDrawProc(panel
->iconList
, drawIconProc
);
532 WMRedisplayWidget(panel
->iconList
);
533 /* for draw proc to access screen/gc */
534 /*** end preview ***/
537 else if (bPtr
==panel
->chooseButton
) {
540 op
= WMCreateOpenPanel(WMWidgetScreen(bPtr
));
542 if (WMRunModalFilePanelForDirectory(op
, NULL
, "/usr/local", NULL
, NULL
)) {
544 path
= WMGetFilePanelFile(op
);
545 WMSetTextFieldText(panel
->fileField
, path
);
546 setViewedImage(panel
, path
);
549 WMDestroyFilePanel(op
);
556 keyPressHandler(XEvent
*event
, void *data
)
558 IconPanel
*panel
= (IconPanel
*)data
;
567 if (event
->type
== KeyRelease
)
571 count
= XLookupString(&event
->xkey
, buffer
, sizeof(buffer
), &ksym
, NULL
);
574 iidx
= WMGetListSelectedItemRow(panel
->iconList
);
575 didx
= WMGetListSelectedItemRow(panel
->dirList
);
583 list
= panel
->iconList
;
586 if (iidx
< WMGetListNumberOfRows(panel
->iconList
) - 1)
590 list
= panel
->iconList
;
594 list
= panel
->iconList
;
597 item
= WMGetListNumberOfRows(panel
->iconList
) - 1;
598 list
= panel
->iconList
;
601 if (didx
< WMGetListNumberOfRows(panel
->dirList
) - 1)
605 list
= panel
->dirList
;
612 list
= panel
->dirList
;
615 WMPerformButtonClick(panel
->okButton
);
618 WMPerformButtonClick(panel
->cancelButton
);
623 WMSelectListItem(list
, item
);
624 WMSetListPosition(list
, item
- 5);
625 listCallback(list
, panel
);
632 wIconChooserDialog(WScreen
*scr
, char **file
, char *instance
, char *class)
641 panel
= wmalloc(sizeof(IconPanel
));
642 memset(panel
, 0, sizeof(IconPanel
));
646 panel
->win
= WMCreateWindow(scr
->wmscreen
, "iconChooser");
647 WMResizeWidget(panel
->win
, 450, 280);
649 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
|KeyReleaseMask
,
650 keyPressHandler
, panel
);
653 boldFont
= WMBoldSystemFontOfSize(scr
->wmscreen
, 12);
654 panel
->normalfont
= WMSystemFontOfSize(WMWidgetScreen(panel
->win
), 12);
656 panel
->dirLabel
= WMCreateLabel(panel
->win
);
657 WMResizeWidget(panel
->dirLabel
, 200, 20);
658 WMMoveWidget(panel
->dirLabel
, 10, 7);
659 WMSetLabelText(panel
->dirLabel
, _("Directories"));
660 WMSetLabelFont(panel
->dirLabel
, boldFont
);
661 WMSetLabelTextAlignment(panel
->dirLabel
, WACenter
);
663 WMSetLabelRelief(panel
->dirLabel
, WRSunken
);
665 panel
->iconLabel
= WMCreateLabel(panel
->win
);
666 WMResizeWidget(panel
->iconLabel
, 140, 20);
667 WMMoveWidget(panel
->iconLabel
, 215, 7);
668 WMSetLabelText(panel
->iconLabel
, _("Icons"));
669 WMSetLabelFont(panel
->iconLabel
, boldFont
);
670 WMSetLabelTextAlignment(panel
->iconLabel
, WACenter
);
672 WMReleaseFont(boldFont
);
674 color
= WMWhiteColor(scr
->wmscreen
);
675 WMSetLabelTextColor(panel
->dirLabel
, color
);
676 WMSetLabelTextColor(panel
->iconLabel
, color
);
677 WMReleaseColor(color
);
679 color
= WMDarkGrayColor(scr
->wmscreen
);
680 WMSetWidgetBackgroundColor(panel
->iconLabel
, color
);
681 WMSetWidgetBackgroundColor(panel
->dirLabel
, color
);
682 WMReleaseColor(color
);
684 WMSetLabelRelief(panel
->iconLabel
, WRSunken
);
686 panel
->dirList
= WMCreateList(panel
->win
);
687 WMResizeWidget(panel
->dirList
, 200, 170);
688 WMMoveWidget(panel
->dirList
, 10, 30);
689 WMSetListAction(panel
->dirList
, listCallback
, panel
);
691 panel
->iconList
= WMCreateList(panel
->win
);
692 WMResizeWidget(panel
->iconList
, 140, 170);
693 WMMoveWidget(panel
->iconList
, 215, 30);
694 WMSetListAction(panel
->iconList
, listCallback
, panel
);
696 WMHangData(panel
->iconList
,panel
);
698 panel
->previewButton
= WMCreateCommandButton(panel
->win
);
699 WMResizeWidget(panel
->previewButton
, 75, 26);
700 WMMoveWidget(panel
->previewButton
, 365, 130);
701 WMSetButtonText(panel
->previewButton
, _("Preview"));
702 WMSetButtonAction(panel
->previewButton
, buttonCallback
, panel
);
704 panel
->iconView
= WMCreateLabel(panel
->win
);
705 WMResizeWidget(panel
->iconView
, 75, 75);
706 WMMoveWidget(panel
->iconView
, 365, 40);
707 WMSetLabelImagePosition(panel
->iconView
, WIPOverlaps
);
708 WMSetLabelRelief(panel
->iconView
, WRSunken
);
709 WMSetLabelTextAlignment(panel
->iconView
, WACenter
);
711 panel
->fileLabel
= WMCreateLabel(panel
->win
);
712 WMResizeWidget(panel
->fileLabel
, 80, 20);
713 WMMoveWidget(panel
->fileLabel
, 10, 210);
714 WMSetLabelText(panel
->fileLabel
, _("File Name:"));
716 panel
->fileField
= WMCreateTextField(panel
->win
);
717 WMSetViewNextResponder(WMWidgetView(panel
->fileField
), WMWidgetView(panel
->win
));
718 WMResizeWidget(panel
->fileField
, 345, 20);
719 WMMoveWidget(panel
->fileField
, 95, 210);
720 WMSetTextFieldEditable(panel
->fileField
, False
);
722 panel
->okButton
= WMCreateCommandButton(panel
->win
);
723 WMResizeWidget(panel
->okButton
, 80, 26);
724 WMMoveWidget(panel
->okButton
, 360, 240);
725 WMSetButtonText(panel
->okButton
, _("OK"));
726 WMSetButtonEnabled(panel
->okButton
, False
);
727 WMSetButtonAction(panel
->okButton
, buttonCallback
, panel
);
729 panel
->cancelButton
= WMCreateCommandButton(panel
->win
);
730 WMResizeWidget(panel
->cancelButton
, 80, 26);
731 WMMoveWidget(panel
->cancelButton
, 270, 240);
732 WMSetButtonText(panel
->cancelButton
, _("Cancel"));
733 WMSetButtonAction(panel
->cancelButton
, buttonCallback
, panel
);
735 panel
->chooseButton
= WMCreateCommandButton(panel
->win
);
736 WMResizeWidget(panel
->chooseButton
, 110, 26);
737 WMMoveWidget(panel
->chooseButton
, 150, 240);
738 WMSetButtonText(panel
->chooseButton
, _("Choose File"));
739 WMSetButtonAction(panel
->chooseButton
, buttonCallback
, panel
);
741 WMRealizeWidget(panel
->win
);
742 WMMapSubwidgets(panel
->win
);
744 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 450, 280, 0, 0, 0);
746 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
750 int len
= (instance
? strlen(instance
) : 0)
751 + (class ? strlen(class) : 0) + 32;
756 if (tmp
&& (instance
|| class))
757 snprintf(tmp
, len
, "%s [%s.%s]", _("Icon Chooser"), instance
, class);
759 strcpy(tmp
, _("Icon Chooser"));
761 center
= getCenter(scr
, 450, 280);
763 wwin
= wManageInternalWindow(scr
, parent
, None
, tmp
, center
.x
,center
.y
,
768 /* put icon paths in the list */
769 listIconPaths(panel
->dirList
);
771 WMMapWidget(panel
->win
);
775 while (!panel
->done
) {
778 WMNextEvent(dpy
, &event
);
779 WMHandleEvent(&event
);
783 char *defaultPath
, *wantedPath
;
785 /* check if the file the user selected is not the one that
786 * would be loaded by default with the current search path */
787 *file
= WMGetListSelectedItem(panel
->iconList
)->text
;
792 defaultPath
= FindImage(wPreferences
.icon_path
, *file
);
793 wantedPath
= WMGetTextFieldText(panel
->fileField
);
794 /* if the file is not the default, use full path */
795 if (strcmp(wantedPath
, defaultPath
)!=0) {
798 *file
= wstrdup(*file
);
807 result
= panel
->result
;
809 WMReleaseFont(panel
->normalfont
);
811 WMUnmapWidget(panel
->win
);
813 WMDestroyWidget(panel
->win
);
815 wUnmanageWindow(wwin
, False
, False
);
819 XDestroyWindow(dpy
, parent
);
826 ***********************************************************************
828 ***********************************************************************
864 #define COPYRIGHT_TEXT \
865 "Copyright \xc2\xa9 1997-2004 Alfredo K. Kojima <kojima@windowmaker.org>\n"\
866 "Copyright \xc2\xa9 1998-2004 Dan Pascu <dan@windowmaker.org>"
870 static InfoPanel
*thePanel
= NULL
;
873 destroyInfoPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
876 if (thePanel
->timer
) {
877 WMDeleteTimerHandler(thePanel
->timer
);
879 if (thePanel
->oldPix
) {
880 WMReleasePixmap(thePanel
->oldPix
);
882 if (thePanel
->oldFont
) {
883 WMReleaseFont(thePanel
->oldFont
);
885 if (thePanel
->icon
) {
886 RReleaseImage(thePanel
->icon
);
889 RReleaseImage(thePanel
->pic
);
891 #endif /* SILLYNESS */
892 WMUnmapWidget(thePanel
);
894 wUnmanageWindow(thePanel
->wwin
, False
, False
);
896 WMDestroyWidget(thePanel
->win
);
906 extern WMPixmap
*DoXThing();
907 extern Bool
InitXThing();
910 logoPushCallback(void *data
)
912 InfoPanel
*panel
= (InfoPanel
*)data
;
917 static int jingobeu
[] = {
918 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
919 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
920 329, 150, 392, 150, 261, 150, 293, 150, 329, 400, -1, 400, 0
926 XKeyboardState ksave
;
927 unsigned long mask
= KBBellPitch
|KBBellDuration
|KBBellPercent
;
929 XGetKeyboardControl(dpy
, &ksave
);
932 if(jingobeu
[panel
->x
-1]==0) {
934 } else if (jingobeu
[panel
->x
-1]<0) {
936 c
=jingobeu
[panel
->x
-1]/50;
940 kc
.bell_pitch
=jingobeu
[panel
->x
-1];
942 kc
.bell_duration
=jingobeu
[panel
->x
-1];
943 c
=jingobeu
[panel
->x
-1]/50;
945 XChangeKeyboardControl(dpy
, mask
, &kc
);
952 if (!(panel
->cycle
% 4)) {
955 p
= DoXThing(panel
->wwin
);
956 WMSetLabelImage(panel
->logoL
, p
);
958 kc
.bell_pitch
= ksave
.bell_pitch
;
959 kc
.bell_percent
= ksave
.bell_percent
;
960 kc
.bell_duration
= ksave
.bell_duration
;
961 XChangeKeyboardControl(dpy
, mask
, &kc
);
962 } else if (panel
->cycle
< 30) {
967 gray
.red
= 0xae; gray
.green
= 0xaa;
968 gray
.blue
= 0xae; gray
.alpha
= 0;
970 image
= RScaleImage(panel
->icon
, panel
->pic
->width
, panel
->pic
->height
);
971 RCombineImagesWithOpaqueness(image
, panel
->pic
, panel
->cycle
*255/30);
972 pix
= WMCreateBlendedPixmapFromRImage(panel
->scr
->wmscreen
, image
, &gray
);
973 RReleaseImage(image
);
974 WMSetLabelImage(panel
->logoL
, pix
);
975 WMReleasePixmap(pix
);
978 /* slow down text a little */
979 i
= (int)(panel
->cycle
* 50.0/85.0)%200;
982 len
= strlen(panel
->str
);
984 strncpy(buffer
, panel
->str
, i
<len
? i
: len
);
986 memset(&buffer
[len
], ' ', i
-len
);
988 strncpy(buffer
, panel
->str
, i
<len
? i
: len
);
990 memset(&buffer
[len
], ' ', i
-len
);
993 WMSetLabelText(panel
->versionL
, buffer
);
995 XFlush(WMScreenDisplay(WMWidgetScreen(panel
->versionL
)));
1000 panel
->timer
= WMAddTimerHandler(50, logoPushCallback
, panel
);
1006 handleLogoPush(XEvent
*event
, void *data
)
1008 InfoPanel
*panel
= (InfoPanel
*)data
;
1009 static int broken
= 0;
1010 static int clicks
= 0;
1011 static char *pic_data
[] = {
1070 " ............... ",
1071 " ....XoO+@##+O$%.... ",
1072 " ...%X&*========-;;:o... ",
1073 " ...>.>,<122222222222134@... ",
1074 " ..>5678912222222222222220q%.. ",
1075 " ..$.&-w2222222222222222222er>.. ",
1076 " ..O.t31222222222222222222222y4>.. ",
1077 " ...O5u3222222222222222222222222yri... ",
1078 " ..>p&a22222222222222222222222222wso.. ",
1079 " ..ids91222222222222222222222222222wfi.. ",
1080 " ..X.7w222222wgs-w2222222213=g0222222<hi.. ",
1081 " ..Xuj2222222<@X5=222222229k@l:022222y4i.. ",
1082 " .Xdz22222222*X%.s22222222axo%$-222222<c>.. ",
1083 " ..o7y22222222v...r222222223hX.i82222221si.. ",
1084 "..io*222222222&...u22222222yt..%*22222220:%. ",
1085 "..>k02222222227...f222222222v..X=222222229t. ",
1086 "..dz12222222220ui:y2222222223d%qw222222221g. ",
1087 ".%vw222222222221y2222222222219*y2222222222wd.",
1088 ".X;2222222222222222222222222222222222222222b.",
1089 ".i*2222222222222222222222222222222222222222v.",
1090 ".i*2222222222222222222222222222222222222222;.",
1091 ".i*22222222222222222222222222222222222222228.",
1092 ".>*2222222222222222222222222222222222222222=.",
1093 ".i*22222222222222222222222222222222222222228.",
1094 ".i*2222222222222222222222222222222222222222;.",
1095 ".X*222222222222222222222222222222we12222222r.",
1096 ".Xs12222222w3aw22222222222222222y8s0222222wk.",
1097 ".Xq02222222a,na22222222222222222zm6zwy2222gi.",
1098 "..>*22222y<:Xcj22222222222222222-o$k;;02228..",
1099 "..i7y2220rhX.:y22222222222222222jtiXd,a220,..",
1100 " .X@z222a,do%kj2222222222222222wMX5q;gw228%..",
1101 " ..58222wagsh6ry222222222222221;>Of0w222y:...",
1102 " ...:e2222218mdz22222222222222a&$vw222220@...",
1103 " ...O-122222y:.u02222222222229q$uj222221r... ",
1104 " ..%&a1222223&573w2222222219NOxz122221z>... ",
1105 " ...t3222221-l$nr8ay1222yzbo,=12222w-5... ",
1106 " ..X:022222w-k+>o,7s**s7xOn=12221<f5... ",
1107 " ..o:9222221j8:&Bl>>>>ihv<12221=dX... ",
1108 " ..Xb9122222109g-****;<y22221zn%... ",
1109 " ..X&801222222222222222222w-h.... ",
1110 " ...o:=022222222222222221=lX... ",
1111 " ..X@:;3w2222222222210fO... ",
1112 " ...XX&v8<30000003-N@... ",
1113 " .....XmnbN:q&Bo.... ",
1116 static char *msgs
[] = {
1118 "Focus follow mouse users will burn in hell!!!",
1120 "Hi! My name is bobby...",
1121 "AHH! The neurotic monkeys are after me!",
1123 "HOW ARE YOU GENTLEMEN?",
1125 "SOMEBODY SET UP US THE BOMB",
1126 "ALL YOUR BASE ARE BELONG TO US!",
1127 "Oh My God!!! Larry is back!"
1133 if (!panel
->timer
&& !broken
&& clicks
> 0) {
1139 panel
->icon
= WMGetApplicationIconImage(panel
->scr
->wmscreen
);
1146 color
.red
= 0xae; color
.green
= 0xaa;
1147 color
.blue
= 0xae; color
.alpha
= 0;
1149 panel
->icon
= RCloneImage(panel
->icon
);
1150 RCombineImageWithColor(panel
->icon
, &color
);
1154 panel
->pic
= RGetImageFromXPMData(panel
->scr
->rcontext
, pic_data
);
1157 RReleaseImage(panel
->icon
);
1163 panel
->str
= msgs
[rand()%(sizeof(msgs
)/sizeof(char*))];
1165 panel
->timer
= WMAddTimerHandler(50, logoPushCallback
, panel
);
1167 panel
->oldPix
= WMRetainPixmap(WMGetLabelImage(panel
->logoL
));
1168 /* If we don't use a fixed font, scrolling will be jumpy */
1169 /* Alternatively we can draw text in a pixmap and scroll it smoothly */
1170 if ((panel
->oldFont
= WMGetLabelFont(panel
->versionL
))!=NULL
)
1171 WMRetainFont(panel
->oldFont
);
1172 font
= WMCreateFont(WMWidgetScreen(panel
->versionL
),
1173 "Lucida Console,Courier New,monospace:pixelsize=12");
1175 WMSetLabelFont(panel
->versionL
, font
);
1176 WMReleaseFont(font
);
1178 WMSetLabelText(panel
->versionL
, "");
1179 } else if (panel
->timer
) {
1184 WMSetLabelImage(panel
->logoL
, panel
->oldPix
);
1185 WMReleasePixmap(panel
->oldPix
);
1186 panel
->oldPix
= NULL
;
1188 WMDeleteTimerHandler(panel
->timer
);
1189 panel
->timer
= NULL
;
1191 WMSetLabelFont(panel
->versionL
, panel
->oldFont
);
1192 if (panel
->oldFont
) {
1193 WMReleaseFont(panel
->oldFont
);
1194 panel
->oldFont
= NULL
;
1196 snprintf(version
, sizeof(version
), _("Version %s"), VERSION
);
1197 WMSetLabelText(panel
->versionL
, version
);
1198 XFlush(WMScreenDisplay(WMWidgetScreen(panel
->versionL
)));
1203 while (XCheckTypedWindowEvent(dpy
, WMWidgetXID(panel
->versionL
),
1207 #endif /* SILLYNESS */
1211 wShowInfoPanel(WScreen
*scr
)
1217 char *strbuf
= NULL
;
1223 int i
, width
=50, sepWidth
;
1235 if (thePanel
->scr
== scr
) {
1236 wRaiseFrame(thePanel
->wwin
->frame
->core
);
1237 wSetFocusTo(scr
, thePanel
->wwin
);
1242 panel
= wmalloc(sizeof(InfoPanel
));
1243 memset(panel
, 0, sizeof(InfoPanel
));
1247 panel
->win
= WMCreateWindow(scr
->wmscreen
, "info");
1248 WMResizeWidget(panel
->win
, 390, 230);
1250 logo
= WMCreateApplicationIconBlendedPixmap(scr
->wmscreen
, (RColor
*)NULL
);
1252 logo
= WMRetainPixmap(WMGetApplicationIconPixmap(scr
->wmscreen
));
1255 size
= WMGetPixmapSize(logo
);
1256 panel
->logoL
= WMCreateLabel(panel
->win
);
1257 WMResizeWidget(panel
->logoL
, 64, 64);
1258 WMMoveWidget(panel
->logoL
, 30, 20);
1259 WMSetLabelImagePosition(panel
->logoL
, WIPImageOnly
);
1260 WMSetLabelImage(panel
->logoL
, logo
);
1262 WMCreateEventHandler(WMWidgetView(panel
->logoL
), ButtonPressMask
,
1263 handleLogoPush
, panel
);
1265 WMReleasePixmap(logo
);
1269 panel
->name1L
= WMCreateLabel(panel
->win
);
1270 WMResizeWidget(panel
->name1L
, 240, 30 - sepWidth
);
1271 WMMoveWidget(panel
->name1L
, 100, 30);
1273 name
= "Lucida Sans,Comic Sans MS,URW Gothic L,Trebuchet MS,sans:bold:pixelsize=26";
1274 font
= WMCreateFont(scr
->wmscreen
, name
);
1275 strbuf
= "Window Maker";
1277 width
= WMWidthOfString(font
, strbuf
, strlen(strbuf
));
1278 WMSetLabelFont(panel
->name1L
, font
);
1279 WMReleaseFont(font
);
1281 WMSetLabelTextAlignment(panel
->name1L
, WACenter
);
1282 WMSetLabelText(panel
->name1L
, strbuf
);
1284 panel
->lineF
= WMCreateFrame(panel
->win
);
1285 WMResizeWidget(panel
->lineF
, width
, sepWidth
);
1286 WMMoveWidget(panel
->lineF
, 100+(240-width
)/2, 60 - sepWidth
);
1287 WMSetFrameRelief(panel
->lineF
, WRSimple
);
1288 WMSetWidgetBackgroundColor(panel
->lineF
, scr
->black
);
1290 panel
->name2L
= WMCreateLabel(panel
->win
);
1291 WMResizeWidget(panel
->name2L
, 240, 24);
1292 WMMoveWidget(panel
->name2L
, 100, 60);
1293 name
= "URW Gothic L,Nimbus Sans L,sans:pixelsize=16";
1294 font
= WMCreateFont(scr
->wmscreen
, name
);
1296 WMSetLabelFont(panel
->name2L
, font
);
1297 WMReleaseFont(font
);
1300 WMSetLabelTextAlignment(panel
->name2L
, WACenter
);
1301 WMSetLabelText(panel
->name2L
, _("Window Manager for X"));
1303 snprintf(buffer
, sizeof(buffer
), _("Version %s"), VERSION
);
1304 panel
->versionL
= WMCreateLabel(panel
->win
);
1305 WMResizeWidget(panel
->versionL
, 310, 16);
1306 WMMoveWidget(panel
->versionL
, 30, 95);
1307 WMSetLabelTextAlignment(panel
->versionL
, WARight
);
1308 WMSetLabelText(panel
->versionL
, buffer
);
1309 WMSetLabelWraps(panel
->versionL
, False
);
1311 panel
->copyrL
= WMCreateLabel(panel
->win
);
1312 WMResizeWidget(panel
->copyrL
, 360, 40);
1313 WMMoveWidget(panel
->copyrL
, 15, 185);
1314 WMSetLabelTextAlignment(panel
->copyrL
, WALeft
);
1315 WMSetLabelText(panel
->copyrL
, COPYRIGHT_TEXT
);
1316 font
= WMSystemFontOfSize(scr
->wmscreen
, 11);
1318 WMSetLabelFont(panel
->copyrL
, font
);
1319 WMReleaseFont(font
);
1324 snprintf(buffer
, sizeof(buffer
), _("Using visual 0x%x: %s %ibpp "),
1325 (unsigned)scr
->w_visual
->visualid
,
1326 visuals
[scr
->w_visual
->class], scr
->w_depth
);
1328 strbuf
= wstrappend(strbuf
, buffer
);
1330 switch (scr
->w_depth
) {
1332 strbuf
= wstrappend(strbuf
, _("(32 thousand colors)\n"));
1335 strbuf
= wstrappend(strbuf
, _("(64 thousand colors)\n"));
1339 strbuf
= wstrappend(strbuf
, _("(16 million colors)\n"));
1342 snprintf(buffer
, sizeof(buffer
), _("(%d colors)\n"), 1<<scr
->w_depth
);
1343 strbuf
= wstrappend(strbuf
, buffer
);
1348 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
1350 struct mallinfo ma
= mallinfo();
1351 snprintf(buffer
, sizeof(buffer
),
1352 _("Total allocated memory: %i kB. Total memory in use: %i kB.\n"),
1353 (ma
.arena
+ma
.hblkhd
)/1024, (ma
.uordblks
+ma
.hblkhd
)/1024);
1355 strbuf
= wstrappend(strbuf
, buffer
);
1359 strbuf
= wstrappend(strbuf
, _("Supported image formats: "));
1360 strl
= RSupportedFileFormats();
1361 for (i
=0; strl
[i
]!=NULL
; i
++) {
1362 strbuf
= wstrappend(strbuf
, strl
[i
]);
1363 strbuf
= wstrappend(strbuf
, " ");
1366 strbuf
= wstrappend(strbuf
, _("\nAdditional support for: "));
1373 list
[j
++] = "WMSPEC";
1380 for (i
= 0; i
< j
; i
++) {
1383 strcat(buf
, _(" and "));
1387 strcat(buf
, list
[i
]);
1389 strbuf
= wstrappend(strbuf
, buf
);
1392 if (wPreferences
.no_sound
) {
1393 strbuf
= wstrappend(strbuf
, _("\nSound disabled"));
1395 strbuf
= wstrappend(strbuf
, _("\nSound enabled"));
1398 #ifdef VIRTUAL_DESKTOP
1399 if (wPreferences
.vedge_thickness
== 0)
1400 strbuf
= wstrappend(strbuf
, _(", VirtualDesktop disabled"));
1402 strbuf
= wstrappend(strbuf
, _(", VirtualDesktop enabled"));
1406 strbuf
= wstrappend(strbuf
, _("\n"));
1407 #ifdef SOLARIS_XINERAMA
1408 strbuf
= wstrappend(strbuf
, _("Solaris "));
1410 strbuf
= wstrappend(strbuf
, _("Xinerama: "));
1413 snprintf(tmp
, sizeof(tmp
)-1, "%d heads found.", scr
->xine_info
.count
);
1414 strbuf
= wstrappend(strbuf
, tmp
);
1419 panel
->infoL
= WMCreateLabel(panel
->win
);
1420 WMResizeWidget(panel
->infoL
, 350, 75);
1421 WMMoveWidget(panel
->infoL
, 15, 115);
1422 WMSetLabelText(panel
->infoL
, strbuf
);
1423 font
= WMSystemFontOfSize(scr
->wmscreen
, 11);
1425 WMSetLabelFont(panel
->infoL
, font
);
1426 WMReleaseFont(font
);
1432 WMRealizeWidget(panel
->win
);
1433 WMMapSubwidgets(panel
->win
);
1435 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 382, 230, 0, 0, 0);
1437 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1439 WMMapWidget(panel
->win
);
1442 WMPoint center
= getCenter(scr
, 382, 230);
1444 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Info"),
1449 WSETUFLAG(wwin
, no_closable
, 0);
1450 WSETUFLAG(wwin
, no_close_button
, 0);
1451 #ifdef XKB_BUTTON_HINT
1452 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1454 wWindowUpdateButtonImages(wwin
);
1455 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1456 wwin
->frame
->on_click_right
= destroyInfoPanel
;
1464 if (InitXThing(panel
->scr
)) {
1465 panel
->timer
= WMAddTimerHandler(100, logoPushCallback
, panel
);
1468 panel
->str
= _("Merry Christmas!");
1469 panel
->oldPix
= WMRetainPixmap(WMGetLabelImage(panel
->logoL
));
1476 ***********************************************************************
1478 ***********************************************************************
1492 static LegalPanel
*legalPanel
= NULL
;
1495 destroyLegalPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
1497 WMUnmapWidget(legalPanel
->win
);
1499 WMDestroyWidget(legalPanel
->win
);
1501 wUnmanageWindow(legalPanel
->wwin
, False
, False
);
1510 wShowLegalPanel(WScreen
*scr
)
1517 if (legalPanel
->scr
== scr
) {
1518 wRaiseFrame(legalPanel
->wwin
->frame
->core
);
1519 wSetFocusTo(scr
, legalPanel
->wwin
);
1524 panel
= wmalloc(sizeof(LegalPanel
));
1528 panel
->win
= WMCreateWindow(scr
->wmscreen
, "legal");
1529 WMResizeWidget(panel
->win
, 420, 250);
1532 panel
->licenseL
= WMCreateLabel(panel
->win
);
1533 WMSetLabelWraps(panel
->licenseL
, True
);
1534 WMResizeWidget(panel
->licenseL
, 400, 230);
1535 WMMoveWidget(panel
->licenseL
, 10, 10);
1536 WMSetLabelTextAlignment(panel
->licenseL
, WALeft
);
1537 WMSetLabelText(panel
->licenseL
,
1538 _(" Window Maker is free software; you can redistribute it and/or\n"
1539 "modify it under the terms of the GNU General Public License as\n"
1540 "published by the Free Software Foundation; either version 2 of the\n"
1541 "License, or (at your option) any later version.\n\n"
1542 " Window Maker is distributed in the hope that it will be useful,\n"
1543 "but WITHOUT ANY WARRANTY; without even the implied warranty\n"
1544 "of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
1545 "See the GNU General Public License for more details.\n\n"
1546 " You should have received a copy of the GNU General Public\n"
1547 "License along with this program; if not, write to the Free Software\n"
1548 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA\n"
1549 "02111-1307, USA."));
1550 WMSetLabelRelief(panel
->licenseL
, WRGroove
);
1552 WMRealizeWidget(panel
->win
);
1553 WMMapSubwidgets(panel
->win
);
1555 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 420, 250, 0, 0, 0);
1557 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1560 WMPoint center
= getCenter(scr
, 420, 250);
1562 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Legal"),
1567 WSETUFLAG(wwin
, no_closable
, 0);
1568 WSETUFLAG(wwin
, no_close_button
, 0);
1569 wWindowUpdateButtonImages(wwin
);
1570 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1571 #ifdef XKB_BUTTON_HINT
1572 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1574 wwin
->frame
->on_click_right
= destroyLegalPanel
;
1578 WMMapWidget(panel
->win
);
1587 ***********************************************************************
1588 * Crashing Dialog Panel
1589 ***********************************************************************
1592 extern WDDomain
*WDWindowAttributes
;
1595 typedef struct _CrashPanel
{
1596 WMWindow
*win
; /* main window */
1598 WMLabel
*iconL
; /* application icon */
1599 WMLabel
*nameL
; /* title of panel */
1601 WMFrame
*sepF
; /* separator frame */
1603 WMLabel
*noteL
; /* Title of note */
1604 WMLabel
*note2L
; /* body of note with what happened */
1606 WMFrame
*whatF
; /* "what to do next" frame */
1607 WMPopUpButton
*whatP
; /* action selection popup button */
1609 WMButton
*okB
; /* ok button */
1611 Bool done
; /* if finished with this dialog */
1612 int action
; /* what to do after */
1620 handleKeyPress(XEvent
*event
, void *clientData
)
1622 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1624 if (event
->xkey
.keycode
== panel
->retKey
) {
1625 WMPerformButtonClick(panel
->okB
);
1631 okButtonCallback(void *self
, void *clientData
)
1633 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1640 setCrashAction(void *self
, void *clientData
)
1642 WMPopUpButton
*pop
= (WMPopUpButton
*)self
;
1643 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1645 panel
->action
= WMGetPopUpButtonSelectedItem(pop
);
1650 getWindowMakerIconImage(WMScreen
*scr
)
1652 WMPropList
*dict
, *key
, *option
, *value
=NULL
;
1656 WMPLSetCaseSensitive(True
);
1658 key
= WMCreatePLString("Logo.WMPanel");
1659 option
= WMCreatePLString("Icon");
1661 dict
= WMGetFromPLDictionary(WDWindowAttributes
->dictionary
, key
);
1664 value
= WMGetFromPLDictionary(dict
, option
);
1667 WMReleasePropList(key
);
1668 WMReleasePropList(option
);
1670 WMPLSetCaseSensitive(False
);
1672 if (value
&& WMIsPLString(value
)) {
1673 path
= FindImage(wPreferences
.icon_path
, WMGetFromPLString(value
));
1678 gray
.red
= 0xae; gray
.green
= 0xaa;
1679 gray
.blue
= 0xae; gray
.alpha
= 0;
1681 pix
= WMCreateBlendedPixmapFromFile(scr
, path
, &gray
);
1695 wShowCrashingDialogPanel(int whatSig
)
1701 int screen_no
, scr_width
, scr_height
;
1705 panel
= wmalloc(sizeof(CrashPanel
));
1706 memset(panel
, 0, sizeof(CrashPanel
));
1708 screen_no
= DefaultScreen(dpy
);
1709 scr_width
= WidthOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1710 scr_height
= HeightOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1712 scr
= WMCreateScreen(dpy
, screen_no
);
1714 wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
1718 panel
->retKey
= XKeysymToKeycode(dpy
, XK_Return
);
1720 panel
->win
= WMCreateWindow(scr
, "crashingDialog");
1721 WMResizeWidget(panel
->win
, PWIDTH
, PHEIGHT
);
1722 WMMoveWidget(panel
->win
, (scr_width
- PWIDTH
)/2, (scr_height
- PHEIGHT
)/2);
1724 logo
= getWindowMakerIconImage(scr
);
1726 panel
->iconL
= WMCreateLabel(panel
->win
);
1727 WMResizeWidget(panel
->iconL
, 64, 64);
1728 WMMoveWidget(panel
->iconL
, 10, 10);
1729 WMSetLabelImagePosition(panel
->iconL
, WIPImageOnly
);
1730 WMSetLabelImage(panel
->iconL
, logo
);
1733 panel
->nameL
= WMCreateLabel(panel
->win
);
1734 WMResizeWidget(panel
->nameL
, 190, 18);
1735 WMMoveWidget(panel
->nameL
, 80, 35);
1736 WMSetLabelTextAlignment(panel
->nameL
, WALeft
);
1737 font
= WMBoldSystemFontOfSize(scr
, 18);
1738 WMSetLabelFont(panel
->nameL
, font
);
1739 WMReleaseFont(font
);
1740 WMSetLabelText(panel
->nameL
, _("Fatal error"));
1742 panel
->sepF
= WMCreateFrame(panel
->win
);
1743 WMResizeWidget(panel
->sepF
, PWIDTH
+4, 2);
1744 WMMoveWidget(panel
->sepF
, -2, 80);
1746 panel
->noteL
= WMCreateLabel(panel
->win
);
1747 WMResizeWidget(panel
->noteL
, PWIDTH
-20, 40);
1748 WMMoveWidget(panel
->noteL
, 10, 90);
1749 WMSetLabelTextAlignment(panel
->noteL
, WAJustified
);
1750 #ifdef SYS_SIGLIST_DECLARED
1751 snprintf(buf
, sizeof(buf
), _("Window Maker received signal %i\n(%s)."),
1752 whatSig
, sys_siglist
[whatSig
]);
1754 snprintf(buf
, sizeof(buf
), _("Window Maker received signal %i."), whatSig
);
1756 WMSetLabelText(panel
->noteL
, buf
);
1758 panel
->note2L
= WMCreateLabel(panel
->win
);
1759 WMResizeWidget(panel
->note2L
, PWIDTH
-20, 100);
1760 WMMoveWidget(panel
->note2L
, 10, 130);
1761 WMSetLabelTextAlignment(panel
->note2L
, WALeft
);
1762 WMSetLabelText(panel
->note2L
,
1763 _(" This fatal error occured probably due to a bug."
1764 " Please fill the included BUGFORM and "
1765 "report it to bugs@windowmaker.org."));
1766 WMSetLabelWraps(panel
->note2L
, True
);
1769 panel
->whatF
= WMCreateFrame(panel
->win
);
1770 WMResizeWidget(panel
->whatF
, PWIDTH
-20, 50);
1771 WMMoveWidget(panel
->whatF
, 10, 240);
1772 WMSetFrameTitle(panel
->whatF
, _("What do you want to do now?"));
1774 panel
->whatP
= WMCreatePopUpButton(panel
->whatF
);
1775 WMResizeWidget(panel
->whatP
, PWIDTH
-20-70, 20);
1776 WMMoveWidget(panel
->whatP
, 35, 20);
1777 WMSetPopUpButtonPullsDown(panel
->whatP
, False
);
1778 WMSetPopUpButtonText(panel
->whatP
, _("Select action"));
1779 WMAddPopUpButtonItem(panel
->whatP
, _("Abort and leave a core file"));
1780 WMAddPopUpButtonItem(panel
->whatP
, _("Restart Window Maker"));
1781 WMAddPopUpButtonItem(panel
->whatP
, _("Start alternate window manager"));
1782 WMSetPopUpButtonAction(panel
->whatP
, setCrashAction
, panel
);
1783 WMSetPopUpButtonSelectedItem(panel
->whatP
, WMRestart
);
1784 panel
->action
= WMRestart
;
1786 WMMapSubwidgets(panel
->whatF
);
1788 panel
->okB
= WMCreateCommandButton(panel
->win
);
1789 WMResizeWidget(panel
->okB
, 80, 26);
1790 WMMoveWidget(panel
->okB
, 205, 309);
1791 WMSetButtonText(panel
->okB
, _("OK"));
1792 WMSetButtonImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIReturnArrow
));
1793 WMSetButtonAltImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIHighlightedReturnArrow
));
1794 WMSetButtonImagePosition(panel
->okB
, WIPRight
);
1795 WMSetButtonAction(panel
->okB
, okButtonCallback
, panel
);
1799 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
,
1800 handleKeyPress
, panel
);
1802 WMRealizeWidget(panel
->win
);
1803 WMMapSubwidgets(panel
->win
);
1805 WMMapWidget(panel
->win
);
1807 XSetInputFocus(dpy
, WMWidgetXID(panel
->win
), RevertToParent
, CurrentTime
);
1809 while (!panel
->done
) {
1812 WMNextEvent(dpy
, &event
);
1813 WMHandleEvent(&event
);
1816 action
= panel
->action
;
1818 WMUnmapWidget(panel
->win
);
1819 WMDestroyWidget(panel
->win
);
1828 /*****************************************************************************
1829 * About GNUstep Panel
1830 *****************************************************************************/
1834 drawGNUstepLogo(Display
*dpy
, Drawable d
, int width
, int height
,
1835 unsigned long blackPixel
, unsigned long whitePixel
)
1839 XRectangle rects
[3];
1841 gcv
.foreground
= blackPixel
;
1842 gc
= XCreateGC(dpy
, d
, GCForeground
, &gcv
);
1844 XFillArc(dpy
, d
, gc
, width
/45, height
/45,
1845 width
- 2*width
/45, height
- 2*height
/45, 0, 360*64);
1848 rects
[0].y
= 37*height
/45;
1849 rects
[0].width
= width
/3;
1850 rects
[0].height
= height
- rects
[0].y
;
1852 rects
[1].x
= rects
[0].width
;
1853 rects
[1].y
= height
/2;
1854 rects
[1].width
= width
- 2*width
/3;
1855 rects
[1].height
= height
- rects
[1].y
;
1857 rects
[2].x
= 2*width
/3;
1858 rects
[2].y
= height
- 37*height
/45;
1859 rects
[2].width
= width
/3;
1860 rects
[2].height
= height
- rects
[2].y
;
1862 XSetClipRectangles(dpy
, gc
, 0, 0, rects
, 3, Unsorted
);
1863 XFillRectangle(dpy
, d
, gc
, 0, 0, width
, height
);
1865 XSetForeground(dpy
, gc
, whitePixel
);
1866 XFillArc(dpy
, d
, gc
, width
/45, height
/45,
1867 width
- 2*width
/45, height
- 2*height
/45, 0, 360*64);
1885 static GNUstepPanel
*gnustepPanel
= NULL
;
1888 destroyGNUstepPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
1890 WMUnmapWidget(gnustepPanel
->win
);
1892 WMDestroyWidget(gnustepPanel
->win
);
1894 wUnmanageWindow(gnustepPanel
->wwin
, False
, False
);
1896 wfree(gnustepPanel
);
1898 gnustepPanel
= NULL
;
1903 wShowGNUstepPanel(WScreen
*scr
)
1905 GNUstepPanel
*panel
;
1912 if (gnustepPanel
->scr
== scr
) {
1913 wRaiseFrame(gnustepPanel
->wwin
->frame
->core
);
1914 wSetFocusTo(scr
, gnustepPanel
->wwin
);
1919 panel
= wmalloc(sizeof(GNUstepPanel
));
1923 panel
->win
= WMCreateWindow(scr
->wmscreen
, "About GNUstep");
1924 WMResizeWidget(panel
->win
, 325, 205);
1926 pixmap
= WMCreatePixmap(scr
->wmscreen
, 130, 130,
1927 WMScreenDepth(scr
->wmscreen
), True
);
1929 color
= WMCreateNamedColor(scr
->wmscreen
, "gray50", True
);
1931 drawGNUstepLogo(dpy
, WMGetPixmapXID(pixmap
), 130, 130,
1932 WMColorPixel(color
), scr
->white_pixel
);
1934 WMReleaseColor(color
);
1936 XSetForeground(dpy
, scr
->mono_gc
, 0);
1937 XFillRectangle(dpy
, WMGetPixmapMaskXID(pixmap
), scr
->mono_gc
, 0, 0,
1939 drawGNUstepLogo(dpy
, WMGetPixmapMaskXID(pixmap
), 130, 130, 1, 1);
1941 panel
->gstepL
= WMCreateLabel(panel
->win
);
1942 WMResizeWidget(panel
->gstepL
, 285, 64);
1943 WMMoveWidget(panel
->gstepL
, 20, 0);
1944 WMSetLabelTextAlignment(panel
->gstepL
, WARight
);
1945 WMSetLabelText(panel
->gstepL
, "GNUstep");
1947 WMFont
*font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 24);
1949 WMSetLabelFont(panel
->gstepL
, font
);
1950 WMReleaseFont(font
);
1953 panel
->textL
= WMCreateLabel(panel
->win
);
1954 WMResizeWidget(panel
->textL
, 305, 140);
1955 WMMoveWidget(panel
->textL
, 10, 50);
1956 WMSetLabelTextAlignment(panel
->textL
, WARight
);
1957 WMSetLabelImagePosition(panel
->textL
, WIPOverlaps
);
1958 WMSetLabelText(panel
->textL
,
1959 _("Window Maker is part of the GNUstep project.\n"\
1960 "The GNUstep project aims to create a free\n"\
1961 "implementation of the OpenStep(tm) specification\n"\
1962 "which is a object-oriented framework for\n"\
1963 "creating advanced graphical, multi-platform\n"\
1964 "applications. Additionally, a development and\n"\
1965 "user desktop enviroment will be created on top\n"\
1966 "of the framework. For more information about\n"\
1967 "GNUstep, please visit: www.gnustep.org"));
1968 WMSetLabelImage(panel
->textL
, pixmap
);
1970 WMReleasePixmap(pixmap
);
1972 WMRealizeWidget(panel
->win
);
1973 WMMapSubwidgets(panel
->win
);
1975 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 325, 200, 0, 0, 0);
1977 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1980 WMPoint center
= getCenter(scr
, 325, 200);
1982 wwin
= wManageInternalWindow(scr
, parent
, None
, _("About GNUstep"),
1987 WSETUFLAG(wwin
, no_closable
, 0);
1988 WSETUFLAG(wwin
, no_close_button
, 0);
1989 wWindowUpdateButtonImages(wwin
);
1990 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1991 #ifdef XKB_BUTTON_HINT
1992 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1994 wwin
->frame
->on_click_right
= destroyGNUstepPanel
;
1998 WMMapWidget(panel
->win
);
2002 gnustepPanel
= panel
;