1 /* dialog.c - dialog windows for internal use
3 * Window Maker window manager
5 * Copyright (c) 1997-2002 Alfredo K. Kojima
6 * Copyright (c) 1998-2002 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
;
70 static WMPoint
getCenter(WScreen
*scr
, int width
, int height
)
77 rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
79 pt
.x
= rect
.pos
.x
+ (rect
.size
.width
- width
)/2;
80 pt
.y
= rect
.pos
.y
+ (rect
.size
.height
- height
)/2;
82 pt
.x
= (scr
->scr_width
- width
) / 2;
83 pt
.y
= (scr
->scr_height
- height
) / 2;
92 wMessageDialog(WScreen
*scr
, char *title
, char *message
,
93 char *defBtn
, char *altBtn
, char *othBtn
)
101 panel
= WMCreateAlertPanel(scr
->wmscreen
, NULL
, title
, message
,
102 defBtn
, altBtn
, othBtn
);
104 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 400, 180, 0, 0, 0);
106 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
109 center
= getCenter(scr
, 400, 180);
110 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
,
112 wwin
->client_leader
= WMWidgetXID(panel
->win
);
114 WMMapWidget(panel
->win
);
118 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
120 result
= panel
->result
;
122 WMUnmapWidget(panel
->win
);
124 wUnmanageWindow(wwin
, False
, False
);
126 WMDestroyAlertPanel(panel
);
128 XDestroyWindow(dpy
, parent
);
135 toggleSaveSession(WMWidget
*w
, void *data
)
137 wPreferences
.save_session_on_exit
= WMGetButtonSelected((WMButton
*) w
);
142 wExitDialog(WScreen
*scr
, char *title
, char *message
,
143 char *defBtn
, char *altBtn
, char *othBtn
)
146 WMButton
*saveSessionBtn
;
151 panel
= WMCreateAlertPanel(scr
->wmscreen
, NULL
, title
, message
,
152 defBtn
, altBtn
, othBtn
);
154 /* add save session button */
155 saveSessionBtn
= WMCreateSwitchButton(panel
->hbox
);
156 WMSetButtonAction(saveSessionBtn
, toggleSaveSession
, NULL
);
157 WMAddBoxSubview(panel
->hbox
, WMWidgetView(saveSessionBtn
),
158 False
, True
, 200, 0, 0);
159 WMSetButtonText(saveSessionBtn
, _("Save workspace state"));
160 WMSetButtonSelected(saveSessionBtn
, wPreferences
.save_session_on_exit
);
161 WMRealizeWidget(saveSessionBtn
);
162 WMMapWidget(saveSessionBtn
);
164 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 400, 180, 0, 0, 0);
166 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
168 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
,
169 (scr
->scr_width
- 400)/2,
170 (scr
->scr_height
- 180)/2, 400, 180);
171 wwin
->client_leader
= WMWidgetXID(panel
->win
);
173 WMMapWidget(panel
->win
);
177 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
179 result
= panel
->result
;
181 WMUnmapWidget(panel
->win
);
183 wUnmanageWindow(wwin
, False
, False
);
185 WMDestroyAlertPanel(panel
);
187 XDestroyWindow(dpy
, parent
);
194 wInputDialog(WScreen
*scr
, char *title
, char *message
, char **text
)
202 panel
= WMCreateInputPanel(scr
->wmscreen
, NULL
, title
, message
, *text
,
203 _("OK"), _("Cancel"));
206 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 320, 160, 0, 0, 0);
207 XSelectInput(dpy
, parent
, KeyPressMask
|KeyReleaseMask
);
209 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
211 center
= getCenter(scr
, 320, 160);
212 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
,
215 wwin
->client_leader
= WMWidgetXID(panel
->win
);
217 WMMapWidget(panel
->win
);
221 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
223 if (panel
->result
== WAPRDefault
)
224 result
= WMGetTextFieldText(panel
->text
);
228 wUnmanageWindow(wwin
, False
, False
);
230 WMDestroyInputPanel(panel
);
232 XDestroyWindow(dpy
, parent
);
247 *****************************************************************
248 * Icon Selection Panel
249 *****************************************************************
252 typedef struct IconPanel
{
265 WMButton
*previewButton
;
270 WMTextField
*fileField
;
273 WMButton
*cancelButton
;
275 WMButton
*chooseButton
;
285 listPixmaps(WScreen
*scr
, WMList
*lPtr
, char *path
)
287 struct dirent
*dentry
;
289 char pbuf
[PATH_MAX
+16];
291 IconPanel
*panel
= WMGetHangedData(lPtr
);
293 panel
->preview
= False
;
295 apath
= wexpandpath(path
);
296 dir
= opendir(apath
);
301 tmp
= _("Could not open directory ");
302 msg
= wmalloc(strlen(tmp
)+strlen(path
)+6);
306 wMessageDialog(scr
, _("Error"), msg
, _("OK"), NULL
, NULL
);
312 /* list contents in the column */
313 while ((dentry
= readdir(dir
))) {
316 if (strcmp(dentry
->d_name
, ".")==0 ||
317 strcmp(dentry
->d_name
, "..")==0)
322 strcat(pbuf
, dentry
->d_name
);
324 if (stat(pbuf
, &statb
)<0)
327 if (statb
.st_mode
& (S_IRUSR
|S_IRGRP
|S_IROTH
)
328 && statb
.st_mode
& (S_IFREG
|S_IFLNK
)) {
329 WMAddListItem(lPtr
, dentry
->d_name
);
332 WMSortListItems(lPtr
);
336 panel
->preview
= True
;
342 setViewedImage(IconPanel
*panel
, char *file
)
351 pixmap
= WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel
->win
),
354 WMSetButtonEnabled(panel
->okButton
, False
);
356 WMSetLabelText(panel
->iconView
, _("Could not load image file "));
358 WMSetLabelImage(panel
->iconView
, NULL
);
360 WMSetButtonEnabled(panel
->okButton
, True
);
362 WMSetLabelText(panel
->iconView
, NULL
);
363 WMSetLabelImage(panel
->iconView
, pixmap
);
364 WMReleasePixmap(pixmap
);
370 listCallback(void *self
, void *data
)
372 WMList
*lPtr
= (WMList
*)self
;
373 IconPanel
*panel
= (IconPanel
*)data
;
376 if (lPtr
==panel
->dirList
) {
377 WMListItem
*item
= WMGetListSelectedItem(lPtr
);
383 WMSetTextFieldText(panel
->fileField
, path
);
385 WMSetLabelImage(panel
->iconView
, NULL
);
387 WMSetButtonEnabled(panel
->okButton
, False
);
389 WMClearList(panel
->iconList
);
390 listPixmaps(panel
->scr
, panel
->iconList
, path
);
392 char *tmp
, *iconFile
;
393 WMListItem
*item
= WMGetListSelectedItem(panel
->dirList
);
398 tmp
= wexpandpath(path
);
400 item
= WMGetListSelectedItem(panel
->iconList
);
403 iconFile
= item
->text
;
405 path
= wmalloc(strlen(tmp
)+strlen(iconFile
)+4);
408 strcat(path
, iconFile
);
410 WMSetTextFieldText(panel
->fileField
, path
);
411 setViewedImage(panel
, path
);
418 listIconPaths(WMList
*lPtr
)
423 paths
= wstrdup(wPreferences
.icon_path
);
425 path
= strtok(paths
, ":");
430 tmp
= wexpandpath(path
);
431 /* do not sort, because the order implies the order of
432 * directories searched */
433 if (access(tmp
, X_OK
)==0)
434 WMAddListItem(lPtr
, path
);
436 } while ((path
=strtok(NULL
, ":"))!=NULL
);
443 drawIconProc(WMList
*lPtr
, int index
, Drawable d
, char *text
, int state
,
446 IconPanel
*panel
= WMGetHangedData(lPtr
);
447 WScreen
*scr
= panel
->scr
;
448 GC gc
= scr
->draw_gc
;
449 GC copygc
= scr
->copy_gc
;
450 char *file
, *dirfile
;
454 WMScreen
*wmscr
= WMWidgetScreen(panel
->win
);
456 int x
, y
, width
, height
, len
;
458 if(!panel
->preview
) return;
462 width
= rect
->size
.width
;
463 height
= rect
->size
.height
;
465 back
= (state
& WLDSSelected
) ? scr
->white
: scr
->gray
;
467 dirfile
= wexpandpath(WMGetListSelectedItem(panel
->dirList
)->text
);
468 len
= strlen(dirfile
)+strlen(text
)+4;
470 snprintf(file
, len
, "%s/%s", dirfile
, text
);
473 color
.red
= WMRedComponentOfColor(back
) >> 8;
474 color
.green
= WMGreenComponentOfColor(back
) >> 8;
475 color
.blue
= WMBlueComponentOfColor(back
) >> 8;
476 color
.alpha
= WMGetColorAlpha(back
) >> 8;
478 pixmap
= WMCreateBlendedPixmapFromFile(wmscr
, file
, &color
);
482 /*WMRemoveListItem(lPtr, index);*/
486 XFillRectangle(dpy
, d
, WMColorGC(back
), x
, y
, width
, height
);
488 XSetClipMask(dpy
, gc
, None
);
489 /*XDrawRectangle(dpy, d, WMColorGC(white), x+5, y+5, width-10, 54);*/
490 XDrawLine(dpy
, d
, WMColorGC(scr
->white
), x
, y
+height
-1, x
+width
, y
+height
-1);
492 size
= WMGetPixmapSize(pixmap
);
494 XSetClipMask(dpy
, copygc
, WMGetPixmapMaskXID(pixmap
));
495 XSetClipOrigin(dpy
, copygc
, x
+ (width
-size
.width
)/2, y
+2);
496 XCopyArea(dpy
, WMGetPixmapXID(pixmap
), d
, copygc
, 0, 0,
497 size
.width
>100?100:size
.width
, size
.height
>64?64:size
.height
,
498 x
+ (width
-size
.width
)/2, y
+2);
502 int fheight
= WMFontHeight(panel
->normalfont
);
503 int tlen
= strlen(text
);
504 int twidth
= WMWidthOfString(panel
->normalfont
, text
, tlen
);
507 ofx
= x
+ (width
- twidth
)/2;
508 ofy
= y
+ 64 - fheight
;
512 WMDrawString(wmscr
, d
, scr
->white
, panel
->normalfont
,
513 ofx
+i
, ofy
+j
, text
, tlen
);
515 WMDrawString(wmscr
, d
, scr
->black
, panel
->normalfont
, ofx
, ofy
,
519 WMReleasePixmap(pixmap
);
520 /* I hope it is better to do not use cache / on my box it is fast nuff */
526 buttonCallback(void *self
, void *clientData
)
528 WMButton
*bPtr
= (WMButton
*)self
;
529 IconPanel
*panel
= (IconPanel
*)clientData
;
532 if (bPtr
==panel
->okButton
) {
534 panel
->result
= True
;
535 } else if (bPtr
==panel
->cancelButton
) {
537 panel
->result
= False
;
538 } else if (bPtr
==panel
->previewButton
) {
539 /**** Previewer ****/
540 WMSetButtonEnabled(bPtr
, False
);
541 WMSetListUserDrawItemHeight(panel
->iconList
, 68);
542 WMSetListUserDrawProc(panel
->iconList
, drawIconProc
);
543 WMRedisplayWidget(panel
->iconList
);
544 /* for draw proc to access screen/gc */
545 /*** end preview ***/
548 else if (bPtr
==panel
->chooseButton
) {
551 op
= WMCreateOpenPanel(WMWidgetScreen(bPtr
));
553 if (WMRunModalFilePanelForDirectory(op
, NULL
, "/usr/local", NULL
, NULL
)) {
555 path
= WMGetFilePanelFile(op
);
556 WMSetTextFieldText(panel
->fileField
, path
);
557 setViewedImage(panel
, path
);
560 WMDestroyFilePanel(op
);
567 keyPressHandler(XEvent
*event
, void *data
)
569 IconPanel
*panel
= (IconPanel
*)data
;
578 if (event
->type
== KeyRelease
)
582 count
= XLookupString(&event
->xkey
, buffer
, sizeof(buffer
), &ksym
, NULL
);
585 iidx
= WMGetListSelectedItemRow(panel
->iconList
);
586 didx
= WMGetListSelectedItemRow(panel
->dirList
);
594 list
= panel
->iconList
;
597 if (iidx
< WMGetListNumberOfRows(panel
->iconList
) - 1)
601 list
= panel
->iconList
;
605 list
= panel
->iconList
;
608 item
= WMGetListNumberOfRows(panel
->iconList
) - 1;
609 list
= panel
->iconList
;
612 if (didx
< WMGetListNumberOfRows(panel
->dirList
) - 1)
616 list
= panel
->dirList
;
623 list
= panel
->dirList
;
626 WMPerformButtonClick(panel
->okButton
);
629 WMPerformButtonClick(panel
->cancelButton
);
634 WMSelectListItem(list
, item
);
635 WMSetListPosition(list
, item
- 5);
636 listCallback(list
, panel
);
643 wIconChooserDialog(WScreen
*scr
, char **file
, char *instance
, char *class)
651 panel
= wmalloc(sizeof(IconPanel
));
652 memset(panel
, 0, sizeof(IconPanel
));
656 panel
->win
= WMCreateWindow(scr
->wmscreen
, "iconChooser");
657 WMResizeWidget(panel
->win
, 450, 280);
659 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
|KeyReleaseMask
,
660 keyPressHandler
, panel
);
663 boldFont
= WMBoldSystemFontOfSize(scr
->wmscreen
, 12);
664 panel
->normalfont
= WMSystemFontOfSize(WMWidgetScreen(panel
->win
), 12);
666 panel
->dirLabel
= WMCreateLabel(panel
->win
);
667 WMResizeWidget(panel
->dirLabel
, 200, 20);
668 WMMoveWidget(panel
->dirLabel
, 10, 7);
669 WMSetLabelText(panel
->dirLabel
, _("Directories"));
670 WMSetLabelFont(panel
->dirLabel
, boldFont
);
671 WMSetLabelTextAlignment(panel
->dirLabel
, WACenter
);
673 WMSetLabelRelief(panel
->dirLabel
, WRSunken
);
675 panel
->iconLabel
= WMCreateLabel(panel
->win
);
676 WMResizeWidget(panel
->iconLabel
, 140, 20);
677 WMMoveWidget(panel
->iconLabel
, 215, 7);
678 WMSetLabelText(panel
->iconLabel
, _("Icons"));
679 WMSetLabelFont(panel
->iconLabel
, boldFont
);
680 WMSetLabelTextAlignment(panel
->iconLabel
, WACenter
);
682 WMReleaseFont(boldFont
);
684 color
= WMWhiteColor(scr
->wmscreen
);
685 WMSetLabelTextColor(panel
->dirLabel
, color
);
686 WMSetLabelTextColor(panel
->iconLabel
, color
);
687 WMReleaseColor(color
);
689 color
= WMDarkGrayColor(scr
->wmscreen
);
690 WMSetWidgetBackgroundColor(panel
->iconLabel
, color
);
691 WMSetWidgetBackgroundColor(panel
->dirLabel
, color
);
692 WMReleaseColor(color
);
694 WMSetLabelRelief(panel
->iconLabel
, WRSunken
);
696 panel
->dirList
= WMCreateList(panel
->win
);
697 WMResizeWidget(panel
->dirList
, 200, 170);
698 WMMoveWidget(panel
->dirList
, 10, 30);
699 WMSetListAction(panel
->dirList
, listCallback
, panel
);
701 panel
->iconList
= WMCreateList(panel
->win
);
702 WMResizeWidget(panel
->iconList
, 140, 170);
703 WMMoveWidget(panel
->iconList
, 215, 30);
704 WMSetListAction(panel
->iconList
, listCallback
, panel
);
706 WMHangData(panel
->iconList
,panel
);
708 panel
->previewButton
= WMCreateCommandButton(panel
->win
);
709 WMResizeWidget(panel
->previewButton
, 75, 26);
710 WMMoveWidget(panel
->previewButton
, 365, 130);
711 WMSetButtonText(panel
->previewButton
, _("Preview"));
712 WMSetButtonAction(panel
->previewButton
, buttonCallback
, panel
);
714 panel
->iconView
= WMCreateLabel(panel
->win
);
715 WMResizeWidget(panel
->iconView
, 75, 75);
716 WMMoveWidget(panel
->iconView
, 365, 40);
717 WMSetLabelImagePosition(panel
->iconView
, WIPOverlaps
);
718 WMSetLabelRelief(panel
->iconView
, WRSunken
);
719 WMSetLabelTextAlignment(panel
->iconView
, WACenter
);
721 panel
->fileLabel
= WMCreateLabel(panel
->win
);
722 WMResizeWidget(panel
->fileLabel
, 80, 20);
723 WMMoveWidget(panel
->fileLabel
, 10, 210);
724 WMSetLabelText(panel
->fileLabel
, _("File Name:"));
726 panel
->fileField
= WMCreateTextField(panel
->win
);
727 WMSetViewNextResponder(WMWidgetView(panel
->fileField
), WMWidgetView(panel
->win
));
728 WMResizeWidget(panel
->fileField
, 345, 20);
729 WMMoveWidget(panel
->fileField
, 95, 210);
730 WMSetTextFieldEditable(panel
->fileField
, False
);
732 panel
->okButton
= WMCreateCommandButton(panel
->win
);
733 WMResizeWidget(panel
->okButton
, 80, 26);
734 WMMoveWidget(panel
->okButton
, 360, 240);
735 WMSetButtonText(panel
->okButton
, _("OK"));
736 WMSetButtonEnabled(panel
->okButton
, False
);
737 WMSetButtonAction(panel
->okButton
, buttonCallback
, panel
);
739 panel
->cancelButton
= WMCreateCommandButton(panel
->win
);
740 WMResizeWidget(panel
->cancelButton
, 80, 26);
741 WMMoveWidget(panel
->cancelButton
, 270, 240);
742 WMSetButtonText(panel
->cancelButton
, _("Cancel"));
743 WMSetButtonAction(panel
->cancelButton
, buttonCallback
, panel
);
745 panel
->chooseButton
= WMCreateCommandButton(panel
->win
);
746 WMResizeWidget(panel
->chooseButton
, 110, 26);
747 WMMoveWidget(panel
->chooseButton
, 150, 240);
748 WMSetButtonText(panel
->chooseButton
, _("Choose File"));
749 WMSetButtonAction(panel
->chooseButton
, buttonCallback
, panel
);
751 WMRealizeWidget(panel
->win
);
752 WMMapSubwidgets(panel
->win
);
754 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 450, 280, 0, 0, 0);
756 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
760 int len
= (instance
? strlen(instance
) : 0)
761 + (class ? strlen(class) : 0) + 32;
766 if (tmp
&& (instance
|| class))
767 snprintf(tmp
, len
, "%s [%s.%s]", _("Icon Chooser"), instance
, class);
769 strcpy(tmp
, _("Icon Chooser"));
771 center
= getCenter(scr
, 450, 280);
773 wwin
= wManageInternalWindow(scr
, parent
, None
, tmp
, center
.x
,center
.y
,
778 /* put icon paths in the list */
779 listIconPaths(panel
->dirList
);
781 WMMapWidget(panel
->win
);
785 while (!panel
->done
) {
788 WMNextEvent(dpy
, &event
);
789 WMHandleEvent(&event
);
793 char *defaultPath
, *wantedPath
;
795 /* check if the file the user selected is not the one that
796 * would be loaded by default with the current search path */
797 *file
= WMGetListSelectedItem(panel
->iconList
)->text
;
802 defaultPath
= FindImage(wPreferences
.icon_path
, *file
);
803 wantedPath
= WMGetTextFieldText(panel
->fileField
);
804 /* if the file is not the default, use full path */
805 if (strcmp(wantedPath
, defaultPath
)!=0) {
808 *file
= wstrdup(*file
);
817 WMReleaseFont(panel
->normalfont
);
819 WMUnmapWidget(panel
->win
);
821 WMDestroyWidget(panel
->win
);
823 wUnmanageWindow(wwin
, False
, False
);
827 XDestroyWindow(dpy
, parent
);
829 return panel
->result
;
834 ***********************************************************************
836 ***********************************************************************
872 #define COPYRIGHT_TEXT \
873 "Copyright \xa9 1997-2002 Alfredo K. Kojima <kojima@windowmaker.org>\n"\
874 "Copyright \xa9 1998-2002 Dan Pascu <dan@windowmaker.org>"
878 static InfoPanel
*thePanel
= NULL
;
881 destroyInfoPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
884 if (thePanel
->timer
) {
885 WMDeleteTimerHandler(thePanel
->timer
);
887 if (thePanel
->oldPix
) {
888 WMReleasePixmap(thePanel
->oldPix
);
890 if (thePanel
->oldFont
) {
891 WMReleaseFont(thePanel
->oldFont
);
893 if (thePanel
->icon
) {
894 RReleaseImage(thePanel
->icon
);
897 RReleaseImage(thePanel
->pic
);
899 #endif /* SILLYNESS */
900 WMUnmapWidget(thePanel
);
902 wUnmanageWindow(thePanel
->wwin
, False
, False
);
904 WMDestroyWidget(thePanel
->win
);
914 extern WMPixmap
*DoXThing();
915 extern Bool
InitXThing();
918 logoPushCallback(void *data
)
920 InfoPanel
*panel
= (InfoPanel
*)data
;
925 static int jingobeu
[] = {
926 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
927 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
928 329, 150, 392, 150, 261, 150, 293, 150, 329, 400, -1, 400, 0
934 XKeyboardState ksave
;
935 unsigned long mask
= KBBellPitch
|KBBellDuration
|KBBellPercent
;
937 XGetKeyboardControl(dpy
, &ksave
);
940 if(jingobeu
[panel
->x
-1]==0) {
942 } else if (jingobeu
[panel
->x
-1]<0) {
944 c
=jingobeu
[panel
->x
-1]/50;
948 kc
.bell_pitch
=jingobeu
[panel
->x
-1];
950 kc
.bell_duration
=jingobeu
[panel
->x
-1];
951 c
=jingobeu
[panel
->x
-1]/50;
953 XChangeKeyboardControl(dpy
, mask
, &kc
);
960 if (!(panel
->cycle
% 4)) {
963 p
= DoXThing(panel
->wwin
);
964 WMSetLabelImage(panel
->logoL
, p
);
966 kc
.bell_pitch
= ksave
.bell_pitch
;
967 kc
.bell_percent
= ksave
.bell_percent
;
968 kc
.bell_duration
= ksave
.bell_duration
;
969 XChangeKeyboardControl(dpy
, mask
, &kc
);
970 } else if (panel
->cycle
< 30) {
975 gray
.red
= 0xae; gray
.green
= 0xaa;
976 gray
.blue
= 0xae; gray
.alpha
= 0;
978 image
= RScaleImage(panel
->icon
, panel
->pic
->width
, panel
->pic
->height
);
979 RCombineImagesWithOpaqueness(image
, panel
->pic
, panel
->cycle
*255/30);
980 pix
= WMCreateBlendedPixmapFromRImage(panel
->scr
->wmscreen
, image
, &gray
);
981 RReleaseImage(image
);
982 WMSetLabelImage(panel
->logoL
, pix
);
983 WMReleasePixmap(pix
);
986 /* slow down text a little */
987 i
= (int)(panel
->cycle
* 50.0/85.0)%200;
990 len
= strlen(panel
->str
);
992 strncpy(buffer
, panel
->str
, i
<len
? i
: len
);
994 memset(&buffer
[len
], ' ', i
-len
);
996 strncpy(buffer
, panel
->str
, i
<len
? i
: len
);
998 memset(&buffer
[len
], ' ', i
-len
);
1001 WMSetLabelText(panel
->versionL
, buffer
);
1003 XFlush(WMScreenDisplay(WMWidgetScreen(panel
->versionL
)));
1008 panel
->timer
= WMAddTimerHandler(50, logoPushCallback
, panel
);
1014 handleLogoPush(XEvent
*event
, void *data
)
1016 InfoPanel
*panel
= (InfoPanel
*)data
;
1017 static int broken
= 0;
1018 static int clicks
= 0;
1019 static char *pic_data
[] = {
1078 " ............... ",
1079 " ....XoO+@##+O$%.... ",
1080 " ...%X&*========-;;:o... ",
1081 " ...>.>,<122222222222134@... ",
1082 " ..>5678912222222222222220q%.. ",
1083 " ..$.&-w2222222222222222222er>.. ",
1084 " ..O.t31222222222222222222222y4>.. ",
1085 " ...O5u3222222222222222222222222yri... ",
1086 " ..>p&a22222222222222222222222222wso.. ",
1087 " ..ids91222222222222222222222222222wfi.. ",
1088 " ..X.7w222222wgs-w2222222213=g0222222<hi.. ",
1089 " ..Xuj2222222<@X5=222222229k@l:022222y4i.. ",
1090 " .Xdz22222222*X%.s22222222axo%$-222222<c>.. ",
1091 " ..o7y22222222v...r222222223hX.i82222221si.. ",
1092 "..io*222222222&...u22222222yt..%*22222220:%. ",
1093 "..>k02222222227...f222222222v..X=222222229t. ",
1094 "..dz12222222220ui:y2222222223d%qw222222221g. ",
1095 ".%vw222222222221y2222222222219*y2222222222wd.",
1096 ".X;2222222222222222222222222222222222222222b.",
1097 ".i*2222222222222222222222222222222222222222v.",
1098 ".i*2222222222222222222222222222222222222222;.",
1099 ".i*22222222222222222222222222222222222222228.",
1100 ".>*2222222222222222222222222222222222222222=.",
1101 ".i*22222222222222222222222222222222222222228.",
1102 ".i*2222222222222222222222222222222222222222;.",
1103 ".X*222222222222222222222222222222we12222222r.",
1104 ".Xs12222222w3aw22222222222222222y8s0222222wk.",
1105 ".Xq02222222a,na22222222222222222zm6zwy2222gi.",
1106 "..>*22222y<:Xcj22222222222222222-o$k;;02228..",
1107 "..i7y2220rhX.:y22222222222222222jtiXd,a220,..",
1108 " .X@z222a,do%kj2222222222222222wMX5q;gw228%..",
1109 " ..58222wagsh6ry222222222222221;>Of0w222y:...",
1110 " ...:e2222218mdz22222222222222a&$vw222220@...",
1111 " ...O-122222y:.u02222222222229q$uj222221r... ",
1112 " ..%&a1222223&573w2222222219NOxz122221z>... ",
1113 " ...t3222221-l$nr8ay1222yzbo,=12222w-5... ",
1114 " ..X:022222w-k+>o,7s**s7xOn=12221<f5... ",
1115 " ..o:9222221j8:&Bl>>>>ihv<12221=dX... ",
1116 " ..Xb9122222109g-****;<y22221zn%... ",
1117 " ..X&801222222222222222222w-h.... ",
1118 " ...o:=022222222222222221=lX... ",
1119 " ..X@:;3w2222222222210fO... ",
1120 " ...XX&v8<30000003-N@... ",
1121 " .....XmnbN:q&Bo.... ",
1124 static char *msgs
[] = {
1126 "Focus follow mouse users will burn in hell!!!",
1128 "Hi! My name is bobby...",
1129 "AHH! The neurotic monkeys are after me!",
1131 "HOW ARE YOU GENTLEMEN?",
1133 "SOMEBODY SET UP US THE BOMB",
1134 "ALL YOUR BASE ARE BELONG TO US!",
1135 "Oh My God!!! Larry is back!"
1141 if (!panel
->timer
&& !broken
&& clicks
> 0) {
1147 panel
->icon
= WMGetApplicationIconImage(panel
->scr
->wmscreen
);
1154 color
.red
= 0xae; color
.green
= 0xaa;
1155 color
.blue
= 0xae; color
.alpha
= 0;
1157 panel
->icon
= RCloneImage(panel
->icon
);
1158 RCombineImageWithColor(panel
->icon
, &color
);
1162 panel
->pic
= RGetImageFromXPMData(panel
->scr
->rcontext
, pic_data
);
1165 RReleaseImage(panel
->icon
);
1171 panel
->str
= msgs
[rand()%(sizeof(msgs
)/sizeof(char*))];
1173 panel
->timer
= WMAddTimerHandler(50, logoPushCallback
, panel
);
1175 panel
->oldPix
= WMRetainPixmap(WMGetLabelImage(panel
->logoL
));
1176 /* If we don't use a fixed font, scrolling will be jumpy */
1177 /* Alternatively we can draw text in a pixmap and scroll it smoothly */
1178 if ((panel
->oldFont
= WMGetLabelFont(panel
->versionL
))!=NULL
)
1179 WMRetainFont(panel
->oldFont
);
1180 font
= WMCreateFont(WMWidgetScreen(panel
->versionL
), "-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*");
1182 WMSetLabelFont(panel
->versionL
, font
);
1183 WMReleaseFont(font
);
1185 WMSetLabelText(panel
->versionL
, "");
1186 } else if (panel
->timer
) {
1191 WMSetLabelImage(panel
->logoL
, panel
->oldPix
);
1192 WMReleasePixmap(panel
->oldPix
);
1193 panel
->oldPix
= NULL
;
1195 WMDeleteTimerHandler(panel
->timer
);
1196 panel
->timer
= NULL
;
1198 WMSetLabelFont(panel
->versionL
, panel
->oldFont
);
1199 if (panel
->oldFont
) {
1200 WMReleaseFont(panel
->oldFont
);
1201 panel
->oldFont
= NULL
;
1203 snprintf(version
, sizeof(version
), _("Version %s"), VERSION
);
1204 WMSetLabelText(panel
->versionL
, version
);
1205 XFlush(WMScreenDisplay(WMWidgetScreen(panel
->versionL
)));
1210 while (XCheckTypedWindowEvent(dpy
, WMWidgetXID(panel
->versionL
),
1214 #endif /* SILLYNESS */
1218 wShowInfoPanel(WScreen
*scr
)
1224 char *strbuf
= NULL
;
1229 int i
, width
, sepWidth
;
1241 if (thePanel
->scr
== scr
) {
1242 wRaiseFrame(thePanel
->wwin
->frame
->core
);
1243 wSetFocusTo(scr
, thePanel
->wwin
);
1248 panel
= wmalloc(sizeof(InfoPanel
));
1249 memset(panel
, 0, sizeof(InfoPanel
));
1253 panel
->win
= WMCreateWindow(scr
->wmscreen
, "info");
1254 WMResizeWidget(panel
->win
, 390, 230);
1256 logo
= WMCreateApplicationIconBlendedPixmap(scr
->wmscreen
, (RColor
*)NULL
);
1258 logo
= WMRetainPixmap(WMGetApplicationIconPixmap(scr
->wmscreen
));
1261 size
= WMGetPixmapSize(logo
);
1262 panel
->logoL
= WMCreateLabel(panel
->win
);
1263 WMResizeWidget(panel
->logoL
, 64, 64);
1264 WMMoveWidget(panel
->logoL
, 30, 20);
1265 WMSetLabelImagePosition(panel
->logoL
, WIPImageOnly
);
1266 WMSetLabelImage(panel
->logoL
, logo
);
1268 WMCreateEventHandler(WMWidgetView(panel
->logoL
), ButtonPressMask
,
1269 handleLogoPush
, panel
);
1271 WMReleasePixmap(logo
);
1275 panel
->name1L
= WMCreateLabel(panel
->win
);
1276 WMResizeWidget(panel
->name1L
, 240, 30 - sepWidth
);
1277 WMMoveWidget(panel
->name1L
, 100, 30);
1279 if (WMIsAntialiasingEnabled(scr
->wmscreen
)) {
1280 font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 24);
1282 font
= WMCreateFont(scr
->wmscreen
, "-*-utopia-*-r-*-*-25-*");
1283 font
= font
? font
: WMBoldSystemFontOfSize(scr
->wmscreen
, 24);
1285 strbuf
= "Window Maker";
1287 width
= WMWidthOfString(font
, strbuf
, strlen(strbuf
));
1288 WMSetLabelFont(panel
->name1L
, font
);
1289 WMReleaseFont(font
);
1291 WMSetLabelTextAlignment(panel
->name1L
, WACenter
);
1292 WMSetLabelText(panel
->name1L
, strbuf
);
1294 panel
->lineF
= WMCreateFrame(panel
->win
);
1295 WMResizeWidget(panel
->lineF
, width
, sepWidth
);
1296 WMMoveWidget(panel
->lineF
, 100+(240-width
)/2, 60 - sepWidth
);
1297 WMSetFrameRelief(panel
->lineF
, WRSimple
);
1298 WMSetWidgetBackgroundColor(panel
->lineF
, scr
->black
);
1300 panel
->name2L
= WMCreateLabel(panel
->win
);
1301 WMResizeWidget(panel
->name2L
, 240, 24);
1302 WMMoveWidget(panel
->name2L
, 100, 60);
1303 font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 18);
1305 WMSetLabelFont(panel
->name2L
, font
);
1306 WMReleaseFont(font
);
1309 WMSetLabelTextAlignment(panel
->name2L
, WACenter
);
1310 WMSetLabelText(panel
->name2L
, _("Window Manager for X"));
1312 snprintf(buffer
, sizeof(buffer
), _("Version %s"), VERSION
);
1313 panel
->versionL
= WMCreateLabel(panel
->win
);
1314 WMResizeWidget(panel
->versionL
, 310, 16);
1315 WMMoveWidget(panel
->versionL
, 30, 95);
1316 WMSetLabelTextAlignment(panel
->versionL
, WARight
);
1317 WMSetLabelText(panel
->versionL
, buffer
);
1318 WMSetLabelWraps(panel
->versionL
, False
);
1320 panel
->copyrL
= WMCreateLabel(panel
->win
);
1321 WMResizeWidget(panel
->copyrL
, 360, 40);
1322 WMMoveWidget(panel
->copyrL
, 15, 185);
1323 WMSetLabelTextAlignment(panel
->copyrL
, WALeft
);
1324 WMSetLabelText(panel
->copyrL
, COPYRIGHT_TEXT
);
1325 /* we want the (c) character in the font, so don't use a FontSet here */
1326 font
= WMCreateFontWithFlags(scr
->wmscreen
, "SystemFont-11", WFNormalFont
);
1328 WMSetLabelFont(panel
->copyrL
, font
);
1329 WMReleaseFont(font
);
1334 snprintf(buffer
, sizeof(buffer
), _("Using visual 0x%x: %s %ibpp "),
1335 (unsigned)scr
->w_visual
->visualid
,
1336 visuals
[scr
->w_visual
->class], scr
->w_depth
);
1338 strbuf
= wstrappend(strbuf
, buffer
);
1340 switch (scr
->w_depth
) {
1342 strbuf
= wstrappend(strbuf
, _("(32 thousand colors)\n"));
1345 strbuf
= wstrappend(strbuf
, _("(64 thousand colors)\n"));
1349 strbuf
= wstrappend(strbuf
, _("(16 million colors)\n"));
1352 snprintf(buffer
, sizeof(buffer
), _("(%d colors)\n"), 1<<scr
->w_depth
);
1353 strbuf
= wstrappend(strbuf
, buffer
);
1358 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
1360 struct mallinfo ma
= mallinfo();
1361 snprintf(buffer
, sizeof(buffer
),
1362 _("Total allocated memory: %i kB. Total memory in use: %i kB.\n"),
1363 (ma
.arena
+ma
.hblkhd
)/1024, (ma
.uordblks
+ma
.hblkhd
)/1024);
1365 strbuf
= wstrappend(strbuf
, buffer
);
1369 strbuf
= wstrappend(strbuf
, _("Supported image formats: "));
1370 strl
= RSupportedFileFormats();
1371 for (i
=0; strl
[i
]!=NULL
; i
++) {
1372 strbuf
= wstrappend(strbuf
, strl
[i
]);
1373 strbuf
= wstrappend(strbuf
, " ");
1376 strbuf
= wstrappend(strbuf
, _("\nAdditional support for: "));
1389 list
[j
++] = "GNOME";
1396 for (i
= 0; i
< j
; i
++) {
1399 strcat(buf
, _(" and "));
1403 strcat(buf
, list
[i
]);
1405 strbuf
= wstrappend(strbuf
, buf
);
1408 if (wPreferences
.no_sound
) {
1409 strbuf
= wstrappend(strbuf
, _("\nSound disabled"));
1411 strbuf
= wstrappend(strbuf
, _("\nSound enabled"));
1415 panel
->infoL
= WMCreateLabel(panel
->win
);
1416 WMResizeWidget(panel
->infoL
, 350, 75);
1417 WMMoveWidget(panel
->infoL
, 15, 115);
1418 WMSetLabelText(panel
->infoL
, strbuf
);
1419 font
= WMSystemFontOfSize(scr
->wmscreen
, 11);
1421 WMSetLabelFont(panel
->infoL
, font
);
1422 WMReleaseFont(font
);
1428 WMRealizeWidget(panel
->win
);
1429 WMMapSubwidgets(panel
->win
);
1431 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 382, 230, 0, 0, 0);
1433 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1435 WMMapWidget(panel
->win
);
1438 WMPoint center
= getCenter(scr
, 382, 230);
1440 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Info"),
1445 WSETUFLAG(wwin
, no_closable
, 0);
1446 WSETUFLAG(wwin
, no_close_button
, 0);
1447 #ifdef XKB_BUTTON_HINT
1448 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1450 wWindowUpdateButtonImages(wwin
);
1451 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1452 wwin
->frame
->on_click_right
= destroyInfoPanel
;
1460 if (InitXThing(panel
->scr
)) {
1461 panel
->timer
= WMAddTimerHandler(100, logoPushCallback
, panel
);
1464 panel
->str
= _("Merry Christmas!");
1465 panel
->oldPix
= WMRetainPixmap(WMGetLabelImage(panel
->logoL
));
1472 ***********************************************************************
1474 ***********************************************************************
1488 static LegalPanel
*legalPanel
= NULL
;
1491 destroyLegalPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
1493 WMUnmapWidget(legalPanel
->win
);
1495 WMDestroyWidget(legalPanel
->win
);
1497 wUnmanageWindow(legalPanel
->wwin
, False
, False
);
1506 wShowLegalPanel(WScreen
*scr
)
1513 if (legalPanel
->scr
== scr
) {
1514 wRaiseFrame(legalPanel
->wwin
->frame
->core
);
1515 wSetFocusTo(scr
, legalPanel
->wwin
);
1520 panel
= wmalloc(sizeof(LegalPanel
));
1524 panel
->win
= WMCreateWindow(scr
->wmscreen
, "legal");
1525 WMResizeWidget(panel
->win
, 420, 250);
1528 panel
->licenseL
= WMCreateLabel(panel
->win
);
1529 WMSetLabelWraps(panel
->licenseL
, True
);
1530 WMResizeWidget(panel
->licenseL
, 400, 230);
1531 WMMoveWidget(panel
->licenseL
, 10, 10);
1532 WMSetLabelTextAlignment(panel
->licenseL
, WALeft
);
1533 WMSetLabelText(panel
->licenseL
,
1534 _(" Window Maker is free software; you can redistribute it and/or\n"
1535 "modify it under the terms of the GNU General Public License as\n"
1536 "published by the Free Software Foundation; either version 2 of the\n"
1537 "License, or (at your option) any later version.\n\n"
1538 " Window Maker is distributed in the hope that it will be useful,\n"
1539 "but WITHOUT ANY WARRANTY; without even the implied warranty\n"
1540 "of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
1541 "See the GNU General Public License for more details.\n\n"
1542 " You should have received a copy of the GNU General Public\n"
1543 "License along with this program; if not, write to the Free Software\n"
1544 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA\n"
1545 "02111-1307, USA."));
1546 WMSetLabelRelief(panel
->licenseL
, WRGroove
);
1548 WMRealizeWidget(panel
->win
);
1549 WMMapSubwidgets(panel
->win
);
1551 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 420, 250, 0, 0, 0);
1553 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1556 WMPoint center
= getCenter(scr
, 420, 250);
1558 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Legal"),
1563 WSETUFLAG(wwin
, no_closable
, 0);
1564 WSETUFLAG(wwin
, no_close_button
, 0);
1565 wWindowUpdateButtonImages(wwin
);
1566 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1567 #ifdef XKB_BUTTON_HINT
1568 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1570 wwin
->frame
->on_click_right
= destroyLegalPanel
;
1574 WMMapWidget(panel
->win
);
1583 ***********************************************************************
1584 * Crashing Dialog Panel
1585 ***********************************************************************
1588 extern WDDomain
*WDWindowAttributes
;
1591 typedef struct _CrashPanel
{
1592 WMWindow
*win
; /* main window */
1594 WMLabel
*iconL
; /* application icon */
1595 WMLabel
*nameL
; /* title of panel */
1597 WMFrame
*sepF
; /* separator frame */
1599 WMLabel
*noteL
; /* Title of note */
1600 WMLabel
*note2L
; /* body of note with what happened */
1602 WMFrame
*whatF
; /* "what to do next" frame */
1603 WMPopUpButton
*whatP
; /* action selection popup button */
1605 WMButton
*okB
; /* ok button */
1607 Bool done
; /* if finished with this dialog */
1608 int action
; /* what to do after */
1616 handleKeyPress(XEvent
*event
, void *clientData
)
1618 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1620 if (event
->xkey
.keycode
== panel
->retKey
) {
1621 WMPerformButtonClick(panel
->okB
);
1627 okButtonCallback(void *self
, void *clientData
)
1629 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1636 setCrashAction(void *self
, void *clientData
)
1638 WMPopUpButton
*pop
= (WMPopUpButton
*)self
;
1639 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1641 panel
->action
= WMGetPopUpButtonSelectedItem(pop
);
1646 getWindowMakerIconImage(WMScreen
*scr
)
1648 WMPropList
*dict
, *key
, *option
, *value
=NULL
;
1652 WMPLSetCaseSensitive(True
);
1654 key
= WMCreatePLString("Logo.WMPanel");
1655 option
= WMCreatePLString("Icon");
1657 dict
= WMGetFromPLDictionary(WDWindowAttributes
->dictionary
, key
);
1660 value
= WMGetFromPLDictionary(dict
, option
);
1663 WMReleasePropList(key
);
1664 WMReleasePropList(option
);
1666 WMPLSetCaseSensitive(False
);
1668 if (value
&& WMIsPLString(value
)) {
1669 path
= FindImage(wPreferences
.icon_path
, WMGetFromPLString(value
));
1674 gray
.red
= 0xae; gray
.green
= 0xaa;
1675 gray
.blue
= 0xae; gray
.alpha
= 0;
1677 pix
= WMCreateBlendedPixmapFromFile(scr
, path
, &gray
);
1691 wShowCrashingDialogPanel(int whatSig
)
1697 int screen_no
, scr_width
, scr_height
;
1701 panel
= wmalloc(sizeof(CrashPanel
));
1702 memset(panel
, 0, sizeof(CrashPanel
));
1704 screen_no
= DefaultScreen(dpy
);
1705 scr_width
= WidthOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1706 scr_height
= HeightOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1708 scr
= WMCreateScreen(dpy
, screen_no
);
1710 wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
1714 panel
->retKey
= XKeysymToKeycode(dpy
, XK_Return
);
1716 panel
->win
= WMCreateWindow(scr
, "crashingDialog");
1717 WMResizeWidget(panel
->win
, PWIDTH
, PHEIGHT
);
1718 WMMoveWidget(panel
->win
, (scr_width
- PWIDTH
)/2, (scr_height
- PHEIGHT
)/2);
1720 logo
= getWindowMakerIconImage(scr
);
1722 panel
->iconL
= WMCreateLabel(panel
->win
);
1723 WMResizeWidget(panel
->iconL
, 64, 64);
1724 WMMoveWidget(panel
->iconL
, 10, 10);
1725 WMSetLabelImagePosition(panel
->iconL
, WIPImageOnly
);
1726 WMSetLabelImage(panel
->iconL
, logo
);
1729 panel
->nameL
= WMCreateLabel(panel
->win
);
1730 WMResizeWidget(panel
->nameL
, 190, 18);
1731 WMMoveWidget(panel
->nameL
, 80, 35);
1732 WMSetLabelTextAlignment(panel
->nameL
, WALeft
);
1733 font
= WMBoldSystemFontOfSize(scr
, 18);
1734 WMSetLabelFont(panel
->nameL
, font
);
1735 WMReleaseFont(font
);
1736 WMSetLabelText(panel
->nameL
, _("Fatal error"));
1738 panel
->sepF
= WMCreateFrame(panel
->win
);
1739 WMResizeWidget(panel
->sepF
, PWIDTH
+4, 2);
1740 WMMoveWidget(panel
->sepF
, -2, 80);
1742 panel
->noteL
= WMCreateLabel(panel
->win
);
1743 WMResizeWidget(panel
->noteL
, PWIDTH
-20, 40);
1744 WMMoveWidget(panel
->noteL
, 10, 90);
1745 WMSetLabelTextAlignment(panel
->noteL
, WAJustified
);
1746 #ifdef SYS_SIGLIST_DECLARED
1747 snprintf(buf
, sizeof(buf
), _("Window Maker received signal %i\n(%s)."),
1748 whatSig
, sys_siglist
[whatSig
]);
1750 snprintf(buf
, sizeof(buf
), _("Window Maker received signal %i."), whatSig
);
1752 WMSetLabelText(panel
->noteL
, buf
);
1754 panel
->note2L
= WMCreateLabel(panel
->win
);
1755 WMResizeWidget(panel
->note2L
, PWIDTH
-20, 100);
1756 WMMoveWidget(panel
->note2L
, 10, 130);
1757 WMSetLabelTextAlignment(panel
->note2L
, WALeft
);
1758 WMSetLabelText(panel
->note2L
,
1759 _(" This fatal error occured probably due to a bug."
1760 " Please fill the included BUGFORM and "
1761 "report it to bugs@windowmaker.org."));
1762 WMSetLabelWraps(panel
->note2L
, True
);
1765 panel
->whatF
= WMCreateFrame(panel
->win
);
1766 WMResizeWidget(panel
->whatF
, PWIDTH
-20, 50);
1767 WMMoveWidget(panel
->whatF
, 10, 240);
1768 WMSetFrameTitle(panel
->whatF
, _("What do you want to do now?"));
1770 panel
->whatP
= WMCreatePopUpButton(panel
->whatF
);
1771 WMResizeWidget(panel
->whatP
, PWIDTH
-20-70, 20);
1772 WMMoveWidget(panel
->whatP
, 35, 20);
1773 WMSetPopUpButtonPullsDown(panel
->whatP
, False
);
1774 WMSetPopUpButtonText(panel
->whatP
, _("Select action"));
1775 WMAddPopUpButtonItem(panel
->whatP
, _("Abort and leave a core file"));
1776 WMAddPopUpButtonItem(panel
->whatP
, _("Restart Window Maker"));
1777 WMAddPopUpButtonItem(panel
->whatP
, _("Start alternate window manager"));
1778 WMSetPopUpButtonAction(panel
->whatP
, setCrashAction
, panel
);
1779 WMSetPopUpButtonSelectedItem(panel
->whatP
, WMRestart
);
1780 panel
->action
= WMRestart
;
1782 WMMapSubwidgets(panel
->whatF
);
1784 panel
->okB
= WMCreateCommandButton(panel
->win
);
1785 WMResizeWidget(panel
->okB
, 80, 26);
1786 WMMoveWidget(panel
->okB
, 205, 309);
1787 WMSetButtonText(panel
->okB
, _("OK"));
1788 WMSetButtonImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIReturnArrow
));
1789 WMSetButtonAltImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIHighlightedReturnArrow
));
1790 WMSetButtonImagePosition(panel
->okB
, WIPRight
);
1791 WMSetButtonAction(panel
->okB
, okButtonCallback
, panel
);
1795 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
,
1796 handleKeyPress
, panel
);
1798 WMRealizeWidget(panel
->win
);
1799 WMMapSubwidgets(panel
->win
);
1801 WMMapWidget(panel
->win
);
1803 XSetInputFocus(dpy
, WMWidgetXID(panel
->win
), RevertToParent
, CurrentTime
);
1805 while (!panel
->done
) {
1808 WMNextEvent(dpy
, &event
);
1809 WMHandleEvent(&event
);
1812 action
= panel
->action
;
1814 WMUnmapWidget(panel
->win
);
1815 WMDestroyWidget(panel
->win
);
1824 /*****************************************************************************
1825 * About GNUstep Panel
1826 *****************************************************************************/
1830 drawGNUstepLogo(Display
*dpy
, Drawable d
, int width
, int height
,
1831 unsigned long blackPixel
, unsigned long whitePixel
)
1835 XRectangle rects
[3];
1837 gcv
.foreground
= blackPixel
;
1838 gc
= XCreateGC(dpy
, d
, GCForeground
, &gcv
);
1840 XFillArc(dpy
, d
, gc
, width
/45, height
/45,
1841 width
- 2*width
/45, height
- 2*height
/45, 0, 360*64);
1844 rects
[0].y
= 37*height
/45;
1845 rects
[0].width
= width
/3;
1846 rects
[0].height
= height
- rects
[0].y
;
1848 rects
[1].x
= rects
[0].width
;
1849 rects
[1].y
= height
/2;
1850 rects
[1].width
= width
- 2*width
/3;
1851 rects
[1].height
= height
- rects
[1].y
;
1853 rects
[2].x
= 2*width
/3;
1854 rects
[2].y
= height
- 37*height
/45;
1855 rects
[2].width
= width
/3;
1856 rects
[2].height
= height
- rects
[2].y
;
1858 XSetClipRectangles(dpy
, gc
, 0, 0, rects
, 3, Unsorted
);
1859 XFillRectangle(dpy
, d
, gc
, 0, 0, width
, height
);
1861 XSetForeground(dpy
, gc
, whitePixel
);
1862 XFillArc(dpy
, d
, gc
, width
/45, height
/45,
1863 width
- 2*width
/45, height
- 2*height
/45, 0, 360*64);
1881 static GNUstepPanel
*gnustepPanel
= NULL
;
1884 destroyGNUstepPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
1886 WMUnmapWidget(gnustepPanel
->win
);
1888 WMDestroyWidget(gnustepPanel
->win
);
1890 wUnmanageWindow(gnustepPanel
->wwin
, False
, False
);
1892 wfree(gnustepPanel
);
1894 gnustepPanel
= NULL
;
1899 wShowGNUstepPanel(WScreen
*scr
)
1901 GNUstepPanel
*panel
;
1908 if (gnustepPanel
->scr
== scr
) {
1909 wRaiseFrame(gnustepPanel
->wwin
->frame
->core
);
1910 wSetFocusTo(scr
, gnustepPanel
->wwin
);
1915 panel
= wmalloc(sizeof(GNUstepPanel
));
1919 panel
->win
= WMCreateWindow(scr
->wmscreen
, "About GNUstep");
1920 WMResizeWidget(panel
->win
, 325, 200);
1922 pixmap
= WMCreatePixmap(scr
->wmscreen
, 130, 130,
1923 WMScreenDepth(scr
->wmscreen
), True
);
1925 color
= WMCreateNamedColor(scr
->wmscreen
, "gray50", True
);
1927 drawGNUstepLogo(dpy
, WMGetPixmapXID(pixmap
), 130, 130,
1928 WMColorPixel(color
), scr
->white_pixel
);
1930 WMReleaseColor(color
);
1932 XSetForeground(dpy
, scr
->mono_gc
, 0);
1933 XFillRectangle(dpy
, WMGetPixmapMaskXID(pixmap
), scr
->mono_gc
, 0, 0,
1935 drawGNUstepLogo(dpy
, WMGetPixmapMaskXID(pixmap
), 130, 130, 1, 1);
1937 panel
->gstepL
= WMCreateLabel(panel
->win
);
1938 WMResizeWidget(panel
->gstepL
, 285, 64);
1939 WMMoveWidget(panel
->gstepL
, 20, 0);
1940 WMSetLabelTextAlignment(panel
->gstepL
, WARight
);
1941 WMSetLabelText(panel
->gstepL
, "GNUstep");
1943 WMFont
*font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 24);
1945 WMSetLabelFont(panel
->gstepL
, font
);
1946 WMReleaseFont(font
);
1949 panel
->textL
= WMCreateLabel(panel
->win
);
1950 WMResizeWidget(panel
->textL
, 275, 130);
1951 WMMoveWidget(panel
->textL
, 30, 50);
1952 WMSetLabelTextAlignment(panel
->textL
, WARight
);
1953 WMSetLabelImagePosition(panel
->textL
, WIPOverlaps
);
1954 WMSetLabelText(panel
->textL
,
1955 _("Window Maker is part of the GNUstep project.\n"\
1956 "The GNUstep project aims to create a free\n"\
1957 "implementation of the OpenStep(tm) specification\n"\
1958 "which is a object-oriented framework for\n"\
1959 "creating advanced graphical, multi-platform\n"\
1960 "applications. Additionally, a development and\n"\
1961 "user desktop enviroment will be created on top\n"\
1962 "of the framework. For more information about\n"\
1963 "GNUstep, please visit: www.gnustep.org"));
1964 WMSetLabelImage(panel
->textL
, pixmap
);
1966 WMReleasePixmap(pixmap
);
1968 WMRealizeWidget(panel
->win
);
1969 WMMapSubwidgets(panel
->win
);
1971 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 325, 200, 0, 0, 0);
1973 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1976 WMPoint center
= getCenter(scr
, 325, 200);
1978 wwin
= wManageInternalWindow(scr
, parent
, None
, _("About GNUstep"),
1983 WSETUFLAG(wwin
, no_closable
, 0);
1984 WSETUFLAG(wwin
, no_close_button
, 0);
1985 wWindowUpdateButtonImages(wwin
);
1986 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1987 #ifdef XKB_BUTTON_HINT
1988 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1990 wwin
->frame
->on_click_right
= destroyGNUstepPanel
;
1994 WMMapWidget(panel
->win
);
1998 gnustepPanel
= panel
;