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 wPreferences
.save_session_on_exit
= WMGetButtonSelected((WMButton
*) w
);
111 int wExitDialog(WScreen
*scr
, const char *title
, const char *message
, const char *defBtn
, const char *altBtn
, const char *othBtn
)
114 WMButton
*saveSessionBtn
;
120 panel
= WMCreateAlertPanel(scr
->wmscreen
, NULL
, title
, message
, defBtn
, altBtn
, othBtn
);
122 /* add save session button */
123 saveSessionBtn
= WMCreateSwitchButton(panel
->hbox
);
124 WMSetButtonAction(saveSessionBtn
, toggleSaveSession
, NULL
);
125 WMAddBoxSubview(panel
->hbox
, WMWidgetView(saveSessionBtn
), False
, True
, 200, 0, 0);
126 WMSetButtonText(saveSessionBtn
, _("Save workspace state"));
127 WMSetButtonSelected(saveSessionBtn
, wPreferences
.save_session_on_exit
);
128 WMRealizeWidget(saveSessionBtn
);
129 WMMapWidget(saveSessionBtn
);
131 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 400, 180, 0, 0, 0);
133 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
135 center
= getCenter(scr
, 400, 180);
136 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
, 400, 180);
138 wwin
->client_leader
= WMWidgetXID(panel
->win
);
140 WMMapWidget(panel
->win
);
144 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
146 result
= panel
->result
;
148 WMUnmapWidget(panel
->win
);
150 wUnmanageWindow(wwin
, False
, False
);
152 WMDestroyAlertPanel(panel
);
154 XDestroyWindow(dpy
, parent
);
159 typedef struct _WMInputPanelWithHistory
{
168 } WMInputPanelWithHistory
;
170 static char *HistoryFileName(const char *name
)
172 char *filename
= NULL
;
174 filename
= wstrdup(wusergnusteppath());
175 filename
= wstrappend(filename
, "/.AppInfo/WindowMaker/History");
176 if (name
&& strlen(name
)) {
177 filename
= wstrappend(filename
, ".");
178 filename
= wstrappend(filename
, name
);
183 static int strmatch(const void *str1
, const void *str2
)
185 return !strcmp((const char *)str1
, (const char *)str2
);
188 static WMArray
*LoadHistory(const char *filename
, int max
)
190 WMPropList
*plhistory
;
196 history
= WMCreateArrayWithDestructor(1, wfree
);
197 WMAddToArray(history
, wstrdup(""));
199 plhistory
= WMReadPropListFromFile(filename
);
202 if (WMIsPLArray(plhistory
)) {
203 num
= WMGetPropListItemCount(plhistory
);
205 for (i
= 0; i
< num
; ++i
) {
206 plitem
= WMGetFromPLArray(plhistory
, i
);
207 if (WMIsPLString(plitem
)) {
208 str
= WMGetFromPLString(plitem
);
209 if (WMFindInArray(history
, strmatch
, str
) == WANotFound
) {
211 * The string here is duplicated because it will be freed
212 * automatically when the array is deleted. This is not really
213 * great because it is already an allocated string,
214 * unfortunately we cannot re-use it because it will be freed
215 * when we discard the PL (and we don't want to waste the PL's
218 WMAddToArray(history
, wstrdup(str
));
225 WMReleasePropList(plhistory
);
231 static void SaveHistory(WMArray
* history
, const char *filename
)
234 WMPropList
*plhistory
;
236 plhistory
= WMCreatePLArray(NULL
);
238 for (i
= 0; i
< WMGetArrayItemCount(history
); ++i
)
239 WMAddToPLArray(plhistory
, WMCreatePLString(WMGetFromArray(history
, i
)));
241 WMWritePropListToFile(plhistory
, filename
);
242 WMReleasePropList(plhistory
);
245 static int pstrcmp(const char **str1
, const char **str2
)
247 return strcmp(*str1
, *str2
);
251 ScanFiles(const char *dir
, const char *prefix
, unsigned acceptmask
, unsigned declinemask
, WMArray
* result
)
257 char *fullfilename
, *suffix
;
259 prefixlen
= strlen(prefix
);
260 if ((d
= opendir(dir
)) != NULL
) {
261 while ((de
= readdir(d
)) != NULL
) {
262 if (strlen(de
->d_name
) > prefixlen
&&
263 !strncmp(prefix
, de
->d_name
, prefixlen
) &&
264 strcmp(de
->d_name
, ".") != 0 && strcmp(de
->d_name
, "..")) {
265 fullfilename
= wstrconcat((char *)dir
, "/");
266 fullfilename
= wstrappend(fullfilename
, de
->d_name
);
268 if (stat(fullfilename
, &sb
) == 0 &&
269 (sb
.st_mode
& acceptmask
) &&
270 !(sb
.st_mode
& declinemask
) &&
271 WMFindInArray(result
, (WMMatchDataProc
*) strmatch
,
272 de
->d_name
+ prefixlen
) == WANotFound
) {
273 suffix
= wstrdup(de
->d_name
+ prefixlen
);
274 if (sb
.st_mode
& S_IFDIR
)
275 wstrappend(suffix
,"/");
276 WMAddToArray(result
, suffix
);
285 static WMArray
*GenerateVariants(const char *complete
)
287 Bool firstWord
= True
;
288 WMArray
*variants
= NULL
;
289 char *pos
= NULL
, *path
= NULL
, *tmp
= NULL
, *dir
= NULL
, *prefix
= NULL
;
291 variants
= WMCreateArrayWithDestructor(0, wfree
);
293 while (*complete
== ' ')
296 if ((pos
= strrchr(complete
, ' ')) != NULL
) {
301 if ((pos
= strrchr(complete
, '/')) != NULL
) {
302 tmp
= wstrndup((char *)complete
, pos
- complete
+ 1);
303 if (*tmp
== '~' && *(tmp
+ 1) == '/' && getenv("HOME")) {
304 dir
= wstrdup(getenv("HOME"));
305 dir
= wstrappend(dir
, tmp
+ 1);
310 prefix
= wstrdup(pos
+ 1);
311 ScanFiles(dir
, prefix
, (unsigned)-1, 0, variants
);
314 } else if (*complete
== '~') {
315 WMAddToArray(variants
, wstrdup("/"));
316 } else if (firstWord
) {
317 path
= getenv("PATH");
319 pos
= strchr(path
, ':');
321 tmp
= wstrndup(path
, pos
- path
);
323 } else if (*path
!= '\0') {
328 ScanFiles(tmp
, complete
, S_IXOTH
| S_IXGRP
| S_IXUSR
, S_IFDIR
, variants
);
333 WMSortArray(variants
, (WMCompareDataProc
*) pstrcmp
);
337 static void handleHistoryKeyPress(XEvent
* event
, void *clientData
)
341 WMInputPanelWithHistory
*p
= (WMInputPanelWithHistory
*) clientData
;
344 ksym
= XLookupKeysym(&event
->xkey
, 0);
348 if (p
->histpos
< WMGetArrayItemCount(p
->history
) - 1) {
350 wfree(WMReplaceInArray(p
->history
, 0, WMGetTextFieldText(p
->panel
->text
)));
352 WMSetTextFieldText(p
->panel
->text
, WMGetFromArray(p
->history
, p
->histpos
));
356 if (p
->histpos
> 0) {
358 WMSetTextFieldText(p
->panel
->text
, WMGetFromArray(p
->history
, p
->histpos
));
363 text
= WMGetTextFieldText(p
->panel
->text
);
364 pos
= WMGetTextFieldCursorPosition(p
->panel
->text
);
365 p
->prefix
= wstrndup(text
, pos
);
366 p
->suffix
= wstrdup(text
+ pos
);
368 p
->variants
= GenerateVariants(p
->prefix
);
377 if (p
->variants
&& p
->prefix
&& p
->suffix
) {
379 if (p
->varpos
> WMGetArrayItemCount(p
->variants
))
382 text
= wstrconcat(p
->prefix
, WMGetFromArray(p
->variants
, p
->varpos
- 1));
384 text
= wstrdup(p
->prefix
);
386 text
= wstrappend(text
, p
->suffix
);
387 WMSetTextFieldText(p
->panel
->text
, text
);
388 WMSetTextFieldCursorPosition(p
->panel
->text
, pos
);
393 if (ksym
!= XK_Tab
) {
403 WMFreeArray(p
->variants
);
409 int wAdvancedInputDialog(WScreen
*scr
, const char *title
, const char *message
, const char *name
, char **text
)
415 WMInputPanelWithHistory
*p
;
418 filename
= HistoryFileName(name
);
419 p
= wmalloc(sizeof(WMInputPanelWithHistory
));
420 p
->panel
= WMCreateInputPanel(scr
->wmscreen
, NULL
, title
, message
, *text
, _("OK"), _("Cancel"));
421 p
->history
= LoadHistory(filename
, wPreferences
.history_lines
);
428 WMCreateEventHandler(WMWidgetView(p
->panel
->text
), KeyPressMask
, handleHistoryKeyPress
, p
);
430 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 320, 160, 0, 0, 0);
431 XSelectInput(dpy
, parent
, KeyPressMask
| KeyReleaseMask
);
433 XReparentWindow(dpy
, WMWidgetXID(p
->panel
->win
), parent
, 0, 0);
435 center
= getCenter(scr
, 320, 160);
436 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
, 320, 160);
438 wwin
->client_leader
= WMWidgetXID(p
->panel
->win
);
440 WMMapWidget(p
->panel
->win
);
444 WMRunModalLoop(WMWidgetScreen(p
->panel
->win
), WMWidgetView(p
->panel
->win
));
446 if (p
->panel
->result
== WAPRDefault
) {
447 result
= WMGetTextFieldText(p
->panel
->text
);
448 wfree(WMReplaceInArray(p
->history
, 0, wstrdup(result
)));
449 SaveHistory(p
->history
, filename
);
453 wUnmanageWindow(wwin
, False
, False
);
455 WMDestroyInputPanel(p
->panel
);
456 WMFreeArray(p
->history
);
460 XDestroyWindow(dpy
, parent
);
473 int wInputDialog(WScreen
*scr
, const char *title
, const char *message
, char **text
)
481 panel
= WMCreateInputPanel(scr
->wmscreen
, NULL
, title
, message
, *text
, _("OK"), _("Cancel"));
483 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 320, 160, 0, 0, 0);
484 XSelectInput(dpy
, parent
, KeyPressMask
| KeyReleaseMask
);
486 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
488 center
= getCenter(scr
, 320, 160);
489 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
, 320, 160);
491 wwin
->client_leader
= WMWidgetXID(panel
->win
);
493 WMMapWidget(panel
->win
);
497 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
499 if (panel
->result
== WAPRDefault
)
500 result
= WMGetTextFieldText(panel
->text
);
504 wUnmanageWindow(wwin
, False
, False
);
506 WMDestroyInputPanel(panel
);
508 XDestroyWindow(dpy
, parent
);
522 *****************************************************************
523 * Icon Selection Panel
524 *****************************************************************
527 typedef struct IconPanel
{
540 WMButton
*previewButton
;
545 WMTextField
*fileField
;
548 WMButton
*cancelButton
;
550 WMButton
*chooseButton
;
557 static void listPixmaps(WScreen
*scr
, WMList
*lPtr
, const char *path
)
559 struct dirent
*dentry
;
561 char pbuf
[PATH_MAX
+ 16];
563 IconPanel
*panel
= WMGetHangedData(lPtr
);
565 panel
->preview
= False
;
567 apath
= wexpandpath(path
);
568 dir
= opendir(apath
);
573 tmp
= _("Could not open directory ");
574 msg
= wmalloc(strlen(tmp
) + strlen(path
) + 6);
578 wMessageDialog(scr
, _("Error"), msg
, _("OK"), NULL
, NULL
);
584 /* list contents in the column */
585 while ((dentry
= readdir(dir
))) {
588 if (strcmp(dentry
->d_name
, ".") == 0 || strcmp(dentry
->d_name
, "..") == 0)
593 strcat(pbuf
, dentry
->d_name
);
595 if (stat(pbuf
, &statb
) < 0)
598 if (statb
.st_mode
& (S_IRUSR
| S_IRGRP
| S_IROTH
)
599 && statb
.st_mode
& (S_IFREG
| S_IFLNK
)) {
600 WMAddListItem(lPtr
, dentry
->d_name
);
603 WMSortListItems(lPtr
);
607 panel
->preview
= True
;
610 static void setViewedImage(IconPanel
*panel
, const char *file
)
619 pixmap
= WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel
->win
), file
, &color
);
621 WMSetButtonEnabled(panel
->okButton
, False
);
623 WMSetLabelText(panel
->iconView
, _("Could not load image file "));
625 WMSetLabelImage(panel
->iconView
, NULL
);
627 WMSetButtonEnabled(panel
->okButton
, True
);
629 WMSetLabelText(panel
->iconView
, NULL
);
630 WMSetLabelImage(panel
->iconView
, pixmap
);
631 WMReleasePixmap(pixmap
);
635 static void listCallback(void *self
, void *data
)
637 WMList
*lPtr
= (WMList
*) self
;
638 IconPanel
*panel
= (IconPanel
*) data
;
641 if (lPtr
== panel
->dirList
) {
642 WMListItem
*item
= WMGetListSelectedItem(lPtr
);
648 WMSetTextFieldText(panel
->fileField
, path
);
650 WMSetLabelImage(panel
->iconView
, NULL
);
652 WMSetButtonEnabled(panel
->okButton
, False
);
654 WMClearList(panel
->iconList
);
655 listPixmaps(panel
->scr
, panel
->iconList
, path
);
657 char *tmp
, *iconFile
;
658 WMListItem
*item
= WMGetListSelectedItem(panel
->dirList
);
663 tmp
= wexpandpath(path
);
665 item
= WMGetListSelectedItem(panel
->iconList
);
668 iconFile
= item
->text
;
670 path
= wmalloc(strlen(tmp
) + strlen(iconFile
) + 4);
673 strcat(path
, iconFile
);
675 WMSetTextFieldText(panel
->fileField
, path
);
676 setViewedImage(panel
, path
);
681 static void listIconPaths(WMList
* lPtr
)
686 paths
= wstrdup(wPreferences
.icon_path
);
688 path
= strtok(paths
, ":");
693 tmp
= wexpandpath(path
);
694 /* do not sort, because the order implies the order of
695 * directories searched */
696 if (access(tmp
, X_OK
) == 0)
697 WMAddListItem(lPtr
, path
);
699 } while ((path
= strtok(NULL
, ":")) != NULL
);
704 static void drawIconProc(WMList
* lPtr
, int index
, Drawable d
, char *text
, int state
, WMRect
* rect
)
706 IconPanel
*panel
= WMGetHangedData(lPtr
);
707 WScreen
*scr
= panel
->scr
;
708 GC gc
= scr
->draw_gc
;
709 GC copygc
= scr
->copy_gc
;
710 char *file
, *dirfile
;
714 WMScreen
*wmscr
= WMWidgetScreen(panel
->win
);
716 int x
, y
, width
, height
, len
;
723 width
= rect
->size
.width
;
724 height
= rect
->size
.height
;
726 back
= (state
& WLDSSelected
) ? scr
->white
: scr
->gray
;
728 dirfile
= wexpandpath(WMGetListSelectedItem(panel
->dirList
)->text
);
729 len
= strlen(dirfile
) + strlen(text
) + 4;
731 snprintf(file
, len
, "%s/%s", dirfile
, text
);
734 color
.red
= WMRedComponentOfColor(back
) >> 8;
735 color
.green
= WMGreenComponentOfColor(back
) >> 8;
736 color
.blue
= WMBlueComponentOfColor(back
) >> 8;
737 color
.alpha
= WMGetColorAlpha(back
) >> 8;
739 pixmap
= WMCreateBlendedPixmapFromFile(wmscr
, file
, &color
);
743 /*WMRemoveListItem(lPtr, index); */
747 XFillRectangle(dpy
, d
, WMColorGC(back
), x
, y
, width
, height
);
749 XSetClipMask(dpy
, gc
, None
);
750 /*XDrawRectangle(dpy, d, WMColorGC(white), x+5, y+5, width-10, 54); */
751 XDrawLine(dpy
, d
, WMColorGC(scr
->white
), x
, y
+ height
- 1, x
+ width
, y
+ height
- 1);
753 size
= WMGetPixmapSize(pixmap
);
755 XSetClipMask(dpy
, copygc
, WMGetPixmapMaskXID(pixmap
));
756 XSetClipOrigin(dpy
, copygc
, x
+ (width
- size
.width
) / 2, y
+ 2);
757 XCopyArea(dpy
, WMGetPixmapXID(pixmap
), d
, copygc
, 0, 0,
758 size
.width
> 100 ? 100 : size
.width
, size
.height
> 64 ? 64 : size
.height
,
759 x
+ (width
- size
.width
) / 2, y
+ 2);
763 int fheight
= WMFontHeight(panel
->normalfont
);
764 int tlen
= strlen(text
);
765 int twidth
= WMWidthOfString(panel
->normalfont
, text
, tlen
);
768 ofx
= x
+ (width
- twidth
) / 2;
769 ofy
= y
+ 64 - fheight
;
771 for (i
= -1; i
< 2; i
++)
772 for (j
= -1; j
< 2; j
++)
773 WMDrawString(wmscr
, d
, scr
->white
, panel
->normalfont
,
774 ofx
+ i
, ofy
+ j
, text
, tlen
);
776 WMDrawString(wmscr
, d
, scr
->black
, panel
->normalfont
, ofx
, ofy
, text
, tlen
);
779 WMReleasePixmap(pixmap
);
780 /* I hope it is better to do not use cache / on my box it is fast nuff */
784 static void buttonCallback(void *self
, void *clientData
)
786 WMButton
*bPtr
= (WMButton
*) self
;
787 IconPanel
*panel
= (IconPanel
*) clientData
;
789 if (bPtr
== panel
->okButton
) {
791 panel
->result
= True
;
792 } else if (bPtr
== panel
->cancelButton
) {
794 panel
->result
= False
;
795 } else if (bPtr
== panel
->previewButton
) {
796 /**** Previewer ****/
797 WMSetButtonEnabled(bPtr
, False
);
798 WMSetListUserDrawItemHeight(panel
->iconList
, 68);
799 WMSetListUserDrawProc(panel
->iconList
, drawIconProc
);
800 WMRedisplayWidget(panel
->iconList
);
801 /* for draw proc to access screen/gc */
802 /*** end preview ***/
805 else if (bPtr
== panel
->chooseButton
) {
808 op
= WMCreateOpenPanel(WMWidgetScreen(bPtr
));
810 if (WMRunModalFilePanelForDirectory(op
, NULL
, "/usr/local", NULL
, NULL
)) {
812 path
= WMGetFilePanelFile(op
);
813 WMSetTextFieldText(panel
->fileField
, path
);
814 setViewedImage(panel
, path
);
817 WMDestroyFilePanel(op
);
822 static void keyPressHandler(XEvent
* event
, void *data
)
824 IconPanel
*panel
= (IconPanel
*) data
;
832 if (event
->type
== KeyRelease
)
836 XLookupString(&event
->xkey
, buffer
, sizeof(buffer
), &ksym
, NULL
);
838 iidx
= WMGetListSelectedItemRow(panel
->iconList
);
839 didx
= WMGetListSelectedItemRow(panel
->dirList
);
847 list
= panel
->iconList
;
850 if (iidx
< WMGetListNumberOfRows(panel
->iconList
) - 1)
854 list
= panel
->iconList
;
858 list
= panel
->iconList
;
861 item
= WMGetListNumberOfRows(panel
->iconList
) - 1;
862 list
= panel
->iconList
;
865 if (didx
< WMGetListNumberOfRows(panel
->dirList
) - 1)
869 list
= panel
->dirList
;
876 list
= panel
->dirList
;
879 WMPerformButtonClick(panel
->okButton
);
882 WMPerformButtonClick(panel
->cancelButton
);
887 WMSelectListItem(list
, item
);
888 WMSetListPosition(list
, item
- 5);
889 listCallback(list
, panel
);
893 Bool
wIconChooserDialog(WScreen
*scr
, char **file
, const char *instance
, const char *class)
902 panel
= wmalloc(sizeof(IconPanel
));
906 panel
->win
= WMCreateWindow(scr
->wmscreen
, "iconChooser");
907 WMResizeWidget(panel
->win
, 450, 280);
909 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
| KeyReleaseMask
, keyPressHandler
, panel
);
911 boldFont
= WMBoldSystemFontOfSize(scr
->wmscreen
, 12);
912 panel
->normalfont
= WMSystemFontOfSize(WMWidgetScreen(panel
->win
), 12);
914 panel
->dirLabel
= WMCreateLabel(panel
->win
);
915 WMResizeWidget(panel
->dirLabel
, 200, 20);
916 WMMoveWidget(panel
->dirLabel
, 10, 7);
917 WMSetLabelText(panel
->dirLabel
, _("Directories"));
918 WMSetLabelFont(panel
->dirLabel
, boldFont
);
919 WMSetLabelTextAlignment(panel
->dirLabel
, WACenter
);
921 WMSetLabelRelief(panel
->dirLabel
, WRSunken
);
923 panel
->iconLabel
= WMCreateLabel(panel
->win
);
924 WMResizeWidget(panel
->iconLabel
, 140, 20);
925 WMMoveWidget(panel
->iconLabel
, 215, 7);
926 WMSetLabelText(panel
->iconLabel
, _("Icons"));
927 WMSetLabelFont(panel
->iconLabel
, boldFont
);
928 WMSetLabelTextAlignment(panel
->iconLabel
, WACenter
);
930 WMReleaseFont(boldFont
);
932 color
= WMWhiteColor(scr
->wmscreen
);
933 WMSetLabelTextColor(panel
->dirLabel
, color
);
934 WMSetLabelTextColor(panel
->iconLabel
, color
);
935 WMReleaseColor(color
);
937 color
= WMDarkGrayColor(scr
->wmscreen
);
938 WMSetWidgetBackgroundColor(panel
->iconLabel
, color
);
939 WMSetWidgetBackgroundColor(panel
->dirLabel
, color
);
940 WMReleaseColor(color
);
942 WMSetLabelRelief(panel
->iconLabel
, WRSunken
);
944 panel
->dirList
= WMCreateList(panel
->win
);
945 WMResizeWidget(panel
->dirList
, 200, 170);
946 WMMoveWidget(panel
->dirList
, 10, 30);
947 WMSetListAction(panel
->dirList
, listCallback
, panel
);
949 panel
->iconList
= WMCreateList(panel
->win
);
950 WMResizeWidget(panel
->iconList
, 140, 170);
951 WMMoveWidget(panel
->iconList
, 215, 30);
952 WMSetListAction(panel
->iconList
, listCallback
, panel
);
954 WMHangData(panel
->iconList
, panel
);
956 panel
->previewButton
= WMCreateCommandButton(panel
->win
);
957 WMResizeWidget(panel
->previewButton
, 75, 26);
958 WMMoveWidget(panel
->previewButton
, 365, 130);
959 WMSetButtonText(panel
->previewButton
, _("Preview"));
960 WMSetButtonAction(panel
->previewButton
, buttonCallback
, panel
);
962 panel
->iconView
= WMCreateLabel(panel
->win
);
963 WMResizeWidget(panel
->iconView
, 75, 75);
964 WMMoveWidget(panel
->iconView
, 365, 40);
965 WMSetLabelImagePosition(panel
->iconView
, WIPOverlaps
);
966 WMSetLabelRelief(panel
->iconView
, WRSunken
);
967 WMSetLabelTextAlignment(panel
->iconView
, WACenter
);
969 panel
->fileLabel
= WMCreateLabel(panel
->win
);
970 WMResizeWidget(panel
->fileLabel
, 80, 20);
971 WMMoveWidget(panel
->fileLabel
, 10, 210);
972 WMSetLabelText(panel
->fileLabel
, _("File Name:"));
974 panel
->fileField
= WMCreateTextField(panel
->win
);
975 WMSetViewNextResponder(WMWidgetView(panel
->fileField
), WMWidgetView(panel
->win
));
976 WMResizeWidget(panel
->fileField
, 345, 20);
977 WMMoveWidget(panel
->fileField
, 95, 210);
978 WMSetTextFieldEditable(panel
->fileField
, False
);
980 panel
->okButton
= WMCreateCommandButton(panel
->win
);
981 WMResizeWidget(panel
->okButton
, 80, 26);
982 WMMoveWidget(panel
->okButton
, 360, 240);
983 WMSetButtonText(panel
->okButton
, _("OK"));
984 WMSetButtonEnabled(panel
->okButton
, False
);
985 WMSetButtonAction(panel
->okButton
, buttonCallback
, panel
);
987 panel
->cancelButton
= WMCreateCommandButton(panel
->win
);
988 WMResizeWidget(panel
->cancelButton
, 80, 26);
989 WMMoveWidget(panel
->cancelButton
, 270, 240);
990 WMSetButtonText(panel
->cancelButton
, _("Cancel"));
991 WMSetButtonAction(panel
->cancelButton
, buttonCallback
, panel
);
993 panel
->chooseButton
= WMCreateCommandButton(panel
->win
);
994 WMResizeWidget(panel
->chooseButton
, 110, 26);
995 WMMoveWidget(panel
->chooseButton
, 150, 240);
996 WMSetButtonText(panel
->chooseButton
, _("Choose File"));
997 WMSetButtonAction(panel
->chooseButton
, buttonCallback
, panel
);
999 WMRealizeWidget(panel
->win
);
1000 WMMapSubwidgets(panel
->win
);
1002 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 450, 280, 0, 0, 0);
1004 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1008 int len
= (instance
? strlen(instance
) : 0)
1009 + (class ? strlen(class) : 0) + 32;
1014 if (tmp
&& (instance
|| class))
1015 snprintf(tmp
, len
, "%s [%s.%s]", _("Icon Chooser"), instance
, class);
1017 strcpy(tmp
, _("Icon Chooser"));
1019 center
= getCenter(scr
, 450, 280);
1021 wwin
= wManageInternalWindow(scr
, parent
, None
, tmp
, center
.x
, center
.y
, 450, 280);
1025 /* put icon paths in the list */
1026 listIconPaths(panel
->dirList
);
1028 WMMapWidget(panel
->win
);
1032 while (!panel
->done
) {
1035 WMNextEvent(dpy
, &event
);
1036 WMHandleEvent(&event
);
1039 if (panel
->result
) {
1040 char *defaultPath
, *wantedPath
;
1042 /* check if the file the user selected is not the one that
1043 * would be loaded by default with the current search path */
1044 *file
= WMGetListSelectedItem(panel
->iconList
)->text
;
1049 defaultPath
= FindImage(wPreferences
.icon_path
, *file
);
1050 wantedPath
= WMGetTextFieldText(panel
->fileField
);
1051 /* if the file is not the default, use full path */
1052 if (strcmp(wantedPath
, defaultPath
) != 0) {
1055 *file
= wstrdup(*file
);
1064 result
= panel
->result
;
1066 WMReleaseFont(panel
->normalfont
);
1068 WMUnmapWidget(panel
->win
);
1070 WMDestroyWidget(panel
->win
);
1072 wUnmanageWindow(wwin
, False
, False
);
1076 XDestroyWindow(dpy
, parent
);
1082 ***********************************************************************
1084 ***********************************************************************
1100 #define COPYRIGHT_TEXT \
1101 "Copyright \xc2\xa9 1997-2006 Alfredo K. Kojima\n"\
1102 "Copyright \xc2\xa9 1998-2006 Dan Pascu"
1104 static InfoPanel
*thePanel
= NULL
;
1106 static void destroyInfoPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
1108 WMUnmapWidget(thePanel
);
1109 wUnmanageWindow(thePanel
->wwin
, False
, False
);
1110 WMDestroyWidget(thePanel
->win
);
1115 void wShowInfoPanel(WScreen
* scr
)
1120 char *strbuf
= NULL
;
1121 const char *separator
;
1127 int i
, width
= 50, sepHeight
;
1138 if (thePanel
->scr
== scr
) {
1139 wRaiseFrame(thePanel
->wwin
->frame
->core
);
1140 wSetFocusTo(scr
, thePanel
->wwin
);
1145 panel
= wmalloc(sizeof(InfoPanel
));
1149 panel
->win
= WMCreateWindow(scr
->wmscreen
, "info");
1150 WMResizeWidget(panel
->win
, 390, 230);
1152 logo
= WMCreateApplicationIconBlendedPixmap(scr
->wmscreen
, (RColor
*) NULL
);
1154 logo
= WMRetainPixmap(WMGetApplicationIconPixmap(scr
->wmscreen
));
1157 panel
->logoL
= WMCreateLabel(panel
->win
);
1158 WMResizeWidget(panel
->logoL
, 64, 64);
1159 WMMoveWidget(panel
->logoL
, 30, 20);
1160 WMSetLabelImagePosition(panel
->logoL
, WIPImageOnly
);
1161 WMSetLabelImage(panel
->logoL
, logo
);
1162 WMReleasePixmap(logo
);
1166 panel
->name1L
= WMCreateLabel(panel
->win
);
1167 WMResizeWidget(panel
->name1L
, 240, 30 + 2);
1168 WMMoveWidget(panel
->name1L
, 100, 30 - 2 - sepHeight
);
1170 name
= "Lucida Sans,Comic Sans MS,URW Gothic L,Trebuchet MS" ":italic:pixelsize=28:antialias=true";
1171 font
= WMCreateFont(scr
->wmscreen
, name
);
1172 strbuf
= "Window Maker";
1174 width
= WMWidthOfString(font
, strbuf
, strlen(strbuf
));
1175 WMSetLabelFont(panel
->name1L
, font
);
1176 WMReleaseFont(font
);
1178 WMSetLabelTextAlignment(panel
->name1L
, WACenter
);
1179 WMSetLabelText(panel
->name1L
, strbuf
);
1181 panel
->lineF
= WMCreateFrame(panel
->win
);
1182 WMResizeWidget(panel
->lineF
, width
, sepHeight
);
1183 WMMoveWidget(panel
->lineF
, 100 + (240 - width
) / 2, 60 - sepHeight
);
1184 WMSetFrameRelief(panel
->lineF
, WRSimple
);
1185 WMSetWidgetBackgroundColor(panel
->lineF
, scr
->black
);
1187 panel
->name2L
= WMCreateLabel(panel
->win
);
1188 WMResizeWidget(panel
->name2L
, 240, 24);
1189 WMMoveWidget(panel
->name2L
, 100, 60);
1190 name
= "URW Gothic L,Nimbus Sans L:pixelsize=16:antialias=true";
1191 font
= WMCreateFont(scr
->wmscreen
, name
);
1193 WMSetLabelFont(panel
->name2L
, font
);
1194 WMReleaseFont(font
);
1197 WMSetLabelTextAlignment(panel
->name2L
, WACenter
);
1198 WMSetLabelText(panel
->name2L
, _("Window Manager for X"));
1200 snprintf(buffer
, sizeof(buffer
), _("Version %s"), VERSION
);
1201 panel
->versionL
= WMCreateLabel(panel
->win
);
1202 WMResizeWidget(panel
->versionL
, 310, 16);
1203 WMMoveWidget(panel
->versionL
, 30, 95);
1204 WMSetLabelTextAlignment(panel
->versionL
, WARight
);
1205 WMSetLabelText(panel
->versionL
, buffer
);
1206 WMSetLabelWraps(panel
->versionL
, False
);
1208 panel
->copyrL
= WMCreateLabel(panel
->win
);
1209 WMResizeWidget(panel
->copyrL
, 360, 40);
1210 WMMoveWidget(panel
->copyrL
, 15, 185);
1211 WMSetLabelTextAlignment(panel
->copyrL
, WALeft
);
1212 WMSetLabelText(panel
->copyrL
, COPYRIGHT_TEXT
);
1213 font
= WMSystemFontOfSize(scr
->wmscreen
, 11);
1215 WMSetLabelFont(panel
->copyrL
, font
);
1216 WMReleaseFont(font
);
1221 snprintf(buffer
, sizeof(buffer
), _("Using visual 0x%x: %s %ibpp "),
1222 (unsigned)scr
->w_visual
->visualid
, visuals
[scr
->w_visual
->class], scr
->w_depth
);
1224 strbuf
= wstrappend(strbuf
, buffer
);
1226 switch (scr
->w_depth
) {
1228 strbuf
= wstrappend(strbuf
, _("(32 thousand colors)\n"));
1231 strbuf
= wstrappend(strbuf
, _("(64 thousand colors)\n"));
1235 strbuf
= wstrappend(strbuf
, _("(16 million colors)\n"));
1238 snprintf(buffer
, sizeof(buffer
), _("(%d colors)\n"), 1 << scr
->w_depth
);
1239 strbuf
= wstrappend(strbuf
, buffer
);
1243 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
1245 struct mallinfo ma
= mallinfo();
1246 snprintf(buffer
, sizeof(buffer
),
1248 _("Total memory allocated: %i kB (in use: %i kB, %d free chunks).\n"),
1250 _("Total memory allocated: %i kB (in use: %i kB).\n"),
1252 (ma
.arena
+ ma
.hblkhd
) / 1024,
1253 (ma
.uordblks
+ ma
.hblkhd
) / 1024
1256 * This information is representative of the memory
1257 * fragmentation. In ideal case it should be 1, but
1258 * that is never possible
1264 strbuf
= wstrappend(strbuf
, buffer
);
1268 strbuf
= wstrappend(strbuf
, _("Supported image formats: "));
1269 strl
= RSupportedFileFormats();
1271 for (i
= 0; strl
[i
] != NULL
; i
++) {
1272 if (separator
!= NULL
)
1273 strbuf
= wstrappend(strbuf
, separator
);
1274 strbuf
= wstrappend(strbuf
, strl
[i
]);
1278 strbuf
= wstrappend(strbuf
, _("\nAdditional support for: "));
1279 strbuf
= wstrappend(strbuf
, "WMSPEC");
1282 strbuf
= wstrappend(strbuf
, ", XRandR ");
1283 if (w_global
.xext
.randr
.supported
)
1284 strbuf
= wstrappend(strbuf
, _("(Supported)"));
1286 strbuf
= wstrappend(strbuf
, _("(Unsupported)"));
1290 strbuf
= wstrappend(strbuf
, ", MWM");
1294 strbuf
= wstrappend(strbuf
, _("\n"));
1295 #ifdef SOLARIS_XINERAMA
1296 strbuf
= wstrappend(strbuf
, _("Solaris "));
1298 strbuf
= wstrappend(strbuf
, _("Xinerama: "));
1301 snprintf(tmp
, sizeof(tmp
) - 1, _("%d heads found."), scr
->xine_info
.count
);
1302 strbuf
= wstrappend(strbuf
, tmp
);
1306 panel
->infoL
= WMCreateLabel(panel
->win
);
1307 WMResizeWidget(panel
->infoL
, 350, 75);
1308 WMMoveWidget(panel
->infoL
, 15, 115);
1309 WMSetLabelText(panel
->infoL
, strbuf
);
1310 font
= WMSystemFontOfSize(scr
->wmscreen
, 11);
1312 WMSetLabelFont(panel
->infoL
, font
);
1313 WMReleaseFont(font
);
1318 WMRealizeWidget(panel
->win
);
1319 WMMapSubwidgets(panel
->win
);
1321 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 382, 230, 0, 0, 0);
1323 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1325 WMMapWidget(panel
->win
);
1328 WMPoint center
= getCenter(scr
, 382, 230);
1330 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Info"), center
.x
, center
.y
, 382, 230);
1333 WSETUFLAG(wwin
, no_closable
, 0);
1334 WSETUFLAG(wwin
, no_close_button
, 0);
1335 #ifdef XKB_BUTTON_HINT
1336 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1338 wWindowUpdateButtonImages(wwin
);
1339 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1340 wwin
->frame
->on_click_right
= destroyInfoPanel
;
1349 ***********************************************************************
1351 ***********************************************************************
1364 static LegalPanel
*legalPanel
= NULL
;
1366 static void destroyLegalPanel(WCoreWindow
* foo
, void *data
, XEvent
* event
)
1368 WMUnmapWidget(legalPanel
->win
);
1370 WMDestroyWidget(legalPanel
->win
);
1372 wUnmanageWindow(legalPanel
->wwin
, False
, False
);
1379 void wShowLegalPanel(WScreen
* scr
)
1386 if (legalPanel
->scr
== scr
) {
1387 wRaiseFrame(legalPanel
->wwin
->frame
->core
);
1388 wSetFocusTo(scr
, legalPanel
->wwin
);
1393 panel
= wmalloc(sizeof(LegalPanel
));
1397 panel
->win
= WMCreateWindow(scr
->wmscreen
, "legal");
1398 WMResizeWidget(panel
->win
, 420, 250);
1400 panel
->licenseL
= WMCreateLabel(panel
->win
);
1401 WMSetLabelWraps(panel
->licenseL
, True
);
1402 WMResizeWidget(panel
->licenseL
, 400, 230);
1403 WMMoveWidget(panel
->licenseL
, 10, 10);
1404 WMSetLabelTextAlignment(panel
->licenseL
, WALeft
);
1405 WMSetLabelText(panel
->licenseL
,
1406 _(" Window Maker is free software; you can redistribute it and/or\n"
1407 "modify it under the terms of the GNU General Public License as\n"
1408 "published by the Free Software Foundation; either version 2 of the\n"
1409 "License, or (at your option) any later version.\n\n"
1410 " Window Maker is distributed in the hope that it will be useful,\n"
1411 "but WITHOUT ANY WARRANTY; without even the implied warranty\n"
1412 "of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
1413 "See the GNU General Public License for more details.\n\n"
1414 " You should have received a copy of the GNU General Public\n"
1415 "License along with this program; if not, write to the Free Software\n"
1416 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\n"
1417 "02110-1301 USA."));
1418 WMSetLabelRelief(panel
->licenseL
, WRGroove
);
1420 WMRealizeWidget(panel
->win
);
1421 WMMapSubwidgets(panel
->win
);
1423 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 420, 250, 0, 0, 0);
1425 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1428 WMPoint center
= getCenter(scr
, 420, 250);
1430 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Legal"), center
.x
, center
.y
, 420, 250);
1433 WSETUFLAG(wwin
, no_closable
, 0);
1434 WSETUFLAG(wwin
, no_close_button
, 0);
1435 wWindowUpdateButtonImages(wwin
);
1436 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1437 #ifdef XKB_BUTTON_HINT
1438 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1440 wwin
->frame
->on_click_right
= destroyLegalPanel
;
1444 WMMapWidget(panel
->win
);
1452 ***********************************************************************
1453 * Crashing Dialog Panel
1454 ***********************************************************************
1457 typedef struct _CrashPanel
{
1458 WMWindow
*win
; /* main window */
1460 WMLabel
*iconL
; /* application icon */
1461 WMLabel
*nameL
; /* title of panel */
1463 WMFrame
*sepF
; /* separator frame */
1465 WMLabel
*noteL
; /* Title of note */
1466 WMLabel
*note2L
; /* body of note with what happened */
1468 WMFrame
*whatF
; /* "what to do next" frame */
1469 WMPopUpButton
*whatP
; /* action selection popup button */
1471 WMButton
*okB
; /* ok button */
1473 Bool done
; /* if finished with this dialog */
1474 int action
; /* what to do after */
1480 static void handleKeyPress(XEvent
* event
, void *clientData
)
1482 CrashPanel
*panel
= (CrashPanel
*) clientData
;
1484 if (event
->xkey
.keycode
== panel
->retKey
) {
1485 WMPerformButtonClick(panel
->okB
);
1489 static void okButtonCallback(void *self
, void *clientData
)
1491 CrashPanel
*panel
= (CrashPanel
*) clientData
;
1496 static void setCrashAction(void *self
, void *clientData
)
1498 WMPopUpButton
*pop
= (WMPopUpButton
*) self
;
1499 CrashPanel
*panel
= (CrashPanel
*) clientData
;
1501 panel
->action
= WMGetPopUpButtonSelectedItem(pop
);
1504 /* Make this read the logo from a compiled in pixmap -Dan */
1505 static WMPixmap
*getWindowMakerIconImage(WMScreen
*scr
)
1507 WMPixmap
*pix
= NULL
;
1510 /* Get the Logo icon, without the default icon */
1511 path
= get_icon_filename("Logo", "WMPanel", NULL
, False
);
1521 pix
= WMCreateBlendedPixmapFromFile(scr
, path
, &gray
);
1531 int wShowCrashingDialogPanel(int whatSig
)
1537 int screen_no
, scr_width
, scr_height
;
1541 panel
= wmalloc(sizeof(CrashPanel
));
1543 screen_no
= DefaultScreen(dpy
);
1544 scr_width
= WidthOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1545 scr_height
= HeightOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1547 scr
= WMCreateScreen(dpy
, screen_no
);
1549 werror(_("cannot open connection for crashing dialog panel. Aborting."));
1553 panel
->retKey
= XKeysymToKeycode(dpy
, XK_Return
);
1555 panel
->win
= WMCreateWindow(scr
, "crashingDialog");
1556 WMResizeWidget(panel
->win
, PWIDTH
, PHEIGHT
);
1557 WMMoveWidget(panel
->win
, (scr_width
- PWIDTH
) / 2, (scr_height
- PHEIGHT
) / 2);
1559 logo
= getWindowMakerIconImage(scr
);
1561 panel
->iconL
= WMCreateLabel(panel
->win
);
1562 WMResizeWidget(panel
->iconL
, 64, 64);
1563 WMMoveWidget(panel
->iconL
, 10, 10);
1564 WMSetLabelImagePosition(panel
->iconL
, WIPImageOnly
);
1565 WMSetLabelImage(panel
->iconL
, logo
);
1568 panel
->nameL
= WMCreateLabel(panel
->win
);
1569 WMResizeWidget(panel
->nameL
, 200, 30);
1570 WMMoveWidget(panel
->nameL
, 80, 25);
1571 WMSetLabelTextAlignment(panel
->nameL
, WALeft
);
1572 font
= WMBoldSystemFontOfSize(scr
, 24);
1573 WMSetLabelFont(panel
->nameL
, font
);
1574 WMReleaseFont(font
);
1575 WMSetLabelText(panel
->nameL
, _("Fatal error"));
1577 panel
->sepF
= WMCreateFrame(panel
->win
);
1578 WMResizeWidget(panel
->sepF
, PWIDTH
+ 4, 2);
1579 WMMoveWidget(panel
->sepF
, -2, 80);
1581 panel
->noteL
= WMCreateLabel(panel
->win
);
1582 WMResizeWidget(panel
->noteL
, PWIDTH
- 20, 40);
1583 WMMoveWidget(panel
->noteL
, 10, 90);
1584 WMSetLabelTextAlignment(panel
->noteL
, WAJustified
);
1585 snprintf(buf
, sizeof(buf
), _("Window Maker received signal %i."), whatSig
);
1586 WMSetLabelText(panel
->noteL
, buf
);
1588 panel
->note2L
= WMCreateLabel(panel
->win
);
1589 WMResizeWidget(panel
->note2L
, PWIDTH
- 20, 100);
1590 WMMoveWidget(panel
->note2L
, 10, 130);
1591 WMSetLabelTextAlignment(panel
->note2L
, WALeft
);
1592 WMSetLabelText(panel
->note2L
,
1593 _(" This fatal error occured probably due to a bug."
1594 " Please fill the included BUGFORM and " "report it to bugs@windowmaker.info."));
1595 WMSetLabelWraps(panel
->note2L
, True
);
1597 panel
->whatF
= WMCreateFrame(panel
->win
);
1598 WMResizeWidget(panel
->whatF
, PWIDTH
- 20, 50);
1599 WMMoveWidget(panel
->whatF
, 10, 240);
1600 WMSetFrameTitle(panel
->whatF
, _("What do you want to do now?"));
1602 panel
->whatP
= WMCreatePopUpButton(panel
->whatF
);
1603 WMResizeWidget(panel
->whatP
, PWIDTH
- 20 - 70, 20);
1604 WMMoveWidget(panel
->whatP
, 35, 20);
1605 WMSetPopUpButtonPullsDown(panel
->whatP
, False
);
1606 WMSetPopUpButtonText(panel
->whatP
, _("Select action"));
1607 WMAddPopUpButtonItem(panel
->whatP
, _("Abort and leave a core file"));
1608 WMAddPopUpButtonItem(panel
->whatP
, _("Restart Window Maker"));
1609 WMAddPopUpButtonItem(panel
->whatP
, _("Start alternate window manager"));
1610 WMSetPopUpButtonAction(panel
->whatP
, setCrashAction
, panel
);
1611 WMSetPopUpButtonSelectedItem(panel
->whatP
, WMRestart
);
1612 panel
->action
= WMRestart
;
1614 WMMapSubwidgets(panel
->whatF
);
1616 panel
->okB
= WMCreateCommandButton(panel
->win
);
1617 WMResizeWidget(panel
->okB
, 80, 26);
1618 WMMoveWidget(panel
->okB
, 205, 309);
1619 WMSetButtonText(panel
->okB
, _("OK"));
1620 WMSetButtonImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIReturnArrow
));
1621 WMSetButtonAltImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIHighlightedReturnArrow
));
1622 WMSetButtonImagePosition(panel
->okB
, WIPRight
);
1623 WMSetButtonAction(panel
->okB
, okButtonCallback
, panel
);
1627 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
, handleKeyPress
, panel
);
1629 WMRealizeWidget(panel
->win
);
1630 WMMapSubwidgets(panel
->win
);
1632 WMMapWidget(panel
->win
);
1634 XSetInputFocus(dpy
, WMWidgetXID(panel
->win
), RevertToParent
, CurrentTime
);
1636 while (!panel
->done
) {
1639 WMNextEvent(dpy
, &event
);
1640 WMHandleEvent(&event
);
1643 action
= panel
->action
;
1645 WMUnmapWidget(panel
->win
);
1646 WMDestroyWidget(panel
->win
);