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 along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <X11/Xutil.h>
27 #include <X11/keysym.h>
33 #include <sys/types.h>
44 #include <sys/signal.h>
48 #define PATH_MAX DEFAULT_PATH_MAX
51 #include "WindowMaker.h"
64 static WMPoint
getCenter(WScreen
* scr
, int width
, int height
)
66 return wGetPointToCenterRectInHead(scr
, wGetHeadForPointerLocation(scr
), width
, height
);
69 int wMessageDialog(WScreen
*scr
, const char *title
, const char *message
, const char *defBtn
, const char *altBtn
, const char *othBtn
)
77 panel
= WMCreateAlertPanel(scr
->wmscreen
, NULL
, title
, message
, defBtn
, altBtn
, othBtn
);
79 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 400, 180, 0, 0, 0);
81 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
83 center
= getCenter(scr
, 400, 180);
84 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
, 400, 180);
85 wwin
->client_leader
= WMWidgetXID(panel
->win
);
87 WMMapWidget(panel
->win
);
91 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
93 result
= panel
->result
;
95 WMUnmapWidget(panel
->win
);
97 wUnmanageWindow(wwin
, False
, False
);
99 WMDestroyAlertPanel(panel
);
101 XDestroyWindow(dpy
, parent
);
106 static void toggleSaveSession(WMWidget
*w
, void *data
)
108 /* Parameter not used, but tell the compiler that it is ok */
111 wPreferences
.save_session_on_exit
= WMGetButtonSelected((WMButton
*) w
);
114 int wExitDialog(WScreen
*scr
, const char *title
, const char *message
, const char *defBtn
, const char *altBtn
, const char *othBtn
)
117 WMButton
*saveSessionBtn
;
123 panel
= WMCreateAlertPanel(scr
->wmscreen
, NULL
, title
, message
, defBtn
, altBtn
, othBtn
);
125 /* add save session button */
126 saveSessionBtn
= WMCreateSwitchButton(panel
->hbox
);
127 WMSetButtonAction(saveSessionBtn
, toggleSaveSession
, NULL
);
128 WMAddBoxSubview(panel
->hbox
, WMWidgetView(saveSessionBtn
), False
, True
, 200, 0, 0);
129 WMSetButtonText(saveSessionBtn
, _("Save workspace state"));
130 WMSetButtonSelected(saveSessionBtn
, wPreferences
.save_session_on_exit
);
131 WMRealizeWidget(saveSessionBtn
);
132 WMMapWidget(saveSessionBtn
);
134 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 400, 180, 0, 0, 0);
136 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
138 center
= getCenter(scr
, 400, 180);
139 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
, 400, 180);
141 wwin
->client_leader
= WMWidgetXID(panel
->win
);
143 WMMapWidget(panel
->win
);
147 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
149 result
= panel
->result
;
151 WMUnmapWidget(panel
->win
);
153 wUnmanageWindow(wwin
, False
, False
);
155 WMDestroyAlertPanel(panel
);
157 XDestroyWindow(dpy
, parent
);
162 typedef struct _WMInputPanelWithHistory
{
171 } WMInputPanelWithHistory
;
173 static char *HistoryFileName(const char *name
)
175 char *filename
= NULL
;
177 filename
= wstrdup(wusergnusteppath());
178 filename
= wstrappend(filename
, "/.AppInfo/WindowMaker/History");
179 if (name
&& strlen(name
)) {
180 filename
= wstrappend(filename
, ".");
181 filename
= wstrappend(filename
, name
);
186 static int strmatch(const void *str1
, const void *str2
)
188 return !strcmp((const char *)str1
, (const char *)str2
);
191 static WMArray
*LoadHistory(const char *filename
, int max
)
193 WMPropList
*plhistory
;
199 history
= WMCreateArrayWithDestructor(1, wfree
);
200 WMAddToArray(history
, wstrdup(""));
202 plhistory
= WMReadPropListFromFile(filename
);
205 if (WMIsPLArray(plhistory
)) {
206 num
= WMGetPropListItemCount(plhistory
);
208 for (i
= 0; i
< num
; ++i
) {
209 plitem
= WMGetFromPLArray(plhistory
, i
);
210 if (WMIsPLString(plitem
)) {
211 str
= WMGetFromPLString(plitem
);
212 if (WMFindInArray(history
, strmatch
, str
) == WANotFound
) {
214 * The string here is duplicated because it will be freed
215 * automatically when the array is deleted. This is not really
216 * great because it is already an allocated string,
217 * unfortunately we cannot re-use it because it will be freed
218 * when we discard the PL (and we don't want to waste the PL's
221 WMAddToArray(history
, wstrdup(str
));
228 WMReleasePropList(plhistory
);
234 static void SaveHistory(WMArray
* history
, const char *filename
)
237 WMPropList
*plhistory
;
239 plhistory
= WMCreatePLArray(NULL
);
241 for (i
= 0; i
< WMGetArrayItemCount(history
); ++i
)
242 WMAddToPLArray(plhistory
, WMCreatePLString(WMGetFromArray(history
, i
)));
244 WMWritePropListToFile(plhistory
, filename
);
245 WMReleasePropList(plhistory
);
248 static int pstrcmp(const char **str1
, const char **str2
)
250 return strcmp(*str1
, *str2
);
254 ScanFiles(const char *dir
, const char *prefix
, unsigned acceptmask
, unsigned declinemask
, WMArray
* result
)
260 char *fullfilename
, *suffix
;
262 prefixlen
= strlen(prefix
);
263 if ((d
= opendir(dir
)) != NULL
) {
264 while ((de
= readdir(d
)) != NULL
) {
265 if (strlen(de
->d_name
) > prefixlen
&&
266 !strncmp(prefix
, de
->d_name
, prefixlen
) &&
267 strcmp(de
->d_name
, ".") != 0 && strcmp(de
->d_name
, "..")) {
268 fullfilename
= wstrconcat((char *)dir
, "/");
269 fullfilename
= wstrappend(fullfilename
, de
->d_name
);
271 if (stat(fullfilename
, &sb
) == 0 &&
272 (sb
.st_mode
& acceptmask
) &&
273 !(sb
.st_mode
& declinemask
) &&
274 WMFindInArray(result
, (WMMatchDataProc
*) strmatch
,
275 de
->d_name
+ prefixlen
) == WANotFound
) {
276 suffix
= wstrdup(de
->d_name
+ prefixlen
);
277 if (sb
.st_mode
& S_IFDIR
)
278 wstrappend(suffix
,"/");
279 WMAddToArray(result
, suffix
);
288 static WMArray
*GenerateVariants(const char *complete
)
290 Bool firstWord
= True
;
291 WMArray
*variants
= NULL
;
292 char *pos
= NULL
, *path
= NULL
, *tmp
= NULL
, *dir
= NULL
, *prefix
= NULL
;
294 variants
= WMCreateArrayWithDestructor(0, wfree
);
296 while (*complete
== ' ')
299 if ((pos
= strrchr(complete
, ' ')) != NULL
) {
304 if ((pos
= strrchr(complete
, '/')) != NULL
) {
305 tmp
= wstrndup((char *)complete
, pos
- complete
+ 1);
306 if (*tmp
== '~' && *(tmp
+ 1) == '/' && getenv("HOME")) {
307 dir
= wstrdup(getenv("HOME"));
308 dir
= wstrappend(dir
, tmp
+ 1);
313 prefix
= wstrdup(pos
+ 1);
314 ScanFiles(dir
, prefix
, (unsigned)-1, 0, variants
);
317 } else if (*complete
== '~') {
318 WMAddToArray(variants
, wstrdup("/"));
319 } else if (firstWord
) {
320 path
= getenv("PATH");
322 pos
= strchr(path
, ':');
324 tmp
= wstrndup(path
, pos
- path
);
326 } else if (*path
!= '\0') {
331 ScanFiles(tmp
, complete
, S_IXOTH
| S_IXGRP
| S_IXUSR
, S_IFDIR
, variants
);
336 WMSortArray(variants
, (WMCompareDataProc
*) pstrcmp
);
340 static void handleHistoryKeyPress(XEvent
* event
, void *clientData
)
344 WMInputPanelWithHistory
*p
= (WMInputPanelWithHistory
*) clientData
;
347 ksym
= XLookupKeysym(&event
->xkey
, 0);
351 if (p
->histpos
< WMGetArrayItemCount(p
->history
) - 1) {
353 wfree(WMReplaceInArray(p
->history
, 0, WMGetTextFieldText(p
->panel
->text
)));
355 WMSetTextFieldText(p
->panel
->text
, WMGetFromArray(p
->history
, p
->histpos
));
359 if (p
->histpos
> 0) {
361 WMSetTextFieldText(p
->panel
->text
, WMGetFromArray(p
->history
, p
->histpos
));
366 text
= WMGetTextFieldText(p
->panel
->text
);
367 pos
= WMGetTextFieldCursorPosition(p
->panel
->text
);
368 p
->prefix
= wstrndup(text
, pos
);
369 p
->suffix
= wstrdup(text
+ pos
);
371 p
->variants
= GenerateVariants(p
->prefix
);
380 if (p
->variants
&& p
->prefix
&& p
->suffix
) {
382 if (p
->varpos
> WMGetArrayItemCount(p
->variants
))
385 text
= wstrconcat(p
->prefix
, WMGetFromArray(p
->variants
, p
->varpos
- 1));
387 text
= wstrdup(p
->prefix
);
389 text
= wstrappend(text
, p
->suffix
);
390 WMSetTextFieldText(p
->panel
->text
, text
);
391 WMSetTextFieldCursorPosition(p
->panel
->text
, pos
);
396 if (ksym
!= XK_Tab
) {
406 WMFreeArray(p
->variants
);
412 int wAdvancedInputDialog(WScreen
*scr
, const char *title
, const char *message
, const char *name
, char **text
)
418 WMInputPanelWithHistory
*p
;
421 filename
= HistoryFileName(name
);
422 p
= wmalloc(sizeof(WMInputPanelWithHistory
));
423 p
->panel
= WMCreateInputPanel(scr
->wmscreen
, NULL
, title
, message
, *text
, _("OK"), _("Cancel"));
424 p
->history
= LoadHistory(filename
, wPreferences
.history_lines
);
431 WMCreateEventHandler(WMWidgetView(p
->panel
->text
), KeyPressMask
, handleHistoryKeyPress
, p
);
433 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 320, 160, 0, 0, 0);
434 XSelectInput(dpy
, parent
, KeyPressMask
| KeyReleaseMask
);
436 XReparentWindow(dpy
, WMWidgetXID(p
->panel
->win
), parent
, 0, 0);
438 center
= getCenter(scr
, 320, 160);
439 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
, 320, 160);
441 wwin
->client_leader
= WMWidgetXID(p
->panel
->win
);
443 WMMapWidget(p
->panel
->win
);
447 WMRunModalLoop(WMWidgetScreen(p
->panel
->win
), WMWidgetView(p
->panel
->win
));
449 if (p
->panel
->result
== WAPRDefault
) {
450 result
= WMGetTextFieldText(p
->panel
->text
);
451 wfree(WMReplaceInArray(p
->history
, 0, wstrdup(result
)));
452 SaveHistory(p
->history
, filename
);
456 wUnmanageWindow(wwin
, False
, False
);
458 WMDestroyInputPanel(p
->panel
);
459 WMFreeArray(p
->history
);
463 XDestroyWindow(dpy
, parent
);
476 int wInputDialog(WScreen
*scr
, const char *title
, const char *message
, char **text
)
484 panel
= WMCreateInputPanel(scr
->wmscreen
, NULL
, title
, message
, *text
, _("OK"), _("Cancel"));
486 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 320, 160, 0, 0, 0);
487 XSelectInput(dpy
, parent
, KeyPressMask
| KeyReleaseMask
);
489 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
491 center
= getCenter(scr
, 320, 160);
492 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
, 320, 160);
494 wwin
->client_leader
= WMWidgetXID(panel
->win
);
496 WMMapWidget(panel
->win
);
500 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
502 if (panel
->result
== WAPRDefault
)
503 result
= WMGetTextFieldText(panel
->text
);
507 wUnmanageWindow(wwin
, False
, False
);
509 WMDestroyInputPanel(panel
);
511 XDestroyWindow(dpy
, parent
);
525 *****************************************************************
526 * Icon Selection Panel
527 *****************************************************************
530 typedef struct IconPanel
{
543 WMButton
*previewButton
;
548 WMTextField
*fileField
;
551 WMButton
*cancelButton
;
553 WMButton
*chooseButton
;
560 static void listPixmaps(WScreen
*scr
, WMList
*lPtr
, const char *path
)
562 struct dirent
*dentry
;
564 char pbuf
[PATH_MAX
+ 16];
566 IconPanel
*panel
= WMGetHangedData(lPtr
);
568 panel
->preview
= False
;
570 apath
= wexpandpath(path
);
571 dir
= opendir(apath
);
576 tmp
= _("Could not open directory ");
577 msg
= wmalloc(strlen(tmp
) + strlen(path
) + 6);
581 wMessageDialog(scr
, _("Error"), msg
, _("OK"), NULL
, NULL
);
587 /* list contents in the column */
588 while ((dentry
= readdir(dir
))) {
591 if (strcmp(dentry
->d_name
, ".") == 0 || strcmp(dentry
->d_name
, "..") == 0)
596 strcat(pbuf
, dentry
->d_name
);
598 if (stat(pbuf
, &statb
) < 0)
601 if (statb
.st_mode
& (S_IRUSR
| S_IRGRP
| S_IROTH
)
602 && statb
.st_mode
& (S_IFREG
| S_IFLNK
)) {
603 WMAddListItem(lPtr
, dentry
->d_name
);
606 WMSortListItems(lPtr
);
610 panel
->preview
= True
;
613 static void setViewedImage(IconPanel
*panel
, const char *file
)
622 pixmap
= WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel
->win
), file
, &color
);
624 WMSetButtonEnabled(panel
->okButton
, False
);
626 WMSetLabelText(panel
->iconView
, _("Could not load image file "));
628 WMSetLabelImage(panel
->iconView
, NULL
);
630 WMSetButtonEnabled(panel
->okButton
, True
);
632 WMSetLabelText(panel
->iconView
, NULL
);
633 WMSetLabelImage(panel
->iconView
, pixmap
);
634 WMReleasePixmap(pixmap
);
638 static void listCallback(void *self
, void *data
)
640 WMList
*lPtr
= (WMList
*) self
;
641 IconPanel
*panel
= (IconPanel
*) data
;
644 if (lPtr
== panel
->dirList
) {
645 WMListItem
*item
= WMGetListSelectedItem(lPtr
);
651 WMSetTextFieldText(panel
->fileField
, path
);
653 WMSetLabelImage(panel
->iconView
, NULL
);
655 WMSetButtonEnabled(panel
->okButton
, False
);
657 WMClearList(panel
->iconList
);
658 listPixmaps(panel
->scr
, panel
->iconList
, path
);
660 char *tmp
, *iconFile
;
661 WMListItem
*item
= WMGetListSelectedItem(panel
->dirList
);
666 tmp
= wexpandpath(path
);
668 item
= WMGetListSelectedItem(panel
->iconList
);
671 iconFile
= item
->text
;
673 path
= wmalloc(strlen(tmp
) + strlen(iconFile
) + 4);
676 strcat(path
, iconFile
);
678 WMSetTextFieldText(panel
->fileField
, path
);
679 setViewedImage(panel
, path
);
684 static void listIconPaths(WMList
* lPtr
)
689 paths
= wstrdup(wPreferences
.icon_path
);
691 path
= strtok(paths
, ":");
696 tmp
= wexpandpath(path
);
697 /* do not sort, because the order implies the order of
698 * directories searched */
699 if (access(tmp
, X_OK
) == 0)
700 WMAddListItem(lPtr
, path
);
702 } while ((path
= strtok(NULL
, ":")) != NULL
);
707 static void drawIconProc(WMList
* lPtr
, int index
, Drawable d
, char *text
, int state
, WMRect
* rect
)
709 IconPanel
*panel
= WMGetHangedData(lPtr
);
710 WScreen
*scr
= panel
->scr
;
711 GC gc
= scr
->draw_gc
;
712 GC copygc
= scr
->copy_gc
;
713 char *file
, *dirfile
;
717 WMScreen
*wmscr
= WMWidgetScreen(panel
->win
);
719 int x
, y
, width
, height
, len
;
721 /* Parameter not used, but tell the compiler that it is ok */
729 width
= rect
->size
.width
;
730 height
= rect
->size
.height
;
732 back
= (state
& WLDSSelected
) ? scr
->white
: scr
->gray
;
734 dirfile
= wexpandpath(WMGetListSelectedItem(panel
->dirList
)->text
);
735 len
= strlen(dirfile
) + strlen(text
) + 4;
737 snprintf(file
, len
, "%s/%s", dirfile
, text
);
740 color
.red
= WMRedComponentOfColor(back
) >> 8;
741 color
.green
= WMGreenComponentOfColor(back
) >> 8;
742 color
.blue
= WMBlueComponentOfColor(back
) >> 8;
743 color
.alpha
= WMGetColorAlpha(back
) >> 8;
745 pixmap
= WMCreateBlendedPixmapFromFile(wmscr
, file
, &color
);
749 /*WMRemoveListItem(lPtr, index); */
753 XFillRectangle(dpy
, d
, WMColorGC(back
), x
, y
, width
, height
);
755 XSetClipMask(dpy
, gc
, None
);
756 /*XDrawRectangle(dpy, d, WMColorGC(white), x+5, y+5, width-10, 54); */
757 XDrawLine(dpy
, d
, WMColorGC(scr
->white
), x
, y
+ height
- 1, x
+ width
, y
+ height
- 1);
759 size
= WMGetPixmapSize(pixmap
);
761 XSetClipMask(dpy
, copygc
, WMGetPixmapMaskXID(pixmap
));
762 XSetClipOrigin(dpy
, copygc
, x
+ (width
- size
.width
) / 2, y
+ 2);
763 XCopyArea(dpy
, WMGetPixmapXID(pixmap
), d
, copygc
, 0, 0,
764 size
.width
> 100 ? 100 : size
.width
, size
.height
> 64 ? 64 : size
.height
,
765 x
+ (width
- size
.width
) / 2, y
+ 2);
769 int fheight
= WMFontHeight(panel
->normalfont
);
770 int tlen
= strlen(text
);
771 int twidth
= WMWidthOfString(panel
->normalfont
, text
, tlen
);
774 ofx
= x
+ (width
- twidth
) / 2;
775 ofy
= y
+ 64 - fheight
;
777 for (i
= -1; i
< 2; i
++)
778 for (j
= -1; j
< 2; j
++)
779 WMDrawString(wmscr
, d
, scr
->white
, panel
->normalfont
,
780 ofx
+ i
, ofy
+ j
, text
, tlen
);
782 WMDrawString(wmscr
, d
, scr
->black
, panel
->normalfont
, ofx
, ofy
, text
, tlen
);
785 WMReleasePixmap(pixmap
);
786 /* I hope it is better to do not use cache / on my box it is fast nuff */
790 static void buttonCallback(void *self
, void *clientData
)
792 WMButton
*bPtr
= (WMButton
*) self
;
793 IconPanel
*panel
= (IconPanel
*) clientData
;
795 if (bPtr
== panel
->okButton
) {
797 panel
->result
= True
;
798 } else if (bPtr
== panel
->cancelButton
) {
800 panel
->result
= False
;
801 } else if (bPtr
== panel
->previewButton
) {
802 /**** Previewer ****/
803 WMSetButtonEnabled(bPtr
, False
);
804 WMSetListUserDrawItemHeight(panel
->iconList
, 68);
805 WMSetListUserDrawProc(panel
->iconList
, drawIconProc
);
806 WMRedisplayWidget(panel
->iconList
);
807 /* for draw proc to access screen/gc */
808 /*** end preview ***/
811 else if (bPtr
== panel
->chooseButton
) {
814 op
= WMCreateOpenPanel(WMWidgetScreen(bPtr
));
816 if (WMRunModalFilePanelForDirectory(op
, NULL
, "/usr/local", NULL
, NULL
)) {
818 path
= WMGetFilePanelFile(op
);
819 WMSetTextFieldText(panel
->fileField
, path
);
820 setViewedImage(panel
, path
);
823 WMDestroyFilePanel(op
);
828 static void keyPressHandler(XEvent
* event
, void *data
)
830 IconPanel
*panel
= (IconPanel
*) data
;
838 if (event
->type
== KeyRelease
)
842 XLookupString(&event
->xkey
, buffer
, sizeof(buffer
), &ksym
, NULL
);
844 iidx
= WMGetListSelectedItemRow(panel
->iconList
);
845 didx
= WMGetListSelectedItemRow(panel
->dirList
);
853 list
= panel
->iconList
;
856 if (iidx
< WMGetListNumberOfRows(panel
->iconList
) - 1)
860 list
= panel
->iconList
;
864 list
= panel
->iconList
;
867 item
= WMGetListNumberOfRows(panel
->iconList
) - 1;
868 list
= panel
->iconList
;
871 if (didx
< WMGetListNumberOfRows(panel
->dirList
) - 1)
875 list
= panel
->dirList
;
882 list
= panel
->dirList
;
885 WMPerformButtonClick(panel
->okButton
);
888 WMPerformButtonClick(panel
->cancelButton
);
893 WMSelectListItem(list
, item
);
894 WMSetListPosition(list
, item
- 5);
895 listCallback(list
, panel
);
899 Bool
wIconChooserDialog(WScreen
*scr
, char **file
, const char *instance
, const char *class)
908 panel
= wmalloc(sizeof(IconPanel
));
912 panel
->win
= WMCreateWindow(scr
->wmscreen
, "iconChooser");
913 WMResizeWidget(panel
->win
, 450, 280);
915 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
| KeyReleaseMask
, keyPressHandler
, panel
);
917 boldFont
= WMBoldSystemFontOfSize(scr
->wmscreen
, 12);
918 panel
->normalfont
= WMSystemFontOfSize(WMWidgetScreen(panel
->win
), 12);
920 panel
->dirLabel
= WMCreateLabel(panel
->win
);
921 WMResizeWidget(panel
->dirLabel
, 200, 20);
922 WMMoveWidget(panel
->dirLabel
, 10, 7);
923 WMSetLabelText(panel
->dirLabel
, _("Directories"));
924 WMSetLabelFont(panel
->dirLabel
, boldFont
);
925 WMSetLabelTextAlignment(panel
->dirLabel
, WACenter
);
927 WMSetLabelRelief(panel
->dirLabel
, WRSunken
);
929 panel
->iconLabel
= WMCreateLabel(panel
->win
);
930 WMResizeWidget(panel
->iconLabel
, 140, 20);
931 WMMoveWidget(panel
->iconLabel
, 215, 7);
932 WMSetLabelText(panel
->iconLabel
, _("Icons"));
933 WMSetLabelFont(panel
->iconLabel
, boldFont
);
934 WMSetLabelTextAlignment(panel
->iconLabel
, WACenter
);
936 WMReleaseFont(boldFont
);
938 color
= WMWhiteColor(scr
->wmscreen
);
939 WMSetLabelTextColor(panel
->dirLabel
, color
);
940 WMSetLabelTextColor(panel
->iconLabel
, color
);
941 WMReleaseColor(color
);
943 color
= WMDarkGrayColor(scr
->wmscreen
);
944 WMSetWidgetBackgroundColor(panel
->iconLabel
, color
);
945 WMSetWidgetBackgroundColor(panel
->dirLabel
, color
);
946 WMReleaseColor(color
);
948 WMSetLabelRelief(panel
->iconLabel
, WRSunken
);
950 panel
->dirList
= WMCreateList(panel
->win
);
951 WMResizeWidget(panel
->dirList
, 200, 170);
952 WMMoveWidget(panel
->dirList
, 10, 30);
953 WMSetListAction(panel
->dirList
, listCallback
, panel
);
955 panel
->iconList
= WMCreateList(panel
->win
);
956 WMResizeWidget(panel
->iconList
, 140, 170);
957 WMMoveWidget(panel
->iconList
, 215, 30);
958 WMSetListAction(panel
->iconList
, listCallback
, panel
);
960 WMHangData(panel
->iconList
, panel
);
962 panel
->previewButton
= WMCreateCommandButton(panel
->win
);
963 WMResizeWidget(panel
->previewButton
, 75, 26);
964 WMMoveWidget(panel
->previewButton
, 365, 130);
965 WMSetButtonText(panel
->previewButton
, _("Preview"));
966 WMSetButtonAction(panel
->previewButton
, buttonCallback
, panel
);
968 panel
->iconView
= WMCreateLabel(panel
->win
);
969 WMResizeWidget(panel
->iconView
, 75, 75);
970 WMMoveWidget(panel
->iconView
, 365, 40);
971 WMSetLabelImagePosition(panel
->iconView
, WIPOverlaps
);
972 WMSetLabelRelief(panel
->iconView
, WRSunken
);
973 WMSetLabelTextAlignment(panel
->iconView
, WACenter
);
975 panel
->fileLabel
= WMCreateLabel(panel
->win
);
976 WMResizeWidget(panel
->fileLabel
, 80, 20);
977 WMMoveWidget(panel
->fileLabel
, 10, 210);
978 WMSetLabelText(panel
->fileLabel
, _("File Name:"));
980 panel
->fileField
= WMCreateTextField(panel
->win
);
981 WMSetViewNextResponder(WMWidgetView(panel
->fileField
), WMWidgetView(panel
->win
));
982 WMResizeWidget(panel
->fileField
, 345, 20);
983 WMMoveWidget(panel
->fileField
, 95, 210);
984 WMSetTextFieldEditable(panel
->fileField
, False
);
986 panel
->okButton
= WMCreateCommandButton(panel
->win
);
987 WMResizeWidget(panel
->okButton
, 80, 26);
988 WMMoveWidget(panel
->okButton
, 360, 240);
989 WMSetButtonText(panel
->okButton
, _("OK"));
990 WMSetButtonEnabled(panel
->okButton
, False
);
991 WMSetButtonAction(panel
->okButton
, buttonCallback
, panel
);
993 panel
->cancelButton
= WMCreateCommandButton(panel
->win
);
994 WMResizeWidget(panel
->cancelButton
, 80, 26);
995 WMMoveWidget(panel
->cancelButton
, 270, 240);
996 WMSetButtonText(panel
->cancelButton
, _("Cancel"));
997 WMSetButtonAction(panel
->cancelButton
, buttonCallback
, panel
);
999 panel
->chooseButton
= WMCreateCommandButton(panel
->win
);
1000 WMResizeWidget(panel
->chooseButton
, 110, 26);
1001 WMMoveWidget(panel
->chooseButton
, 150, 240);
1002 WMSetButtonText(panel
->chooseButton
, _("Choose File"));
1003 WMSetButtonAction(panel
->chooseButton
, buttonCallback
, panel
);
1005 WMRealizeWidget(panel
->win
);
1006 WMMapSubwidgets(panel
->win
);
1008 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 450, 280, 0, 0, 0);
1010 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1014 int len
= (instance
? strlen(instance
) : 0)
1015 + (class ? strlen(class) : 0) + 32;
1020 if (tmp
&& (instance
|| class))
1021 snprintf(tmp
, len
, "%s [%s.%s]", _("Icon Chooser"), instance
, class);
1023 strcpy(tmp
, _("Icon Chooser"));
1025 center
= getCenter(scr
, 450, 280);
1027 wwin
= wManageInternalWindow(scr
, parent
, None
, tmp
, center
.x
, center
.y
, 450, 280);
1031 /* put icon paths in the list */
1032 listIconPaths(panel
->dirList
);
1034 WMMapWidget(panel
->win
);
1038 while (!panel
->done
) {
1041 WMNextEvent(dpy
, &event
);
1042 WMHandleEvent(&event
);
1045 if (panel
->result
) {
1046 char *defaultPath
, *wantedPath
;
1048 /* check if the file the user selected is not the one that
1049 * would be loaded by default with the current search path */
1050 *file
= WMGetListSelectedItem(panel
->iconList
)->text
;
1055 defaultPath
= FindImage(wPreferences
.icon_path
, *file
);
1056 wantedPath
= WMGetTextFieldText(panel
->fileField
);
1057 /* if the file is not the default, use full path */
1058 if (strcmp(wantedPath
, defaultPath
) != 0) {
1061 *file
= wstrdup(*file
);
1070 result
= panel
->result
;
1072 WMReleaseFont(panel
->normalfont
);
1074 WMUnmapWidget(panel
->win
);
1076 WMDestroyWidget(panel
->win
);
1078 wUnmanageWindow(wwin
, False
, False
);
1082 XDestroyWindow(dpy
, parent
);
1088 ***********************************************************************
1090 ***********************************************************************
1106 #define COPYRIGHT_TEXT \
1107 "Copyright \xc2\xa9 1997-2006 Alfredo K. Kojima\n"\
1108 "Copyright \xc2\xa9 1998-2006 Dan Pascu\n"\
1109 "Copyright \xc2\xa9 2013-2014 Window Maker Developers Team"
1111 static InfoPanel
*thePanel
= NULL
;
1113 static void destroyInfoPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
1115 /* Parameter not used, but tell the compiler that it is ok */
1120 WMUnmapWidget(thePanel
);
1121 wUnmanageWindow(thePanel
->wwin
, False
, False
);
1122 WMDestroyWidget(thePanel
->win
);
1127 void wShowInfoPanel(WScreen
*scr
)
1129 const int win_width
= 382;
1130 const int win_height
= 250;
1134 char *name
, *strbuf
= NULL
;
1135 const char *separator
;
1141 int i
, width
= 50, sepHeight
;
1152 if (thePanel
->scr
== scr
) {
1153 wRaiseFrame(thePanel
->wwin
->frame
->core
);
1154 wSetFocusTo(scr
, thePanel
->wwin
);
1159 panel
= wmalloc(sizeof(InfoPanel
));
1163 panel
->win
= WMCreateWindow(scr
->wmscreen
, "info");
1164 WMResizeWidget(panel
->win
, win_width
, win_height
);
1166 logo
= WMCreateApplicationIconBlendedPixmap(scr
->wmscreen
, (RColor
*) NULL
);
1168 logo
= WMRetainPixmap(WMGetApplicationIconPixmap(scr
->wmscreen
));
1171 panel
->logoL
= WMCreateLabel(panel
->win
);
1172 WMResizeWidget(panel
->logoL
, 64, 64);
1173 WMMoveWidget(panel
->logoL
, 30, 20);
1174 WMSetLabelImagePosition(panel
->logoL
, WIPImageOnly
);
1175 WMSetLabelImage(panel
->logoL
, logo
);
1176 WMReleasePixmap(logo
);
1180 panel
->name1L
= WMCreateLabel(panel
->win
);
1181 WMResizeWidget(panel
->name1L
, 240, 30 + 2);
1182 WMMoveWidget(panel
->name1L
, 100, 30 - 2 - sepHeight
);
1184 name
= "Lucida Sans,Comic Sans MS,URW Gothic L,Trebuchet MS" ":italic:pixelsize=28:antialias=true";
1185 font
= WMCreateFont(scr
->wmscreen
, name
);
1186 strbuf
= "Window Maker";
1188 width
= WMWidthOfString(font
, strbuf
, strlen(strbuf
));
1189 WMSetLabelFont(panel
->name1L
, font
);
1190 WMReleaseFont(font
);
1192 WMSetLabelTextAlignment(panel
->name1L
, WACenter
);
1193 WMSetLabelText(panel
->name1L
, strbuf
);
1195 panel
->lineF
= WMCreateFrame(panel
->win
);
1196 WMResizeWidget(panel
->lineF
, width
, sepHeight
);
1197 WMMoveWidget(panel
->lineF
, 100 + (240 - width
) / 2, 60 - sepHeight
);
1198 WMSetFrameRelief(panel
->lineF
, WRSimple
);
1199 WMSetWidgetBackgroundColor(panel
->lineF
, scr
->black
);
1201 panel
->name2L
= WMCreateLabel(panel
->win
);
1202 WMResizeWidget(panel
->name2L
, 240, 24);
1203 WMMoveWidget(panel
->name2L
, 100, 60);
1204 name
= "URW Gothic L,Nimbus Sans L:pixelsize=16:antialias=true";
1205 font
= WMCreateFont(scr
->wmscreen
, name
);
1207 WMSetLabelFont(panel
->name2L
, font
);
1208 WMReleaseFont(font
);
1211 WMSetLabelTextAlignment(panel
->name2L
, WACenter
);
1212 WMSetLabelText(panel
->name2L
, _("Window Manager for X"));
1214 snprintf(buffer
, sizeof(buffer
), _("Version %s"), VERSION
);
1215 panel
->versionL
= WMCreateLabel(panel
->win
);
1216 WMResizeWidget(panel
->versionL
, 310, 16);
1217 WMMoveWidget(panel
->versionL
, 30, 95);
1218 WMSetLabelTextAlignment(panel
->versionL
, WARight
);
1219 WMSetLabelText(panel
->versionL
, buffer
);
1220 WMSetLabelWraps(panel
->versionL
, False
);
1222 panel
->copyrL
= WMCreateLabel(panel
->win
);
1223 WMResizeWidget(panel
->copyrL
, 360, 60);
1224 WMMoveWidget(panel
->copyrL
, 15, 185);
1225 WMSetLabelTextAlignment(panel
->copyrL
, WALeft
);
1226 WMSetLabelText(panel
->copyrL
, COPYRIGHT_TEXT
);
1227 font
= WMSystemFontOfSize(scr
->wmscreen
, 11);
1229 WMSetLabelFont(panel
->copyrL
, font
);
1230 WMReleaseFont(font
);
1235 snprintf(buffer
, sizeof(buffer
), _("Using visual 0x%x: %s %ibpp "),
1236 (unsigned)scr
->w_visual
->visualid
, visuals
[scr
->w_visual
->class], scr
->w_depth
);
1238 strbuf
= wstrappend(strbuf
, buffer
);
1240 switch (scr
->w_depth
) {
1242 strbuf
= wstrappend(strbuf
, _("(32 thousand colors)\n"));
1245 strbuf
= wstrappend(strbuf
, _("(64 thousand colors)\n"));
1249 strbuf
= wstrappend(strbuf
, _("(16 million colors)\n"));
1252 snprintf(buffer
, sizeof(buffer
), _("(%d colors)\n"), 1 << scr
->w_depth
);
1253 strbuf
= wstrappend(strbuf
, buffer
);
1257 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
1259 struct mallinfo ma
= mallinfo();
1260 snprintf(buffer
, sizeof(buffer
),
1262 _("Total memory allocated: %i kB (in use: %i kB, %d free chunks).\n"),
1264 _("Total memory allocated: %i kB (in use: %i kB).\n"),
1266 (ma
.arena
+ ma
.hblkhd
) / 1024,
1267 (ma
.uordblks
+ ma
.hblkhd
) / 1024
1270 * This information is representative of the memory
1271 * fragmentation. In ideal case it should be 1, but
1272 * that is never possible
1278 strbuf
= wstrappend(strbuf
, buffer
);
1282 strbuf
= wstrappend(strbuf
, _("Supported image formats: "));
1283 strl
= RSupportedFileFormats();
1285 for (i
= 0; strl
[i
] != NULL
; i
++) {
1286 if (separator
!= NULL
)
1287 strbuf
= wstrappend(strbuf
, separator
);
1288 strbuf
= wstrappend(strbuf
, strl
[i
]);
1292 strbuf
= wstrappend(strbuf
, _("\nAdditional support for: "));
1293 strbuf
= wstrappend(strbuf
, "WMSPEC");
1296 strbuf
= wstrappend(strbuf
, ", XRandR ");
1297 if (w_global
.xext
.randr
.supported
)
1298 strbuf
= wstrappend(strbuf
, _("(Supported)"));
1300 strbuf
= wstrappend(strbuf
, _("(Unsupported)"));
1304 strbuf
= wstrappend(strbuf
, ", MWM");
1308 strbuf
= wstrappend(strbuf
, _("\n"));
1309 #ifdef SOLARIS_XINERAMA
1310 strbuf
= wstrappend(strbuf
, _("Solaris "));
1312 strbuf
= wstrappend(strbuf
, _("Xinerama: "));
1315 snprintf(tmp
, sizeof(tmp
) - 1, _("%d heads found."), scr
->xine_info
.count
);
1316 strbuf
= wstrappend(strbuf
, tmp
);
1320 panel
->infoL
= WMCreateLabel(panel
->win
);
1321 WMResizeWidget(panel
->infoL
, 350, 75);
1322 WMMoveWidget(panel
->infoL
, 15, 115);
1323 WMSetLabelText(panel
->infoL
, strbuf
);
1324 font
= WMSystemFontOfSize(scr
->wmscreen
, 11);
1326 WMSetLabelFont(panel
->infoL
, font
);
1327 WMReleaseFont(font
);
1332 WMRealizeWidget(panel
->win
);
1333 WMMapSubwidgets(panel
->win
);
1335 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, win_width
, win_height
, 0, 0, 0);
1337 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1339 WMMapWidget(panel
->win
);
1341 center
= getCenter(scr
, win_width
, win_height
);
1342 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Info"), center
.x
, center
.y
, win_width
, win_height
);
1344 WSETUFLAG(wwin
, no_closable
, 0);
1345 WSETUFLAG(wwin
, no_close_button
, 0);
1346 #ifdef XKB_BUTTON_HINT
1347 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1349 wWindowUpdateButtonImages(wwin
);
1350 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1351 wwin
->frame
->on_click_right
= destroyInfoPanel
;
1360 ***********************************************************************
1362 ***********************************************************************
1372 static LegalPanel
*legalPanel
= NULL
;
1374 static void destroyLegalPanel(WCoreWindow
* foo
, void *data
, XEvent
* event
)
1376 /* Parameter not used, but tell the compiler that it is ok */
1381 WMUnmapWidget(legalPanel
->win
);
1382 WMDestroyWidget(legalPanel
->win
);
1383 wUnmanageWindow(legalPanel
->wwin
, False
, False
);
1388 void wShowLegalPanel(WScreen
*scr
)
1390 const int win_width
= 420;
1391 const int win_height
= 250;
1392 const int margin
= 10;
1399 if (legalPanel
->scr
== scr
) {
1400 wRaiseFrame(legalPanel
->wwin
->frame
->core
);
1401 wSetFocusTo(scr
, legalPanel
->wwin
);
1406 panel
= wmalloc(sizeof(LegalPanel
));
1408 panel
->win
= WMCreateWindow(scr
->wmscreen
, "legal");
1409 WMResizeWidget(panel
->win
, win_width
, win_height
);
1411 panel
->licenseL
= WMCreateLabel(panel
->win
);
1412 WMSetLabelWraps(panel
->licenseL
, True
);
1413 WMResizeWidget(panel
->licenseL
, win_width
- (2 * margin
), win_height
- (2 * margin
));
1414 WMMoveWidget(panel
->licenseL
, margin
, margin
);
1415 WMSetLabelTextAlignment(panel
->licenseL
, WALeft
);
1416 WMSetLabelText(panel
->licenseL
,
1417 _(" Window Maker is free software; you can redistribute it and/or "
1418 "modify it under the terms of the GNU General Public License as "
1419 "published by the Free Software Foundation; either version 2 of the "
1420 "License, or (at your option) any later version.\n\n"
1421 " Window Maker is distributed in the hope that it will be useful, "
1422 "but WITHOUT ANY WARRANTY; without even the implied warranty "
1423 "of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
1424 "See the GNU General Public License for more details.\n\n"
1425 " You should have received a copy of the GNU General Public "
1426 "License along with this program; if not, write to the Free Software "
1427 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA"
1428 "02110-1301 USA."));
1429 WMSetLabelRelief(panel
->licenseL
, WRGroove
);
1431 WMRealizeWidget(panel
->win
);
1432 WMMapSubwidgets(panel
->win
);
1434 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, win_width
, win_height
, 0, 0, 0);
1435 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1436 center
= getCenter(scr
, win_width
, win_height
);
1437 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Legal"), center
.x
, center
.y
, win_width
, win_height
);
1439 WSETUFLAG(wwin
, no_closable
, 0);
1440 WSETUFLAG(wwin
, no_close_button
, 0);
1441 wWindowUpdateButtonImages(wwin
);
1442 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1443 #ifdef XKB_BUTTON_HINT
1444 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1446 wwin
->frame
->on_click_right
= destroyLegalPanel
;
1449 WMMapWidget(panel
->win
);
1455 ***********************************************************************
1456 * Crashing Dialog Panel
1457 ***********************************************************************
1460 typedef struct _CrashPanel
{
1461 WMWindow
*win
; /* main window */
1463 WMLabel
*iconL
; /* application icon */
1464 WMLabel
*nameL
; /* title of panel */
1466 WMFrame
*sepF
; /* separator frame */
1468 WMLabel
*noteL
; /* Title of note */
1469 WMLabel
*note2L
; /* body of note with what happened */
1471 WMFrame
*whatF
; /* "what to do next" frame */
1472 WMPopUpButton
*whatP
; /* action selection popup button */
1474 WMButton
*okB
; /* ok button */
1476 Bool done
; /* if finished with this dialog */
1477 int action
; /* what to do after */
1483 static void handleKeyPress(XEvent
* event
, void *clientData
)
1485 CrashPanel
*panel
= (CrashPanel
*) clientData
;
1487 if (event
->xkey
.keycode
== panel
->retKey
) {
1488 WMPerformButtonClick(panel
->okB
);
1492 static void okButtonCallback(void *self
, void *clientData
)
1494 CrashPanel
*panel
= (CrashPanel
*) clientData
;
1496 /* Parameter not used, but tell the compiler that it is ok */
1502 static void setCrashAction(void *self
, void *clientData
)
1504 WMPopUpButton
*pop
= (WMPopUpButton
*) self
;
1505 CrashPanel
*panel
= (CrashPanel
*) clientData
;
1507 panel
->action
= WMGetPopUpButtonSelectedItem(pop
);
1510 /* Make this read the logo from a compiled in pixmap -Dan */
1511 static WMPixmap
*getWindowMakerIconImage(WMScreen
*scr
)
1513 WMPixmap
*pix
= NULL
;
1516 /* Get the Logo icon, without the default icon */
1517 path
= get_icon_filename("Logo", "WMPanel", NULL
, False
);
1527 pix
= WMCreateBlendedPixmapFromFile(scr
, path
, &gray
);
1537 int wShowCrashingDialogPanel(int whatSig
)
1543 int screen_no
, scr_width
, scr_height
;
1547 panel
= wmalloc(sizeof(CrashPanel
));
1549 screen_no
= DefaultScreen(dpy
);
1550 scr_width
= WidthOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1551 scr_height
= HeightOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1553 scr
= WMCreateScreen(dpy
, screen_no
);
1555 werror(_("cannot open connection for crashing dialog panel. Aborting."));
1559 panel
->retKey
= XKeysymToKeycode(dpy
, XK_Return
);
1561 panel
->win
= WMCreateWindow(scr
, "crashingDialog");
1562 WMResizeWidget(panel
->win
, PWIDTH
, PHEIGHT
);
1563 WMMoveWidget(panel
->win
, (scr_width
- PWIDTH
) / 2, (scr_height
- PHEIGHT
) / 2);
1565 logo
= getWindowMakerIconImage(scr
);
1567 panel
->iconL
= WMCreateLabel(panel
->win
);
1568 WMResizeWidget(panel
->iconL
, 64, 64);
1569 WMMoveWidget(panel
->iconL
, 10, 10);
1570 WMSetLabelImagePosition(panel
->iconL
, WIPImageOnly
);
1571 WMSetLabelImage(panel
->iconL
, logo
);
1574 panel
->nameL
= WMCreateLabel(panel
->win
);
1575 WMResizeWidget(panel
->nameL
, 200, 30);
1576 WMMoveWidget(panel
->nameL
, 80, 25);
1577 WMSetLabelTextAlignment(panel
->nameL
, WALeft
);
1578 font
= WMBoldSystemFontOfSize(scr
, 24);
1579 WMSetLabelFont(panel
->nameL
, font
);
1580 WMReleaseFont(font
);
1581 WMSetLabelText(panel
->nameL
, _("Fatal error"));
1583 panel
->sepF
= WMCreateFrame(panel
->win
);
1584 WMResizeWidget(panel
->sepF
, PWIDTH
+ 4, 2);
1585 WMMoveWidget(panel
->sepF
, -2, 80);
1587 panel
->noteL
= WMCreateLabel(panel
->win
);
1588 WMResizeWidget(panel
->noteL
, PWIDTH
- 20, 40);
1589 WMMoveWidget(panel
->noteL
, 10, 90);
1590 WMSetLabelTextAlignment(panel
->noteL
, WAJustified
);
1591 snprintf(buf
, sizeof(buf
), _("Window Maker received signal %i."), whatSig
);
1592 WMSetLabelText(panel
->noteL
, buf
);
1594 panel
->note2L
= WMCreateLabel(panel
->win
);
1595 WMResizeWidget(panel
->note2L
, PWIDTH
- 20, 100);
1596 WMMoveWidget(panel
->note2L
, 10, 130);
1597 WMSetLabelTextAlignment(panel
->note2L
, WALeft
);
1598 WMSetLabelText(panel
->note2L
,
1599 _(" This fatal error occured probably due to a bug."
1600 " Please fill the included BUGFORM and " "report it to bugs@windowmaker.info."));
1601 WMSetLabelWraps(panel
->note2L
, True
);
1603 panel
->whatF
= WMCreateFrame(panel
->win
);
1604 WMResizeWidget(panel
->whatF
, PWIDTH
- 20, 50);
1605 WMMoveWidget(panel
->whatF
, 10, 240);
1606 WMSetFrameTitle(panel
->whatF
, _("What do you want to do now?"));
1608 panel
->whatP
= WMCreatePopUpButton(panel
->whatF
);
1609 WMResizeWidget(panel
->whatP
, PWIDTH
- 20 - 70, 20);
1610 WMMoveWidget(panel
->whatP
, 35, 20);
1611 WMSetPopUpButtonPullsDown(panel
->whatP
, False
);
1612 WMSetPopUpButtonText(panel
->whatP
, _("Select action"));
1613 WMAddPopUpButtonItem(panel
->whatP
, _("Abort and leave a core file"));
1614 WMAddPopUpButtonItem(panel
->whatP
, _("Restart Window Maker"));
1615 WMAddPopUpButtonItem(panel
->whatP
, _("Start alternate window manager"));
1616 WMSetPopUpButtonAction(panel
->whatP
, setCrashAction
, panel
);
1617 WMSetPopUpButtonSelectedItem(panel
->whatP
, WMRestart
);
1618 panel
->action
= WMRestart
;
1620 WMMapSubwidgets(panel
->whatF
);
1622 panel
->okB
= WMCreateCommandButton(panel
->win
);
1623 WMResizeWidget(panel
->okB
, 80, 26);
1624 WMMoveWidget(panel
->okB
, 205, 309);
1625 WMSetButtonText(panel
->okB
, _("OK"));
1626 WMSetButtonImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIReturnArrow
));
1627 WMSetButtonAltImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIHighlightedReturnArrow
));
1628 WMSetButtonImagePosition(panel
->okB
, WIPRight
);
1629 WMSetButtonAction(panel
->okB
, okButtonCallback
, panel
);
1633 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
, handleKeyPress
, panel
);
1635 WMRealizeWidget(panel
->win
);
1636 WMMapSubwidgets(panel
->win
);
1638 WMMapWidget(panel
->win
);
1640 XSetInputFocus(dpy
, WMWidgetXID(panel
->win
), RevertToParent
, CurrentTime
);
1642 while (!panel
->done
) {
1645 WMNextEvent(dpy
, &event
);
1646 WMHandleEvent(&event
);
1649 action
= panel
->action
;
1651 WMUnmapWidget(panel
->win
);
1652 WMDestroyWidget(panel
->win
);