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"
62 extern WPreferences wPreferences
;
64 static WMPoint
getCenter(WScreen
* scr
, int width
, int height
)
66 return wGetPointToCenterRectInHead(scr
, wGetHeadForPointerLocation(scr
), width
, height
);
69 int wMessageDialog(WScreen
* scr
, char *title
, char *message
, char *defBtn
, char *altBtn
, 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
, char *title
, char *message
, char *defBtn
, char *altBtn
, 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(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(char *filename
, int max
)
190 WMPropList
*plhistory
;
195 history
= WMCreateArrayWithDestructor(1, wfree
);
196 WMAddToArray(history
, wstrdup(""));
198 plhistory
= WMReadPropListFromFile((char *)filename
);
200 if (plhistory
&& WMIsPLArray(plhistory
)) {
201 num
= WMGetPropListItemCount(plhistory
);
205 for (i
= 0; i
< num
; ++i
) {
206 plitem
= WMGetFromPLArray(plhistory
, i
);
207 if (WMIsPLString(plitem
) && WMFindInArray(history
, strmatch
,
208 WMGetFromPLString(plitem
)) == WANotFound
)
209 WMAddToArray(history
, WMGetFromPLString(plitem
));
216 static void SaveHistory(WMArray
* history
, char *filename
)
219 WMPropList
*plhistory
;
221 plhistory
= WMCreatePLArray(NULL
);
223 for (i
= 0; i
< WMGetArrayItemCount(history
); ++i
)
224 WMAddToPLArray(plhistory
, WMCreatePLString(WMGetFromArray(history
, i
)));
226 WMWritePropListToFile(plhistory
, (char *)filename
);
227 WMReleasePropList(plhistory
);
230 static int pstrcmp(const char **str1
, const char **str2
)
232 return strcmp(*str1
, *str2
);
236 ScanFiles(const char *dir
, const char *prefix
, unsigned acceptmask
, unsigned declinemask
, WMArray
* result
)
242 char *fullfilename
, *suffix
;
244 prefixlen
= strlen(prefix
);
245 if ((d
= opendir(dir
)) != NULL
) {
246 while ((de
= readdir(d
)) != NULL
) {
247 if (strlen(de
->d_name
) > prefixlen
&&
248 !strncmp(prefix
, de
->d_name
, prefixlen
) &&
249 strcmp(de
->d_name
, ".") != 0 && strcmp(de
->d_name
, "..")) {
250 fullfilename
= wstrconcat((char *)dir
, "/");
251 fullfilename
= wstrappend(fullfilename
, de
->d_name
);
253 if (stat(fullfilename
, &sb
) == 0 &&
254 (sb
.st_mode
& acceptmask
) &&
255 !(sb
.st_mode
& declinemask
) &&
256 WMFindInArray(result
, (WMMatchDataProc
*) strmatch
,
257 de
->d_name
+ prefixlen
) == WANotFound
) {
258 suffix
= wstrdup(de
->d_name
+ prefixlen
);
259 if (sb
.st_mode
& S_IFDIR
)
260 wstrappend(suffix
,"/");
261 WMAddToArray(result
, suffix
);
270 static WMArray
*GenerateVariants(const char *complete
)
272 Bool firstWord
= True
;
273 WMArray
*variants
= NULL
;
274 char *pos
= NULL
, *path
= NULL
, *tmp
= NULL
, *dir
= NULL
, *prefix
= NULL
;
276 variants
= WMCreateArrayWithDestructor(0, wfree
);
278 while (*complete
== ' ')
281 if ((pos
= strrchr(complete
, ' ')) != NULL
) {
286 if ((pos
= strrchr(complete
, '/')) != NULL
) {
287 tmp
= wstrndup((char *)complete
, pos
- complete
+ 1);
288 if (*tmp
== '~' && *(tmp
+ 1) == '/' && getenv("HOME")) {
289 dir
= wstrdup(getenv("HOME"));
290 dir
= wstrappend(dir
, tmp
+ 1);
295 prefix
= wstrdup(pos
+ 1);
296 ScanFiles(dir
, prefix
, (unsigned)-1, 0, variants
);
299 } else if (*complete
== '~') {
300 WMAddToArray(variants
, wstrdup("/"));
301 } else if (firstWord
) {
302 path
= getenv("PATH");
304 pos
= strchr(path
, ':');
306 tmp
= wstrndup(path
, pos
- path
);
308 } else if (*path
!= '\0') {
313 ScanFiles(tmp
, complete
, S_IXOTH
| S_IXGRP
| S_IXUSR
, S_IFDIR
, variants
);
318 WMSortArray(variants
, (WMCompareDataProc
*) pstrcmp
);
322 static void handleHistoryKeyPress(XEvent
* event
, void *clientData
)
326 WMInputPanelWithHistory
*p
= (WMInputPanelWithHistory
*) clientData
;
329 ksym
= XLookupKeysym(&event
->xkey
, 0);
333 if (p
->histpos
< WMGetArrayItemCount(p
->history
) - 1) {
335 wfree(WMReplaceInArray(p
->history
, 0, WMGetTextFieldText(p
->panel
->text
)));
337 WMSetTextFieldText(p
->panel
->text
, WMGetFromArray(p
->history
, p
->histpos
));
341 if (p
->histpos
> 0) {
343 WMSetTextFieldText(p
->panel
->text
, WMGetFromArray(p
->history
, p
->histpos
));
348 text
= WMGetTextFieldText(p
->panel
->text
);
349 pos
= WMGetTextFieldCursorPosition(p
->panel
->text
);
350 p
->prefix
= wstrndup(text
, pos
);
351 p
->suffix
= wstrdup(text
+ pos
);
353 p
->variants
= GenerateVariants(p
->prefix
);
362 if (p
->variants
&& p
->prefix
&& p
->suffix
) {
364 if (p
->varpos
> WMGetArrayItemCount(p
->variants
))
367 text
= wstrconcat(p
->prefix
, WMGetFromArray(p
->variants
, p
->varpos
- 1));
369 text
= wstrdup(p
->prefix
);
371 text
= wstrappend(text
, p
->suffix
);
372 WMSetTextFieldText(p
->panel
->text
, text
);
373 WMSetTextFieldCursorPosition(p
->panel
->text
, pos
);
378 if (ksym
!= XK_Tab
) {
388 WMFreeArray(p
->variants
);
394 int wAdvancedInputDialog(WScreen
* scr
, char *title
, char *message
, char *name
, char **text
)
400 WMInputPanelWithHistory
*p
;
403 filename
= HistoryFileName(name
);
404 p
= wmalloc(sizeof(WMInputPanelWithHistory
));
405 p
->panel
= WMCreateInputPanel(scr
->wmscreen
, NULL
, title
, message
, *text
, _("OK"), _("Cancel"));
406 p
->history
= LoadHistory(filename
, wPreferences
.history_lines
);
413 WMCreateEventHandler(WMWidgetView(p
->panel
->text
), KeyPressMask
, handleHistoryKeyPress
, p
);
415 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 320, 160, 0, 0, 0);
416 XSelectInput(dpy
, parent
, KeyPressMask
| KeyReleaseMask
);
418 XReparentWindow(dpy
, WMWidgetXID(p
->panel
->win
), parent
, 0, 0);
420 center
= getCenter(scr
, 320, 160);
421 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
, 320, 160);
423 wwin
->client_leader
= WMWidgetXID(p
->panel
->win
);
425 WMMapWidget(p
->panel
->win
);
429 WMRunModalLoop(WMWidgetScreen(p
->panel
->win
), WMWidgetView(p
->panel
->win
));
431 if (p
->panel
->result
== WAPRDefault
) {
432 result
= WMGetTextFieldText(p
->panel
->text
);
433 wfree(WMReplaceInArray(p
->history
, 0, wstrdup(result
)));
434 SaveHistory(p
->history
, filename
);
438 wUnmanageWindow(wwin
, False
, False
);
440 WMDestroyInputPanel(p
->panel
);
441 WMFreeArray(p
->history
);
445 XDestroyWindow(dpy
, parent
);
458 int wInputDialog(WScreen
* scr
, char *title
, char *message
, char **text
)
466 panel
= WMCreateInputPanel(scr
->wmscreen
, NULL
, title
, message
, *text
, _("OK"), _("Cancel"));
468 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 320, 160, 0, 0, 0);
469 XSelectInput(dpy
, parent
, KeyPressMask
| KeyReleaseMask
);
471 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
473 center
= getCenter(scr
, 320, 160);
474 wwin
= wManageInternalWindow(scr
, parent
, None
, NULL
, center
.x
, center
.y
, 320, 160);
476 wwin
->client_leader
= WMWidgetXID(panel
->win
);
478 WMMapWidget(panel
->win
);
482 WMRunModalLoop(WMWidgetScreen(panel
->win
), WMWidgetView(panel
->win
));
484 if (panel
->result
== WAPRDefault
)
485 result
= WMGetTextFieldText(panel
->text
);
489 wUnmanageWindow(wwin
, False
, False
);
491 WMDestroyInputPanel(panel
);
493 XDestroyWindow(dpy
, parent
);
507 *****************************************************************
508 * Icon Selection Panel
509 *****************************************************************
512 typedef struct IconPanel
{
525 WMButton
*previewButton
;
530 WMTextField
*fileField
;
533 WMButton
*cancelButton
;
535 WMButton
*chooseButton
;
542 static void listPixmaps(WScreen
* scr
, WMList
* lPtr
, char *path
)
544 struct dirent
*dentry
;
546 char pbuf
[PATH_MAX
+ 16];
548 IconPanel
*panel
= WMGetHangedData(lPtr
);
550 panel
->preview
= False
;
552 apath
= wexpandpath(path
);
553 dir
= opendir(apath
);
558 tmp
= _("Could not open directory ");
559 msg
= wmalloc(strlen(tmp
) + strlen(path
) + 6);
563 wMessageDialog(scr
, _("Error"), msg
, _("OK"), NULL
, NULL
);
569 /* list contents in the column */
570 while ((dentry
= readdir(dir
))) {
573 if (strcmp(dentry
->d_name
, ".") == 0 || strcmp(dentry
->d_name
, "..") == 0)
578 strcat(pbuf
, dentry
->d_name
);
580 if (stat(pbuf
, &statb
) < 0)
583 if (statb
.st_mode
& (S_IRUSR
| S_IRGRP
| S_IROTH
)
584 && statb
.st_mode
& (S_IFREG
| S_IFLNK
)) {
585 WMAddListItem(lPtr
, dentry
->d_name
);
588 WMSortListItems(lPtr
);
592 panel
->preview
= True
;
595 static void setViewedImage(IconPanel
* panel
, char *file
)
604 pixmap
= WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel
->win
), file
, &color
);
606 WMSetButtonEnabled(panel
->okButton
, False
);
608 WMSetLabelText(panel
->iconView
, _("Could not load image file "));
610 WMSetLabelImage(panel
->iconView
, NULL
);
612 WMSetButtonEnabled(panel
->okButton
, True
);
614 WMSetLabelText(panel
->iconView
, NULL
);
615 WMSetLabelImage(panel
->iconView
, pixmap
);
616 WMReleasePixmap(pixmap
);
620 static void listCallback(void *self
, void *data
)
622 WMList
*lPtr
= (WMList
*) self
;
623 IconPanel
*panel
= (IconPanel
*) data
;
626 if (lPtr
== panel
->dirList
) {
627 WMListItem
*item
= WMGetListSelectedItem(lPtr
);
633 WMSetTextFieldText(panel
->fileField
, path
);
635 WMSetLabelImage(panel
->iconView
, NULL
);
637 WMSetButtonEnabled(panel
->okButton
, False
);
639 WMClearList(panel
->iconList
);
640 listPixmaps(panel
->scr
, panel
->iconList
, path
);
642 char *tmp
, *iconFile
;
643 WMListItem
*item
= WMGetListSelectedItem(panel
->dirList
);
648 tmp
= wexpandpath(path
);
650 item
= WMGetListSelectedItem(panel
->iconList
);
653 iconFile
= item
->text
;
655 path
= wmalloc(strlen(tmp
) + strlen(iconFile
) + 4);
658 strcat(path
, iconFile
);
660 WMSetTextFieldText(panel
->fileField
, path
);
661 setViewedImage(panel
, path
);
666 static void listIconPaths(WMList
* lPtr
)
671 paths
= wstrdup(wPreferences
.icon_path
);
673 path
= strtok(paths
, ":");
678 tmp
= wexpandpath(path
);
679 /* do not sort, because the order implies the order of
680 * directories searched */
681 if (access(tmp
, X_OK
) == 0)
682 WMAddListItem(lPtr
, path
);
684 } while ((path
= strtok(NULL
, ":")) != NULL
);
689 static void drawIconProc(WMList
* lPtr
, int index
, Drawable d
, char *text
, int state
, WMRect
* rect
)
691 IconPanel
*panel
= WMGetHangedData(lPtr
);
692 WScreen
*scr
= panel
->scr
;
693 GC gc
= scr
->draw_gc
;
694 GC copygc
= scr
->copy_gc
;
695 char *file
, *dirfile
;
699 WMScreen
*wmscr
= WMWidgetScreen(panel
->win
);
701 int x
, y
, width
, height
, len
;
708 width
= rect
->size
.width
;
709 height
= rect
->size
.height
;
711 back
= (state
& WLDSSelected
) ? scr
->white
: scr
->gray
;
713 dirfile
= wexpandpath(WMGetListSelectedItem(panel
->dirList
)->text
);
714 len
= strlen(dirfile
) + strlen(text
) + 4;
716 snprintf(file
, len
, "%s/%s", dirfile
, text
);
719 color
.red
= WMRedComponentOfColor(back
) >> 8;
720 color
.green
= WMGreenComponentOfColor(back
) >> 8;
721 color
.blue
= WMBlueComponentOfColor(back
) >> 8;
722 color
.alpha
= WMGetColorAlpha(back
) >> 8;
724 pixmap
= WMCreateBlendedPixmapFromFile(wmscr
, file
, &color
);
728 /*WMRemoveListItem(lPtr, index); */
732 XFillRectangle(dpy
, d
, WMColorGC(back
), x
, y
, width
, height
);
734 XSetClipMask(dpy
, gc
, None
);
735 /*XDrawRectangle(dpy, d, WMColorGC(white), x+5, y+5, width-10, 54); */
736 XDrawLine(dpy
, d
, WMColorGC(scr
->white
), x
, y
+ height
- 1, x
+ width
, y
+ height
- 1);
738 size
= WMGetPixmapSize(pixmap
);
740 XSetClipMask(dpy
, copygc
, WMGetPixmapMaskXID(pixmap
));
741 XSetClipOrigin(dpy
, copygc
, x
+ (width
- size
.width
) / 2, y
+ 2);
742 XCopyArea(dpy
, WMGetPixmapXID(pixmap
), d
, copygc
, 0, 0,
743 size
.width
> 100 ? 100 : size
.width
, size
.height
> 64 ? 64 : size
.height
,
744 x
+ (width
- size
.width
) / 2, y
+ 2);
748 int fheight
= WMFontHeight(panel
->normalfont
);
749 int tlen
= strlen(text
);
750 int twidth
= WMWidthOfString(panel
->normalfont
, text
, tlen
);
753 ofx
= x
+ (width
- twidth
) / 2;
754 ofy
= y
+ 64 - fheight
;
756 for (i
= -1; i
< 2; i
++)
757 for (j
= -1; j
< 2; j
++)
758 WMDrawString(wmscr
, d
, scr
->white
, panel
->normalfont
,
759 ofx
+ i
, ofy
+ j
, text
, tlen
);
761 WMDrawString(wmscr
, d
, scr
->black
, panel
->normalfont
, ofx
, ofy
, text
, tlen
);
764 WMReleasePixmap(pixmap
);
765 /* I hope it is better to do not use cache / on my box it is fast nuff */
769 static void buttonCallback(void *self
, void *clientData
)
771 WMButton
*bPtr
= (WMButton
*) self
;
772 IconPanel
*panel
= (IconPanel
*) clientData
;
774 if (bPtr
== panel
->okButton
) {
776 panel
->result
= True
;
777 } else if (bPtr
== panel
->cancelButton
) {
779 panel
->result
= False
;
780 } else if (bPtr
== panel
->previewButton
) {
781 /**** Previewer ****/
782 WMSetButtonEnabled(bPtr
, False
);
783 WMSetListUserDrawItemHeight(panel
->iconList
, 68);
784 WMSetListUserDrawProc(panel
->iconList
, drawIconProc
);
785 WMRedisplayWidget(panel
->iconList
);
786 /* for draw proc to access screen/gc */
787 /*** end preview ***/
790 else if (bPtr
== panel
->chooseButton
) {
793 op
= WMCreateOpenPanel(WMWidgetScreen(bPtr
));
795 if (WMRunModalFilePanelForDirectory(op
, NULL
, "/usr/local", NULL
, NULL
)) {
797 path
= WMGetFilePanelFile(op
);
798 WMSetTextFieldText(panel
->fileField
, path
);
799 setViewedImage(panel
, path
);
802 WMDestroyFilePanel(op
);
807 static void keyPressHandler(XEvent
* event
, void *data
)
809 IconPanel
*panel
= (IconPanel
*) data
;
818 if (event
->type
== KeyRelease
)
822 count
= XLookupString(&event
->xkey
, buffer
, sizeof(buffer
), &ksym
, NULL
);
824 iidx
= WMGetListSelectedItemRow(panel
->iconList
);
825 didx
= WMGetListSelectedItemRow(panel
->dirList
);
833 list
= panel
->iconList
;
836 if (iidx
< WMGetListNumberOfRows(panel
->iconList
) - 1)
840 list
= panel
->iconList
;
844 list
= panel
->iconList
;
847 item
= WMGetListNumberOfRows(panel
->iconList
) - 1;
848 list
= panel
->iconList
;
851 if (didx
< WMGetListNumberOfRows(panel
->dirList
) - 1)
855 list
= panel
->dirList
;
862 list
= panel
->dirList
;
865 WMPerformButtonClick(panel
->okButton
);
868 WMPerformButtonClick(panel
->cancelButton
);
873 WMSelectListItem(list
, item
);
874 WMSetListPosition(list
, item
- 5);
875 listCallback(list
, panel
);
879 Bool
wIconChooserDialog(WScreen
* scr
, char **file
, char *instance
, char *class)
888 panel
= wmalloc(sizeof(IconPanel
));
889 memset(panel
, 0, sizeof(IconPanel
));
893 panel
->win
= WMCreateWindow(scr
->wmscreen
, "iconChooser");
894 WMResizeWidget(panel
->win
, 450, 280);
896 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
| KeyReleaseMask
, keyPressHandler
, panel
);
898 boldFont
= WMBoldSystemFontOfSize(scr
->wmscreen
, 12);
899 panel
->normalfont
= WMSystemFontOfSize(WMWidgetScreen(panel
->win
), 12);
901 panel
->dirLabel
= WMCreateLabel(panel
->win
);
902 WMResizeWidget(panel
->dirLabel
, 200, 20);
903 WMMoveWidget(panel
->dirLabel
, 10, 7);
904 WMSetLabelText(panel
->dirLabel
, _("Directories"));
905 WMSetLabelFont(panel
->dirLabel
, boldFont
);
906 WMSetLabelTextAlignment(panel
->dirLabel
, WACenter
);
908 WMSetLabelRelief(panel
->dirLabel
, WRSunken
);
910 panel
->iconLabel
= WMCreateLabel(panel
->win
);
911 WMResizeWidget(panel
->iconLabel
, 140, 20);
912 WMMoveWidget(panel
->iconLabel
, 215, 7);
913 WMSetLabelText(panel
->iconLabel
, _("Icons"));
914 WMSetLabelFont(panel
->iconLabel
, boldFont
);
915 WMSetLabelTextAlignment(panel
->iconLabel
, WACenter
);
917 WMReleaseFont(boldFont
);
919 color
= WMWhiteColor(scr
->wmscreen
);
920 WMSetLabelTextColor(panel
->dirLabel
, color
);
921 WMSetLabelTextColor(panel
->iconLabel
, color
);
922 WMReleaseColor(color
);
924 color
= WMDarkGrayColor(scr
->wmscreen
);
925 WMSetWidgetBackgroundColor(panel
->iconLabel
, color
);
926 WMSetWidgetBackgroundColor(panel
->dirLabel
, color
);
927 WMReleaseColor(color
);
929 WMSetLabelRelief(panel
->iconLabel
, WRSunken
);
931 panel
->dirList
= WMCreateList(panel
->win
);
932 WMResizeWidget(panel
->dirList
, 200, 170);
933 WMMoveWidget(panel
->dirList
, 10, 30);
934 WMSetListAction(panel
->dirList
, listCallback
, panel
);
936 panel
->iconList
= WMCreateList(panel
->win
);
937 WMResizeWidget(panel
->iconList
, 140, 170);
938 WMMoveWidget(panel
->iconList
, 215, 30);
939 WMSetListAction(panel
->iconList
, listCallback
, panel
);
941 WMHangData(panel
->iconList
, panel
);
943 panel
->previewButton
= WMCreateCommandButton(panel
->win
);
944 WMResizeWidget(panel
->previewButton
, 75, 26);
945 WMMoveWidget(panel
->previewButton
, 365, 130);
946 WMSetButtonText(panel
->previewButton
, _("Preview"));
947 WMSetButtonAction(panel
->previewButton
, buttonCallback
, panel
);
949 panel
->iconView
= WMCreateLabel(panel
->win
);
950 WMResizeWidget(panel
->iconView
, 75, 75);
951 WMMoveWidget(panel
->iconView
, 365, 40);
952 WMSetLabelImagePosition(panel
->iconView
, WIPOverlaps
);
953 WMSetLabelRelief(panel
->iconView
, WRSunken
);
954 WMSetLabelTextAlignment(panel
->iconView
, WACenter
);
956 panel
->fileLabel
= WMCreateLabel(panel
->win
);
957 WMResizeWidget(panel
->fileLabel
, 80, 20);
958 WMMoveWidget(panel
->fileLabel
, 10, 210);
959 WMSetLabelText(panel
->fileLabel
, _("File Name:"));
961 panel
->fileField
= WMCreateTextField(panel
->win
);
962 WMSetViewNextResponder(WMWidgetView(panel
->fileField
), WMWidgetView(panel
->win
));
963 WMResizeWidget(panel
->fileField
, 345, 20);
964 WMMoveWidget(panel
->fileField
, 95, 210);
965 WMSetTextFieldEditable(panel
->fileField
, False
);
967 panel
->okButton
= WMCreateCommandButton(panel
->win
);
968 WMResizeWidget(panel
->okButton
, 80, 26);
969 WMMoveWidget(panel
->okButton
, 360, 240);
970 WMSetButtonText(panel
->okButton
, _("OK"));
971 WMSetButtonEnabled(panel
->okButton
, False
);
972 WMSetButtonAction(panel
->okButton
, buttonCallback
, panel
);
974 panel
->cancelButton
= WMCreateCommandButton(panel
->win
);
975 WMResizeWidget(panel
->cancelButton
, 80, 26);
976 WMMoveWidget(panel
->cancelButton
, 270, 240);
977 WMSetButtonText(panel
->cancelButton
, _("Cancel"));
978 WMSetButtonAction(panel
->cancelButton
, buttonCallback
, panel
);
980 panel
->chooseButton
= WMCreateCommandButton(panel
->win
);
981 WMResizeWidget(panel
->chooseButton
, 110, 26);
982 WMMoveWidget(panel
->chooseButton
, 150, 240);
983 WMSetButtonText(panel
->chooseButton
, _("Choose File"));
984 WMSetButtonAction(panel
->chooseButton
, buttonCallback
, panel
);
986 WMRealizeWidget(panel
->win
);
987 WMMapSubwidgets(panel
->win
);
989 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 450, 280, 0, 0, 0);
991 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
995 int len
= (instance
? strlen(instance
) : 0)
996 + (class ? strlen(class) : 0) + 32;
1001 if (tmp
&& (instance
|| class))
1002 snprintf(tmp
, len
, "%s [%s.%s]", _("Icon Chooser"), instance
, class);
1004 strcpy(tmp
, _("Icon Chooser"));
1006 center
= getCenter(scr
, 450, 280);
1008 wwin
= wManageInternalWindow(scr
, parent
, None
, tmp
, center
.x
, center
.y
, 450, 280);
1012 /* put icon paths in the list */
1013 listIconPaths(panel
->dirList
);
1015 WMMapWidget(panel
->win
);
1019 while (!panel
->done
) {
1022 WMNextEvent(dpy
, &event
);
1023 WMHandleEvent(&event
);
1026 if (panel
->result
) {
1027 char *defaultPath
, *wantedPath
;
1029 /* check if the file the user selected is not the one that
1030 * would be loaded by default with the current search path */
1031 *file
= WMGetListSelectedItem(panel
->iconList
)->text
;
1036 defaultPath
= FindImage(wPreferences
.icon_path
, *file
);
1037 wantedPath
= WMGetTextFieldText(panel
->fileField
);
1038 /* if the file is not the default, use full path */
1039 if (strcmp(wantedPath
, defaultPath
) != 0) {
1042 *file
= wstrdup(*file
);
1051 result
= panel
->result
;
1053 WMReleaseFont(panel
->normalfont
);
1055 WMUnmapWidget(panel
->win
);
1057 WMDestroyWidget(panel
->win
);
1059 wUnmanageWindow(wwin
, False
, False
);
1063 XDestroyWindow(dpy
, parent
);
1069 ***********************************************************************
1071 ***********************************************************************
1087 #define COPYRIGHT_TEXT \
1088 "Copyright \xc2\xa9 1997-2006 Alfredo K. Kojima\n"\
1089 "Copyright \xc2\xa9 1998-2006 Dan Pascu"
1091 static InfoPanel
*thePanel
= NULL
;
1093 static void destroyInfoPanel(WCoreWindow
*foo
, void *data
, XEvent
*event
)
1095 WMUnmapWidget(thePanel
);
1096 wUnmanageWindow(thePanel
->wwin
, False
, False
);
1097 WMDestroyWidget(thePanel
->win
);
1102 void wShowInfoPanel(WScreen
* scr
)
1108 char *strbuf
= NULL
;
1114 int i
, width
= 50, sepHeight
;
1125 if (thePanel
->scr
== scr
) {
1126 wRaiseFrame(thePanel
->wwin
->frame
->core
);
1127 wSetFocusTo(scr
, thePanel
->wwin
);
1132 panel
= wmalloc(sizeof(InfoPanel
));
1133 memset(panel
, 0, sizeof(InfoPanel
));
1137 panel
->win
= WMCreateWindow(scr
->wmscreen
, "info");
1138 WMResizeWidget(panel
->win
, 390, 230);
1140 logo
= WMCreateApplicationIconBlendedPixmap(scr
->wmscreen
, (RColor
*) NULL
);
1142 logo
= WMRetainPixmap(WMGetApplicationIconPixmap(scr
->wmscreen
));
1145 size
= WMGetPixmapSize(logo
);
1146 panel
->logoL
= WMCreateLabel(panel
->win
);
1147 WMResizeWidget(panel
->logoL
, 64, 64);
1148 WMMoveWidget(panel
->logoL
, 30, 20);
1149 WMSetLabelImagePosition(panel
->logoL
, WIPImageOnly
);
1150 WMSetLabelImage(panel
->logoL
, logo
);
1151 WMReleasePixmap(logo
);
1155 panel
->name1L
= WMCreateLabel(panel
->win
);
1156 WMResizeWidget(panel
->name1L
, 240, 30 + 2);
1157 WMMoveWidget(panel
->name1L
, 100, 30 - 2 - sepHeight
);
1159 name
= "Lucida Sans,Comic Sans MS,URW Gothic L,Trebuchet MS" ":italic:pixelsize=28:antialias=true";
1160 font
= WMCreateFont(scr
->wmscreen
, name
);
1161 strbuf
= "Window Maker";
1163 width
= WMWidthOfString(font
, strbuf
, strlen(strbuf
));
1164 WMSetLabelFont(panel
->name1L
, font
);
1165 WMReleaseFont(font
);
1167 WMSetLabelTextAlignment(panel
->name1L
, WACenter
);
1168 WMSetLabelText(panel
->name1L
, strbuf
);
1170 panel
->lineF
= WMCreateFrame(panel
->win
);
1171 WMResizeWidget(panel
->lineF
, width
, sepHeight
);
1172 WMMoveWidget(panel
->lineF
, 100 + (240 - width
) / 2, 60 - sepHeight
);
1173 WMSetFrameRelief(panel
->lineF
, WRSimple
);
1174 WMSetWidgetBackgroundColor(panel
->lineF
, scr
->black
);
1176 panel
->name2L
= WMCreateLabel(panel
->win
);
1177 WMResizeWidget(panel
->name2L
, 240, 24);
1178 WMMoveWidget(panel
->name2L
, 100, 60);
1179 name
= "URW Gothic L,Nimbus Sans L:pixelsize=16:antialias=true";
1180 font
= WMCreateFont(scr
->wmscreen
, name
);
1182 WMSetLabelFont(panel
->name2L
, font
);
1183 WMReleaseFont(font
);
1186 WMSetLabelTextAlignment(panel
->name2L
, WACenter
);
1187 WMSetLabelText(panel
->name2L
, _("Window Manager for X"));
1189 snprintf(buffer
, sizeof(buffer
), _("Version %s"), VERSION
);
1190 panel
->versionL
= WMCreateLabel(panel
->win
);
1191 WMResizeWidget(panel
->versionL
, 310, 16);
1192 WMMoveWidget(panel
->versionL
, 30, 95);
1193 WMSetLabelTextAlignment(panel
->versionL
, WARight
);
1194 WMSetLabelText(panel
->versionL
, buffer
);
1195 WMSetLabelWraps(panel
->versionL
, False
);
1197 panel
->copyrL
= WMCreateLabel(panel
->win
);
1198 WMResizeWidget(panel
->copyrL
, 360, 40);
1199 WMMoveWidget(panel
->copyrL
, 15, 185);
1200 WMSetLabelTextAlignment(panel
->copyrL
, WALeft
);
1201 WMSetLabelText(panel
->copyrL
, COPYRIGHT_TEXT
);
1202 font
= WMSystemFontOfSize(scr
->wmscreen
, 11);
1204 WMSetLabelFont(panel
->copyrL
, font
);
1205 WMReleaseFont(font
);
1210 snprintf(buffer
, sizeof(buffer
), _("Using visual 0x%x: %s %ibpp "),
1211 (unsigned)scr
->w_visual
->visualid
, visuals
[scr
->w_visual
->class], scr
->w_depth
);
1213 strbuf
= wstrappend(strbuf
, buffer
);
1215 switch (scr
->w_depth
) {
1217 strbuf
= wstrappend(strbuf
, _("(32 thousand colors)\n"));
1220 strbuf
= wstrappend(strbuf
, _("(64 thousand colors)\n"));
1224 strbuf
= wstrappend(strbuf
, _("(16 million colors)\n"));
1227 snprintf(buffer
, sizeof(buffer
), _("(%d colors)\n"), 1 << scr
->w_depth
);
1228 strbuf
= wstrappend(strbuf
, buffer
);
1232 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
1234 struct mallinfo ma
= mallinfo();
1235 snprintf(buffer
, sizeof(buffer
),
1236 _("Total allocated memory: %i kB. Total memory in use: %i kB.\n"),
1237 (ma
.arena
+ ma
.hblkhd
) / 1024, (ma
.uordblks
+ ma
.hblkhd
) / 1024);
1239 strbuf
= wstrappend(strbuf
, buffer
);
1243 strbuf
= wstrappend(strbuf
, _("Supported image formats: "));
1244 strl
= RSupportedFileFormats();
1245 for (i
= 0; strl
[i
] != NULL
; i
++) {
1246 strbuf
= wstrappend(strbuf
, strl
[i
]);
1247 strbuf
= wstrappend(strbuf
, " ");
1250 strbuf
= wstrappend(strbuf
, _("\nAdditional support for: "));
1256 list
[j
++] = "WMSPEC";
1262 for (i
= 0; i
< j
; i
++) {
1265 strcat(buf
, _(" and "));
1269 strcat(buf
, list
[i
]);
1271 strbuf
= wstrappend(strbuf
, buf
);
1275 strbuf
= wstrappend(strbuf
, _("\n"));
1276 #ifdef SOLARIS_XINERAMA
1277 strbuf
= wstrappend(strbuf
, _("Solaris "));
1279 strbuf
= wstrappend(strbuf
, _("Xinerama: "));
1282 snprintf(tmp
, sizeof(tmp
) - 1, "%d heads found.", scr
->xine_info
.count
);
1283 strbuf
= wstrappend(strbuf
, tmp
);
1287 panel
->infoL
= WMCreateLabel(panel
->win
);
1288 WMResizeWidget(panel
->infoL
, 350, 75);
1289 WMMoveWidget(panel
->infoL
, 15, 115);
1290 WMSetLabelText(panel
->infoL
, strbuf
);
1291 font
= WMSystemFontOfSize(scr
->wmscreen
, 11);
1293 WMSetLabelFont(panel
->infoL
, font
);
1294 WMReleaseFont(font
);
1299 WMRealizeWidget(panel
->win
);
1300 WMMapSubwidgets(panel
->win
);
1302 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 382, 230, 0, 0, 0);
1304 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1306 WMMapWidget(panel
->win
);
1309 WMPoint center
= getCenter(scr
, 382, 230);
1311 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Info"), center
.x
, center
.y
, 382, 230);
1314 WSETUFLAG(wwin
, no_closable
, 0);
1315 WSETUFLAG(wwin
, no_close_button
, 0);
1316 #ifdef XKB_BUTTON_HINT
1317 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1319 wWindowUpdateButtonImages(wwin
);
1320 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1321 wwin
->frame
->on_click_right
= destroyInfoPanel
;
1330 ***********************************************************************
1332 ***********************************************************************
1345 static LegalPanel
*legalPanel
= NULL
;
1347 static void destroyLegalPanel(WCoreWindow
* foo
, void *data
, XEvent
* event
)
1349 WMUnmapWidget(legalPanel
->win
);
1351 WMDestroyWidget(legalPanel
->win
);
1353 wUnmanageWindow(legalPanel
->wwin
, False
, False
);
1360 void wShowLegalPanel(WScreen
* scr
)
1367 if (legalPanel
->scr
== scr
) {
1368 wRaiseFrame(legalPanel
->wwin
->frame
->core
);
1369 wSetFocusTo(scr
, legalPanel
->wwin
);
1374 panel
= wmalloc(sizeof(LegalPanel
));
1378 panel
->win
= WMCreateWindow(scr
->wmscreen
, "legal");
1379 WMResizeWidget(panel
->win
, 420, 250);
1381 panel
->licenseL
= WMCreateLabel(panel
->win
);
1382 WMSetLabelWraps(panel
->licenseL
, True
);
1383 WMResizeWidget(panel
->licenseL
, 400, 230);
1384 WMMoveWidget(panel
->licenseL
, 10, 10);
1385 WMSetLabelTextAlignment(panel
->licenseL
, WALeft
);
1386 WMSetLabelText(panel
->licenseL
,
1387 _(" Window Maker is free software; you can redistribute it and/or\n"
1388 "modify it under the terms of the GNU General Public License as\n"
1389 "published by the Free Software Foundation; either version 2 of the\n"
1390 "License, or (at your option) any later version.\n\n"
1391 " Window Maker is distributed in the hope that it will be useful,\n"
1392 "but WITHOUT ANY WARRANTY; without even the implied warranty\n"
1393 "of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
1394 "See the GNU General Public License for more details.\n\n"
1395 " You should have received a copy of the GNU General Public\n"
1396 "License along with this program; if not, write to the Free Software\n"
1397 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\n"
1398 "02110-1301 USA."));
1399 WMSetLabelRelief(panel
->licenseL
, WRGroove
);
1401 WMRealizeWidget(panel
->win
);
1402 WMMapSubwidgets(panel
->win
);
1404 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 420, 250, 0, 0, 0);
1406 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1409 WMPoint center
= getCenter(scr
, 420, 250);
1411 wwin
= wManageInternalWindow(scr
, parent
, None
, _("Legal"), center
.x
, center
.y
, 420, 250);
1414 WSETUFLAG(wwin
, no_closable
, 0);
1415 WSETUFLAG(wwin
, no_close_button
, 0);
1416 wWindowUpdateButtonImages(wwin
);
1417 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1418 #ifdef XKB_BUTTON_HINT
1419 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1421 wwin
->frame
->on_click_right
= destroyLegalPanel
;
1425 WMMapWidget(panel
->win
);
1433 ***********************************************************************
1434 * Crashing Dialog Panel
1435 ***********************************************************************
1438 extern WDDomain
*WDWindowAttributes
;
1440 typedef struct _CrashPanel
{
1441 WMWindow
*win
; /* main window */
1443 WMLabel
*iconL
; /* application icon */
1444 WMLabel
*nameL
; /* title of panel */
1446 WMFrame
*sepF
; /* separator frame */
1448 WMLabel
*noteL
; /* Title of note */
1449 WMLabel
*note2L
; /* body of note with what happened */
1451 WMFrame
*whatF
; /* "what to do next" frame */
1452 WMPopUpButton
*whatP
; /* action selection popup button */
1454 WMButton
*okB
; /* ok button */
1456 Bool done
; /* if finished with this dialog */
1457 int action
; /* what to do after */
1463 static void handleKeyPress(XEvent
* event
, void *clientData
)
1465 CrashPanel
*panel
= (CrashPanel
*) clientData
;
1467 if (event
->xkey
.keycode
== panel
->retKey
) {
1468 WMPerformButtonClick(panel
->okB
);
1472 static void okButtonCallback(void *self
, void *clientData
)
1474 CrashPanel
*panel
= (CrashPanel
*) clientData
;
1479 static void setCrashAction(void *self
, void *clientData
)
1481 WMPopUpButton
*pop
= (WMPopUpButton
*) self
;
1482 CrashPanel
*panel
= (CrashPanel
*) clientData
;
1484 panel
->action
= WMGetPopUpButtonSelectedItem(pop
);
1487 /* Make this read the logo from a compiled in pixmap -Dan */
1488 static WMPixmap
*getWindowMakerIconImage(WMScreen
* scr
)
1490 WMPropList
*dict
, *key
, *option
, *value
= NULL
;
1491 WMPixmap
*pix
= NULL
;
1494 if (!WDWindowAttributes
|| !WDWindowAttributes
->dictionary
)
1497 WMPLSetCaseSensitive(True
);
1499 key
= WMCreatePLString("Logo.WMPanel");
1500 option
= WMCreatePLString("Icon");
1502 dict
= WMGetFromPLDictionary(WDWindowAttributes
->dictionary
, key
);
1505 value
= WMGetFromPLDictionary(dict
, option
);
1508 WMReleasePropList(key
);
1509 WMReleasePropList(option
);
1511 WMPLSetCaseSensitive(False
);
1513 if (value
&& WMIsPLString(value
)) {
1514 path
= FindImage(wPreferences
.icon_path
, WMGetFromPLString(value
));
1524 pix
= WMCreateBlendedPixmapFromFile(scr
, path
, &gray
);
1535 int wShowCrashingDialogPanel(int whatSig
)
1541 int screen_no
, scr_width
, scr_height
;
1545 panel
= wmalloc(sizeof(CrashPanel
));
1546 memset(panel
, 0, sizeof(CrashPanel
));
1548 screen_no
= DefaultScreen(dpy
);
1549 scr_width
= WidthOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1550 scr_height
= HeightOfScreen(ScreenOfDisplay(dpy
, screen_no
));
1552 scr
= WMCreateScreen(dpy
, screen_no
);
1554 werror(_("cannot open connection for crashing dialog panel. Aborting."));
1558 panel
->retKey
= XKeysymToKeycode(dpy
, XK_Return
);
1560 panel
->win
= WMCreateWindow(scr
, "crashingDialog");
1561 WMResizeWidget(panel
->win
, PWIDTH
, PHEIGHT
);
1562 WMMoveWidget(panel
->win
, (scr_width
- PWIDTH
) / 2, (scr_height
- PHEIGHT
) / 2);
1564 logo
= getWindowMakerIconImage(scr
);
1566 panel
->iconL
= WMCreateLabel(panel
->win
);
1567 WMResizeWidget(panel
->iconL
, 64, 64);
1568 WMMoveWidget(panel
->iconL
, 10, 10);
1569 WMSetLabelImagePosition(panel
->iconL
, WIPImageOnly
);
1570 WMSetLabelImage(panel
->iconL
, logo
);
1573 panel
->nameL
= WMCreateLabel(panel
->win
);
1574 WMResizeWidget(panel
->nameL
, 200, 30);
1575 WMMoveWidget(panel
->nameL
, 80, 25);
1576 WMSetLabelTextAlignment(panel
->nameL
, WALeft
);
1577 font
= WMBoldSystemFontOfSize(scr
, 24);
1578 WMSetLabelFont(panel
->nameL
, font
);
1579 WMReleaseFont(font
);
1580 WMSetLabelText(panel
->nameL
, _("Fatal error"));
1582 panel
->sepF
= WMCreateFrame(panel
->win
);
1583 WMResizeWidget(panel
->sepF
, PWIDTH
+ 4, 2);
1584 WMMoveWidget(panel
->sepF
, -2, 80);
1586 panel
->noteL
= WMCreateLabel(panel
->win
);
1587 WMResizeWidget(panel
->noteL
, PWIDTH
- 20, 40);
1588 WMMoveWidget(panel
->noteL
, 10, 90);
1589 WMSetLabelTextAlignment(panel
->noteL
, WAJustified
);
1590 snprintf(buf
, sizeof(buf
), _("Window Maker received signal %i."), whatSig
);
1591 WMSetLabelText(panel
->noteL
, buf
);
1593 panel
->note2L
= WMCreateLabel(panel
->win
);
1594 WMResizeWidget(panel
->note2L
, PWIDTH
- 20, 100);
1595 WMMoveWidget(panel
->note2L
, 10, 130);
1596 WMSetLabelTextAlignment(panel
->note2L
, WALeft
);
1597 WMSetLabelText(panel
->note2L
,
1598 _(" This fatal error occured probably due to a bug."
1599 " Please fill the included BUGFORM and " "report it to bugs@windowmaker.info."));
1600 WMSetLabelWraps(panel
->note2L
, True
);
1602 panel
->whatF
= WMCreateFrame(panel
->win
);
1603 WMResizeWidget(panel
->whatF
, PWIDTH
- 20, 50);
1604 WMMoveWidget(panel
->whatF
, 10, 240);
1605 WMSetFrameTitle(panel
->whatF
, _("What do you want to do now?"));
1607 panel
->whatP
= WMCreatePopUpButton(panel
->whatF
);
1608 WMResizeWidget(panel
->whatP
, PWIDTH
- 20 - 70, 20);
1609 WMMoveWidget(panel
->whatP
, 35, 20);
1610 WMSetPopUpButtonPullsDown(panel
->whatP
, False
);
1611 WMSetPopUpButtonText(panel
->whatP
, _("Select action"));
1612 WMAddPopUpButtonItem(panel
->whatP
, _("Abort and leave a core file"));
1613 WMAddPopUpButtonItem(panel
->whatP
, _("Restart Window Maker"));
1614 WMAddPopUpButtonItem(panel
->whatP
, _("Start alternate window manager"));
1615 WMSetPopUpButtonAction(panel
->whatP
, setCrashAction
, panel
);
1616 WMSetPopUpButtonSelectedItem(panel
->whatP
, WMRestart
);
1617 panel
->action
= WMRestart
;
1619 WMMapSubwidgets(panel
->whatF
);
1621 panel
->okB
= WMCreateCommandButton(panel
->win
);
1622 WMResizeWidget(panel
->okB
, 80, 26);
1623 WMMoveWidget(panel
->okB
, 205, 309);
1624 WMSetButtonText(panel
->okB
, _("OK"));
1625 WMSetButtonImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIReturnArrow
));
1626 WMSetButtonAltImage(panel
->okB
, WMGetSystemPixmap(scr
, WSIHighlightedReturnArrow
));
1627 WMSetButtonImagePosition(panel
->okB
, WIPRight
);
1628 WMSetButtonAction(panel
->okB
, okButtonCallback
, panel
);
1632 WMCreateEventHandler(WMWidgetView(panel
->win
), KeyPressMask
, handleKeyPress
, panel
);
1634 WMRealizeWidget(panel
->win
);
1635 WMMapSubwidgets(panel
->win
);
1637 WMMapWidget(panel
->win
);
1639 XSetInputFocus(dpy
, WMWidgetXID(panel
->win
), RevertToParent
, CurrentTime
);
1641 while (!panel
->done
) {
1644 WMNextEvent(dpy
, &event
);
1645 WMHandleEvent(&event
);
1648 action
= panel
->action
;
1650 WMUnmapWidget(panel
->win
);
1651 WMDestroyWidget(panel
->win
);
1657 /*****************************************************************************
1658 * About GNUstep Panel
1659 *****************************************************************************/
1662 drawGNUstepLogo(Display
* dpy
, Drawable d
, int width
, int height
,
1663 unsigned long blackPixel
, unsigned long whitePixel
)
1667 XRectangle rects
[3];
1669 gcv
.foreground
= blackPixel
;
1670 gc
= XCreateGC(dpy
, d
, GCForeground
, &gcv
);
1672 XFillArc(dpy
, d
, gc
, width
/ 45, height
/ 45,
1673 width
- 2 * width
/ 45, height
- 2 * height
/ 45, 0, 360 * 64);
1676 rects
[0].y
= 37 * height
/ 45;
1677 rects
[0].width
= width
/ 3;
1678 rects
[0].height
= height
- rects
[0].y
;
1680 rects
[1].x
= rects
[0].width
;
1681 rects
[1].y
= height
/ 2;
1682 rects
[1].width
= width
- 2 * width
/ 3;
1683 rects
[1].height
= height
- rects
[1].y
;
1685 rects
[2].x
= 2 * width
/ 3;
1686 rects
[2].y
= height
- 37 * height
/ 45;
1687 rects
[2].width
= width
/ 3;
1688 rects
[2].height
= height
- rects
[2].y
;
1690 XSetClipRectangles(dpy
, gc
, 0, 0, rects
, 3, Unsorted
);
1691 XFillRectangle(dpy
, d
, gc
, 0, 0, width
, height
);
1693 XSetForeground(dpy
, gc
, whitePixel
);
1694 XFillArc(dpy
, d
, gc
, width
/ 45, height
/ 45,
1695 width
- 2 * width
/ 45, height
- 2 * height
/ 45, 0, 360 * 64);
1711 static GNUstepPanel
*gnustepPanel
= NULL
;
1713 static void destroyGNUstepPanel(WCoreWindow
* foo
, void *data
, XEvent
* event
)
1715 WMUnmapWidget(gnustepPanel
->win
);
1717 WMDestroyWidget(gnustepPanel
->win
);
1719 wUnmanageWindow(gnustepPanel
->wwin
, False
, False
);
1721 wfree(gnustepPanel
);
1723 gnustepPanel
= NULL
;
1726 void wShowGNUstepPanel(WScreen
* scr
)
1728 GNUstepPanel
*panel
;
1735 if (gnustepPanel
->scr
== scr
) {
1736 wRaiseFrame(gnustepPanel
->wwin
->frame
->core
);
1737 wSetFocusTo(scr
, gnustepPanel
->wwin
);
1742 panel
= wmalloc(sizeof(GNUstepPanel
));
1746 panel
->win
= WMCreateWindow(scr
->wmscreen
, "About GNUstep");
1747 WMResizeWidget(panel
->win
, 325, 205);
1749 pixmap
= WMCreatePixmap(scr
->wmscreen
, 130, 130, WMScreenDepth(scr
->wmscreen
), True
);
1751 color
= WMCreateNamedColor(scr
->wmscreen
, "gray50", True
);
1753 drawGNUstepLogo(dpy
, WMGetPixmapXID(pixmap
), 130, 130, WMColorPixel(color
), scr
->white_pixel
);
1755 WMReleaseColor(color
);
1757 XSetForeground(dpy
, scr
->mono_gc
, 0);
1758 XFillRectangle(dpy
, WMGetPixmapMaskXID(pixmap
), scr
->mono_gc
, 0, 0, 130, 130);
1759 drawGNUstepLogo(dpy
, WMGetPixmapMaskXID(pixmap
), 130, 130, 1, 1);
1761 panel
->gstepL
= WMCreateLabel(panel
->win
);
1762 WMResizeWidget(panel
->gstepL
, 285, 64);
1763 WMMoveWidget(panel
->gstepL
, 20, 0);
1764 WMSetLabelTextAlignment(panel
->gstepL
, WARight
);
1765 WMSetLabelText(panel
->gstepL
, "GNUstep");
1767 WMFont
*font
= WMBoldSystemFontOfSize(scr
->wmscreen
, 24);
1769 WMSetLabelFont(panel
->gstepL
, font
);
1770 WMReleaseFont(font
);
1773 panel
->textL
= WMCreateLabel(panel
->win
);
1774 WMResizeWidget(panel
->textL
, 305, 140);
1775 WMMoveWidget(panel
->textL
, 10, 50);
1776 WMSetLabelTextAlignment(panel
->textL
, WARight
);
1777 WMSetLabelImagePosition(panel
->textL
, WIPOverlaps
);
1778 WMSetLabelText(panel
->textL
,
1779 _("Window Maker is part of the GNUstep project.\n"
1780 "The GNUstep project aims to create a free\n"
1781 "implementation of the OpenStep(tm) specification\n"
1782 "which is a object-oriented framework for\n"
1783 "creating advanced graphical, multi-platform\n"
1784 "applications. Additionally, a development and\n"
1785 "user desktop environment will be created on top\n"
1786 "of the framework. For more information about\n"
1787 "GNUstep, please visit: www.gnustep.org"));
1788 WMSetLabelImage(panel
->textL
, pixmap
);
1790 WMReleasePixmap(pixmap
);
1792 WMRealizeWidget(panel
->win
);
1793 WMMapSubwidgets(panel
->win
);
1795 parent
= XCreateSimpleWindow(dpy
, scr
->root_win
, 0, 0, 325, 200, 0, 0, 0);
1797 XReparentWindow(dpy
, WMWidgetXID(panel
->win
), parent
, 0, 0);
1800 WMPoint center
= getCenter(scr
, 325, 200);
1802 wwin
= wManageInternalWindow(scr
, parent
, None
, _("About GNUstep"), center
.x
, center
.y
, 325, 200);
1805 WSETUFLAG(wwin
, no_closable
, 0);
1806 WSETUFLAG(wwin
, no_close_button
, 0);
1807 wWindowUpdateButtonImages(wwin
);
1808 wFrameWindowShowButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1809 #ifdef XKB_BUTTON_HINT
1810 wFrameWindowHideButton(wwin
->frame
, WFF_LANGUAGE_BUTTON
);
1812 wwin
->frame
->on_click_right
= destroyGNUstepPanel
;
1816 WMMapWidget(panel
->win
);
1820 gnustepPanel
= panel
;