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>
49 #define PATH_MAX DEFAULT_PATH_MAX
52 #include "WindowMaker.h"
64 extern WPreferences wPreferences
;
66 static WMPoint
getCenter(WScreen
* scr
, int width
, int height
)
68 return wGetPointToCenterRectInHead(scr
, wGetHeadForPointerLocation(scr
), width
, height
);
71 int wMessageDialog(WScreen
* scr
, char *title
, char *message
, char *defBtn
, char *altBtn
, char *othBtn
)
79 panel
= WMCreateAlertPanel(scr
->wmscreen
, NULL
, title
, message
, 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 center
= getCenter(scr
, 400, 180);
86 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
, 400, 180);
87 wwin
->client_leader
= WMWidgetXID(panel
->win
);
89 WMMapWidget(panel
->win
);
93 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
95 result
= panel
->result
;
97 WMUnmapWidget(panel
->win
);
99 wUnmanageWindow(wwin
, False
, False
);
101 WMDestroyAlertPanel(panel
);
103 XDestroyWindow(dpy
, parent
);
108 void toggleSaveSession(WMWidget
* w
, void *data
)
110 wPreferences
.save_session_on_exit
= WMGetButtonSelected((WMButton
*) w
);
113 int wExitDialog(WScreen
* scr
, char *title
, char *message
, char *defBtn
, char *altBtn
, char *othBtn
)
116 WMButton
*saveSessionBtn
;
122 panel
= WMCreateAlertPanel(scr
->wmscreen
, NULL
, title
, message
, defBtn
, altBtn
, othBtn
);
124 /* add save session button */
125 saveSessionBtn
= WMCreateSwitchButton(panel
->hbox
);
126 WMSetButtonAction(saveSessionBtn
, toggleSaveSession
, NULL
);
127 WMAddBoxSubview(panel
->hbox
, WMWidgetView(saveSessionBtn
), False
, True
, 200, 0, 0);
128 WMSetButtonText(saveSessionBtn
, _("Save workspace state"));
129 WMSetButtonSelected(saveSessionBtn
, wPreferences
.save_session_on_exit
);
130 WMRealizeWidget(saveSessionBtn
);
131 WMMapWidget(saveSessionBtn
);
133 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 400, 180, 0, 0, 0);
135 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
137 center
= getCenter(scr
, 400, 180);
138 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
, 400, 180);
140 wwin
->client_leader
= WMWidgetXID(panel
->win
);
142 WMMapWidget(panel
->win
);
146 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
148 result
= panel
->result
;
150 WMUnmapWidget(panel
->win
);
152 wUnmanageWindow(wwin
, False
, False
);
154 WMDestroyAlertPanel(panel
);
156 XDestroyWindow(dpy
, parent
);
161 int wInputDialog(WScreen
* scr
, char *title
, char *message
, char **text
)
169 panel
= WMCreateInputPanel(scr
->wmscreen
, NULL
, title
, message
, *text
, _("OK"), _("Cancel"));
171 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 320, 160, 0, 0, 0);
172 XSelectInput(dpy
, parent
, KeyPressMask
| KeyReleaseMask
);
174 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
176 center
= getCenter(scr
, 320, 160);
177 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
, 320, 160);
179 wwin
->client_leader
= WMWidgetXID(panel
->win
);
181 WMMapWidget(panel
->win
);
185 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
187 if (panel
->result
== WAPRDefault
)
188 result
= WMGetTextFieldText(panel
->text
);
192 wUnmanageWindow(wwin
, False
, False
);
194 WMDestroyInputPanel(panel
);
196 XDestroyWindow(dpy
, parent
);
210 *****************************************************************
211 * Icon Selection Panel
212 *****************************************************************
215 typedef struct IconPanel
{
228 WMButton
*previewButton
;
233 WMTextField
*fileField
;
236 WMButton
*cancelButton
;
238 WMButton
*chooseButton
;
245 static void listPixmaps(WScreen
* scr
, WMList
* lPtr
, char *path
)
247 struct dirent
*dentry
;
249 char pbuf
[PATH_MAX
+ 16];
251 IconPanel
*panel
= WMGetHangedData(lPtr
);
253 panel
->preview
= False
;
255 apath
= wexpandpath(path
);
256 dir
= opendir(apath
);
261 tmp
= _("Could not open directory ");
262 msg
= wmalloc(strlen(tmp
) + strlen(path
) + 6);
266 wMessageDialog(scr
, _("Error"), msg
, _("OK"), NULL
, NULL
);
272 /* list contents in the column */
273 while ((dentry
= readdir(dir
))) {
276 if (strcmp(dentry
->d_name
, ".") == 0 || strcmp(dentry
->d_name
, "..") == 0)
281 strcat(pbuf
, dentry
->d_name
);
283 if (stat(pbuf
, &statb
) < 0)
286 if (statb
.st_mode
& (S_IRUSR
| S_IRGRP
| S_IROTH
)
287 && statb
.st_mode
& (S_IFREG
| S_IFLNK
)) {
288 WMAddListItem(lPtr
, dentry
->d_name
);
291 WMSortListItems(lPtr
);
295 panel
->preview
= True
;
298 static void setViewedImage(IconPanel
* panel
, char *file
)
307 pixmap
= WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel
->win
), file
, &color
);
309 WMSetButtonEnabled(panel
->okButton
, False
);
311 WMSetLabelText(panel
->iconView
, _("Could not load image file "));
313 WMSetLabelImage(panel
->iconView
, NULL
);
315 WMSetButtonEnabled(panel
->okButton
, True
);
317 WMSetLabelText(panel
->iconView
, NULL
);
318 WMSetLabelImage(panel
->iconView
, pixmap
);
319 WMReleasePixmap(pixmap
);
323 static void listCallback(void *self
, void *data
)
325 WMList
*lPtr
= (WMList
*) self
;
326 IconPanel
*panel
= (IconPanel
*) data
;
329 if (lPtr
== panel
->dirList
) {
330 WMListItem
*item
= WMGetListSelectedItem(lPtr
);
336 WMSetTextFieldText(panel
->fileField
, path
);
338 WMSetLabelImage(panel
->iconView
, NULL
);
340 WMSetButtonEnabled(panel
->okButton
, False
);
342 WMClearList(panel
->iconList
);
343 listPixmaps(panel
->scr
, panel
->iconList
, path
);
345 char *tmp
, *iconFile
;
346 WMListItem
*item
= WMGetListSelectedItem(panel
->dirList
);
351 tmp
= wexpandpath(path
);
353 item
= WMGetListSelectedItem(panel
->iconList
);
356 iconFile
= item
->text
;
358 path
= wmalloc(strlen(tmp
) + strlen(iconFile
) + 4);
361 strcat(path
, iconFile
);
363 WMSetTextFieldText(panel
->fileField
, path
);
364 setViewedImage(panel
, path
);
369 static void listIconPaths(WMList
* lPtr
)
374 paths
= wstrdup(wPreferences
.icon_path
);
376 path
= strtok(paths
, ":");
381 tmp
= wexpandpath(path
);
382 /* do not sort, because the order implies the order of
383 * directories searched */
384 if (access(tmp
, X_OK
) == 0)
385 WMAddListItem(lPtr
, path
);
387 } while ((path
= strtok(NULL
, ":")) != NULL
);
392 static void drawIconProc(WMList
* lPtr
, int index
, Drawable d
, char *text
, int state
, WMRect
* rect
)
394 IconPanel
*panel
= WMGetHangedData(lPtr
);
395 WScreen
*scr
= panel
->scr
;
396 GC gc
= scr
->draw_gc
;
397 GC copygc
= scr
->copy_gc
;
398 char *file
, *dirfile
;
402 WMScreen
*wmscr
= WMWidgetScreen(panel
->win
);
404 int x
, y
, width
, height
, len
;
411 width
= rect
->size
.width
;
412 height
= rect
->size
.height
;
414 back
= (state
& WLDSSelected
) ? scr
->white
: scr
->gray
;
416 dirfile
= wexpandpath(WMGetListSelectedItem(panel
->dirList
)->text
);
417 len
= strlen(dirfile
) + strlen(text
) + 4;
419 snprintf(file
, len
, "%s/%s", dirfile
, text
);
422 color
.red
= WMRedComponentOfColor(back
) >> 8;
423 color
.green
= WMGreenComponentOfColor(back
) >> 8;
424 color
.blue
= WMBlueComponentOfColor(back
) >> 8;
425 color
.alpha
= WMGetColorAlpha(back
) >> 8;
427 pixmap
= WMCreateBlendedPixmapFromFile(wmscr
, file
, &color
);
431 /*WMRemoveListItem(lPtr, index); */
435 XFillRectangle(dpy
, d
, WMColorGC(back
), x
, y
, width
, height
);
437 XSetClipMask(dpy
, gc
, None
);
438 /*XDrawRectangle(dpy, d, WMColorGC(white), x+5, y+5, width-10, 54); */
439 XDrawLine(dpy
, d
, WMColorGC(scr
->white
), x
, y
+ height
- 1, x
+ width
, y
+ height
- 1);
441 size
= WMGetPixmapSize(pixmap
);
443 XSetClipMask(dpy
, copygc
, WMGetPixmapMaskXID(pixmap
));
444 XSetClipOrigin(dpy
, copygc
, x
+ (width
- size
.width
) / 2, y
+ 2);
445 XCopyArea(dpy
, WMGetPixmapXID(pixmap
), d
, copygc
, 0, 0,
446 size
.width
> 100 ? 100 : size
.width
, size
.height
> 64 ? 64 : size
.height
,
447 x
+ (width
- size
.width
) / 2, y
+ 2);
451 int fheight
= WMFontHeight(panel
->normalfont
);
452 int tlen
= strlen(text
);
453 int twidth
= WMWidthOfString(panel
->normalfont
, text
, tlen
);
456 ofx
= x
+ (width
- twidth
) / 2;
457 ofy
= y
+ 64 - fheight
;
459 for (i
= -1; i
< 2; i
++)
460 for (j
= -1; j
< 2; j
++)
461 WMDrawString(wmscr
, d
, scr
->white
, panel
->normalfont
,
462 ofx
+ i
, ofy
+ j
, text
, tlen
);
464 WMDrawString(wmscr
, d
, scr
->black
, panel
->normalfont
, ofx
, ofy
, text
, tlen
);
467 WMReleasePixmap(pixmap
);
468 /* I hope it is better to do not use cache / on my box it is fast nuff */
472 static void buttonCallback(void *self
, void *clientData
)
474 WMButton
*bPtr
= (WMButton
*) self
;
475 IconPanel
*panel
= (IconPanel
*) clientData
;
477 if (bPtr
== panel
->okButton
) {
479 panel
->result
= True
;
480 } else if (bPtr
== panel
->cancelButton
) {
482 panel
->result
= False
;
483 } else if (bPtr
== panel
->previewButton
) {
484 /**** Previewer ****/
485 WMSetButtonEnabled(bPtr
, False
);
486 WMSetListUserDrawItemHeight(panel
->iconList
, 68);
487 WMSetListUserDrawProc(panel
->iconList
, drawIconProc
);
488 WMRedisplayWidget(panel
->iconList
);
489 /* for draw proc to access screen/gc */
490 /*** end preview ***/
493 else if (bPtr
== panel
->chooseButton
) {
496 op
= WMCreateOpenPanel(WMWidgetScreen(bPtr
));
498 if (WMRunModalFilePanelForDirectory(op
, NULL
, "/usr/local", NULL
, NULL
)) {
500 path
= WMGetFilePanelFile(op
);
501 WMSetTextFieldText(panel
->fileField
, path
);
502 setViewedImage(panel
, path
);
505 WMDestroyFilePanel(op
);
510 static void keyPressHandler(XEvent
* event
, void *data
)
512 IconPanel
*panel
= (IconPanel
*) data
;
521 if (event
->type
== KeyRelease
)
525 count
= XLookupString(&event
->xkey
, buffer
, sizeof(buffer
), &ksym
, NULL
);
527 iidx
= WMGetListSelectedItemRow(panel
->iconList
);
528 didx
= WMGetListSelectedItemRow(panel
->dirList
);
536 list
= panel
->iconList
;
539 if (iidx
< WMGetListNumberOfRows(panel
->iconList
) - 1)
543 list
= panel
->iconList
;
547 list
= panel
->iconList
;
550 item
= WMGetListNumberOfRows(panel
->iconList
) - 1;
551 list
= panel
->iconList
;
554 if (didx
< WMGetListNumberOfRows(panel
->dirList
) - 1)
558 list
= panel
->dirList
;
565 list
= panel
->dirList
;
568 WMPerformButtonClick(panel
->okButton
);
571 WMPerformButtonClick(panel
->cancelButton
);
576 WMSelectListItem(list
, item
);
577 WMSetListPosition(list
, item
- 5);
578 listCallback(list
, panel
);
582 Bool
wIconChooserDialog(WScreen
* scr
, char **file
, char *instance
, char *class)
591 panel
= wmalloc(sizeof(IconPanel
));
592 memset(panel
, 0, sizeof(IconPanel
));
596 panel
->win
= WMCreateWindow(scr
->wmscreen
, "iconChooser");
597 WMResizeWidget(panel
->win
, 450, 280);
599 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
| KeyReleaseMask
, keyPressHandler
, panel
);
601 boldFont
= WMBoldSystemFontOfSize(scr
->wmscreen
, 12);
602 panel
->normalfont
= WMSystemFontOfSize(WMWidgetScreen(panel
->win
), 12);
604 panel
->dirLabel
= WMCreateLabel(panel
->win
);
605 WMResizeWidget(panel
->dirLabel
, 200, 20);
606 WMMoveWidget(panel
->dirLabel
, 10, 7);
607 WMSetLabelText(panel
->dirLabel
, _("Directories"));
608 WMSetLabelFont(panel
->dirLabel
, boldFont
);
609 WMSetLabelTextAlignment(panel
->dirLabel
, WACenter
);
611 WMSetLabelRelief(panel
->dirLabel
, WRSunken
);
613 panel
->iconLabel
= WMCreateLabel(panel
->win
);
614 WMResizeWidget(panel
->iconLabel
, 140, 20);
615 WMMoveWidget(panel
->iconLabel
, 215, 7);
616 WMSetLabelText(panel
->iconLabel
, _("Icons"));
617 WMSetLabelFont(panel
->iconLabel
, boldFont
);
618 WMSetLabelTextAlignment(panel
->iconLabel
, WACenter
);
620 WMReleaseFont(boldFont
);
622 color
= WMWhiteColor(scr
->wmscreen
);
623 WMSetLabelTextColor(panel
->dirLabel
, color
);
624 WMSetLabelTextColor(panel
->iconLabel
, color
);
625 WMReleaseColor(color
);
627 color
= WMDarkGrayColor(scr
->wmscreen
);
628 WMSetWidgetBackgroundColor(panel
->iconLabel
, color
);
629 WMSetWidgetBackgroundColor(panel
->dirLabel
, color
);
630 WMReleaseColor(color
);
632 WMSetLabelRelief(panel
->iconLabel
, WRSunken
);
634 panel
->dirList
= WMCreateList(panel
->win
);
635 WMResizeWidget(panel
->dirList
, 200, 170);
636 WMMoveWidget(panel
->dirList
, 10, 30);
637 WMSetListAction(panel
->dirList
, listCallback
, panel
);
639 panel
->iconList
= WMCreateList(panel
->win
);
640 WMResizeWidget(panel
->iconList
, 140, 170);
641 WMMoveWidget(panel
->iconList
, 215, 30);
642 WMSetListAction(panel
->iconList
, listCallback
, panel
);
644 WMHangData(panel
->iconList
, panel
);
646 panel
->previewButton
= WMCreateCommandButton(panel
->win
);
647 WMResizeWidget(panel
->previewButton
, 75, 26);
648 WMMoveWidget(panel
->previewButton
, 365, 130);
649 WMSetButtonText(panel
->previewButton
, _("Preview"));
650 WMSetButtonAction(panel
->previewButton
, buttonCallback
, panel
);
652 panel
->iconView
= WMCreateLabel(panel
->win
);
653 WMResizeWidget(panel
->iconView
, 75, 75);
654 WMMoveWidget(panel
->iconView
, 365, 40);
655 WMSetLabelImagePosition(panel
->iconView
, WIPOverlaps
);
656 WMSetLabelRelief(panel
->iconView
, WRSunken
);
657 WMSetLabelTextAlignment(panel
->iconView
, WACenter
);
659 panel
->fileLabel
= WMCreateLabel(panel
->win
);
660 WMResizeWidget(panel
->fileLabel
, 80, 20);
661 WMMoveWidget(panel
->fileLabel
, 10, 210);
662 WMSetLabelText(panel
->fileLabel
, _("File Name:"));
664 panel
->fileField
= WMCreateTextField(panel
->win
);
665 WMSetViewNextResponder(WMWidgetView(panel
->fileField
), WMWidgetView(panel
->win
));
666 WMResizeWidget(panel
->fileField
, 345, 20);
667 WMMoveWidget(panel
->fileField
, 95, 210);
668 WMSetTextFieldEditable(panel
->fileField
, False
);
670 panel
->okButton
= WMCreateCommandButton(panel
->win
);
671 WMResizeWidget(panel
->okButton
, 80, 26);
672 WMMoveWidget(panel
->okButton
, 360, 240);
673 WMSetButtonText(panel
->okButton
, _("OK"));
674 WMSetButtonEnabled(panel
->okButton
, False
);
675 WMSetButtonAction(panel
->okButton
, buttonCallback
, panel
);
677 panel
->cancelButton
= WMCreateCommandButton(panel
->win
);
678 WMResizeWidget(panel
->cancelButton
, 80, 26);
679 WMMoveWidget(panel
->cancelButton
, 270, 240);
680 WMSetButtonText(panel
->cancelButton
, _("Cancel"));
681 WMSetButtonAction(panel
->cancelButton
, buttonCallback
, panel
);
683 panel
->chooseButton
= WMCreateCommandButton(panel
->win
);
684 WMResizeWidget(panel
->chooseButton
, 110, 26);
685 WMMoveWidget(panel
->chooseButton
, 150, 240);
686 WMSetButtonText(panel
->chooseButton
, _("Choose File"));
687 WMSetButtonAction(panel
->chooseButton
, buttonCallback
, panel
);
689 WMRealizeWidget(panel
->win
);
690 WMMapSubwidgets(panel
->win
);
692 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 450, 280, 0, 0, 0);
694 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
698 int len
= (instance
? strlen(instance
) : 0)
699 + (class ? strlen(class) : 0) + 32;
704 if (tmp
&& (instance
|| class))
705 snprintf(tmp
, len
, "%s [%s.%s]", _("Icon Chooser"), instance
, class);
707 strcpy(tmp
, _("Icon Chooser"));
709 center
= getCenter(scr
, 450, 280);
711 wwin
= wManageInternalWindow(scr
, parent
, None
, tmp
, center
.x
, center
.y
, 450, 280);
715 /* put icon paths in the list */
716 listIconPaths(panel
->dirList
);
718 WMMapWidget(panel
->win
);
722 while (!panel
->done
) {
725 WMNextEvent(dpy
, &event
);
726 WMHandleEvent(&event
);
730 char *defaultPath
, *wantedPath
;
732 /* check if the file the user selected is not the one that
733 * would be loaded by default with the current search path */
734 *file
= WMGetListSelectedItem(panel
->iconList
)->text
;
739 defaultPath
= FindImage(wPreferences
.icon_path
, *file
);
740 wantedPath
= WMGetTextFieldText(panel
->fileField
);
741 /* if the file is not the default, use full path */
742 if (strcmp(wantedPath
, defaultPath
) != 0) {
745 *file
= wstrdup(*file
);
754 result
= panel
->result
;
756 WMReleaseFont(panel
->normalfont
);
758 WMUnmapWidget(panel
->win
);
760 WMDestroyWidget(panel
->win
);
762 wUnmanageWindow(wwin
, False
, False
);
766 XDestroyWindow(dpy
, parent
);
772 ***********************************************************************
774 ***********************************************************************
807 #define COPYRIGHT_TEXT \
808 "Copyright \xc2\xa9 1997-2006 Alfredo K. Kojima\n"\
809 "Copyright \xc2\xa9 1998-2006 Dan Pascu"
811 static InfoPanel
*thePanel
= NULL
;
813 static void destroyInfoPanel(WCoreWindow
* foo
, void *data
, XEvent
* event
)
816 if (thePanel
->timer
) {
817 WMDeleteTimerHandler(thePanel
->timer
);
819 if (thePanel
->oldPix
) {
820 WMReleasePixmap(thePanel
->oldPix
);
822 if (thePanel
->oldFont
) {
823 WMReleaseFont(thePanel
->oldFont
);
825 if (thePanel
->icon
) {
826 RReleaseImage(thePanel
->icon
);
829 RReleaseImage(thePanel
->pic
);
831 #endif /* SILLYNESS */
832 WMUnmapWidget(thePanel
);
834 wUnmanageWindow(thePanel
->wwin
, False
, False
);
836 WMDestroyWidget(thePanel
->win
);
845 extern WMPixmap
*DoXThing();
846 extern Bool
InitXThing();
848 static void logoPushCallback(void *data
)
850 InfoPanel
*panel
= (InfoPanel
*) data
;
855 static int jingobeu
[] = {
856 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
857 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
858 329, 150, 392, 150, 261, 150, 293, 150, 329, 400, -1, 400, 0
864 XKeyboardState ksave
;
865 unsigned long mask
= KBBellPitch
| KBBellDuration
| KBBellPercent
;
867 XGetKeyboardControl(dpy
, &ksave
);
870 if (jingobeu
[panel
->x
- 1] == 0) {
872 } else if (jingobeu
[panel
->x
- 1] < 0) {
874 c
= jingobeu
[panel
->x
- 1] / 50;
877 kc
.bell_percent
= 50;
878 kc
.bell_pitch
= jingobeu
[panel
->x
- 1];
880 kc
.bell_duration
= jingobeu
[panel
->x
- 1];
881 c
= jingobeu
[panel
->x
- 1] / 50;
883 XChangeKeyboardControl(dpy
, mask
, &kc
);
890 if (!(panel
->cycle
% 4)) {
893 p
= DoXThing(panel
->wwin
);
894 WMSetLabelImage(panel
->logoL
, p
);
896 kc
.bell_pitch
= ksave
.bell_pitch
;
897 kc
.bell_percent
= ksave
.bell_percent
;
898 kc
.bell_duration
= ksave
.bell_duration
;
899 XChangeKeyboardControl(dpy
, mask
, &kc
);
900 } else if (panel
->cycle
< 30) {
910 image
= RScaleImage(panel
->icon
, panel
->pic
->width
, panel
->pic
->height
);
911 RCombineImagesWithOpaqueness(image
, panel
->pic
, panel
->cycle
* 255 / 30);
912 pix
= WMCreateBlendedPixmapFromRImage(panel
->scr
->wmscreen
, image
, &gray
);
913 RReleaseImage(image
);
914 WMSetLabelImage(panel
->logoL
, pix
);
915 WMReleasePixmap(pix
);
918 /* slow down text a little */
919 i
= (int)(panel
->cycle
* 50.0 / 85.0) % 200;
922 len
= strlen(panel
->str
);
924 strncpy(buffer
, panel
->str
, i
< len
? i
: len
);
926 memset(&buffer
[len
], ' ', i
- len
);
928 strncpy(buffer
, panel
->str
, i
< len
? i
: len
);
930 memset(&buffer
[len
], ' ', i
- len
);
933 WMSetLabelText(panel
->versionL
, buffer
);
935 XFlush(WMScreenDisplay(WMWidgetScreen(panel
->versionL
)));
940 panel
->timer
= WMAddTimerHandler(50, logoPushCallback
, panel
);
944 static void handleLogoPush(XEvent
* event
, void *data
)
946 InfoPanel
*panel
= (InfoPanel
*) data
;
947 static int broken
= 0;
948 static int clicks
= 0;
949 static char *pic_data
[] = {
1008 " ............... ",
1009 " ....XoO+@##+O$%.... ",
1010 " ...%X&*========-;;:o... ",
1011 " ...>.>,<122222222222134@... ",
1012 " ..>5678912222222222222220q%.. ",
1013 " ..$.&-w2222222222222222222er>.. ",
1014 " ..O.t31222222222222222222222y4>.. ",
1015 " ...O5u3222222222222222222222222yri... ",
1016 " ..>p&a22222222222222222222222222wso.. ",
1017 " ..ids91222222222222222222222222222wfi.. ",
1018 " ..X.7w222222wgs-w2222222213=g0222222<hi.. ",
1019 " ..Xuj2222222<@X5=222222229k@l:022222y4i.. ",
1020 " .Xdz22222222*X%.s22222222axo%$-222222<c>.. ",
1021 " ..o7y22222222v...r222222223hX.i82222221si.. ",
1022 "..io*222222222&...u22222222yt..%*22222220:%. ",
1023 "..>k02222222227...f222222222v..X=222222229t. ",
1024 "..dz12222222220ui:y2222222223d%qw222222221g. ",
1025 ".%vw222222222221y2222222222219*y2222222222wd.",
1026 ".X;2222222222222222222222222222222222222222b.",
1027 ".i*2222222222222222222222222222222222222222v.",
1028 ".i*2222222222222222222222222222222222222222;.",
1029 ".i*22222222222222222222222222222222222222228.",
1030 ".>*2222222222222222222222222222222222222222=.",
1031 ".i*22222222222222222222222222222222222222228.",
1032 ".i*2222222222222222222222222222222222222222;.",
1033 ".X*222222222222222222222222222222we12222222r.",
1034 ".Xs12222222w3aw22222222222222222y8s0222222wk.",
1035 ".Xq02222222a,na22222222222222222zm6zwy2222gi.",
1036 "..>*22222y<:Xcj22222222222222222-o$k;;02228..",
1037 "..i7y2220rhX.:y22222222222222222jtiXd,a220,..",
1038 " .X@z222a,do%kj2222222222222222wMX5q;gw228%..",
1039 " ..58222wagsh6ry222222222222221;>Of0w222y:...",
1040 " ...:e2222218mdz22222222222222a&$vw222220@...",
1041 " ...O-122222y:.u02222222222229q$uj222221r... ",
1042 " ..%&a1222223&573w2222222219NOxz122221z>... ",
1043 " ...t3222221-l$nr8ay1222yzbo,=12222w-5... ",
1044 " ..X:022222w-k+>o,7s**s7xOn=12221<f5... ",
1045 " ..o:9222221j8:&Bl>>>>ihv<12221=dX... ",
1046 " ..Xb9122222109g-****;<y22221zn%... ",
1047 " ..X&801222222222222222222w-h.... ",
1048 " ...o:=022222222222222221=lX... ",
1049 " ..X@:;3w2222222222210fO... ",
1050 " ...XX&v8<30000003-N@... ",
1051 " .....XmnbN:q&Bo.... ",
1054 static char *msgs
[] = {
1056 "Focus follow mouse users will burn in hell!!!",
1058 "Hi! My name is bobby...",
1059 "AHH! The neurotic monkeys are after me!",
1061 "HOW ARE YOU GENTLEMEN?",
1063 "SOMEBODY SET UP US THE BOMB",
1064 "ALL YOUR BASE ARE BELONG TO US!",
1065 "Oh My God!!! Larry is back!",
1066 "Alex Perez is aliveeeeeeee!!!"
1071 if (!panel
->timer
&& !broken
&& clicks
> 0) {
1077 panel
->icon
= WMGetApplicationIconImage(panel
->scr
->wmscreen
);
1089 panel
->icon
= RCloneImage(panel
->icon
);
1090 RCombineImageWithColor(panel
->icon
, &color
);
1094 panel
->pic
= RGetImageFromXPMData(panel
->scr
->rcontext
, pic_data
);
1097 RReleaseImage(panel
->icon
);
1103 panel
->str
= msgs
[rand() % (sizeof(msgs
) / sizeof(char *))];
1105 panel
->timer
= WMAddTimerHandler(50, logoPushCallback
, panel
);
1107 panel
->oldPix
= WMRetainPixmap(WMGetLabelImage(panel
->logoL
));
1108 /* If we don't use a fixed font, scrolling will be jumpy */
1109 /* Alternatively we can draw text in a pixmap and scroll it smoothly */
1110 if ((panel
->oldFont
= WMGetLabelFont(panel
->versionL
)) != NULL
)
1111 WMRetainFont(panel
->oldFont
);
1112 font
= WMCreateFont(WMWidgetScreen(panel
->versionL
),
1113 "Lucida Console,Courier New,monospace:pixelsize=12");
1115 WMSetLabelFont(panel
->versionL
, font
);
1116 WMReleaseFont(font
);
1118 WMSetLabelText(panel
->versionL
, "");
1119 } else if (panel
->timer
) {
1124 WMSetLabelImage(panel
->logoL
, panel
->oldPix
);
1125 WMReleasePixmap(panel
->oldPix
);
1126 panel
->oldPix
= NULL
;
1128 WMDeleteTimerHandler(panel
->timer
);
1129 panel
->timer
= NULL
;
1131 WMSetLabelFont(panel
->versionL
, panel
->oldFont
);
1132 if (panel
->oldFont
) {
1133 WMReleaseFont(panel
->oldFont
);
1134 panel
->oldFont
= NULL
;
1136 snprintf(version
, sizeof(version
), _("Version %s"), VERSION
);
1137 WMSetLabelText(panel
->versionL
, version
);
1138 XFlush(WMScreenDisplay(WMWidgetScreen(panel
->versionL
)));
1143 while (XCheckTypedWindowEvent(dpy
, WMWidgetXID(panel
->versionL
), ButtonPress
, &ev
)) ;
1146 #endif /* SILLYNESS */
1148 void wShowInfoPanel(WScreen
* scr
)
1154 char *strbuf
= NULL
;
1160 int i
, width
= 50, sepHeight
;
1171 if (thePanel
->scr
== scr
) {
1172 wRaiseFrame(thePanel
->wwin
->frame
->core
);
1173 wSetFocusTo(scr
, thePanel
->wwin
);
1178 panel
= wmalloc(sizeof(InfoPanel
));
1179 memset(panel
, 0, sizeof(InfoPanel
));
1183 panel
->win
= WMCreateWindow(scr
->wmscreen
, "info");
1184 WMResizeWidget(panel
->win
, 390, 230);
1186 logo
= WMCreateApplicationIconBlendedPixmap(scr
->wmscreen
, (RColor
*) NULL
);
1188 logo
= WMRetainPixmap(WMGetApplicationIconPixmap(scr
->wmscreen
));
1191 size
= WMGetPixmapSize(logo
);
1192 panel
->logoL
= WMCreateLabel(panel
->win
);
1193 WMResizeWidget(panel
->logoL
, 64, 64);
1194 WMMoveWidget(panel
->logoL
, 30, 20);
1195 WMSetLabelImagePosition(panel
->logoL
, WIPImageOnly
);
1196 WMSetLabelImage(panel
->logoL
, logo
);
1198 WMCreateEventHandler(WMWidgetView(panel
->logoL
), ButtonPressMask
, handleLogoPush
, panel
);
1200 WMReleasePixmap(logo
);
1204 panel
->name1L
= WMCreateLabel(panel
->win
);
1205 WMResizeWidget(panel
->name1L
, 240, 30 + 2);
1206 WMMoveWidget(panel
->name1L
, 100, 30 - 2 - sepHeight
);
1208 name
= "Lucida Sans,Comic Sans MS,URW Gothic L,Trebuchet MS" ":italic:pixelsize=28:antialias=true";
1209 font
= WMCreateFont(scr
->wmscreen
, name
);
1210 strbuf
= "Window Maker";
1212 width
= WMWidthOfString(font
, strbuf
, strlen(strbuf
));
1213 WMSetLabelFont(panel
->name1L
, font
);
1214 WMReleaseFont(font
);
1216 WMSetLabelTextAlignment(panel
->name1L
, WACenter
);
1217 WMSetLabelText(panel
->name1L
, strbuf
);
1219 panel
->lineF
= WMCreateFrame(panel
->win
);
1220 WMResizeWidget(panel
->lineF
, width
, sepHeight
);
1221 WMMoveWidget(panel
->lineF
, 100 + (240 - width
) / 2, 60 - sepHeight
);
1222 WMSetFrameRelief(panel
->lineF
, WRSimple
);
1223 WMSetWidgetBackgroundColor(panel
->lineF
, scr
->black
);
1225 panel
->name2L
= WMCreateLabel(panel
->win
);
1226 WMResizeWidget(panel
->name2L
, 240, 24);
1227 WMMoveWidget(panel
->name2L
, 100, 60);
1228 name
= "URW Gothic L,Nimbus Sans L:pixelsize=16:antialias=true";
1229 font
= WMCreateFont(scr
->wmscreen
, name
);
1231 WMSetLabelFont(panel
->name2L
, font
);
1232 WMReleaseFont(font
);
1235 WMSetLabelTextAlignment(panel
->name2L
, WACenter
);
1236 WMSetLabelText(panel
->name2L
, _("Window Manager for X"));
1238 snprintf(buffer
, sizeof(buffer
), _("Version %s"), VERSION
);
1239 panel
->versionL
= WMCreateLabel(panel
->win
);
1240 WMResizeWidget(panel
->versionL
, 310, 16);
1241 WMMoveWidget(panel
->versionL
, 30, 95);
1242 WMSetLabelTextAlignment(panel
->versionL
, WARight
);
1243 WMSetLabelText(panel
->versionL
, buffer
);
1244 WMSetLabelWraps(panel
->versionL
, False
);
1246 panel
->copyrL
= WMCreateLabel(panel
->win
);
1247 WMResizeWidget(panel
->copyrL
, 360, 40);
1248 WMMoveWidget(panel
->copyrL
, 15, 185);
1249 WMSetLabelTextAlignment(panel
->copyrL
, WALeft
);
1250 WMSetLabelText(panel
->copyrL
, COPYRIGHT_TEXT
);
1251 font
= WMSystemFontOfSize(scr
->wmscreen
, 11);
1253 WMSetLabelFont(panel
->copyrL
, font
);
1254 WMReleaseFont(font
);
1259 snprintf(buffer
, sizeof(buffer
), _("Using visual 0x%x: %s %ibpp "),
1260 (unsigned)scr
->w_visual
->visualid
, visuals
[scr
->w_visual
->class], scr
->w_depth
);
1262 strbuf
= wstrappend(strbuf
, buffer
);
1264 switch (scr
->w_depth
) {
1266 strbuf
= wstrappend(strbuf
, _("(32 thousand colors)\n"));
1269 strbuf
= wstrappend(strbuf
, _("(64 thousand colors)\n"));
1273 strbuf
= wstrappend(strbuf
, _("(16 million colors)\n"));
1276 snprintf(buffer
, sizeof(buffer
), _("(%d colors)\n"), 1 << scr
->w_depth
);
1277 strbuf
= wstrappend(strbuf
, buffer
);
1281 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
1283 struct mallinfo ma
= mallinfo();
1284 snprintf(buffer
, sizeof(buffer
),
1285 _("Total allocated memory: %i kB. Total memory in use: %i kB.\n"),
1286 (ma
.arena
+ ma
.hblkhd
) / 1024, (ma
.uordblks
+ ma
.hblkhd
) / 1024);
1288 strbuf
= wstrappend(strbuf
, buffer
);
1292 strbuf
= wstrappend(strbuf
, _("Supported image formats: "));
1293 strl
= RSupportedFileFormats();
1294 for (i
= 0; strl
[i
] != NULL
; i
++) {
1295 strbuf
= wstrappend(strbuf
, strl
[i
]);
1296 strbuf
= wstrappend(strbuf
, " ");
1299 strbuf
= wstrappend(strbuf
, _("\nAdditional support for: "));
1306 list
[j
++] = "WMSPEC";
1313 for (i
= 0; i
< j
; i
++) {
1316 strcat(buf
, _(" and "));
1320 strcat(buf
, list
[i
]);
1322 strbuf
= wstrappend(strbuf
, buf
);
1325 if (wPreferences
.no_sound
) {
1326 strbuf
= wstrappend(strbuf
, _("\nSound disabled"));
1328 strbuf
= wstrappend(strbuf
, _("\nSound enabled"));
1331 #ifdef VIRTUAL_DESKTOP
1332 if (wPreferences
.vdesk_enable
)
1333 strbuf
= wstrappend(strbuf
, _(", VirtualDesktop enabled"));
1335 strbuf
= wstrappend(strbuf
, _(", VirtualDesktop disabled"));
1339 strbuf
= wstrappend(strbuf
, _("\n"));
1340 #ifdef SOLARIS_XINERAMA
1341 strbuf
= wstrappend(strbuf
, _("Solaris "));
1343 strbuf
= wstrappend(strbuf
, _("Xinerama: "));
1346 snprintf(tmp
, sizeof(tmp
) - 1, "%d heads found.", scr
->xine_info
.count
);
1347 strbuf
= wstrappend(strbuf
, tmp
);
1351 panel
->infoL
= WMCreateLabel(panel
->win
);
1352 WMResizeWidget(panel
->infoL
, 350, 75);
1353 WMMoveWidget(panel
->infoL
, 15, 115);
1354 WMSetLabelText(panel
->infoL
, strbuf
);
1355 font
= WMSystemFontOfSize(scr
->wmscreen
, 11);
1357 WMSetLabelFont(panel
->infoL
, font
);
1358 WMReleaseFont(font
);
1363 WMRealizeWidget(panel
->win
);
1364 WMMapSubwidgets(panel
->win
);
1366 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 382, 230, 0, 0, 0);
1368 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1370 WMMapWidget(panel
->win
);
1373 WMPoint center
= getCenter(scr
, 382, 230);
1375 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Info"), center
.x
, center
.y
, 382, 230);
1378 WSETUFLAG(wwin
, no_closable
, 0);
1379 WSETUFLAG(wwin
, no_close_button
, 0);
1380 #ifdef XKB_BUTTON_HINT
1381 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1383 wWindowUpdateButtonImages(wwin
);
1384 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1385 wwin
->frame
->on_click_right
= destroyInfoPanel
;
1393 if (InitXThing(panel
->scr
)) {
1394 panel
->timer
= WMAddTimerHandler(100, logoPushCallback
, panel
);
1397 panel
->str
= _("Merry Christmas!");
1398 panel
->oldPix
= WMRetainPixmap(WMGetLabelImage(panel
->logoL
));
1404 ***********************************************************************
1406 ***********************************************************************
1419 static LegalPanel
*legalPanel
= NULL
;
1421 static void destroyLegalPanel(WCoreWindow
* foo
, void *data
, XEvent
* event
)
1423 WMUnmapWidget(legalPanel
->win
);
1425 WMDestroyWidget(legalPanel
->win
);
1427 wUnmanageWindow(legalPanel
->wwin
, False
, False
);
1434 void wShowLegalPanel(WScreen
* scr
)
1441 if (legalPanel
->scr
== scr
) {
1442 wRaiseFrame(legalPanel
->wwin
->frame
->core
);
1443 wSetFocusTo(scr
, legalPanel
->wwin
);
1448 panel
= wmalloc(sizeof(LegalPanel
));
1452 panel
->win
= WMCreateWindow(scr
->wmscreen
, "legal");
1453 WMResizeWidget(panel
->win
, 420, 250);
1455 panel
->licenseL
= WMCreateLabel(panel
->win
);
1456 WMSetLabelWraps(panel
->licenseL
, True
);
1457 WMResizeWidget(panel
->licenseL
, 400, 230);
1458 WMMoveWidget(panel
->licenseL
, 10, 10);
1459 WMSetLabelTextAlignment(panel
->licenseL
, WALeft
);
1460 WMSetLabelText(panel
->licenseL
,
1461 _(" Window Maker is free software; you can redistribute it and/or\n"
1462 "modify it under the terms of the GNU General Public License as\n"
1463 "published by the Free Software Foundation; either version 2 of the\n"
1464 "License, or (at your option) any later version.\n\n"
1465 " Window Maker is distributed in the hope that it will be useful,\n"
1466 "but WITHOUT ANY WARRANTY; without even the implied warranty\n"
1467 "of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
1468 "See the GNU General Public License for more details.\n\n"
1469 " You should have received a copy of the GNU General Public\n"
1470 "License along with this program; if not, write to the Free Software\n"
1471 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA\n" "02111-1307, USA."));
1472 WMSetLabelRelief(panel
->licenseL
, WRGroove
);
1474 WMRealizeWidget(panel
->win
);
1475 WMMapSubwidgets(panel
->win
);
1477 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 420, 250, 0, 0, 0);
1479 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1482 WMPoint center
= getCenter(scr
, 420, 250);
1484 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Legal"), center
.x
, center
.y
, 420, 250);
1487 WSETUFLAG(wwin
, no_closable
, 0);
1488 WSETUFLAG(wwin
, no_close_button
, 0);
1489 wWindowUpdateButtonImages(wwin
);
1490 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1491 #ifdef XKB_BUTTON_HINT
1492 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1494 wwin
->frame
->on_click_right
= destroyLegalPanel
;
1498 WMMapWidget(panel
->win
);
1506 ***********************************************************************
1507 * Crashing Dialog Panel
1508 ***********************************************************************
1511 extern WDDomain
*WDWindowAttributes
;
1513 typedef struct _CrashPanel
{
1514 WMWindow
*win
; /* main window */
1516 WMLabel
*iconL
; /* application icon */
1517 WMLabel
*nameL
; /* title of panel */
1519 WMFrame
*sepF
; /* separator frame */
1521 WMLabel
*noteL
; /* Title of note */
1522 WMLabel
*note2L
; /* body of note with what happened */
1524 WMFrame
*whatF
; /* "what to do next" frame */
1525 WMPopUpButton
*whatP
; /* action selection popup button */
1527 WMButton
*okB
; /* ok button */
1529 Bool done
; /* if finished with this dialog */
1530 int action
; /* what to do after */
1536 static void handleKeyPress(XEvent
* event
, void *clientData
)
1538 CrashPanel
*panel
= (CrashPanel
*) clientData
;
1540 if (event
->xkey
.keycode
== panel
->retKey
) {
1541 WMPerformButtonClick(panel
->okB
);
1545 static void okButtonCallback(void *self
, void *clientData
)
1547 CrashPanel
*panel
= (CrashPanel
*) clientData
;
1552 static void setCrashAction(void *self
, void *clientData
)
1554 WMPopUpButton
*pop
= (WMPopUpButton
*) self
;
1555 CrashPanel
*panel
= (CrashPanel
*) clientData
;
1557 panel
->action
= WMGetPopUpButtonSelectedItem(pop
);
1560 /* Make this read the logo from a compiled in pixmap -Dan */
1561 static WMPixmap
*getWindowMakerIconImage(WMScreen
* scr
)
1563 WMPropList
*dict
, *key
, *option
, *value
= NULL
;
1564 WMPixmap
*pix
= NULL
;
1567 if (!WDWindowAttributes
|| !WDWindowAttributes
->dictionary
)
1570 WMPLSetCaseSensitive(True
);
1572 key
= WMCreatePLString("Logo.WMPanel");
1573 option
= WMCreatePLString("Icon");
1575 dict
= WMGetFromPLDictionary(WDWindowAttributes
->dictionary
, key
);
1578 value
= WMGetFromPLDictionary(dict
, option
);
1581 WMReleasePropList(key
);
1582 WMReleasePropList(option
);
1584 WMPLSetCaseSensitive(False
);
1586 if (value
&& WMIsPLString(value
)) {
1587 path
= FindImage(wPreferences
.icon_path
, WMGetFromPLString(value
));
1597 pix
= WMCreateBlendedPixmapFromFile(scr
, path
, &gray
);
1608 int wShowCrashingDialogPanel(int whatSig
)
1614 int screen_no
, scr_width
, scr_height
;
1618 panel
= wmalloc(sizeof(CrashPanel
));
1619 memset(panel
, 0, sizeof(CrashPanel
));
1621 screen_no
= DefaultScreen(dpy
);
1622 scr_width
= WidthOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1623 scr_height
= HeightOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1625 scr
= WMCreateScreen(dpy
, screen_no
);
1627 wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
1631 panel
->retKey
= XKeysymToKeycode(dpy
, XK_Return
);
1633 panel
->win
= WMCreateWindow(scr
, "crashingDialog");
1634 WMResizeWidget(panel
->win
, PWIDTH
, PHEIGHT
);
1635 WMMoveWidget(panel
->win
, (scr_width
- PWIDTH
) / 2, (scr_height
- PHEIGHT
) / 2);
1637 logo
= getWindowMakerIconImage(scr
);
1639 panel
->iconL
= WMCreateLabel(panel
->win
);
1640 WMResizeWidget(panel
->iconL
, 64, 64);
1641 WMMoveWidget(panel
->iconL
, 10, 10);
1642 WMSetLabelImagePosition(panel
->iconL
, WIPImageOnly
);
1643 WMSetLabelImage(panel
->iconL
, logo
);
1646 panel
->nameL
= WMCreateLabel(panel
->win
);
1647 WMResizeWidget(panel
->nameL
, 200, 30);
1648 WMMoveWidget(panel
->nameL
, 80, 25);
1649 WMSetLabelTextAlignment(panel
->nameL
, WALeft
);
1650 font
= WMBoldSystemFontOfSize(scr
, 24);
1651 WMSetLabelFont(panel
->nameL
, font
);
1652 WMReleaseFont(font
);
1653 WMSetLabelText(panel
->nameL
, _("Fatal error"));
1655 panel
->sepF
= WMCreateFrame(panel
->win
);
1656 WMResizeWidget(panel
->sepF
, PWIDTH
+ 4, 2);
1657 WMMoveWidget(panel
->sepF
, -2, 80);
1659 panel
->noteL
= WMCreateLabel(panel
->win
);
1660 WMResizeWidget(panel
->noteL
, PWIDTH
- 20, 40);
1661 WMMoveWidget(panel
->noteL
, 10, 90);
1662 WMSetLabelTextAlignment(panel
->noteL
, WAJustified
);
1663 #ifdef SYS_SIGLIST_DECLARED
1664 snprintf(buf
, sizeof(buf
), _("Window Maker received signal %i\n(%s)."), whatSig
, sys_siglist
[whatSig
]);
1666 snprintf(buf
, sizeof(buf
), _("Window Maker received signal %i."), whatSig
);
1668 WMSetLabelText(panel
->noteL
, buf
);
1670 panel
->note2L
= WMCreateLabel(panel
->win
);
1671 WMResizeWidget(panel
->note2L
, PWIDTH
- 20, 100);
1672 WMMoveWidget(panel
->note2L
, 10, 130);
1673 WMSetLabelTextAlignment(panel
->note2L
, WALeft
);
1674 WMSetLabelText(panel
->note2L
,
1675 _(" This fatal error occured probably due to a bug."
1676 " Please fill the included BUGFORM and " "report it to bugs@windowmaker.info."));
1677 WMSetLabelWraps(panel
->note2L
, True
);
1679 panel
->whatF
= WMCreateFrame(panel
->win
);
1680 WMResizeWidget(panel
->whatF
, PWIDTH
- 20, 50);
1681 WMMoveWidget(panel
->whatF
, 10, 240);
1682 WMSetFrameTitle(panel
->whatF
, _("What do you want to do now?"));
1684 panel
->whatP
= WMCreatePopUpButton(panel
->whatF
);
1685 WMResizeWidget(panel
->whatP
, PWIDTH
- 20 - 70, 20);
1686 WMMoveWidget(panel
->whatP
, 35, 20);
1687 WMSetPopUpButtonPullsDown(panel
->whatP
, False
);
1688 WMSetPopUpButtonText(panel
->whatP
, _("Select action"));
1689 WMAddPopUpButtonItem(panel
->whatP
, _("Abort and leave a core file"));
1690 WMAddPopUpButtonItem(panel
->whatP
, _("Restart Window Maker"));
1691 WMAddPopUpButtonItem(panel
->whatP
, _("Start alternate window manager"));
1692 WMSetPopUpButtonAction(panel
->whatP
, setCrashAction
, panel
);
1693 WMSetPopUpButtonSelectedItem(panel
->whatP
, WMRestart
);
1694 panel
->action
= WMRestart
;
1696 WMMapSubwidgets(panel
->whatF
);
1698 panel
->okB
= WMCreateCommandButton(panel
->win
);
1699 WMResizeWidget(panel
->okB
, 80, 26);
1700 WMMoveWidget(panel
->okB
, 205, 309);
1701 WMSetButtonText(panel
->okB
, _("OK"));
1702 WMSetButtonImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIReturnArrow
));
1703 WMSetButtonAltImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIHighlightedReturnArrow
));
1704 WMSetButtonImagePosition(panel
->okB
, WIPRight
);
1705 WMSetButtonAction(panel
->okB
, okButtonCallback
, panel
);
1709 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
, handleKeyPress
, panel
);
1711 WMRealizeWidget(panel
->win
);
1712 WMMapSubwidgets(panel
->win
);
1714 WMMapWidget(panel
->win
);
1716 XSetInputFocus(dpy
, WMWidgetXID(panel
->win
), RevertToParent
, CurrentTime
);
1718 while (!panel
->done
) {
1721 WMNextEvent(dpy
, &event
);
1722 WMHandleEvent(&event
);
1725 action
= panel
->action
;
1727 WMUnmapWidget(panel
->win
);
1728 WMDestroyWidget(panel
->win
);
1734 /*****************************************************************************
1735 * About GNUstep Panel
1736 *****************************************************************************/
1739 drawGNUstepLogo(Display
* dpy
, Drawable d
, int width
, int height
,
1740 unsigned long blackPixel
, unsigned long whitePixel
)
1744 XRectangle rects
[3];
1746 gcv
.foreground
= blackPixel
;
1747 gc
= XCreateGC(dpy
, d
, GCForeground
, &gcv
);
1749 XFillArc(dpy
, d
, gc
, width
/ 45, height
/ 45,
1750 width
- 2 * width
/ 45, height
- 2 * height
/ 45, 0, 360 * 64);
1753 rects
[0].y
= 37 * height
/ 45;
1754 rects
[0].width
= width
/ 3;
1755 rects
[0].height
= height
- rects
[0].y
;
1757 rects
[1].x
= rects
[0].width
;
1758 rects
[1].y
= height
/ 2;
1759 rects
[1].width
= width
- 2 * width
/ 3;
1760 rects
[1].height
= height
- rects
[1].y
;
1762 rects
[2].x
= 2 * width
/ 3;
1763 rects
[2].y
= height
- 37 * height
/ 45;
1764 rects
[2].width
= width
/ 3;
1765 rects
[2].height
= height
- rects
[2].y
;
1767 XSetClipRectangles(dpy
, gc
, 0, 0, rects
, 3, Unsorted
);
1768 XFillRectangle(dpy
, d
, gc
, 0, 0, width
, height
);
1770 XSetForeground(dpy
, gc
, whitePixel
);
1771 XFillArc(dpy
, d
, gc
, width
/ 45, height
/ 45,
1772 width
- 2 * width
/ 45, height
- 2 * height
/ 45, 0, 360 * 64);
1788 static GNUstepPanel
*gnustepPanel
= NULL
;
1790 static void destroyGNUstepPanel(WCoreWindow
* foo
, void *data
, XEvent
* event
)
1792 WMUnmapWidget(gnustepPanel
->win
);
1794 WMDestroyWidget(gnustepPanel
->win
);
1796 wUnmanageWindow(gnustepPanel
->wwin
, False
, False
);
1798 wfree(gnustepPanel
);
1800 gnustepPanel
= NULL
;
1803 void wShowGNUstepPanel(WScreen
* scr
)
1805 GNUstepPanel
*panel
;
1812 if (gnustepPanel
->scr
== scr
) {
1813 wRaiseFrame(gnustepPanel
->wwin
->frame
->core
);
1814 wSetFocusTo(scr
, gnustepPanel
->wwin
);
1819 panel
= wmalloc(sizeof(GNUstepPanel
));
1823 panel
->win
= WMCreateWindow(scr
->wmscreen
, "About GNUstep");
1824 WMResizeWidget(panel
->win
, 325, 205);
1826 pixmap
= WMCreatePixmap(scr
->wmscreen
, 130, 130, WMScreenDepth(scr
->wmscreen
), True
);
1828 color
= WMCreateNamedColor(scr
->wmscreen
, "gray50", True
);
1830 drawGNUstepLogo(dpy
, WMGetPixmapXID(pixmap
), 130, 130, WMColorPixel(color
), scr
->white_pixel
);
1832 WMReleaseColor(color
);
1834 XSetForeground(dpy
, scr
->mono_gc
, 0);
1835 XFillRectangle(dpy
, WMGetPixmapMaskXID(pixmap
), scr
->mono_gc
, 0, 0, 130, 130);
1836 drawGNUstepLogo(dpy
, WMGetPixmapMaskXID(pixmap
), 130, 130, 1, 1);
1838 panel
->gstepL
= WMCreateLabel(panel
->win
);
1839 WMResizeWidget(panel
->gstepL
, 285, 64);
1840 WMMoveWidget(panel
->gstepL
, 20, 0);
1841 WMSetLabelTextAlignment(panel
->gstepL
, WARight
);
1842 WMSetLabelText(panel
->gstepL
, "GNUstep");
1844 WMFont
*font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 24);
1846 WMSetLabelFont(panel
->gstepL
, font
);
1847 WMReleaseFont(font
);
1850 panel
->textL
= WMCreateLabel(panel
->win
);
1851 WMResizeWidget(panel
->textL
, 305, 140);
1852 WMMoveWidget(panel
->textL
, 10, 50);
1853 WMSetLabelTextAlignment(panel
->textL
, WARight
);
1854 WMSetLabelImagePosition(panel
->textL
, WIPOverlaps
);
1855 WMSetLabelText(panel
->textL
,
1856 _("Window Maker is part of the GNUstep project.\n"
1857 "The GNUstep project aims to create a free\n"
1858 "implementation of the OpenStep(tm) specification\n"
1859 "which is a object-oriented framework for\n"
1860 "creating advanced graphical, multi-platform\n"
1861 "applications. Additionally, a development and\n"
1862 "user desktop enviroment will be created on top\n"
1863 "of the framework. For more information about\n"
1864 "GNUstep, please visit: www.gnustep.org"));
1865 WMSetLabelImage(panel
->textL
, pixmap
);
1867 WMReleasePixmap(pixmap
);
1869 WMRealizeWidget(panel
->win
);
1870 WMMapSubwidgets(panel
->win
);
1872 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 325, 200, 0, 0, 0);
1874 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1877 WMPoint center
= getCenter(scr
, 325, 200);
1879 wwin
= wManageInternalWindow(scr
, parent
, None
, _("About GNUstep"), center
.x
, center
.y
, 325, 200);
1882 WSETUFLAG(wwin
, no_closable
, 0);
1883 WSETUFLAG(wwin
, no_close_button
, 0);
1884 wWindowUpdateButtonImages(wwin
);
1885 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1886 #ifdef XKB_BUTTON_HINT
1887 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1889 wwin
->frame
->on_click_right
= destroyGNUstepPanel
;
1893 WMMapWidget(panel
->win
);
1897 gnustepPanel
= panel
;