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
),
269 WMSetButtonEnabled(panel
->okButton
, False
);
271 WMSetLabelText(panel
->iconView
, _("Could not load image file "));
273 WMSetLabelImage(panel
->iconView
, NULL
);
275 WMSetButtonEnabled(panel
->okButton
, True
);
277 WMSetLabelText(panel
->iconView
, NULL
);
278 WMSetLabelImage(panel
->iconView
, pixmap
);
279 WMReleasePixmap(pixmap
);
285 listCallback(void *self
, void *data
)
287 WMList
*lPtr
= (WMList
*)self
;
288 IconPanel
*panel
= (IconPanel
*)data
;
291 if (lPtr
==panel
->dirList
) {
292 path
= WMGetListSelectedItem(lPtr
)->text
;
294 WMSetTextFieldText(panel
->fileField
, path
);
296 WMSetLabelImage(panel
->iconView
, NULL
);
298 WMSetButtonEnabled(panel
->okButton
, False
);
300 WMClearList(panel
->iconList
);
301 listPixmaps(panel
->scr
, panel
->iconList
, path
);
303 char *tmp
, *iconFile
;
305 path
= WMGetListSelectedItem(panel
->dirList
)->text
;
306 tmp
= wexpandpath(path
);
308 iconFile
= WMGetListSelectedItem(panel
->iconList
)->text
;
310 path
= wmalloc(strlen(tmp
)+strlen(iconFile
)+4);
313 strcat(path
, iconFile
);
315 WMSetTextFieldText(panel
->fileField
, path
);
316 setViewedImage(panel
, path
);
323 listIconPaths(WMList
*lPtr
)
328 paths
= wstrdup(wPreferences
.icon_path
);
330 path
= strtok(paths
, ":");
335 tmp
= wexpandpath(path
);
336 /* do not sort, because the order implies the order of
337 * directories searched */
338 if (access(tmp
, X_OK
)==0)
339 WMAddListItem(lPtr
, path
);
341 } while ((path
=strtok(NULL
, ":"))!=NULL
);
349 buttonCallback(void *self
, void *clientData
)
351 WMButton
*bPtr
= (WMButton
*)self
;
352 IconPanel
*panel
= (IconPanel
*)clientData
;
355 if (bPtr
==panel
->okButton
) {
357 panel
->result
= True
;
358 } else if (bPtr
==panel
->cancelButton
) {
360 panel
->result
= False
;
363 else if (bPtr
==panel
->chooseButton
) {
366 op
= WMCreateOpenPanel(WMWidgetScreen(bPtr
));
368 if (WMRunModalFilePanelForDirectory(op
, NULL
, "/usr/local", NULL
, NULL
)) {
370 path
= WMGetFilePanelFile(op
);
371 WMSetTextFieldText(panel
->fileField
, path
);
372 setViewedImage(panel
, path
);
375 WMDestroyFilePanel(op
);
382 wIconChooserDialog(WScreen
*scr
, char **file
, char *instance
, char *class)
390 panel
= wmalloc(sizeof(IconPanel
));
391 memset(panel
, 0, sizeof(IconPanel
));
395 panel
->win
= WMCreateWindow(scr
->wmscreen
, "iconChooser");
396 WMResizeWidget(panel
->win
, 450, 280);
398 boldFont
= WMBoldSystemFontOfSize(scr
->wmscreen
, 12);
400 panel
->dirLabel
= WMCreateLabel(panel
->win
);
401 WMResizeWidget(panel
->dirLabel
, 200, 20);
402 WMMoveWidget(panel
->dirLabel
, 10, 7);
403 WMSetLabelText(panel
->dirLabel
, _("Directories"));
404 WMSetLabelFont(panel
->dirLabel
, boldFont
);
405 WMSetLabelTextAlignment(panel
->dirLabel
, WACenter
);
407 WMSetLabelRelief(panel
->dirLabel
, WRSunken
);
409 panel
->iconLabel
= WMCreateLabel(panel
->win
);
410 WMResizeWidget(panel
->iconLabel
, 140, 20);
411 WMMoveWidget(panel
->iconLabel
, 215, 7);
412 WMSetLabelText(panel
->iconLabel
, _("Icons"));
413 WMSetLabelFont(panel
->iconLabel
, boldFont
);
414 WMSetLabelTextAlignment(panel
->iconLabel
, WACenter
);
416 WMReleaseFont(boldFont
);
418 color
= WMWhiteColor(scr
->wmscreen
);
419 WMSetLabelTextColor(panel
->dirLabel
, color
);
420 WMSetLabelTextColor(panel
->iconLabel
, color
);
421 WMReleaseColor(color
);
423 color
= WMDarkGrayColor(scr
->wmscreen
);
424 WMSetWidgetBackgroundColor(panel
->iconLabel
, color
);
425 WMSetWidgetBackgroundColor(panel
->dirLabel
, color
);
426 WMReleaseColor(color
);
428 WMSetLabelRelief(panel
->iconLabel
, WRSunken
);
430 panel
->dirList
= WMCreateList(panel
->win
);
431 WMResizeWidget(panel
->dirList
, 200, 170);
432 WMMoveWidget(panel
->dirList
, 10, 30);
433 WMSetListAction(panel
->dirList
, listCallback
, panel
);
435 panel
->iconList
= WMCreateList(panel
->win
);
436 WMResizeWidget(panel
->iconList
, 140, 170);
437 WMMoveWidget(panel
->iconList
, 215, 30);
438 WMSetListAction(panel
->iconList
, listCallback
, panel
);
440 panel
->iconView
= WMCreateLabel(panel
->win
);
441 WMResizeWidget(panel
->iconView
, 75, 75);
442 WMMoveWidget(panel
->iconView
, 365, 60);
443 WMSetLabelImagePosition(panel
->iconView
, WIPOverlaps
);
444 WMSetLabelRelief(panel
->iconView
, WRSunken
);
445 WMSetLabelTextAlignment(panel
->iconView
, WACenter
);
447 panel
->fileLabel
= WMCreateLabel(panel
->win
);
448 WMResizeWidget(panel
->fileLabel
, 80, 20);
449 WMMoveWidget(panel
->fileLabel
, 10, 210);
450 WMSetLabelText(panel
->fileLabel
, _("File Name:"));
452 panel
->fileField
= WMCreateTextField(panel
->win
);
453 WMResizeWidget(panel
->fileField
, 345, 20);
454 WMMoveWidget(panel
->fileField
, 95, 210);
455 WMSetTextFieldEditable(panel
->fileField
, False
);
457 panel
->okButton
= WMCreateCommandButton(panel
->win
);
458 WMResizeWidget(panel
->okButton
, 80, 26);
459 WMMoveWidget(panel
->okButton
, 360, 240);
460 WMSetButtonText(panel
->okButton
, _("OK"));
461 WMSetButtonEnabled(panel
->okButton
, False
);
462 WMSetButtonAction(panel
->okButton
, buttonCallback
, panel
);
464 panel
->cancelButton
= WMCreateCommandButton(panel
->win
);
465 WMResizeWidget(panel
->cancelButton
, 80, 26);
466 WMMoveWidget(panel
->cancelButton
, 270, 240);
467 WMSetButtonText(panel
->cancelButton
, _("Cancel"));
468 WMSetButtonAction(panel
->cancelButton
, buttonCallback
, panel
);
470 panel
->chooseButton
= WMCreateCommandButton(panel
->win
);
471 WMResizeWidget(panel
->chooseButton
, 110, 26);
472 WMMoveWidget(panel
->chooseButton
, 150, 240);
473 WMSetButtonText(panel
->chooseButton
, _("Choose File"));
474 WMSetButtonAction(panel
->chooseButton
, buttonCallback
, panel
);
476 WMRealizeWidget(panel
->win
);
477 WMMapSubwidgets(panel
->win
);
479 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 450, 280, 0, 0, 0);
481 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
486 tmp
= malloc((instance
? strlen(instance
) : 0)
487 + (class ? strlen(class) : 0) + 32);
489 if (tmp
&& (instance
|| class))
490 sprintf(tmp
, "%s [%s.%s]", _("Icon Chooser"), instance
, class);
492 strcpy(tmp
, _("Icon Chooser"));
494 wwin
= wManageInternalWindow(scr
, parent
, None
, tmp
,
495 (scr
->scr_width
- 450)/2,
496 (scr
->scr_height
- 280)/2, 450, 280);
500 /* put icon paths in the list */
501 listIconPaths(panel
->dirList
);
503 WMMapWidget(panel
->win
);
507 while (!panel
->done
) {
510 WMNextEvent(dpy
, &event
);
511 WMHandleEvent(&event
);
515 char *defaultPath
, *wantedPath
;
517 /* check if the file the user selected is not the one that
518 * would be loaded by default with the current search path */
519 *file
= WMGetListSelectedItem(panel
->iconList
)->text
;
524 defaultPath
= FindImage(wPreferences
.icon_path
, *file
);
525 wantedPath
= WMGetTextFieldText(panel
->fileField
);
526 /* if the file is not the default, use full path */
527 if (strcmp(wantedPath
, defaultPath
)!=0) {
530 *file
= wstrdup(*file
);
539 WMUnmapWidget(panel
->win
);
541 WMDestroyWidget(panel
->win
);
543 wUnmanageWindow(wwin
, False
, False
);
547 XDestroyWindow(dpy
, parent
);
549 return panel
->result
;
554 ***********************************************************************
556 ***********************************************************************
590 #define COPYRIGHT_TEXT \
591 "Copyright \xa9 1997~1999 Alfredo K. Kojima <kojima@windowmaker.org>\n"\
592 "Copyright \xa9 1998,1999 Dan Pascu <dan@windowmaker.org>"
596 static InfoPanel
*thePanel
= NULL
;
599 destroyInfoPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
602 if (thePanel
->timer
) {
603 WMDeleteTimerHandler(thePanel
->timer
);
605 if (thePanel
->oldPix
) {
606 WMReleasePixmap(thePanel
->oldPix
);
608 if (thePanel
->icon
) {
609 RDestroyImage(thePanel
->icon
);
612 RDestroyImage(thePanel
->pic
);
614 #endif /* SILLYNESS */
615 WMUnmapWidget(thePanel
);
617 wUnmanageWindow(thePanel
->wwin
, False
, False
);
619 WMDestroyWidget(thePanel
->win
);
628 renderText(WMScreen
*scr
, char *text
, char *font
, RColor
*from
, RColor
*to
)
630 WMPixmap
*wpix
= NULL
;
633 RContext
*rc
= WMScreenRContext(scr
);
634 XFontStruct
*f
= NULL
;
638 f
= XLoadQueryFont(dpy
, font
);
642 w
= XTextWidth(f
, text
, strlen(text
));
643 h
= f
->ascent
+f
->descent
;
645 mask
= XCreatePixmap(dpy
, rc
->drawable
, w
, h
, 1);
646 gc
= XCreateGC(dpy
, mask
, 0, NULL
);
647 XSetForeground(dpy
, gc
, 0);
648 XSetFont(dpy
, gc
, f
->fid
);
649 XFillRectangle(dpy
, mask
, gc
, 0, 0, w
, h
);
651 XSetForeground(dpy
, gc
, 1);
652 XDrawString(dpy
, mask
, gc
, 0, f
->ascent
, text
, strlen(text
));
653 XSetLineAttributes(dpy
, gc
, 3, LineSolid
, CapRound
, JoinMiter
);
654 XDrawLine(dpy
, mask
, gc
, 0, h
-2, w
, h
-2);
656 grad
= XCreatePixmap(dpy
, rc
->drawable
, w
, h
, rc
->depth
);
660 color
= WMBlackColor(scr
);
661 XFillRectangle(dpy
, grad
, WMColorGC(color
), 0, 0, w
, h
);
662 WMReleaseColor(color
);
665 wpix
= WMCreatePixmapFromXPixmaps(scr
, grad
, mask
, w
, h
, rc
->depth
);
676 extern WMPixmap
*DoXThing();
677 extern Bool
InitXThing();
680 logoPushCallback(void *data
)
682 InfoPanel
*panel
= (InfoPanel
*)data
;
686 static int jingobeu
[] = {
687 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
688 329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
689 329, 150, 392, 150, 261, 150, 293, 150, 329, 400, -1, 400, 0
697 if(jingobeu
[panel
->x
-1]==0){panel
->x
=-1;}else if(jingobeu
[panel
->x
698 -1]<0){panel
->x
++;c
=jingobeu
[panel
->x
-1]/50;panel
->x
++;}else if(c
==0){
699 kc
.bell_pitch
=jingobeu
[panel
->x
-1];panel
->x
++;kc
.bell_percent
=50;c
=
700 jingobeu
[panel
->x
-1]/50;kc
.bell_duration
=jingobeu
[panel
->x
-1];panel
->x
++;
701 XChangeKeyboardControl(dpy
,KBBellPitch
|KBBellDuration
|KBBellPercent
,&kc
);
702 XBell(dpy
,50);XFlush(dpy
);}else{c
--;}}
703 if (!(panel
->cycle
% 4)) {
706 p
= DoXThing(panel
->wwin
);
707 WMSetLabelImage(panel
->logoL
, p
);
709 } else if (panel
->cycle
< 30) {
713 image
= RCloneImage(panel
->icon
);
714 RCombineImagesWithOpaqueness(image
, panel
->pic
, panel
->cycle
*255/30);
715 pix
= WMCreatePixmapFromRImage(panel
->scr
->wmscreen
, image
, 128);
716 RDestroyImage(image
);
717 WMSetLabelImage(panel
->logoL
, pix
);
718 WMReleasePixmap(pix
);
721 i
= panel
->cycle
%200;
723 len
= strlen(panel
->str
);
725 strncpy(buffer
, panel
->str
, i
<len
? i
: len
);
727 memset(&buffer
[len
], ' ', i
-len
);
729 strncpy(buffer
, panel
->str
, i
<len
? i
: len
);
731 memset(&buffer
[len
], ' ', i
-len
);
733 WMSetLabelText(panel
->versionL
, buffer
);
735 panel
->timer
= WMAddTimerHandler(50, logoPushCallback
, panel
);
741 handleLogoPush(XEvent
*event
, void *data
)
743 InfoPanel
*panel
= (InfoPanel
*)data
;
744 static int broken
= 0;
745 static int clicks
= 0;
746 static char *pic_data
[] = {
806 " ....XoO+@##+O$%.... ",
807 " ...%X&*========-;;:o... ",
808 " ...>.>,<122222222222134@... ",
809 " ..>5678912222222222222220q%.. ",
810 " ..$.&-w2222222222222222222er>.. ",
811 " ..O.t31222222222222222222222y4>.. ",
812 " ...O5u3222222222222222222222222yri... ",
813 " ..>p&a22222222222222222222222222wso.. ",
814 " ..ids91222222222222222222222222222wfi.. ",
815 " ..X.7w222222wgs-w2222222213=g0222222<hi.. ",
816 " ..Xuj2222222<@X5=222222229k@l:022222y4i.. ",
817 " .Xdz22222222*X%.s22222222axo%$-222222<c>.. ",
818 " ..o7y22222222v...r222222223hX.i82222221si.. ",
819 "..io*222222222&...u22222222yt..%*22222220:%. ",
820 "..>k02222222227...f222222222v..X=222222229t. ",
821 "..dz12222222220ui:y2222222223d%qw222222221g. ",
822 ".%vw222222222221y2222222222219*y2222222222wd.",
823 ".X;2222222222222222222222222222222222222222b.",
824 ".i*2222222222222222222222222222222222222222v.",
825 ".i*2222222222222222222222222222222222222222;.",
826 ".i*22222222222222222222222222222222222222228.",
827 ".>*2222222222222222222222222222222222222222=.",
828 ".i*22222222222222222222222222222222222222228.",
829 ".i*2222222222222222222222222222222222222222;.",
830 ".X*222222222222222222222222222222we12222222r.",
831 ".Xs12222222w3aw22222222222222222y8s0222222wk.",
832 ".Xq02222222a,na22222222222222222zm6zwy2222gi.",
833 "..>*22222y<:Xcj22222222222222222-o$k;;02228..",
834 "..i7y2220rhX.:y22222222222222222jtiXd,a220,..",
835 " .X@z222a,do%kj2222222222222222wMX5q;gw228%..",
836 " ..58222wagsh6ry222222222222221;>Of0w222y:...",
837 " ...:e2222218mdz22222222222222a&$vw222220@...",
838 " ...O-122222y:.u02222222222229q$uj222221r... ",
839 " ..%&a1222223&573w2222222219NOxz122221z>... ",
840 " ...t3222221-l$nr8ay1222yzbo,=12222w-5... ",
841 " ..X:022222w-k+>o,7s**s7xOn=12221<f5... ",
842 " ..o:9222221j8:&Bl>>>>ihv<12221=dX... ",
843 " ..Xb9122222109g-****;<y22221zn%... ",
844 " ..X&801222222222222222222w-h.... ",
845 " ...o:=022222222222222221=lX... ",
846 " ..X@:;3w2222222222210fO... ",
847 " ...XX&v8<30000003-N@... ",
848 " .....XmnbN:q&Bo.... ",
850 static char *msgs
[] = {
851 "Sloppy focus is a *?#@",
852 "Repent! Sloppy focus users will burn in hell!!!",
858 if (!panel
->timer
&& !broken
&& clicks
> 0) {
865 file
= wDefaultGetIconFile(panel
->scr
, "Logo", "WMPanel", False
);
871 path
= FindImage(wPreferences
.icon_path
, file
);
877 panel
->icon
= RLoadImage(panel
->scr
->rcontext
, path
, 0);
885 panel
->pic
= RGetImageFromXPMData(panel
->scr
->rcontext
, pic_data
);
886 if (!panel
->pic
|| panel
->icon
->width
!=panel
->pic
->width
887 || panel
->icon
->height
!=panel
->pic
->height
) {
889 RDestroyImage(panel
->icon
);
892 RDestroyImage(panel
->pic
);
904 RCombineImageWithColor(panel
->icon
, &color
);
905 RCombineImageWithColor(panel
->pic
, &color
);
909 panel
->str
= msgs
[rand()%(sizeof(msgs
)/sizeof(char*))];
911 panel
->timer
= WMAddTimerHandler(50, logoPushCallback
, panel
);
913 panel
->oldPix
= WMRetainPixmap(WMGetLabelImage(panel
->logoL
));
914 } else if (panel
->timer
) {
919 WMSetLabelImage(panel
->logoL
, panel
->oldPix
);
920 WMReleasePixmap(panel
->oldPix
);
921 panel
->oldPix
= NULL
;
923 WMDeleteTimerHandler(panel
->timer
);
926 sprintf(version
, "Version %s", VERSION
);
927 WMSetLabelText(panel
->versionL
, version
);
932 while (XCheckTypedWindowEvent(dpy
, WMWidgetXID(panel
->versionL
),
936 #endif /* SILLYNESS */
940 wShowInfoPanel(WScreen
*scr
)
950 RColor color1
, color2
;
964 if (thePanel
->scr
== scr
) {
965 wRaiseFrame(thePanel
->wwin
->frame
->core
);
966 wSetFocusTo(scr
, thePanel
->wwin
);
971 panel
= wmalloc(sizeof(InfoPanel
));
972 memset(panel
, 0, sizeof(InfoPanel
));
976 panel
->win
= WMCreateWindow(scr
->wmscreen
, "info");
977 WMResizeWidget(panel
->win
, 382, 230);
979 logo
= WMGetApplicationIconImage(scr
->wmscreen
);
981 size
= WMGetPixmapSize(logo
);
982 panel
->logoL
= WMCreateLabel(panel
->win
);
983 WMResizeWidget(panel
->logoL
, 64, 64);
984 WMMoveWidget(panel
->logoL
, 30, 20);
985 WMSetLabelImagePosition(panel
->logoL
, WIPImageOnly
);
986 WMSetLabelImage(panel
->logoL
, logo
);
988 WMCreateEventHandler(WMWidgetView(panel
->logoL
), ButtonPressMask
,
989 handleLogoPush
, panel
);
993 panel
->name1L
= WMCreateLabel(panel
->win
);
994 WMResizeWidget(panel
->name1L
, 240, 30);
995 WMMoveWidget(panel
->name1L
, 100, 30);
1000 color2
.green
= 0x50;
1002 logo
= renderText(scr
->wmscreen
, "GNU Window Maker",
1003 "-*-utopia-*-r-*-*-25-*", &color1
, &color2
);
1005 WMSetLabelImagePosition(panel
->name1L
, WIPImageOnly
);
1006 WMSetLabelImage(panel
->name1L
, logo
);
1007 WMReleasePixmap(logo
);
1009 font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 20);
1011 WMSetLabelFont(panel
->name1L
, font
);
1012 WMReleaseFont(font
);
1014 WMSetLabelTextAlignment(panel
->name1L
, WACenter
);
1015 WMSetLabelText(panel
->name1L
, "GNU Window Maker");
1018 panel
->name2L
= WMCreateLabel(panel
->win
);
1019 WMResizeWidget(panel
->name2L
, 240, 24);
1020 WMMoveWidget(panel
->name2L
, 100, 60);
1021 font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 18);
1023 WMSetLabelFont(panel
->name2L
, font
);
1024 WMReleaseFont(font
);
1027 WMSetLabelTextAlignment(panel
->name2L
, WACenter
);
1028 WMSetLabelText(panel
->name2L
, "Window Manager for X");
1031 sprintf(version
, "Version %s", VERSION
);
1032 panel
->versionL
= WMCreateLabel(panel
->win
);
1033 WMResizeWidget(panel
->versionL
, 310, 16);
1034 WMMoveWidget(panel
->versionL
, 30, 95);
1035 WMSetLabelTextAlignment(panel
->versionL
, WARight
);
1036 WMSetLabelText(panel
->versionL
, version
);
1037 WMSetLabelWraps(panel
->versionL
, False
);
1039 panel
->copyrL
= WMCreateLabel(panel
->win
);
1040 WMResizeWidget(panel
->copyrL
, 340, 40);
1041 WMMoveWidget(panel
->copyrL
, 15, 185);
1042 WMSetLabelTextAlignment(panel
->copyrL
, WALeft
);
1043 WMSetLabelText(panel
->copyrL
, COPYRIGHT_TEXT
);
1044 /* we want the (c) character in the helvetica font */
1045 font
= WMCreateFontInDefaultEncoding(scr
->wmscreen
, HELVETICA10_FONT
);
1047 WMSetLabelFont(panel
->copyrL
, font
);
1050 switch (scr
->w_depth
) {
1052 strcpy(version
, "32 thousand");
1055 strcpy(version
, "64 thousand");
1059 strcpy(version
, "16 million");
1062 sprintf(version
, "%d", 1<<scr
->w_depth
);
1066 sprintf(buffer
, "Using visual 0x%x: %s %ibpp (%s colors)\n",
1067 (unsigned)scr
->w_visual
->visualid
,
1068 visuals
[scr
->w_visual
->class], scr
->w_depth
, version
);
1070 strcat(buffer
, "Supported image formats: ");
1071 strl
= RSupportedFileFormats();
1072 for (i
=0; strl
[i
]!=NULL
; i
++) {
1073 strcat(buffer
, strl
[i
]);
1074 strcat(buffer
, " ");
1077 strcat(buffer
, "\nAdditional Support For: ");
1090 list
[j
++] = "GNOME";
1096 list
[j
++] = "Sound";
1100 for (i
= 0; i
< j
; i
++) {
1103 strcat(buf
, " and ");
1107 strcat(buf
, list
[i
]);
1109 strcat(buffer
, buf
);
1113 panel
->infoL
= WMCreateLabel(panel
->win
);
1114 WMResizeWidget(panel
->infoL
, 350, 75);
1115 WMMoveWidget(panel
->infoL
, 15, 115);
1116 WMSetLabelText(panel
->infoL
, buffer
);
1118 WMSetLabelFont(panel
->infoL
, font
);
1119 WMReleaseFont(font
);
1123 WMRealizeWidget(panel
->win
);
1124 WMMapSubwidgets(panel
->win
);
1126 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 382, 230, 0, 0, 0);
1128 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1130 WMMapWidget(panel
->win
);
1132 wwin
= wManageInternalWindow(scr
, parent
, None
, "Info",
1133 (scr
->scr_width
- 382)/2,
1134 (scr
->scr_height
- 230)/2, 382, 230);
1136 WSETUFLAG(wwin
, no_closable
, 0);
1137 WSETUFLAG(wwin
, no_close_button
, 0);
1138 #ifdef XKB_BUTTON_HINT
1139 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1141 wWindowUpdateButtonImages(wwin
);
1142 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1143 wwin
->frame
->on_click_right
= destroyInfoPanel
;
1151 if (InitXThing(panel
->scr
)) {
1152 panel
->timer
= WMAddTimerHandler(100, logoPushCallback
, panel
);
1155 panel
->str
= "Merry Christmas!";
1156 panel
->oldPix
= WMRetainPixmap(WMGetLabelImage(panel
->logoL
));
1163 ***********************************************************************
1165 ***********************************************************************
1180 #define LICENSE_TEXT \
1181 " Window Maker is free software; you can redistribute it and/or modify "\
1182 "it under the terms of the GNU General Public License as published "\
1183 "by the Free Software Foundation; either version 2 of the License, "\
1184 "or (at your option) any later version.\n\n\n"\
1185 " Window Maker is distributed in the hope that it will be useful, but "\
1186 "WITHOUT ANY WARRANTY; without even the implied warranty of "\
1187 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU "\
1188 "General Public License for more details.\n\n\n"\
1189 " You should have received a copy of the GNU General Public License "\
1190 "along with this program; if not, write to the Free Software "\
1191 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA "\
1195 static LegalPanel
*legalPanel
= NULL
;
1198 destroyLegalPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
1200 WMUnmapWidget(legalPanel
->win
);
1202 WMDestroyWidget(legalPanel
->win
);
1204 wUnmanageWindow(legalPanel
->wwin
, False
, False
);
1213 wShowLegalPanel(WScreen
*scr
)
1220 if (legalPanel
->scr
== scr
) {
1221 wRaiseFrame(legalPanel
->wwin
->frame
->core
);
1222 wSetFocusTo(scr
, legalPanel
->wwin
);
1227 panel
= wmalloc(sizeof(LegalPanel
));
1231 panel
->win
= WMCreateWindow(scr
->wmscreen
, "legal");
1232 WMResizeWidget(panel
->win
, 420, 250);
1235 panel
->licenseL
= WMCreateLabel(panel
->win
);
1236 WMResizeWidget(panel
->licenseL
, 400, 230);
1237 WMMoveWidget(panel
->licenseL
, 10, 10);
1238 WMSetLabelTextAlignment(panel
->licenseL
, WALeft
);
1239 WMSetLabelText(panel
->licenseL
, LICENSE_TEXT
);
1240 WMSetLabelRelief(panel
->licenseL
, WRGroove
);
1242 WMRealizeWidget(panel
->win
);
1243 WMMapSubwidgets(panel
->win
);
1245 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 420, 250, 0, 0, 0);
1247 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1249 wwin
= wManageInternalWindow(scr
, parent
, None
, "Legal",
1250 (scr
->scr_width
- 420)/2,
1251 (scr
->scr_height
- 250)/2, 420, 250);
1253 WSETUFLAG(wwin
, no_closable
, 0);
1254 WSETUFLAG(wwin
, no_close_button
, 0);
1255 wWindowUpdateButtonImages(wwin
);
1256 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1257 #ifdef XKB_BUTTON_HINT
1258 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1260 wwin
->frame
->on_click_right
= destroyLegalPanel
;
1264 WMMapWidget(panel
->win
);
1273 ***********************************************************************
1274 * Crashing Dialog Panel
1275 ***********************************************************************
1278 extern WDDomain
*WDWindowAttributes
;
1281 typedef struct _CrashPanel
{
1282 WMWindow
*win
; /* main window */
1284 WMLabel
*iconL
; /* application icon */
1285 WMLabel
*nameL
; /* title of panel */
1287 WMFrame
*sepF
; /* separator frame */
1289 WMLabel
*noteL
; /* Title of note */
1290 WMLabel
*note2L
; /* body of note with what happened */
1292 WMFrame
*whatF
; /* "what to do next" frame */
1293 WMPopUpButton
*whatP
; /* action selection popup button */
1295 WMButton
*okB
; /* ok button */
1297 Bool done
; /* if finished with this dialog */
1298 int action
; /* what to do after */
1306 handleKeyPress(XEvent
*event
, void *clientData
)
1308 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1310 if (event
->xkey
.keycode
== panel
->retKey
) {
1311 WMPerformButtonClick(panel
->okB
);
1317 okButtonCallback(void *self
, void *clientData
)
1319 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1326 setCrashAction(void *self
, void *clientData
)
1328 WMPopUpButton
*pop
= (WMPopUpButton
*)self
;
1329 CrashPanel
*panel
= (CrashPanel
*)clientData
;
1331 panel
->action
= WMGetPopUpButtonSelectedItem(pop
);
1336 getWindowMakerIconImage(WMScreen
*scr
)
1338 proplist_t dict
, key
, option
, value
=NULL
;
1342 PLSetStringCmpHook(NULL
);
1344 key
= PLMakeString("Logo.WMPanel");
1345 option
= PLMakeString("Icon");
1347 dict
= PLGetDictionaryEntry(WDWindowAttributes
->dictionary
, key
);
1350 value
= PLGetDictionaryEntry(dict
, option
);
1356 PLSetStringCmpHook(StringCompareHook
);
1358 if (value
&& PLIsString(value
)) {
1359 path
= FindImage(wPreferences
.icon_path
, PLGetString(value
));
1364 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
1366 pix
= WMCreatePixmapFromRImage(scr
, image
, 0);
1367 RDestroyImage(image
);
1382 wShowCrashingDialogPanel(int whatSig
)
1388 int screen_no
, scr_width
, scr_height
;
1392 panel
= wmalloc(sizeof(CrashPanel
));
1393 memset(panel
, 0, sizeof(CrashPanel
));
1395 screen_no
= DefaultScreen(dpy
);
1396 scr_width
= WidthOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1397 scr_height
= HeightOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1399 scr
= WMCreateScreen(dpy
, screen_no
);
1401 wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
1405 panel
->retKey
= XKeysymToKeycode(dpy
, XK_Return
);
1407 panel
->win
= WMCreateWindow(scr
, "crashingDialog");
1408 WMResizeWidget(panel
->win
, PWIDTH
, PHEIGHT
);
1409 WMMoveWidget(panel
->win
, (scr_width
- PWIDTH
)/2, (scr_height
- PHEIGHT
)/2);
1411 logo
= getWindowMakerIconImage(scr
);
1413 panel
->iconL
= WMCreateLabel(panel
->win
);
1414 WMResizeWidget(panel
->iconL
, 64, 64);
1415 WMMoveWidget(panel
->iconL
, 10, 10);
1416 WMSetLabelImagePosition(panel
->iconL
, WIPImageOnly
);
1417 WMSetLabelImage(panel
->iconL
, logo
);
1420 panel
->nameL
= WMCreateLabel(panel
->win
);
1421 WMResizeWidget(panel
->nameL
, 190, 18);
1422 WMMoveWidget(panel
->nameL
, 80, 35);
1423 WMSetLabelTextAlignment(panel
->nameL
, WALeft
);
1424 font
= WMBoldSystemFontOfSize(scr
, 18);
1425 WMSetLabelFont(panel
->nameL
, font
);
1426 WMReleaseFont(font
);
1427 WMSetLabelText(panel
->nameL
, _("Fatal error"));
1429 panel
->sepF
= WMCreateFrame(panel
->win
);
1430 WMResizeWidget(panel
->sepF
, PWIDTH
+4, 2);
1431 WMMoveWidget(panel
->sepF
, -2, 80);
1433 panel
->noteL
= WMCreateLabel(panel
->win
);
1434 WMResizeWidget(panel
->noteL
, PWIDTH
-20, 40);
1435 WMMoveWidget(panel
->noteL
, 10, 90);
1436 WMSetLabelTextAlignment(panel
->noteL
, WAJustified
);
1437 #ifdef SYS_SIGLIST_DECLARED
1438 sprintf(buf
, _("Window Maker received signal %i\n(%s)."),
1439 whatSig
, sys_siglist
[whatSig
]);
1441 sprintf(buf
, _("Window Maker received signal %i."), whatSig
);
1443 WMSetLabelText(panel
->noteL
, buf
);
1445 panel
->note2L
= WMCreateLabel(panel
->win
);
1446 WMResizeWidget(panel
->note2L
, PWIDTH
-20, 100);
1447 WMMoveWidget(panel
->note2L
, 10, 130);
1448 WMSetLabelTextAlignment(panel
->note2L
, WALeft
);
1449 WMSetLabelText(panel
->note2L
,
1450 _(" This fatal error occured probably due to a bug."
1451 " Please fill the included BUGFORM and "
1452 "report it to bugs@windowmaker.org."));
1455 panel
->whatF
= WMCreateFrame(panel
->win
);
1456 WMResizeWidget(panel
->whatF
, PWIDTH
-20, 50);
1457 WMMoveWidget(panel
->whatF
, 10, 240);
1458 WMSetFrameTitle(panel
->whatF
, _("What do you want to do now?"));
1460 panel
->whatP
= WMCreatePopUpButton(panel
->whatF
);
1461 WMResizeWidget(panel
->whatP
, PWIDTH
-20-70, 20);
1462 WMMoveWidget(panel
->whatP
, 35, 20);
1463 WMSetPopUpButtonPullsDown(panel
->whatP
, False
);
1464 WMSetPopUpButtonText(panel
->whatP
, _("Select action"));
1465 WMAddPopUpButtonItem(panel
->whatP
, _("Abort and leave a core file"));
1466 WMAddPopUpButtonItem(panel
->whatP
, _("Restart Window Maker"));
1467 WMAddPopUpButtonItem(panel
->whatP
, _("Start alternate window manager"));
1468 WMSetPopUpButtonAction(panel
->whatP
, setCrashAction
, panel
);
1469 WMSetPopUpButtonSelectedItem(panel
->whatP
, WMRestart
);
1470 panel
->action
= WMRestart
;
1472 WMMapSubwidgets(panel
->whatF
);
1474 panel
->okB
= WMCreateCommandButton(panel
->win
);
1475 WMResizeWidget(panel
->okB
, 80, 26);
1476 WMMoveWidget(panel
->okB
, 205, 309);
1477 WMSetButtonText(panel
->okB
, _("OK"));
1478 WMSetButtonImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIReturnArrow
));
1479 WMSetButtonAltImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIHighlightedReturnArrow
));
1480 WMSetButtonImagePosition(panel
->okB
, WIPRight
);
1481 WMSetButtonAction(panel
->okB
, okButtonCallback
, panel
);
1485 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
,
1486 handleKeyPress
, panel
);
1488 WMRealizeWidget(panel
->win
);
1489 WMMapSubwidgets(panel
->win
);
1491 WMMapWidget(panel
->win
);
1493 XSetInputFocus(dpy
, WMWidgetXID(panel
->win
), RevertToParent
, CurrentTime
);
1495 while (!panel
->done
) {
1498 WMNextEvent(dpy
, &event
);
1499 WMHandleEvent(&event
);
1502 action
= panel
->action
;
1504 WMUnmapWidget(panel
->win
);
1505 WMDestroyWidget(panel
->win
);
1514 /*****************************************************************************
1515 * About GNUstep Panel
1516 *****************************************************************************/
1520 drawGNUstepLogo(Display
*dpy
, Drawable d
, int width
, int height
,
1521 unsigned long blackPixel
, unsigned long whitePixel
)
1525 XRectangle rects
[3];
1527 gcv
.foreground
= blackPixel
;
1528 gc
= XCreateGC(dpy
, d
, GCForeground
, &gcv
);
1530 XFillArc(dpy
, d
, gc
, width
/45, height
/45,
1531 width
- 2*width
/45, height
- 2*height
/45, 0, 360*64);
1534 rects
[0].y
= 37*height
/45;
1535 rects
[0].width
= width
/3;
1536 rects
[0].height
= height
- rects
[0].y
;
1538 rects
[1].x
= rects
[0].width
;
1539 rects
[1].y
= height
/2;
1540 rects
[1].width
= width
- 2*width
/3;
1541 rects
[1].height
= height
- rects
[1].y
;
1543 rects
[2].x
= 2*width
/3;
1544 rects
[2].y
= height
- 37*height
/45;
1545 rects
[2].width
= width
/3;
1546 rects
[2].height
= height
- rects
[2].y
;
1548 XSetClipRectangles(dpy
, gc
, 0, 0, rects
, 3, Unsorted
);
1549 XFillRectangle(dpy
, d
, gc
, 0, 0, width
, height
);
1551 XSetForeground(dpy
, gc
, whitePixel
);
1552 XFillArc(dpy
, d
, gc
, width
/45, height
/45,
1553 width
- 2*width
/45, height
- 2*height
/45, 0, 360*64);
1560 #define GNUSTEP_TEXT \
1561 "Window Maker is part of the GNUstep project.\n"\
1562 "The GNUstep project aims to create a free\n"\
1563 "implementation of the OpenStep(tm) specification\n"\
1564 "which is a object-oriented framework for\n"\
1565 "creating advanced graphical, multi-platform\n"\
1566 "applications. Aditionally, a development and\n"\
1567 "user desktop enviroment will be created on top\n"\
1568 "of the framework. For more information about\n"\
1569 "GNUstep, please visit: www.gnustep.org"
1584 static GNUstepPanel
*gnustepPanel
= NULL
;
1587 destroyGNUstepPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
1589 WMUnmapWidget(gnustepPanel
->win
);
1591 WMDestroyWidget(gnustepPanel
->win
);
1593 wUnmanageWindow(gnustepPanel
->wwin
, False
, False
);
1597 gnustepPanel
= NULL
;
1602 wShowGNUstepPanel(WScreen
*scr
)
1604 GNUstepPanel
*panel
;
1611 if (gnustepPanel
->scr
== scr
) {
1612 wRaiseFrame(gnustepPanel
->wwin
->frame
->core
);
1613 wSetFocusTo(scr
, gnustepPanel
->wwin
);
1618 panel
= wmalloc(sizeof(GNUstepPanel
));
1622 panel
->win
= WMCreateWindow(scr
->wmscreen
, "About GNUstep");
1623 WMResizeWidget(panel
->win
, 325, 200);
1625 pixmap
= WMCreatePixmap(scr
->wmscreen
, 130, 130,
1626 WMScreenDepth(scr
->wmscreen
), True
);
1628 color
= WMCreateNamedColor(scr
->wmscreen
, "gray50", True
);
1630 drawGNUstepLogo(dpy
, WMGetPixmapXID(pixmap
), 130, 130,
1631 WMColorPixel(color
), scr
->white_pixel
);
1633 WMReleaseColor(color
);
1635 XSetForeground(dpy
, scr
->mono_gc
, 0);
1636 XFillRectangle(dpy
, WMGetPixmapMaskXID(pixmap
), scr
->mono_gc
, 0, 0,
1638 drawGNUstepLogo(dpy
, WMGetPixmapMaskXID(pixmap
), 130, 130, 1, 1);
1640 panel
->gstepL
= WMCreateLabel(panel
->win
);
1641 WMResizeWidget(panel
->gstepL
, 285, 64);
1642 WMMoveWidget(panel
->gstepL
, 20, 0);
1643 WMSetLabelTextAlignment(panel
->gstepL
, WARight
);
1644 WMSetLabelText(panel
->gstepL
, "GNUstep");
1646 WMFont
*font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 24);
1648 WMSetLabelFont(panel
->gstepL
, font
);
1649 WMReleaseFont(font
);
1652 panel
->textL
= WMCreateLabel(panel
->win
);
1653 WMResizeWidget(panel
->textL
, 275, 130);
1654 WMMoveWidget(panel
->textL
, 30, 50);
1655 WMSetLabelTextAlignment(panel
->textL
, WARight
);
1656 WMSetLabelImagePosition(panel
->textL
, WIPOverlaps
);
1657 WMSetLabelText(panel
->textL
, GNUSTEP_TEXT
);
1658 WMSetLabelImage(panel
->textL
, pixmap
);
1660 WMReleasePixmap(pixmap
);
1662 WMRealizeWidget(panel
->win
);
1663 WMMapSubwidgets(panel
->win
);
1665 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 325, 200, 0, 0, 0);
1667 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1669 wwin
= wManageInternalWindow(scr
, parent
, None
, "About GNUstep",
1670 (scr
->scr_width
- 325)/2,
1671 (scr
->scr_height
- 200)/2, 325, 200);
1673 WSETUFLAG(wwin
, no_closable
, 0);
1674 WSETUFLAG(wwin
, no_close_button
, 0);
1675 wWindowUpdateButtonImages(wwin
);
1676 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1677 #ifdef XKB_BUTTON_HINT
1678 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1680 wwin
->frame
->on_click_right
= destroyGNUstepPanel
;
1684 WMMapWidget(panel
->win
);
1688 gnustepPanel
= panel
;