1 /* dialog.c - dialog windows for internal use
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 * Copyright (c) 1999 Dan Pascu
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 #include <X11/Xutil.h>
28 #include <X11/keysym.h>
34 #include <sys/types.h>
41 #include <sys/signal.h>
46 #define PATH_MAX DEFAULT_PATH_MAX
49 #include "WindowMaker.h"
61 extern WPreferences wPreferences
;
66 wMessageDialog(WScreen
*scr
, char *title
, char *message
,
67 char *defBtn
, char *altBtn
, char *othBtn
)
74 panel
= WMCreateAlertPanel(scr
->wmscreen
, NULL
, title
, message
,
75 defBtn
, altBtn
, othBtn
);
77 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 400, 180, 0, 0, 0);
79 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
81 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
,
82 (scr
->scr_width
- 400)/2,
83 (scr
->scr_height
- 180)/2, 400, 180);
84 wwin
->client_leader
= WMWidgetXID(panel
->win
);
86 WMMapWidget(panel
->win
);
90 while (!panel
->done
) {
93 WMNextEvent(dpy
, &event
);
94 WMHandleEvent(&event
);
97 result
= panel
->result
;
99 WMUnmapWidget(panel
->win
);
101 wUnmanageWindow(wwin
, False
, False
);
103 WMDestroyAlertPanel(panel
);
105 XDestroyWindow(dpy
, parent
);
113 wInputDialog(WScreen
*scr
, char *title
, char *message
, char **text
)
121 panel
= WMCreateInputPanel(scr
->wmscreen
, NULL
, title
, message
, *text
,
122 _("OK"), _("Cancel"));
125 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 320, 160, 0, 0, 0);
126 XSelectInput(dpy
, parent
, KeyPressMask
|KeyReleaseMask
);
128 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
130 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
,
131 (scr
->scr_width
- 320)/2,
132 (scr
->scr_height
- 160)/2, 320, 160);
134 wwin
->client_leader
= WMWidgetXID(panel
->win
);
136 WMMapWidget(panel
->win
);
140 while (!panel
->done
) {
143 WMNextEvent(dpy
, &event
);
144 WMHandleEvent(&event
);
147 if (panel
->result
== WAPRDefault
)
148 result
= WMGetTextFieldText(panel
->text
);
152 wUnmanageWindow(wwin
, False
, False
);
154 WMDestroyInputPanel(panel
);
156 XDestroyWindow(dpy
, parent
);
171 *****************************************************************
172 * Icon Selection Panel
173 *****************************************************************
176 typedef struct IconPanel
{
191 WMTextField
*fileField
;
194 WMButton
*cancelButton
;
196 WMButton
*chooseButton
;
205 listPixmaps(WScreen
*scr
, WMList
*lPtr
, char *path
)
207 struct dirent
*dentry
;
209 char pbuf
[PATH_MAX
+16];
212 apath
= wexpandpath(path
);
213 dir
= opendir(apath
);
218 tmp
= _("Could not open directory ");
219 msg
= wmalloc(strlen(tmp
)+strlen(path
)+6);
223 wMessageDialog(scr
, _("Error"), msg
, _("OK"), NULL
, NULL
);
229 /* list contents in the column */
230 while ((dentry
= readdir(dir
))) {
233 if (strcmp(dentry
->d_name
, ".")==0 ||
234 strcmp(dentry
->d_name
, "..")==0)
239 strcat(pbuf
, dentry
->d_name
);
241 if (stat(pbuf
, &statb
)<0)
244 if (statb
.st_mode
& (S_IRUSR
|S_IRGRP
|S_IROTH
)
245 && statb
.st_mode
& (S_IFREG
|S_IFLNK
)) {
246 WMAddSortedListItem(lPtr
, dentry
->d_name
);
257 setViewedImage(IconPanel
*panel
, char *file
)
266 pixmap
= WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel
->win
),
272 WMSetButtonEnabled(panel
->okButton
, False
);
274 tmp
= _("Could not load image file ");
275 msg
= wmalloc(strlen(tmp
)+strlen(file
)+6);
279 wMessageDialog(panel
->scr
, _("Error"), msg
, _("OK"), NULL
, NULL
);
282 WMSetLabelImage(panel
->iconView
, NULL
);
284 WMSetButtonEnabled(panel
->okButton
, True
);
286 WMSetLabelImage(panel
->iconView
, pixmap
);
287 WMReleasePixmap(pixmap
);
293 listCallback(void *self
, void *data
)
295 WMList
*lPtr
= (WMList
*)self
;
296 IconPanel
*panel
= (IconPanel
*)data
;
299 if (lPtr
==panel
->dirList
) {
300 path
= WMGetListSelectedItem(lPtr
)->text
;
302 WMSetTextFieldText(panel
->fileField
, path
);
304 WMSetLabelImage(panel
->iconView
, NULL
);
306 WMSetButtonEnabled(panel
->okButton
, False
);
308 WMClearList(panel
->iconList
);
309 listPixmaps(panel
->scr
, panel
->iconList
, path
);
311 char *tmp
, *iconFile
;
313 path
= WMGetListSelectedItem(panel
->dirList
)->text
;
314 tmp
= wexpandpath(path
);
316 iconFile
= WMGetListSelectedItem(panel
->iconList
)->text
;
318 path
= wmalloc(strlen(tmp
)+strlen(iconFile
)+4);
321 strcat(path
, iconFile
);
323 WMSetTextFieldText(panel
->fileField
, path
);
324 setViewedImage(panel
, path
);
331 listIconPaths(WMList
*lPtr
)
336 paths
= wstrdup(wPreferences
.icon_path
);
338 path
= strtok(paths
, ":");
343 tmp
= wexpandpath(path
);
344 /* do not sort, because the order implies the order of
345 * directories searched */
346 if (access(tmp
, X_OK
)==0)
347 WMAddListItem(lPtr
, path
);
349 } while ((path
=strtok(NULL
, ":"))!=NULL
);
357 buttonCallback(void *self
, void *clientData
)
359 WMButton
*bPtr
= (WMButton
*)self
;
360 IconPanel
*panel
= (IconPanel
*)clientData
;
363 if (bPtr
==panel
->okButton
) {
365 panel
->result
= True
;
366 } else if (bPtr
==panel
->cancelButton
) {
368 panel
->result
= False
;
371 else if (bPtr
==panel
->chooseButton
) {
374 op
= WMCreateOpenPanel(WMWidgetScreen(bPtr
));
376 if (WMRunModalFilePanelForDirectory(op
, NULL
, "/usr/local", NULL
, NULL
)) {
378 path
= WMGetFilePanelFile(op
);
379 WMSetTextFieldText(panel
->fileField
, path
);
380 setViewedImage(panel
, path
);
383 WMDestroyFilePanel(op
);
390 wIconChooserDialog(WScreen
*scr
, char **file
, char *instance
, char *class)
398 panel
= wmalloc(sizeof(IconPanel
));
399 memset(panel
, 0, sizeof(IconPanel
));
403 panel
->win
= WMCreateWindow(scr
->wmscreen
, "iconChooser");
404 WMResizeWidget(panel
->win
, 450, 280);
406 boldFont
= WMBoldSystemFontOfSize(scr
->wmscreen
, 12);
408 panel
->dirLabel
= WMCreateLabel(panel
->win
);
409 WMResizeWidget(panel
->dirLabel
, 200, 20);
410 WMMoveWidget(panel
->dirLabel
, 10, 7);
411 WMSetLabelText(panel
->dirLabel
, _("Directories"));
412 WMSetLabelFont(panel
->dirLabel
, boldFont
);
413 WMSetLabelTextAlignment(panel
->dirLabel
, WACenter
);
415 WMSetLabelRelief(panel
->dirLabel
, WRSunken
);
417 panel
->iconLabel
= WMCreateLabel(panel
->win
);
418 WMResizeWidget(panel
->iconLabel
, 140, 20);
419 WMMoveWidget(panel
->iconLabel
, 215, 7);
420 WMSetLabelText(panel
->iconLabel
, _("Icons"));
421 WMSetLabelFont(panel
->iconLabel
, boldFont
);
422 WMSetLabelTextAlignment(panel
->iconLabel
, WACenter
);
424 WMReleaseFont(boldFont
);
426 color
= WMWhiteColor(scr
->wmscreen
);
427 WMSetLabelTextColor(panel
->dirLabel
, color
);
428 WMSetLabelTextColor(panel
->iconLabel
, color
);
429 WMReleaseColor(color
);
431 color
= WMDarkGrayColor(scr
->wmscreen
);
432 WMSetWidgetBackgroundColor(panel
->iconLabel
, color
);
433 WMSetWidgetBackgroundColor(panel
->dirLabel
, color
);
434 WMReleaseColor(color
);
436 WMSetLabelRelief(panel
->iconLabel
, WRSunken
);
438 panel
->dirList
= WMCreateList(panel
->win
);
439 WMResizeWidget(panel
->dirList
, 200, 170);
440 WMMoveWidget(panel
->dirList
, 10, 30);
441 WMSetListAction(panel
->dirList
, listCallback
, panel
);
443 panel
->iconList
= WMCreateList(panel
->win
);
444 WMResizeWidget(panel
->iconList
, 140, 170);
445 WMMoveWidget(panel
->iconList
, 215, 30);
446 WMSetListAction(panel
->iconList
, listCallback
, panel
);
448 panel
->iconView
= WMCreateLabel(panel
->win
);
449 WMResizeWidget(panel
->iconView
, 75, 75);
450 WMMoveWidget(panel
->iconView
, 365, 60);
451 WMSetLabelImagePosition(panel
->iconView
, WIPImageOnly
);
452 WMSetLabelRelief(panel
->iconView
, WRSunken
);
454 panel
->fileLabel
= WMCreateLabel(panel
->win
);
455 WMResizeWidget(panel
->fileLabel
, 80, 20);
456 WMMoveWidget(panel
->fileLabel
, 10, 210);
457 WMSetLabelText(panel
->fileLabel
, _("File Name:"));
459 panel
->fileField
= WMCreateTextField(panel
->win
);
460 WMResizeWidget(panel
->fileField
, 345, 20);
461 WMMoveWidget(panel
->fileField
, 95, 210);
462 WMSetTextFieldEditable(panel
->fileField
, False
);
464 panel
->okButton
= WMCreateCommandButton(panel
->win
);
465 WMResizeWidget(panel
->okButton
, 80, 26);
466 WMMoveWidget(panel
->okButton
, 360, 240);
467 WMSetButtonText(panel
->okButton
, _("OK"));
468 WMSetButtonEnabled(panel
->okButton
, False
);
469 WMSetButtonAction(panel
->okButton
, buttonCallback
, panel
);
471 panel
->cancelButton
= WMCreateCommandButton(panel
->win
);
472 WMResizeWidget(panel
->cancelButton
, 80, 26);
473 WMMoveWidget(panel
->cancelButton
, 270, 240);
474 WMSetButtonText(panel
->cancelButton
, _("Cancel"));
475 WMSetButtonAction(panel
->cancelButton
, buttonCallback
, panel
);
477 panel
->chooseButton
= WMCreateCommandButton(panel
->win
);
478 WMResizeWidget(panel
->chooseButton
, 110, 26);
479 WMMoveWidget(panel
->chooseButton
, 150, 240);
480 WMSetButtonText(panel
->chooseButton
, _("Choose File"));
481 WMSetButtonAction(panel
->chooseButton
, buttonCallback
, panel
);
483 WMRealizeWidget(panel
->win
);
484 WMMapSubwidgets(panel
->win
);
486 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 450, 280, 0, 0, 0);
488 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
493 tmp
= malloc((instance
? strlen(instance
) : 0)
494 + (class ? strlen(class) : 0) + 32);
496 if (tmp
&& (instance
|| class))
497 sprintf(tmp
, "%s [%s.%s]", _("Icon Chooser"), instance
, class);
499 strcpy(tmp
, _("Icon Chooser"));
501 wwin
= wManageInternalWindow(scr
, parent
, None
, tmp
,
502 (scr
->scr_width
- 450)/2,
503 (scr
->scr_height
- 280)/2, 450, 280);
507 /* put icon paths in the list */
508 listIconPaths(panel
->dirList
);
510 WMMapWidget(panel
->win
);
514 while (!panel
->done
) {
517 WMNextEvent(dpy
, &event
);
518 WMHandleEvent(&event
);
522 char *defaultPath
, *wantedPath
;
524 /* check if the file the user selected is not the one that
525 * would be loaded by default with the current search path */
526 *file
= WMGetListSelectedItem(panel
->iconList
)->text
;
531 defaultPath
= FindImage(wPreferences
.icon_path
, *file
);
532 wantedPath
= WMGetTextFieldText(panel
->fileField
);
533 /* if the file is not the default, use full path */
534 if (strcmp(wantedPath
, defaultPath
)!=0) {
537 *file
= wstrdup(*file
);
546 WMUnmapWidget(panel
->win
);
548 WMDestroyWidget(panel
->win
);
550 wUnmanageWindow(wwin
, False
, False
);
554 XDestroyWindow(dpy
, parent
);
556 return panel
->result
;
561 ***********************************************************************
563 ***********************************************************************
597 #define COPYRIGHT_TEXT \
598 "Copyright \xa9 1997~1999 Alfredo K. Kojima <kojima@windowmaker.org>\n"\
599 "Copyright \xa9 1998,1999 Dan Pascu <dan@windowmaker.org>"
603 static InfoPanel
*thePanel
= NULL
;
606 destroyInfoPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
609 if (thePanel
->timer
) {
610 WMDeleteTimerHandler(thePanel
->timer
);
612 if (thePanel
->oldPix
) {
613 WMReleasePixmap(thePanel
->oldPix
);
615 if (thePanel
->icon
) {
616 RDestroyImage(thePanel
->icon
);
619 RDestroyImage(thePanel
->pic
);
621 #endif /* SILLYNESS */
622 WMUnmapWidget(thePanel
);
624 wUnmanageWindow(thePanel
->wwin
, False
, False
);
626 WMDestroyWidget(thePanel
->win
);
635 renderText(WMScreen
*scr
, char *text
, char *font
, RColor
*from
, RColor
*to
)
637 WMPixmap
*wpix
= NULL
;
640 RContext
*rc
= WMScreenRContext(scr
);
641 XFontStruct
*f
= NULL
;
645 f
= XLoadQueryFont(dpy
, font
);
649 w
= XTextWidth(f
, text
, strlen(text
));
650 h
= f
->ascent
+f
->descent
;
652 mask
= XCreatePixmap(dpy
, rc
->drawable
, w
, h
, 1);
653 gc
= XCreateGC(dpy
, mask
, 0, NULL
);
654 XSetForeground(dpy
, gc
, 0);
655 XSetFont(dpy
, gc
, f
->fid
);
656 XFillRectangle(dpy
, mask
, gc
, 0, 0, w
, h
);
658 XSetForeground(dpy
, gc
, 1);
659 XDrawString(dpy
, mask
, gc
, 0, f
->ascent
, text
, strlen(text
));
660 XSetLineAttributes(dpy
, gc
, 3, LineSolid
, CapRound
, JoinMiter
);
661 XDrawLine(dpy
, mask
, gc
, 0, h
-2, w
, h
-2);
663 grad
= XCreatePixmap(dpy
, rc
->drawable
, w
, h
, rc
->depth
);
667 color
= WMBlackColor(scr
);
668 XFillRectangle(dpy
, grad
, WMColorGC(color
), 0, 0, w
, h
);
669 WMReleaseColor(color
);
672 wpix
= WMCreatePixmapFromXPixmaps(scr
, grad
, mask
, w
, h
, rc
->depth
);
683 extern WMPixmap
*DoXThing();
684 extern Bool
InitXThing();
687 logoPushCallback(void *data
)
689 InfoPanel
*panel
= (InfoPanel
*)data
;
693 static int jingobeu
[] = {
694 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
695 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
696 329, 150, 392, 150, 261, 150, 293, 150, 329, 400, -1, 400, 0
704 if(jingobeu
[panel
->x
-1]==0){panel
->x
=-1;}else if(jingobeu
[panel
->x
705 -1]<0){panel
->x
++;c
=jingobeu
[panel
->x
-1]/50;panel
->x
++;}else if(c
==0){
706 kc
.bell_pitch
=jingobeu
[panel
->x
-1];panel
->x
++;kc
.bell_percent
=50;c
=
707 jingobeu
[panel
->x
-1]/50;kc
.bell_duration
=jingobeu
[panel
->x
-1];panel
->x
++;
708 XChangeKeyboardControl(dpy
,KBBellPitch
|KBBellDuration
|KBBellPercent
,&kc
);
709 XBell(dpy
,50);XFlush(dpy
);}else{c
--;}}
710 if (!(panel
->cycle
% 4)) {
713 p
= DoXThing(panel
->wwin
);
714 WMSetLabelImage(panel
->logoL
, p
);
716 } else if (panel
->cycle
< 30) {
720 image
= RCloneImage(panel
->icon
);
721 RCombineImagesWithOpaqueness(image
, panel
->pic
, panel
->cycle
*255/30);
722 pix
= WMCreatePixmapFromRImage(panel
->scr
->wmscreen
, image
, 128);
723 RDestroyImage(image
);
724 WMSetLabelImage(panel
->logoL
, pix
);
725 WMReleasePixmap(pix
);
728 i
= panel
->cycle
%200;
730 len
= strlen(panel
->str
);
732 strncpy(buffer
, panel
->str
, i
<len
? i
: len
);
734 memset(&buffer
[len
], ' ', i
-len
);
736 strncpy(buffer
, panel
->str
, i
<len
? i
: len
);
738 memset(&buffer
[len
], ' ', i
-len
);
740 WMSetLabelText(panel
->versionL
, buffer
);
742 panel
->timer
= WMAddTimerHandler(50, logoPushCallback
, panel
);
748 handleLogoPush(XEvent
*event
, void *data
)
750 InfoPanel
*panel
= (InfoPanel
*)data
;
751 static int broken
= 0;
752 static int clicks
= 0;
753 static char *pic_data
[] = {
813 " ....XoO+@##+O$%.... ",
814 " ...%X&*========-;;:o... ",
815 " ...>.>,<122222222222134@... ",
816 " ..>5678912222222222222220q%.. ",
817 " ..$.&-w2222222222222222222er>.. ",
818 " ..O.t31222222222222222222222y4>.. ",
819 " ...O5u3222222222222222222222222yri... ",
820 " ..>p&a22222222222222222222222222wso.. ",
821 " ..ids91222222222222222222222222222wfi.. ",
822 " ..X.7w222222wgs-w2222222213=g0222222<hi.. ",
823 " ..Xuj2222222<@X5=222222229k@l:022222y4i.. ",
824 " .Xdz22222222*X%.s22222222axo%$-222222<c>.. ",
825 " ..o7y22222222v...r222222223hX.i82222221si.. ",
826 "..io*222222222&...u22222222yt..%*22222220:%. ",
827 "..>k02222222227...f222222222v..X=222222229t. ",
828 "..dz12222222220ui:y2222222223d%qw222222221g. ",
829 ".%vw222222222221y2222222222219*y2222222222wd.",
830 ".X;2222222222222222222222222222222222222222b.",
831 ".i*2222222222222222222222222222222222222222v.",
832 ".i*2222222222222222222222222222222222222222;.",
833 ".i*22222222222222222222222222222222222222228.",
834 ".>*2222222222222222222222222222222222222222=.",
835 ".i*22222222222222222222222222222222222222228.",
836 ".i*2222222222222222222222222222222222222222;.",
837 ".X*222222222222222222222222222222we12222222r.",
838 ".Xs12222222w3aw22222222222222222y8s0222222wk.",
839 ".Xq02222222a,na22222222222222222zm6zwy2222gi.",
840 "..>*22222y<:Xcj22222222222222222-o$k;;02228..",
841 "..i7y2220rhX.:y22222222222222222jtiXd,a220,..",
842 " .X@z222a,do%kj2222222222222222wMX5q;gw228%..",
843 " ..58222wagsh6ry222222222222221;>Of0w222y:...",
844 " ...:e2222218mdz22222222222222a&$vw222220@...",
845 " ...O-122222y:.u02222222222229q$uj222221r... ",
846 " ..%&a1222223&573w2222222219NOxz122221z>... ",
847 " ...t3222221-l$nr8ay1222yzbo,=12222w-5... ",
848 " ..X:022222w-k+>o,7s**s7xOn=12221<f5... ",
849 " ..o:9222221j8:&Bl>>>>ihv<12221=dX... ",
850 " ..Xb9122222109g-****;<y22221zn%... ",
851 " ..X&801222222222222222222w-h.... ",
852 " ...o:=022222222222222221=lX... ",
853 " ..X@:;3w2222222222210fO... ",
854 " ...XX&v8<30000003-N@... ",
855 " .....XmnbN:q&Bo.... ",
857 static char *msgs
[] = {
858 "Sloppy focus is a *?#@",
859 "Repent! Sloppy focus users will burn in hell!!!",
865 if (!panel
->timer
&& !broken
&& clicks
> 0) {
872 file
= wDefaultGetIconFile(panel
->scr
, "Logo", "WMPanel", False
);
878 path
= FindImage(wPreferences
.icon_path
, file
);
884 panel
->icon
= RLoadImage(panel
->scr
->rcontext
, path
, 0);
892 panel
->pic
= RGetImageFromXPMData(panel
->scr
->rcontext
, pic_data
);
893 if (!panel
->pic
|| panel
->icon
->width
!=panel
->pic
->width
894 || panel
->icon
->height
!=panel
->pic
->height
) {
896 RDestroyImage(panel
->icon
);
899 RDestroyImage(panel
->pic
);
911 RCombineImageWithColor(panel
->icon
, &color
);
912 RCombineImageWithColor(panel
->pic
, &color
);
916 panel
->str
= msgs
[rand()%(sizeof(msgs
)/sizeof(char*))];
918 panel
->timer
= WMAddTimerHandler(50, logoPushCallback
, panel
);
920 panel
->oldPix
= WMRetainPixmap(WMGetLabelImage(panel
->logoL
));
921 } else if (panel
->timer
) {
926 WMSetLabelImage(panel
->logoL
, panel
->oldPix
);
927 WMReleasePixmap(panel
->oldPix
);
928 panel
->oldPix
= NULL
;
930 WMDeleteTimerHandler(panel
->timer
);
933 sprintf(version
, "Version %s", VERSION
);
934 WMSetLabelText(panel
->versionL
, version
);
939 while (XCheckTypedWindowEvent(dpy
, WMWidgetXID(panel
->versionL
),
943 #endif /* SILLYNESS */
947 wShowInfoPanel(WScreen
*scr
)
957 RColor color1
, color2
;
971 if (thePanel
->scr
== scr
) {
972 wRaiseFrame(thePanel
->wwin
->frame
->core
);
973 wSetFocusTo(scr
, thePanel
->wwin
);
978 panel
= wmalloc(sizeof(InfoPanel
));
979 memset(panel
, 0, sizeof(InfoPanel
));
983 panel
->win
= WMCreateWindow(scr
->wmscreen
, "info");
984 WMResizeWidget(panel
->win
, 382, 230);
986 logo
= WMGetApplicationIconImage(scr
->wmscreen
);
988 size
= WMGetPixmapSize(logo
);
989 panel
->logoL
= WMCreateLabel(panel
->win
);
990 WMResizeWidget(panel
->logoL
, 64, 64);
991 WMMoveWidget(panel
->logoL
, 30, 20);
992 WMSetLabelImagePosition(panel
->logoL
, WIPImageOnly
);
993 WMSetLabelImage(panel
->logoL
, logo
);
995 WMCreateEventHandler(WMWidgetView(panel
->logoL
), ButtonPressMask
,
996 handleLogoPush
, panel
);
1000 panel
->name1L
= WMCreateLabel(panel
->win
);
1001 WMResizeWidget(panel
->name1L
, 240, 30);
1002 WMMoveWidget(panel
->name1L
, 100, 30);
1007 color2
.green
= 0x50;
1009 logo
= renderText(scr
->wmscreen
, "GNU Window Maker",
1010 "-*-utopia-*-r-*-*-25-*", &color1
, &color2
);
1012 WMSetLabelImagePosition(panel
->name1L
, WIPImageOnly
);
1013 WMSetLabelImage(panel
->name1L
, logo
);
1014 WMReleasePixmap(logo
);
1016 font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 20);
1018 WMSetLabelFont(panel
->name1L
, font
);
1019 WMReleaseFont(font
);
1021 WMSetLabelTextAlignment(panel
->name1L
, WACenter
);
1022 WMSetLabelText(panel
->name1L
, "GNU Window Maker");
1025 panel
->name2L
= WMCreateLabel(panel
->win
);
1026 WMResizeWidget(panel
->name2L
, 240, 24);
1027 WMMoveWidget(panel
->name2L
, 100, 60);
1028 font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 18);
1030 WMSetLabelFont(panel
->name2L
, font
);
1031 WMReleaseFont(font
);
1034 WMSetLabelTextAlignment(panel
->name2L
, WACenter
);
1035 WMSetLabelText(panel
->name2L
, "Window Manager for X");
1038 sprintf(version
, "Version %s", VERSION
);
1039 panel
->versionL
= WMCreateLabel(panel
->win
);
1040 WMResizeWidget(panel
->versionL
, 310, 16);
1041 WMMoveWidget(panel
->versionL
, 30, 95);
1042 WMSetLabelTextAlignment(panel
->versionL
, WARight
);
1043 WMSetLabelText(panel
->versionL
, version
);
1044 WMSetLabelWraps(panel
->versionL
, False
);
1046 panel
->copyrL
= WMCreateLabel(panel
->win
);
1047 WMResizeWidget(panel
->copyrL
, 340, 40);
1048 WMMoveWidget(panel
->copyrL
, 15, 185);
1049 WMSetLabelTextAlignment(panel
->copyrL
, WALeft
);
1050 WMSetLabelText(panel
->copyrL
, COPYRIGHT_TEXT
);
1051 /* we want the (c) character in the helvetica font */
1052 font
= WMCreateFontInDefaultEncoding(scr
->wmscreen
, HELVETICA10_FONT
);
1054 WMSetLabelFont(panel
->copyrL
, font
);
1057 switch (scr
->w_depth
) {
1059 strcpy(version
, "32 thousand");
1062 strcpy(version
, "64 thousand");
1066 strcpy(version
, "16 million");
1069 sprintf(version
, "%d", 1<<scr
->w_depth
);
1073 sprintf(buffer
, "Using visual 0x%x: %s %ibpp (%s colors)\n",
1074 (unsigned)scr
->w_visual
->visualid
,
1075 visuals
[scr
->w_visual
->class], scr
->w_depth
, version
);
1077 strcat(buffer
, "Supported image formats: ");
1078 strl
= RSupportedFileFormats();
1079 for (i
=0; strl
[i
]!=NULL
; i
++) {
1080 strcat(buffer
, strl
[i
]);
1081 strcat(buffer
, " ");
1084 strcat(buffer
, "\nAdditional Support For: ");
1097 list
[j
++] = "GNOME";
1103 list
[j
++] = "Sound";
1107 for (i
= 0; i
< j
; i
++) {
1110 strcat(buf
, " and ");
1114 strcat(buf
, list
[i
]);
1116 strcat(buffer
, buf
);
1120 panel
->infoL
= WMCreateLabel(panel
->win
);
1121 WMResizeWidget(panel
->infoL
, 350, 75);
1122 WMMoveWidget(panel
->infoL
, 15, 115);
1123 WMSetLabelText(panel
->infoL
, buffer
);
1125 WMSetLabelFont(panel
->infoL
, font
);
1126 WMReleaseFont(font
);
1130 WMRealizeWidget(panel
->win
);
1131 WMMapSubwidgets(panel
->win
);
1133 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 382, 230, 0, 0, 0);
1135 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1137 WMMapWidget(panel
->win
);
1139 wwin
= wManageInternalWindow(scr
, parent
, None
, "Info",
1140 (scr
->scr_width
- 382)/2,
1141 (scr
->scr_height
- 230)/2, 382, 230);
1143 WSETUFLAG(wwin
, no_closable
, 0);
1144 WSETUFLAG(wwin
, no_close_button
, 0);
1145 wWindowUpdateButtonImages(wwin
);
1146 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1147 wwin
->frame
->on_click_right
= destroyInfoPanel
;
1155 if (InitXThing(panel
->scr
)) {
1156 panel
->timer
= WMAddTimerHandler(100, logoPushCallback
, panel
);
1159 panel
->str
= "Merry Christmas!";
1160 panel
->oldPix
= WMRetainPixmap(WMGetLabelImage(panel
->logoL
));
1167 ***********************************************************************
1169 ***********************************************************************
1184 #define LICENSE_TEXT \
1185 " Window Maker is free software; you can redistribute it and/or modify "\
1186 "it under the terms of the GNU General Public License as published "\
1187 "by the Free Software Foundation; either version 2 of the License, "\
1188 "or (at your option) any later version.\n\n\n"\
1189 " Window Maker is distributed in the hope that it will be useful, but "\
1190 "WITHOUT ANY WARRANTY; without even the implied warranty of "\
1191 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU "\
1192 "General Public License for more details.\n\n\n"\
1193 " You should have received a copy of the GNU General Public License "\
1194 "along with this program; if not, write to the Free Software "\
1195 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA "\
1199 static LegalPanel
*legalPanel
= NULL
;
1202 destroyLegalPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
1204 WMUnmapWidget(legalPanel
->win
);
1206 WMDestroyWidget(legalPanel
->win
);
1208 wUnmanageWindow(legalPanel
->wwin
, False
, False
);
1217 wShowLegalPanel(WScreen
*scr
)
1224 if (legalPanel
->scr
== scr
) {
1225 wRaiseFrame(legalPanel
->wwin
->frame
->core
);
1226 wSetFocusTo(scr
, legalPanel
->wwin
);
1231 panel
= wmalloc(sizeof(LegalPanel
));
1235 panel
->win
= WMCreateWindow(scr
->wmscreen
, "legal");
1236 WMResizeWidget(panel
->win
, 420, 250);
1239 panel
->licenseL
= WMCreateLabel(panel
->win
);
1240 WMResizeWidget(panel
->licenseL
, 400, 230);
1241 WMMoveWidget(panel
->licenseL
, 10, 10);
1242 WMSetLabelTextAlignment(panel
->licenseL
, WALeft
);
1243 WMSetLabelText(panel
->licenseL
, LICENSE_TEXT
);
1244 WMSetLabelRelief(panel
->licenseL
, WRGroove
);
1246 WMRealizeWidget(panel
->win
);
1247 WMMapSubwidgets(panel
->win
);
1249 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 420, 250, 0, 0, 0);
1251 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1253 wwin
= wManageInternalWindow(scr
, parent
, None
, "Legal",
1254 (scr
->scr_width
- 420)/2,
1255 (scr
->scr_height
- 250)/2, 420, 250);
1257 WSETUFLAG(wwin
, no_closable
, 0);
1258 WSETUFLAG(wwin
, no_close_button
, 0);
1259 wWindowUpdateButtonImages(wwin
);
1260 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1261 wwin
->frame
->on_click_right
= destroyLegalPanel
;
1265 WMMapWidget(panel
->win
);
1274 ***********************************************************************
1275 * Crashing Dialog Panel
1276 ***********************************************************************
1279 extern WDDomain
*WDWindowAttributes
;
1282 typedef struct _CrashPanel
{
1283 WMWindow
*win
; /* main window */
1285 WMLabel
*iconL
; /* application icon */
1286 WMLabel
*nameL
; /* title of panel */
1288 WMFrame
*sepF
; /* separator frame */
1290 WMLabel
*noteL
; /* Title of note */
1291 WMLabel
*note2L
; /* body of note with what happened */
1293 WMFrame
*whatF
; /* "what to do next" frame */
1294 WMPopUpButton
*whatP
; /* action selection popup button */
1296 WMButton
*okB
; /* ok button */
1298 Bool done
; /* if finished with this dialog */
1299 int action
; /* what to do after */
1307 handleKeyPress(XEvent
*event
, void *clientData
)
1309 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1311 if (event
->xkey
.keycode
== panel
->retKey
) {
1312 WMPerformButtonClick(panel
->okB
);
1318 okButtonCallback(void *self
, void *clientData
)
1320 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1327 setCrashAction(void *self
, void *clientData
)
1329 WMPopUpButton
*pop
= (WMPopUpButton
*)self
;
1330 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1332 panel
->action
= WMGetPopUpButtonSelectedItem(pop
);
1337 getWindowMakerIconImage(WMScreen
*scr
)
1339 proplist_t dict
, key
, option
, value
=NULL
;
1343 PLSetStringCmpHook(NULL
);
1345 key
= PLMakeString("Logo.WMPanel");
1346 option
= PLMakeString("Icon");
1348 dict
= PLGetDictionaryEntry(WDWindowAttributes
->dictionary
, key
);
1351 value
= PLGetDictionaryEntry(dict
, option
);
1357 PLSetStringCmpHook(StringCompareHook
);
1359 if (value
&& PLIsString(value
)) {
1360 path
= FindImage(wPreferences
.icon_path
, PLGetString(value
));
1365 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
1367 pix
= WMCreatePixmapFromRImage(scr
, image
, 0);
1368 RDestroyImage(image
);
1383 wShowCrashingDialogPanel(int whatSig
)
1389 int screen_no
, scr_width
, scr_height
;
1393 panel
= wmalloc(sizeof(CrashPanel
));
1394 memset(panel
, 0, sizeof(CrashPanel
));
1396 screen_no
= DefaultScreen(dpy
);
1397 scr_width
= WidthOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1398 scr_height
= HeightOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1400 scr
= WMCreateScreen(dpy
, screen_no
);
1402 wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
1406 panel
->retKey
= XKeysymToKeycode(dpy
, XK_Return
);
1408 panel
->win
= WMCreateWindow(scr
, "crashingDialog");
1409 WMResizeWidget(panel
->win
, PWIDTH
, PHEIGHT
);
1410 WMMoveWidget(panel
->win
, (scr_width
- PWIDTH
)/2, (scr_height
- PHEIGHT
)/2);
1412 logo
= getWindowMakerIconImage(scr
);
1414 panel
->iconL
= WMCreateLabel(panel
->win
);
1415 WMResizeWidget(panel
->iconL
, 64, 64);
1416 WMMoveWidget(panel
->iconL
, 10, 10);
1417 WMSetLabelImagePosition(panel
->iconL
, WIPImageOnly
);
1418 WMSetLabelImage(panel
->iconL
, logo
);
1421 panel
->nameL
= WMCreateLabel(panel
->win
);
1422 WMResizeWidget(panel
->nameL
, 190, 18);
1423 WMMoveWidget(panel
->nameL
, 80, 35);
1424 WMSetLabelTextAlignment(panel
->nameL
, WALeft
);
1425 font
= WMBoldSystemFontOfSize(scr
, 18);
1426 WMSetLabelFont(panel
->nameL
, font
);
1427 WMReleaseFont(font
);
1428 WMSetLabelText(panel
->nameL
, _("Fatal error"));
1430 panel
->sepF
= WMCreateFrame(panel
->win
);
1431 WMResizeWidget(panel
->sepF
, PWIDTH
+4, 2);
1432 WMMoveWidget(panel
->sepF
, -2, 80);
1434 panel
->noteL
= WMCreateLabel(panel
->win
);
1435 WMResizeWidget(panel
->noteL
, PWIDTH
-20, 40);
1436 WMMoveWidget(panel
->noteL
, 10, 90);
1437 WMSetLabelTextAlignment(panel
->noteL
, WAJustified
);
1438 #ifdef SYS_SIGLIST_DECLARED
1439 sprintf(buf
, _("Window Maker received signal %i\n(%s)."),
1440 whatSig
, sys_siglist
[whatSig
]);
1442 sprintf(buf
, _("Window Maker received signal %i."), whatSig
);
1444 WMSetLabelText(panel
->noteL
, buf
);
1446 panel
->note2L
= WMCreateLabel(panel
->win
);
1447 WMResizeWidget(panel
->note2L
, PWIDTH
-20, 100);
1448 WMMoveWidget(panel
->note2L
, 10, 130);
1449 WMSetLabelTextAlignment(panel
->note2L
, WALeft
);
1450 WMSetLabelText(panel
->note2L
,
1451 _(" This fatal error occured probably due to a bug."
1452 " Please fill the included BUGFORM and "
1453 "report it to bugs@windowmaker.org."));
1456 panel
->whatF
= WMCreateFrame(panel
->win
);
1457 WMResizeWidget(panel
->whatF
, PWIDTH
-20, 50);
1458 WMMoveWidget(panel
->whatF
, 10, 240);
1459 WMSetFrameTitle(panel
->whatF
, _("What do you want to do now?"));
1461 panel
->whatP
= WMCreatePopUpButton(panel
->whatF
);
1462 WMResizeWidget(panel
->whatP
, PWIDTH
-20-70, 20);
1463 WMMoveWidget(panel
->whatP
, 35, 20);
1464 WMSetPopUpButtonPullsDown(panel
->whatP
, False
);
1465 WMSetPopUpButtonText(panel
->whatP
, _("Select action"));
1466 WMAddPopUpButtonItem(panel
->whatP
, _("Abort and leave a core file"));
1467 WMAddPopUpButtonItem(panel
->whatP
, _("Restart Window Maker"));
1468 WMAddPopUpButtonItem(panel
->whatP
, _("Start alternate window manager"));
1469 WMSetPopUpButtonAction(panel
->whatP
, setCrashAction
, panel
);
1470 WMSetPopUpButtonSelectedItem(panel
->whatP
, WMRestart
);
1471 panel
->action
= WMRestart
;
1473 WMMapSubwidgets(panel
->whatF
);
1475 panel
->okB
= WMCreateCommandButton(panel
->win
);
1476 WMResizeWidget(panel
->okB
, 80, 26);
1477 WMMoveWidget(panel
->okB
, 205, 309);
1478 WMSetButtonText(panel
->okB
, _("OK"));
1479 WMSetButtonImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIReturnArrow
));
1480 WMSetButtonAltImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIHighlightedReturnArrow
));
1481 WMSetButtonImagePosition(panel
->okB
, WIPRight
);
1482 WMSetButtonAction(panel
->okB
, okButtonCallback
, panel
);
1486 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
,
1487 handleKeyPress
, panel
);
1489 WMRealizeWidget(panel
->win
);
1490 WMMapSubwidgets(panel
->win
);
1492 WMMapWidget(panel
->win
);
1494 XSetInputFocus(dpy
, WMWidgetXID(panel
->win
), RevertToParent
, CurrentTime
);
1496 while (!panel
->done
) {
1499 WMNextEvent(dpy
, &event
);
1500 WMHandleEvent(&event
);
1503 action
= panel
->action
;
1505 WMUnmapWidget(panel
->win
);
1506 WMDestroyWidget(panel
->win
);
1515 /*****************************************************************************
1516 * About GNUstep Panel
1517 *****************************************************************************/
1521 drawGNUstepLogo(Display
*dpy
, Drawable d
, int width
, int height
,
1522 unsigned long blackPixel
, unsigned long whitePixel
)
1526 XRectangle rects
[3];
1528 gcv
.foreground
= blackPixel
;
1529 gc
= XCreateGC(dpy
, d
, GCForeground
, &gcv
);
1531 XFillArc(dpy
, d
, gc
, width
/45, height
/45,
1532 width
- 2*width
/45, height
- 2*height
/45, 0, 360*64);
1535 rects
[0].y
= 37*height
/45;
1536 rects
[0].width
= width
/3;
1537 rects
[0].height
= height
- rects
[0].y
;
1539 rects
[1].x
= rects
[0].width
;
1540 rects
[1].y
= height
/2;
1541 rects
[1].width
= width
- 2*width
/3;
1542 rects
[1].height
= height
- rects
[1].y
;
1544 rects
[2].x
= 2*width
/3;
1545 rects
[2].y
= height
- 37*height
/45;
1546 rects
[2].width
= width
/3;
1547 rects
[2].height
= height
- rects
[2].y
;
1549 XSetClipRectangles(dpy
, gc
, 0, 0, rects
, 3, Unsorted
);
1550 XFillRectangle(dpy
, d
, gc
, 0, 0, width
, height
);
1552 XSetForeground(dpy
, gc
, whitePixel
);
1553 XFillArc(dpy
, d
, gc
, width
/45, height
/45,
1554 width
- 2*width
/45, height
- 2*height
/45, 0, 360*64);
1561 #define GNUSTEP_TEXT \
1562 "Window Maker is part of the GNUstep project.\n"\
1563 "The GNUstep project aims to create a free\n"\
1564 "implementation of the OpenStep(tm) specification\n"\
1565 "which is a object-oriented framework for\n"\
1566 "creating advanced graphical, multi-platform\n"\
1567 "applications. Aditionally, a development and\n"\
1568 "user desktop enviroment will be created on top\n"\
1569 "of the framework. For more information about\n"\
1570 "GNUstep, please visit: www.gnustep.org"
1585 static GNUstepPanel
*gnustepPanel
= NULL
;
1588 destroyGNUstepPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
1590 WMUnmapWidget(gnustepPanel
->win
);
1592 WMDestroyWidget(gnustepPanel
->win
);
1594 wUnmanageWindow(gnustepPanel
->wwin
, False
, False
);
1598 gnustepPanel
= NULL
;
1603 wShowGNUstepPanel(WScreen
*scr
)
1605 GNUstepPanel
*panel
;
1612 if (gnustepPanel
->scr
== scr
) {
1613 wRaiseFrame(gnustepPanel
->wwin
->frame
->core
);
1614 wSetFocusTo(scr
, gnustepPanel
->wwin
);
1619 panel
= wmalloc(sizeof(GNUstepPanel
));
1623 panel
->win
= WMCreateWindow(scr
->wmscreen
, "About GNUstep");
1624 WMResizeWidget(panel
->win
, 325, 200);
1626 pixmap
= WMCreatePixmap(scr
->wmscreen
, 130, 130,
1627 WMScreenDepth(scr
->wmscreen
), True
);
1629 color
= WMCreateNamedColor(scr
->wmscreen
, "gray50", True
);
1631 drawGNUstepLogo(dpy
, WMGetPixmapXID(pixmap
), 130, 130,
1632 WMColorPixel(color
), scr
->white_pixel
);
1634 WMReleaseColor(color
);
1636 XSetForeground(dpy
, scr
->mono_gc
, 0);
1637 XFillRectangle(dpy
, WMGetPixmapMaskXID(pixmap
), scr
->mono_gc
, 0, 0,
1639 drawGNUstepLogo(dpy
, WMGetPixmapMaskXID(pixmap
), 130, 130, 1, 1);
1641 panel
->gstepL
= WMCreateLabel(panel
->win
);
1642 WMResizeWidget(panel
->gstepL
, 285, 64);
1643 WMMoveWidget(panel
->gstepL
, 20, 0);
1644 WMSetLabelTextAlignment(panel
->gstepL
, WARight
);
1645 WMSetLabelText(panel
->gstepL
, "GNUstep");
1647 WMFont
*font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 24);
1649 WMSetLabelFont(panel
->gstepL
, font
);
1650 WMReleaseFont(font
);
1653 panel
->textL
= WMCreateLabel(panel
->win
);
1654 WMResizeWidget(panel
->textL
, 275, 130);
1655 WMMoveWidget(panel
->textL
, 30, 50);
1656 WMSetLabelTextAlignment(panel
->textL
, WARight
);
1657 WMSetLabelImagePosition(panel
->textL
, WIPOverlaps
);
1658 WMSetLabelText(panel
->textL
, GNUSTEP_TEXT
);
1659 WMSetLabelImage(panel
->textL
, pixmap
);
1661 WMReleasePixmap(pixmap
);
1663 WMRealizeWidget(panel
->win
);
1664 WMMapSubwidgets(panel
->win
);
1666 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 325, 200, 0, 0, 0);
1668 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1670 wwin
= wManageInternalWindow(scr
, parent
, None
, "About GNUstep",
1671 (scr
->scr_width
- 325)/2,
1672 (scr
->scr_height
- 200)/2, 325, 200);
1674 WSETUFLAG(wwin
, no_closable
, 0);
1675 WSETUFLAG(wwin
, no_close_button
, 0);
1676 wWindowUpdateButtonImages(wwin
);
1677 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1678 wwin
->frame
->on_click_right
= destroyGNUstepPanel
;
1682 WMMapWidget(panel
->win
);
1686 gnustepPanel
= panel
;