2 * xgamelist.c -- Game list window, part of X front end for XBoard
4 * Copyright 1995, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
5 * ------------------------------------------------------------------------
7 * GNU XBoard is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or (at
10 * your option) any later version.
12 * GNU XBoard is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see http://www.gnu.org/licenses/. *
20 *------------------------------------------------------------------------
21 ** See the file ChangeLog for a revision history. */
28 #include <sys/types.h>
33 #else /* not STDC_HEADERS */
34 extern char *getenv();
37 # else /* not HAVE_STRING_H */
39 # endif /* not HAVE_STRING_H */
40 #endif /* not STDC_HEADERS */
46 #include <X11/Intrinsic.h>
47 #include <X11/StringDefs.h>
48 #include <X11/Shell.h>
49 #include <X11/cursorfont.h>
51 #include <X11/Xaw3d/Dialog.h>
52 #include <X11/Xaw3d/Form.h>
53 #include <X11/Xaw3d/List.h>
54 #include <X11/Xaw3d/Label.h>
55 #include <X11/Xaw3d/SimpleMenu.h>
56 #include <X11/Xaw3d/SmeBSB.h>
57 #include <X11/Xaw3d/SmeLine.h>
58 #include <X11/Xaw3d/Box.h>
59 #include <X11/Xaw3d/MenuButton.h>
60 #include <X11/Xaw3d/Text.h>
61 #include <X11/Xaw3d/AsciiText.h>
62 #include <X11/Xaw3d/Viewport.h>
64 #include <X11/Xaw/Dialog.h>
65 #include <X11/Xaw/Form.h>
66 #include <X11/Xaw/List.h>
67 #include <X11/Xaw/Label.h>
68 #include <X11/Xaw/SimpleMenu.h>
69 #include <X11/Xaw/SmeBSB.h>
70 #include <X11/Xaw/SmeLine.h>
71 #include <X11/Xaw/Box.h>
72 #include <X11/Xaw/MenuButton.h>
73 #include <X11/Xaw/Text.h>
74 #include <X11/Xaw/AsciiText.h>
75 #include <X11/Xaw/Viewport.h>
82 #include "xgamelist.h"
86 # define _(s) gettext (s)
87 # define N_(s) gettext_noop (s)
94 void SetFocus P((Widget w, XtPointer data, XEvent *event, Boolean *b));
96 static Widget filterText;
97 static char filterString[MSG_SIZ];
98 static int listLength, wins, losses, draws, page;
100 char gameListTranslations[] =
101 "<Btn1Up>(2): LoadSelectedProc(0) \n \
102 <Key>Home: LoadSelectedProc(-2) \n \
103 <Key>End: LoadSelectedProc(2) \n \
104 Ctrl<Key>Up: LoadSelectedProc(-3) \n \
105 Ctrl<Key>Down: LoadSelectedProc(3) \n \
106 <Key>Up: LoadSelectedProc(-1) \n \
107 <Key>Down: LoadSelectedProc(1) \n \
108 <Key>Left: LoadSelectedProc(-1) \n \
109 <Key>Right: LoadSelectedProc(1) \n \
110 <Key>Return: LoadSelectedProc(0) \n";
111 char filterTranslations[] =
112 "<Key>Return: SetFilterProc() \n";
114 char *dummyList[] = { N_("no games matched your request"), NULL };
125 static GameListClosure *glc = NULL;
128 GameListCreate (char *name, XtCallbackProc callback, XtPointer client_data)
131 Widget shell, form, viewport, listwidg, layout, label;
132 Widget b_load, b_loadprev, b_loadnext, b_close, b_filter;
135 GameListClosure *glc = (GameListClosure *) client_data;
138 XtSetArg(args[j], XtNwidth, &fw_width); j++;
139 XtGetValues(formWidget, args, j);
142 XtSetArg(args[j], XtNresizable, True); j++;
143 XtSetArg(args[j], XtNallowShellResize, True); j++;
145 shell = gameListShell =
146 XtCreatePopupShell(name, topLevelShellWidgetClass,
147 shellWidget, args, j);
149 shell = gameListShell =
150 XtCreatePopupShell(name, transientShellWidgetClass,
151 shellWidget, args, j);
154 XtCreateManagedWidget(layoutName, formWidgetClass, shell,
155 layoutArgs, XtNumber(layoutArgs));
157 XtSetArg(args[j], XtNborderWidth, 0); j++;
159 XtCreateManagedWidget("form", formWidgetClass, layout, args, j);
162 XtSetArg(args[j], XtNtop, XtChainTop); j++;
163 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
164 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
165 XtSetArg(args[j], XtNright, XtChainRight); j++;
166 XtSetArg(args[j], XtNresizable, False); j++;
167 XtSetArg(args[j], XtNwidth, fw_width); j++;
168 XtSetArg(args[j], XtNallowVert, True); j++;
170 XtCreateManagedWidget("viewport", viewportWidgetClass, form, args, j);
173 // XtSetArg(args[j], XtNlist, glc->strings); j++;
174 XtSetArg(args[j], XtNdefaultColumns, 1); j++;
175 XtSetArg(args[j], XtNforceColumns, True); j++;
176 XtSetArg(args[j], XtNverticalList, True); j++;
178 XtCreateManagedWidget("list", listWidgetClass, viewport, args, j);
179 XawListHighlight(listwidg, 0);
180 XtAugmentTranslations(listwidg,
181 XtParseTranslationTable(gameListTranslations));
184 XtSetArg(args[j], XtNfromVert, viewport); j++;
185 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
186 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
187 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
188 XtSetArg(args[j], XtNright, XtChainLeft); j++;
190 XtCreateManagedWidget(_("thresholds"), commandWidgetClass, form, args, j);
191 XtAddCallback(b_load, XtNcallback, callback, client_data);
194 XtSetArg(args[j], XtNfromVert, viewport); j++;
195 XtSetArg(args[j], XtNfromHoriz, b_load); j++;
196 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
197 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
198 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
199 XtSetArg(args[j], XtNright, XtChainLeft); j++;
201 XtCreateManagedWidget(_("find position"), commandWidgetClass, form, args, j);
202 XtAddCallback(b_loadprev, XtNcallback, callback, client_data);
205 XtSetArg(args[j], XtNfromVert, viewport); j++;
206 XtSetArg(args[j], XtNfromHoriz, b_loadprev); j++;
207 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
208 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
209 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
210 XtSetArg(args[j], XtNright, XtChainLeft); j++;
212 XtCreateManagedWidget(_("next"), commandWidgetClass, form, args, j);
213 XtAddCallback(b_loadnext, XtNcallback, callback, client_data);
215 b_loadnext = b_loadprev;
218 XtSetArg(args[j], XtNfromVert, viewport); j++;
219 XtSetArg(args[j], XtNfromHoriz, b_loadnext); j++;
220 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
221 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
222 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
223 XtSetArg(args[j], XtNright, XtChainLeft); j++;
225 XtCreateManagedWidget(_("close"), commandWidgetClass, form, args, j);
226 XtAddCallback(b_close, XtNcallback, callback, client_data);
229 XtSetArg(args[j], XtNfromVert, viewport); j++;
230 XtSetArg(args[j], XtNfromHoriz, b_close); j++;
231 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
232 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
233 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
234 XtSetArg(args[j], XtNright, XtChainLeft); j++;
235 XtSetArg(args[j], XtNborderWidth, 0); j++;
237 XtCreateManagedWidget(_("Filter:"), labelWidgetClass, form, args, j);
240 XtSetArg(args[j], XtNfromVert, viewport); j++;
241 XtSetArg(args[j], XtNfromHoriz, label); j++;
242 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
243 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
244 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
245 XtSetArg(args[j], XtNright, XtChainRight); j++;
246 XtSetArg(args[j], XtNwidth, fw_width - 275 - squareSize); j++;
247 XtSetArg(args[j], XtNstring, filterString); j++;
248 XtSetArg(args[j], XtNdisplayCaret, False); j++;
249 XtSetArg(args[j], XtNresizable, True); j++;
250 // XtSetArg(args[j], XtNwidth, bw_width); j++; /*force wider than buttons*/
251 /* !!Work around an apparent bug in XFree86 4.0.1 (X11R6.4.3) */
252 XtSetArg(args[j], XtNeditType, XawtextEdit); j++;
253 XtSetArg(args[j], XtNuseStringInPlace, False); j++;
255 XtCreateManagedWidget(_("filtertext"), asciiTextWidgetClass, form, args, j);
256 XtAddEventHandler(filterText, ButtonPressMask, False, SetFocus, (XtPointer) shell);
257 XtOverrideTranslations(filterText,
258 XtParseTranslationTable(filterTranslations));
261 XtSetArg(args[j], XtNfromVert, viewport); j++;
262 XtSetArg(args[j], XtNfromHoriz, filterText); j++;
263 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
264 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
265 XtSetArg(args[j], XtNleft, XtChainRight); j++;
266 XtSetArg(args[j], XtNright, XtChainRight); j++;
268 XtCreateManagedWidget(_("apply"), commandWidgetClass, form, args, j);
269 XtAddCallback(b_filter, XtNcallback, callback, client_data);
272 if(wpGameList.width > 0) {
273 glc->x = wpGameList.x;
274 glc->y = wpGameList.y;
275 glc->w = wpGameList.width;
276 glc->h = wpGameList.height;
286 XtSetArg(args[j], XtNheight, &h1); j++;
287 XtSetArg(args[j], XtNy, &y1); j++;
288 XtGetValues(boardWidget, args, j);
289 glc->w = fw_width * 3/4;
290 glc->h = squareSize * 3;
292 XSync(xDisplay, False);
294 /* This code seems to tickle an X bug if it is executed too soon
295 after xboard starts up. The coordinates get transformed as if
296 the main window was positioned at (0, 0).
298 XtTranslateCoords(shellWidget, (fw_width - glc->w) / 2,
299 y1 + (h1 - glc->h + appData.borderYoffset) / 2,
302 XTranslateCoordinates(xDisplay, XtWindow(shellWidget),
303 RootWindowOfScreen(XtScreen(shellWidget)),
304 (fw_width - glc->w) / 2,
305 y1 + (h1 - glc->h + appData.borderYoffset) / 2,
310 if (glc->y < 0) glc->y = 0; /*avoid positioning top offscreen*/
313 XtSetArg(args[j], XtNheight, glc->h); j++;
314 XtSetArg(args[j], XtNwidth, glc->w); j++;
315 XtSetArg(args[j], XtNx, glc->x - appData.borderXoffset); j++;
316 XtSetArg(args[j], XtNy, glc->y - appData.borderYoffset); j++;
317 XtSetValues(shell, args, j);
319 XtRealizeWidget(shell);
320 CatchDeleteWindow(shell, "GameListPopDown");
321 XtSetKeyboardFocus(shell, listwidg);
326 extern int soughtCounts[];
327 extern Board soughtBoard;
330 GameListPrepare (int byPos)
331 { // [HGM] filter: put in separate routine, to make callable from call-back
338 if(st = glc->strings) while(*st) free(*st++);
339 nstrings = ((ListGame *) gameList.tailPred)->number;
340 glc->strings = (char **) malloc((nstrings + 1) * sizeof(char *));
342 lg = (ListGame *) gameList.head;
343 listLength = wins = losses = draws = 0;
344 if(byPos) InitSearch();
347 line = GameListLine(lg->number, &lg->gameInfo);
348 if((filterString[0] == NULLCHAR || SearchPattern( line, filterString )) && (!byPos || (pos=GameContainsPosition(glc->fp, lg)) >= 0) ) {
349 *st++ = line; // [HGM] filter: make adding line conditional.
351 if( lg->gameInfo.result == WhiteWins ) wins++; else
352 if( lg->gameInfo.result == BlackWins ) losses++; else
353 if( lg->gameInfo.result == GameIsDrawn ) draws++;
355 if(lg->number % 2000 == 0) {
357 snprintf(buf, MSG_SIZ, _("Scanning through games (%d)"), lg->number);
361 lg = (ListGame *) lg->node.succ;
363 GetTimeMark(&t2);printf("GameListPrepare %ld msec\n", SubtractTimeMarks(&t2,&t));
364 DisplayTitle("XBoard");
369 static char *list[1003];
373 GameListReplace (int page)
375 // filter: put in separate routine, to make callable from call-back
378 char buf[MSG_SIZ], *p, **st=list;
381 if(page) *st++ = _("previous page"); else if(listLength > 1000) *st++ = "";
382 for(i=0; i<1000; i++) if( !(*st++ = glc->strings[page+i]) ) { st--; break; }
384 if(page + 1000 <= listLength) *st++ = _("next page");
387 listwidg = XtNameToWidget(glc->shell, "*form.viewport.list");
388 XtSetArg(arg, XtNlist, listLength ? list : dummyList); // empty list displays message
389 XawListChange(listwidg, list, 0, 0, True);
390 XtSetValues(listwidg, &arg, 1);
391 XawListHighlight(listwidg, 0);
392 snprintf(buf, MSG_SIZ, _("%s - %d/%d games (%d-%d-%d)"), glc->filename, listLength, ((ListGame *) gameList.tailPred)->number, wins, losses, draws);
393 XtSetArg(arg, XtNtitle, buf);
394 XtSetValues(glc->shell, &arg, 1);
398 GameListCallback (Widget w, XtPointer client_data, XtPointer call_data)
404 GameListClosure *glc = (GameListClosure *) client_data;
405 XawListReturnStruct *rs;
409 XtSetArg(args[j], XtNlabel, &name); j++;
410 XtGetValues(w, args, j);
412 if (strcmp(name, _("close")) == 0) {
416 if (strcmp(name, _("thresholds")) == 0) {
420 listwidg = XtNameToWidget(glc->shell, "*form.viewport.list");
421 rs = XawListShowCurrent(listwidg);
422 if (strcmp(name, _("load")) == 0) {
423 index = rs->list_index;
425 DisplayError(_("No game selected"), 0);
428 } else if (strcmp(name, _("next")) == 0) {
429 index = rs->list_index + 1;
430 if (index >= listLength || !list[index]) {
431 DisplayError(_("Can't go forward any further"), 0);
434 XawListHighlight(listwidg, index);
435 } else if (strcmp(name, _("prev")) == 0) {
436 index = rs->list_index - 1;
438 DisplayError(_("Can't back up any further"), 0);
441 XawListHighlight(listwidg, index);
442 } else if (strcmp(name, _("apply")) == 0 ||
443 strcmp(name, _("find position")) == 0) {
446 XtSetArg(args[j], XtNstring, &text); j++;
447 XtGetValues(filterText, args, j);
448 safeStrCpy(filterString, text, sizeof(filterString)/sizeof(filterString[0]));
449 XawListHighlight(listwidg, 0);
450 GameListPrepare(strcmp(name, _("find position")) == 0); GameListReplace(0);
454 index = atoi(list[index])-1; // [HGM] filter: read true index from sequence nr of line
455 if (cmailMsgLoaded) {
456 CmailLoadGame(glc->fp, index + 1, glc->filename, True);
458 LoadGame(glc->fp, index + 1, glc->filename, True);
461 printf("This code should have been unreachable. Please report bug!\n");
466 GameListPopUp (FILE *fp, char *filename)
473 glc = (GameListClosure *) calloc(1, sizeof(GameListClosure));
474 glc->x = glc->y = -1;
475 glc->filename = NULL;
479 GameListPrepare(False); // [HGM] filter: code put in separate routine
483 if (glc->filename != NULL) free(glc->filename);
484 glc->filename = StrSave(filename);
486 if (glc->shell == NULL) {
487 glc->shell = GameListCreate(filename, GameListCallback, glc);
490 XtSetArg(args[j], XtNiconName, (XtArgVal) filename); j++;
491 // XtSetArg(args[j], XtNtitle, (XtArgVal) filename); j++;
492 XtSetValues(glc->shell, args, j);
495 GameListReplace(0); // [HGM] filter: code put in separate routine, and also called to set title
497 XtPopup(glc->shell, XtGrabNone);
500 XtSetArg(args[j], XtNleftBitmap, xMarkPixmap); j++;
501 XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Game List"),
508 if (glc == NULL) return;
510 if (glc->strings != NULL) {
523 ShowGameListProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
529 DisplayError(_("There is no game list"), 0);
536 XtPopup(glc->shell, XtGrabNone);
539 XtSetArg(args[j], XtNleftBitmap, xMarkPixmap); j++;
540 XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Game List"),
542 GameListHighlight(lastLoadGameNumber);
546 LoadSelectedProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
549 XawListReturnStruct *rs;
550 int index, direction = atoi(prms[0]);
552 if (glc == NULL || listLength == 0) return;
553 listwidg = XtNameToWidget(glc->shell, "*form.viewport.list");
554 rs = XawListShowCurrent(listwidg);
555 index = rs->list_index;
556 if (index < 0) return;
557 if(page && index == 0) {
559 if(page < 0) page = 0; // safety
560 GameListReplace(page);
565 GameListReplace(page);
570 int doLoad = abs(direction) > 2;
571 if(doLoad) direction /= 3;
573 if(direction == -2) index = 0;
574 if(direction == 2) index = listEnd-1;
575 if(index < 0 || index >= listEnd) return;
576 XawListHighlight(listwidg, index);
579 index = atoi(list[index])-1; // [HGM] filter: read true index from sequence nr of line
580 if (cmailMsgLoaded) {
581 CmailLoadGame(glc->fp, index + 1, glc->filename, True);
583 LoadGame(glc->fp, index + 1, glc->filename, True);
584 XSync(xDisplay, False);
585 XSetInputFocus(xDisplay, XtWindow(boardWidget), RevertToPointerRoot, CurrentTime);
590 SetFilterProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
596 XtSetArg(args[j], XtNstring, &name); j++;
597 XtGetValues(filterText, args, j);
598 safeStrCpy(filterString, name, sizeof(filterString)/sizeof(filterString[0]));
599 GameListPrepare(False); GameListReplace(0);
600 list = XtNameToWidget(glc->shell, "*form.viewport.list");
601 XawListHighlight(list, 0);
603 XtSetArg(args[j], XtNdisplayCaret, False); j++;
604 XtSetValues(filterText, args, j);
605 XtSetKeyboardFocus(glc->shell, list);
614 if (glc == NULL) return;
616 XtSetArg(args[j], XtNx, &glc->x); j++;
617 XtSetArg(args[j], XtNy, &glc->y); j++;
618 XtSetArg(args[j], XtNheight, &glc->h); j++;
619 XtSetArg(args[j], XtNwidth, &glc->w); j++;
620 XtGetValues(glc->shell, args, j);
621 wpGameList.x = glc->x - 4;
622 wpGameList.y = glc->y - 23;
623 wpGameList.width = glc->w;
624 wpGameList.height = glc->h;
625 XtPopdown(glc->shell);
626 XtSetKeyboardFocus(shellWidget, formWidget);
629 XtSetArg(args[j], XtNleftBitmap, None); j++;
630 XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Game List"),
635 GameListHighlight (int index)
639 if (glc == NULL || !glc->up) return;
640 listwidg = XtNameToWidget(glc->shell, "*form.viewport.list");
642 while(*st && atoi(*st)<index) st++,i++;
643 XawListHighlight(listwidg, i);
649 return glc && glc->up;
653 SaveGameListAsText (FILE *f)
655 ListGame * lg = (ListGame *) gameList.head;
658 if( !glc || ((ListGame *) gameList.tailPred)->number <= 0 ) {
659 DisplayError(_("Game list not loaded or empty"), 0);
663 /* Copy the list into the global memory block */
666 lg = (ListGame *) gameList.head;
668 for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){
669 char * st = GameListLineFull(lg->number, &lg->gameInfo);
670 char *line = GameListLine(lg->number, &lg->gameInfo);
671 if(filterString[0] == NULLCHAR || SearchPattern( line, filterString ) )
672 fprintf( f, "%s\n", st );
673 free(st); free(line);
674 lg = (ListGame *) lg->node.succ;
682 //--------------------------------- Game-List options dialog ------------------------------------------
684 Widget gameListOptShell, listwidg;
697 GLT_AddToList (char *name)
699 strings[stringPtr++] = name;
700 strings[stringPtr] = NULL;
704 GLT_GetFromList (int index, char *name)
706 safeStrCpy(name, strings[index], MSG_SIZ);
713 XawListChange(listwidg, strings, 0, 0, True);
714 XawListHighlight(listwidg, 0);
718 GameListOptionsPopDown ()
720 if (gameListOptShell == NULL) return;
722 XtPopdown(gameListOptShell);
723 XtDestroyWidget(gameListOptShell);
724 gameListOptShell = 0;
725 XtSetKeyboardFocus(shellWidget, formWidget);
729 GameListOptionsCallback (Widget w, XtPointer client_data, XtPointer call_data)
735 XawListReturnStruct *rs;
740 XtSetArg(args[j], XtNlabel, &name); j++;
741 XtGetValues(w, args, j);
743 if (strcmp(name, _("OK")) == 0) {
745 appData.gameListTags = strdup(lpUserGLT);
746 GameListOptionsPopDown();
749 if (strcmp(name, _("cancel")) == 0) {
750 GameListOptionsPopDown();
753 listwidg = XtNameToWidget(gameListOptShell, "*form.list");
754 rs = XawListShowCurrent(listwidg);
755 index = rs->list_index;
757 DisplayError(_("No tag selected"), 0);
761 if (strcmp(name, _("down")) == 0) {
762 if(index >= strlen(GLT_ALL_TAGS)) return;
763 strings[index] = strings[index+1];
764 strings[++index] = p;
766 if (strcmp(name, _("up")) == 0) {
767 if(index == 0) return;
768 strings[index] = strings[index-1];
769 strings[--index] = p;
771 if (strcmp(name, _("factory")) == 0) {
772 safeStrCpy(lpUserGLT, GLT_DEFAULT_TAGS, LPUSERGLT_SIZE);
773 GLT_TagsToList(lpUserGLT);
776 XawListHighlight(listwidg, index);
780 GameListOptionsCreate ()
783 Widget shell, form, viewport, layout;
784 Widget b_load, b_loadprev, b_loadnext, b_close, b_cancel;
786 XtPointer client_data = NULL;
790 XtSetArg(args[j], XtNwidth, &fw_width); j++;
791 XtGetValues(formWidget, args, j);
794 XtSetArg(args[j], XtNresizable, True); j++;
795 XtSetArg(args[j], XtNallowShellResize, True); j++;
796 shell = gameListOptShell =
797 XtCreatePopupShell(_("Game-list options"), transientShellWidgetClass,
798 shellWidget, args, j);
800 XtCreateManagedWidget(layoutName, formWidgetClass, shell,
801 layoutArgs, XtNumber(layoutArgs));
803 XtSetArg(args[j], XtNborderWidth, 0); j++;
805 XtCreateManagedWidget("form", formWidgetClass, layout, args, j);
808 XtSetArg(args[j], XtNdefaultColumns, 1); j++;
809 XtSetArg(args[j], XtNforceColumns, True); j++;
810 XtSetArg(args[j], XtNverticalList, True); j++;
811 listwidg = viewport =
812 XtCreateManagedWidget("list", listWidgetClass, form, args, j);
813 XawListHighlight(listwidg, 0);
814 // XtAugmentTranslations(listwidg,
815 // XtParseTranslationTable(gameListOptTranslations));
818 XtSetArg(args[j], XtNfromVert, viewport); j++;
819 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
820 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
821 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
822 XtSetArg(args[j], XtNright, XtChainLeft); j++;
824 XtCreateManagedWidget(_("factory"), commandWidgetClass, form, args, j);
825 XtAddCallback(b_load, XtNcallback, GameListOptionsCallback, client_data);
828 XtSetArg(args[j], XtNfromVert, viewport); j++;
829 XtSetArg(args[j], XtNfromHoriz, b_load); j++;
830 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
831 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
832 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
833 XtSetArg(args[j], XtNright, XtChainLeft); j++;
835 XtCreateManagedWidget(_("up"), commandWidgetClass, form, args, j);
836 XtAddCallback(b_loadprev, XtNcallback, GameListOptionsCallback, client_data);
839 XtSetArg(args[j], XtNfromVert, viewport); j++;
840 XtSetArg(args[j], XtNfromHoriz, b_loadprev); j++;
841 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
842 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
843 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
844 XtSetArg(args[j], XtNright, XtChainLeft); j++;
846 XtCreateManagedWidget(_("down"), commandWidgetClass, form, args, j);
847 XtAddCallback(b_loadnext, XtNcallback, GameListOptionsCallback, client_data);
850 XtSetArg(args[j], XtNfromVert, viewport); j++;
851 XtSetArg(args[j], XtNfromHoriz, b_loadnext); j++;
852 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
853 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
854 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
855 XtSetArg(args[j], XtNright, XtChainLeft); j++;
857 XtCreateManagedWidget(_("cancel"), commandWidgetClass, form, args, j);
858 XtAddCallback(b_cancel, XtNcallback, GameListOptionsCallback, client_data);
861 XtSetArg(args[j], XtNfromVert, viewport); j++;
862 XtSetArg(args[j], XtNfromHoriz, b_cancel); j++;
863 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
864 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
865 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
866 XtSetArg(args[j], XtNright, XtChainLeft); j++;
868 XtCreateManagedWidget(_("OK"), commandWidgetClass, form, args, j);
869 XtAddCallback(b_close, XtNcallback, GameListOptionsCallback, client_data);
871 safeStrCpy(lpUserGLT, appData.gameListTags, LPUSERGLT_SIZE);
872 GLT_TagsToList(lpUserGLT);
874 XtRealizeWidget(shell);
875 CatchDeleteWindow(shell, "GameListOptionsPopDown");
881 GameListOptionsPopUp (Widget w, XEvent *event, String *prms, Cardinal *nprms)
883 if (gameListOptShell == NULL)
884 gameListOptShell = GameListOptionsCreate();
886 XtPopup(gameListOptShell, XtGrabNone);