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 "<Btn1Down>: LoadSelectedProc(100) Set() \n \
102 <Btn1Up>(2): LoadSelectedProc(0) \n \
103 <Key>Home: LoadSelectedProc(-2) \n \
104 <Key>End: LoadSelectedProc(2) \n \
105 Ctrl<Key>Up: LoadSelectedProc(-3) \n \
106 Ctrl<Key>Down: LoadSelectedProc(3) \n \
107 <Key>Up: LoadSelectedProc(-1) \n \
108 <Key>Down: LoadSelectedProc(1) \n \
109 <Key>Left: LoadSelectedProc(-1) \n \
110 <Key>Right: LoadSelectedProc(1) \n \
111 <Key>Return: LoadSelectedProc(0) \n";
112 char filterTranslations[] =
113 "<Key>Return: SetFilterProc() \n";
115 char *dummyList[] = { N_("no games matched your request"), NULL };
126 static GameListClosure *glc = NULL;
129 GameListCreate (char *name, XtCallbackProc callback, XtPointer client_data)
132 Widget shell, form, viewport, listwidg, layout, label;
133 Widget b_load, b_loadprev, b_loadnext, b_close, b_filter;
136 GameListClosure *glc = (GameListClosure *) client_data;
139 XtSetArg(args[j], XtNwidth, &fw_width); j++;
140 XtGetValues(formWidget, args, j);
143 XtSetArg(args[j], XtNresizable, True); j++;
144 XtSetArg(args[j], XtNallowShellResize, True); j++;
146 shell = gameListShell =
147 XtCreatePopupShell(name, topLevelShellWidgetClass,
148 shellWidget, args, j);
150 shell = gameListShell =
151 XtCreatePopupShell(name, transientShellWidgetClass,
152 shellWidget, args, j);
155 XtCreateManagedWidget(layoutName, formWidgetClass, shell,
156 layoutArgs, XtNumber(layoutArgs));
158 XtSetArg(args[j], XtNborderWidth, 0); j++;
160 XtCreateManagedWidget("form", formWidgetClass, layout, args, j);
163 XtSetArg(args[j], XtNtop, XtChainTop); j++;
164 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
165 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
166 XtSetArg(args[j], XtNright, XtChainRight); j++;
167 XtSetArg(args[j], XtNresizable, False); j++;
168 XtSetArg(args[j], XtNwidth, fw_width); j++;
169 XtSetArg(args[j], XtNallowVert, True); j++;
171 XtCreateManagedWidget("viewport", viewportWidgetClass, form, args, j);
174 // XtSetArg(args[j], XtNlist, glc->strings); j++;
175 XtSetArg(args[j], XtNdefaultColumns, 1); j++;
176 XtSetArg(args[j], XtNforceColumns, True); j++;
177 XtSetArg(args[j], XtNverticalList, True); j++;
179 XtCreateManagedWidget("list", listWidgetClass, viewport, args, j);
180 XawListHighlight(listwidg, 0);
181 XtOverrideTranslations(listwidg,
182 XtParseTranslationTable(gameListTranslations));
185 XtSetArg(args[j], XtNfromVert, viewport); j++;
186 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
187 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
188 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
189 XtSetArg(args[j], XtNright, XtChainLeft); j++;
191 XtCreateManagedWidget(_("thresholds"), commandWidgetClass, form, args, j);
192 XtAddCallback(b_load, XtNcallback, callback, client_data);
195 XtSetArg(args[j], XtNfromVert, viewport); j++;
196 XtSetArg(args[j], XtNfromHoriz, b_load); j++;
197 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
198 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
199 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
200 XtSetArg(args[j], XtNright, XtChainLeft); j++;
202 XtCreateManagedWidget(_("find position"), commandWidgetClass, form, args, j);
203 XtAddCallback(b_loadprev, XtNcallback, callback, client_data);
206 XtSetArg(args[j], XtNfromVert, viewport); j++;
207 XtSetArg(args[j], XtNfromHoriz, b_loadprev); j++;
208 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
209 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
210 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
211 XtSetArg(args[j], XtNright, XtChainLeft); j++;
213 XtCreateManagedWidget(_("next"), commandWidgetClass, form, args, j);
214 XtAddCallback(b_loadnext, XtNcallback, callback, client_data);
216 b_loadnext = b_loadprev;
219 XtSetArg(args[j], XtNfromVert, viewport); j++;
220 XtSetArg(args[j], XtNfromHoriz, b_loadnext); j++;
221 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
222 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
223 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
224 XtSetArg(args[j], XtNright, XtChainLeft); j++;
226 XtCreateManagedWidget(_("close"), commandWidgetClass, form, args, j);
227 XtAddCallback(b_close, XtNcallback, callback, client_data);
230 XtSetArg(args[j], XtNfromVert, viewport); j++;
231 XtSetArg(args[j], XtNfromHoriz, b_close); j++;
232 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
233 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
234 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
235 XtSetArg(args[j], XtNright, XtChainLeft); j++;
236 XtSetArg(args[j], XtNborderWidth, 0); j++;
238 XtCreateManagedWidget(_("Filter:"), labelWidgetClass, form, args, j);
241 XtSetArg(args[j], XtNfromVert, viewport); j++;
242 XtSetArg(args[j], XtNfromHoriz, label); j++;
243 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
244 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
245 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
246 XtSetArg(args[j], XtNright, XtChainRight); j++;
247 XtSetArg(args[j], XtNwidth, fw_width - 275 - squareSize); j++;
248 XtSetArg(args[j], XtNstring, filterString); j++;
249 XtSetArg(args[j], XtNdisplayCaret, False); j++;
250 XtSetArg(args[j], XtNresizable, True); j++;
251 // XtSetArg(args[j], XtNwidth, bw_width); j++; /*force wider than buttons*/
252 /* !!Work around an apparent bug in XFree86 4.0.1 (X11R6.4.3) */
253 XtSetArg(args[j], XtNeditType, XawtextEdit); j++;
254 XtSetArg(args[j], XtNuseStringInPlace, False); j++;
256 XtCreateManagedWidget(_("filtertext"), asciiTextWidgetClass, form, args, j);
257 XtAddEventHandler(filterText, ButtonPressMask, False, SetFocus, (XtPointer) shell);
258 XtOverrideTranslations(filterText,
259 XtParseTranslationTable(filterTranslations));
262 XtSetArg(args[j], XtNfromVert, viewport); j++;
263 XtSetArg(args[j], XtNfromHoriz, filterText); j++;
264 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
265 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
266 XtSetArg(args[j], XtNleft, XtChainRight); j++;
267 XtSetArg(args[j], XtNright, XtChainRight); j++;
269 XtCreateManagedWidget(_("apply"), commandWidgetClass, form, args, j);
270 XtAddCallback(b_filter, XtNcallback, callback, client_data);
273 if(wpGameList.width > 0) {
274 glc->x = wpGameList.x;
275 glc->y = wpGameList.y;
276 glc->w = wpGameList.width;
277 glc->h = wpGameList.height;
287 XtSetArg(args[j], XtNheight, &h1); j++;
288 XtSetArg(args[j], XtNy, &y1); j++;
289 XtGetValues(boardWidget, args, j);
290 glc->w = fw_width * 3/4;
291 glc->h = squareSize * 3;
293 XSync(xDisplay, False);
295 /* This code seems to tickle an X bug if it is executed too soon
296 after xboard starts up. The coordinates get transformed as if
297 the main window was positioned at (0, 0).
299 XtTranslateCoords(shellWidget, (fw_width - glc->w) / 2,
300 y1 + (h1 - glc->h + appData.borderYoffset) / 2,
303 XTranslateCoordinates(xDisplay, XtWindow(shellWidget),
304 RootWindowOfScreen(XtScreen(shellWidget)),
305 (fw_width - glc->w) / 2,
306 y1 + (h1 - glc->h + appData.borderYoffset) / 2,
311 if (glc->y < 0) glc->y = 0; /*avoid positioning top offscreen*/
314 XtSetArg(args[j], XtNheight, glc->h); j++;
315 XtSetArg(args[j], XtNwidth, glc->w); j++;
316 XtSetArg(args[j], XtNx, glc->x - appData.borderXoffset); j++;
317 XtSetArg(args[j], XtNy, glc->y - appData.borderYoffset); j++;
318 XtSetValues(shell, args, j);
320 XtRealizeWidget(shell);
321 CatchDeleteWindow(shell, "GameListPopDown");
322 XtSetKeyboardFocus(shell, listwidg);
327 extern int soughtCounts[];
328 extern Board soughtBoard;
331 GameListPrepare (int byPos)
332 { // [HGM] filter: put in separate routine, to make callable from call-back
339 if(st = glc->strings) while(*st) free(*st++);
340 nstrings = ((ListGame *) gameList.tailPred)->number;
341 glc->strings = (char **) malloc((nstrings + 1) * sizeof(char *));
343 lg = (ListGame *) gameList.head;
344 listLength = wins = losses = draws = 0;
345 if(byPos) InitSearch();
348 line = GameListLine(lg->number, &lg->gameInfo);
349 if((filterString[0] == NULLCHAR || SearchPattern( line, filterString )) && (!byPos || (pos=GameContainsPosition(glc->fp, lg)) >= 0) ) {
350 *st++ = line; // [HGM] filter: make adding line conditional.
352 if( lg->gameInfo.result == WhiteWins ) wins++; else
353 if( lg->gameInfo.result == BlackWins ) losses++; else
354 if( lg->gameInfo.result == GameIsDrawn ) draws++;
356 if(lg->number % 2000 == 0) {
358 snprintf(buf, MSG_SIZ, _("Scanning through games (%d)"), lg->number);
362 lg = (ListGame *) lg->node.succ;
364 GetTimeMark(&t2);printf("GameListPrepare %ld msec\n", SubtractTimeMarks(&t2,&t));
365 DisplayTitle("XBoard");
370 static char *list[1003];
374 GameListReplace (int page)
376 // filter: put in separate routine, to make callable from call-back
379 char buf[MSG_SIZ], *p, **st=list;
382 if(page) *st++ = _("previous page"); else if(listLength > 1000) *st++ = "";
383 for(i=0; i<1000; i++) if( !(*st++ = glc->strings[page+i]) ) { st--; break; }
385 if(page + 1000 <= listLength) *st++ = _("next page");
388 listwidg = XtNameToWidget(glc->shell, "*form.viewport.list");
389 XtSetArg(arg, XtNlist, listLength ? list : dummyList); // empty list displays message
390 XawListChange(listwidg, list, 0, 0, True);
391 XtSetValues(listwidg, &arg, 1);
392 XawListHighlight(listwidg, 0);
393 snprintf(buf, MSG_SIZ, _("%s - %d/%d games (%d-%d-%d)"), glc->filename, listLength, ((ListGame *) gameList.tailPred)->number, wins, losses, draws);
394 XtSetArg(arg, XtNtitle, buf);
395 XtSetValues(glc->shell, &arg, 1);
399 GameListCallback (Widget w, XtPointer client_data, XtPointer call_data)
405 GameListClosure *glc = (GameListClosure *) client_data;
406 XawListReturnStruct *rs;
410 XtSetArg(args[j], XtNlabel, &name); j++;
411 XtGetValues(w, args, j);
413 if (strcmp(name, _("close")) == 0) {
417 if (strcmp(name, _("thresholds")) == 0) {
421 listwidg = XtNameToWidget(glc->shell, "*form.viewport.list");
422 rs = XawListShowCurrent(listwidg);
423 if (strcmp(name, _("load")) == 0) {
424 index = rs->list_index;
426 DisplayError(_("No game selected"), 0);
429 } else if (strcmp(name, _("next")) == 0) {
430 index = rs->list_index + 1;
431 if (index >= listLength || !list[index]) {
432 DisplayError(_("Can't go forward any further"), 0);
435 XawListHighlight(listwidg, index);
436 } else if (strcmp(name, _("prev")) == 0) {
437 index = rs->list_index - 1;
439 DisplayError(_("Can't back up any further"), 0);
442 XawListHighlight(listwidg, index);
443 } else if (strcmp(name, _("apply")) == 0 ||
444 strcmp(name, _("find position")) == 0) {
447 XtSetArg(args[j], XtNstring, &text); j++;
448 XtGetValues(filterText, args, j);
449 safeStrCpy(filterString, text, sizeof(filterString)/sizeof(filterString[0]));
450 XawListHighlight(listwidg, 0);
451 GameListPrepare(strcmp(name, _("find position")) == 0); GameListReplace(0);
455 index = atoi(list[index])-1; // [HGM] filter: read true index from sequence nr of line
456 if (cmailMsgLoaded) {
457 CmailLoadGame(glc->fp, index + 1, glc->filename, True);
459 LoadGame(glc->fp, index + 1, glc->filename, True);
462 printf("This code should have been unreachable. Please report bug!\n");
467 GameListPopUp (FILE *fp, char *filename)
474 glc = (GameListClosure *) calloc(1, sizeof(GameListClosure));
475 glc->x = glc->y = -1;
476 glc->filename = NULL;
480 GameListPrepare(False); // [HGM] filter: code put in separate routine
484 if (glc->filename != NULL) free(glc->filename);
485 glc->filename = StrSave(filename);
487 if (glc->shell == NULL) {
488 glc->shell = GameListCreate(filename, GameListCallback, glc);
491 XtSetArg(args[j], XtNiconName, (XtArgVal) filename); j++;
492 // XtSetArg(args[j], XtNtitle, (XtArgVal) filename); j++;
493 XtSetValues(glc->shell, args, j);
496 GameListReplace(0); // [HGM] filter: code put in separate routine, and also called to set title
498 XtPopup(glc->shell, XtGrabNone);
501 XtSetArg(args[j], XtNleftBitmap, xMarkPixmap); j++;
502 XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Game List"),
509 if (glc == NULL) return;
511 if (glc->strings != NULL) {
524 ShowGameListProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
530 DisplayError(_("There is no game list"), 0);
537 XtPopup(glc->shell, XtGrabNone);
540 XtSetArg(args[j], XtNleftBitmap, xMarkPixmap); j++;
541 XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Game List"),
543 GameListHighlight(lastLoadGameNumber);
547 LoadSelectedProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
550 XawListReturnStruct *rs;
551 int index, direction = atoi(prms[0]);
552 printf("action(%d)\n",direction);
553 if (glc == NULL || listLength == 0) return;
554 listwidg = XtNameToWidget(glc->shell, "*form.viewport.list");
555 if(direction == 100) { XtSetKeyboardFocus(glc->shell, listwidg); return; }
556 rs = XawListShowCurrent(listwidg);
557 index = rs->list_index;
558 if (index < 0) return;
559 if(page && index == 0) {
561 if(page < 0) page = 0; // safety
562 GameListReplace(page);
567 GameListReplace(page);
572 int doLoad = abs(direction) > 2;
573 if(doLoad) direction /= 3;
575 if(direction == -2) index = 0;
576 if(direction == 2) index = listEnd-1;
577 if(index < 0 || index >= listEnd) return;
578 XawListHighlight(listwidg, index);
581 index = atoi(list[index])-1; // [HGM] filter: read true index from sequence nr of line
582 if (cmailMsgLoaded) {
583 CmailLoadGame(glc->fp, index + 1, glc->filename, True);
585 LoadGame(glc->fp, index + 1, glc->filename, True);
586 XSync(xDisplay, False);
587 XSetInputFocus(xDisplay, XtWindow(boardWidget), RevertToPointerRoot, CurrentTime);
592 SetFilterProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
598 XtSetArg(args[j], XtNstring, &name); j++;
599 XtGetValues(filterText, args, j);
600 safeStrCpy(filterString, name, sizeof(filterString)/sizeof(filterString[0]));
601 GameListPrepare(False); GameListReplace(0);
602 list = XtNameToWidget(glc->shell, "*form.viewport.list");
603 XawListHighlight(list, 0);
605 XtSetArg(args[j], XtNdisplayCaret, False); j++;
606 XtSetValues(filterText, args, j);
607 XtSetKeyboardFocus(glc->shell, list);
616 if (glc == NULL) return;
618 XtSetArg(args[j], XtNx, &glc->x); j++;
619 XtSetArg(args[j], XtNy, &glc->y); j++;
620 XtSetArg(args[j], XtNheight, &glc->h); j++;
621 XtSetArg(args[j], XtNwidth, &glc->w); j++;
622 XtGetValues(glc->shell, args, j);
623 wpGameList.x = glc->x - 4;
624 wpGameList.y = glc->y - 23;
625 wpGameList.width = glc->w;
626 wpGameList.height = glc->h;
627 XtPopdown(glc->shell);
628 XtSetKeyboardFocus(shellWidget, formWidget);
631 XtSetArg(args[j], XtNleftBitmap, None); j++;
632 XtSetValues(XtNameToWidget(menuBarWidget, "menuView.Show Game List"),
637 GameListHighlight (int index)
641 if (glc == NULL || !glc->up) return;
642 listwidg = XtNameToWidget(glc->shell, "*form.viewport.list");
644 while(*st && atoi(*st)<index) st++,i++;
645 XawListHighlight(listwidg, i);
651 return glc && glc->up;
655 SaveGameListAsText (FILE *f)
657 ListGame * lg = (ListGame *) gameList.head;
660 if( !glc || ((ListGame *) gameList.tailPred)->number <= 0 ) {
661 DisplayError(_("Game list not loaded or empty"), 0);
665 /* Copy the list into the global memory block */
668 lg = (ListGame *) gameList.head;
670 for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){
671 char * st = GameListLineFull(lg->number, &lg->gameInfo);
672 char *line = GameListLine(lg->number, &lg->gameInfo);
673 if(filterString[0] == NULLCHAR || SearchPattern( line, filterString ) )
674 fprintf( f, "%s\n", st );
675 free(st); free(line);
676 lg = (ListGame *) lg->node.succ;
684 //--------------------------------- Game-List options dialog ------------------------------------------
686 Widget gameListOptShell, listwidg;
699 GLT_AddToList (char *name)
701 strings[stringPtr++] = name;
702 strings[stringPtr] = NULL;
706 GLT_GetFromList (int index, char *name)
708 safeStrCpy(name, strings[index], MSG_SIZ);
715 XawListChange(listwidg, strings, 0, 0, True);
716 XawListHighlight(listwidg, 0);
720 GameListOptionsPopDown ()
722 if (gameListOptShell == NULL) return;
724 XtPopdown(gameListOptShell);
725 XtDestroyWidget(gameListOptShell);
726 gameListOptShell = 0;
727 XtSetKeyboardFocus(shellWidget, formWidget);
731 GameListOptionsCallback (Widget w, XtPointer client_data, XtPointer call_data)
737 XawListReturnStruct *rs;
742 XtSetArg(args[j], XtNlabel, &name); j++;
743 XtGetValues(w, args, j);
745 if (strcmp(name, _("OK")) == 0) {
747 appData.gameListTags = strdup(lpUserGLT);
748 GameListOptionsPopDown();
751 if (strcmp(name, _("cancel")) == 0) {
752 GameListOptionsPopDown();
755 listwidg = XtNameToWidget(gameListOptShell, "*form.list");
756 rs = XawListShowCurrent(listwidg);
757 index = rs->list_index;
759 DisplayError(_("No tag selected"), 0);
763 if (strcmp(name, _("down")) == 0) {
764 if(index >= strlen(GLT_ALL_TAGS)) return;
765 strings[index] = strings[index+1];
766 strings[++index] = p;
768 if (strcmp(name, _("up")) == 0) {
769 if(index == 0) return;
770 strings[index] = strings[index-1];
771 strings[--index] = p;
773 if (strcmp(name, _("factory")) == 0) {
774 safeStrCpy(lpUserGLT, GLT_DEFAULT_TAGS, LPUSERGLT_SIZE);
775 GLT_TagsToList(lpUserGLT);
778 XawListHighlight(listwidg, index);
782 GameListOptionsCreate ()
785 Widget shell, form, viewport, layout;
786 Widget b_load, b_loadprev, b_loadnext, b_close, b_cancel;
788 XtPointer client_data = NULL;
792 XtSetArg(args[j], XtNwidth, &fw_width); j++;
793 XtGetValues(formWidget, args, j);
796 XtSetArg(args[j], XtNresizable, True); j++;
797 XtSetArg(args[j], XtNallowShellResize, True); j++;
798 shell = gameListOptShell =
799 XtCreatePopupShell(_("Game-list options"), transientShellWidgetClass,
800 shellWidget, args, j);
802 XtCreateManagedWidget(layoutName, formWidgetClass, shell,
803 layoutArgs, XtNumber(layoutArgs));
805 XtSetArg(args[j], XtNborderWidth, 0); j++;
807 XtCreateManagedWidget("form", formWidgetClass, layout, args, j);
810 XtSetArg(args[j], XtNdefaultColumns, 1); j++;
811 XtSetArg(args[j], XtNforceColumns, True); j++;
812 XtSetArg(args[j], XtNverticalList, True); j++;
813 listwidg = viewport =
814 XtCreateManagedWidget("list", listWidgetClass, form, args, j);
815 XawListHighlight(listwidg, 0);
816 // XtAugmentTranslations(listwidg,
817 // XtParseTranslationTable(gameListOptTranslations));
820 XtSetArg(args[j], XtNfromVert, viewport); j++;
821 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
822 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
823 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
824 XtSetArg(args[j], XtNright, XtChainLeft); j++;
826 XtCreateManagedWidget(_("factory"), commandWidgetClass, form, args, j);
827 XtAddCallback(b_load, XtNcallback, GameListOptionsCallback, client_data);
830 XtSetArg(args[j], XtNfromVert, viewport); j++;
831 XtSetArg(args[j], XtNfromHoriz, b_load); j++;
832 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
833 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
834 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
835 XtSetArg(args[j], XtNright, XtChainLeft); j++;
837 XtCreateManagedWidget(_("up"), commandWidgetClass, form, args, j);
838 XtAddCallback(b_loadprev, XtNcallback, GameListOptionsCallback, client_data);
841 XtSetArg(args[j], XtNfromVert, viewport); j++;
842 XtSetArg(args[j], XtNfromHoriz, b_loadprev); j++;
843 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
844 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
845 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
846 XtSetArg(args[j], XtNright, XtChainLeft); j++;
848 XtCreateManagedWidget(_("down"), commandWidgetClass, form, args, j);
849 XtAddCallback(b_loadnext, XtNcallback, GameListOptionsCallback, client_data);
852 XtSetArg(args[j], XtNfromVert, viewport); j++;
853 XtSetArg(args[j], XtNfromHoriz, b_loadnext); j++;
854 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
855 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
856 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
857 XtSetArg(args[j], XtNright, XtChainLeft); j++;
859 XtCreateManagedWidget(_("cancel"), commandWidgetClass, form, args, j);
860 XtAddCallback(b_cancel, XtNcallback, GameListOptionsCallback, client_data);
863 XtSetArg(args[j], XtNfromVert, viewport); j++;
864 XtSetArg(args[j], XtNfromHoriz, b_cancel); j++;
865 XtSetArg(args[j], XtNtop, XtChainBottom); j++;
866 XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
867 XtSetArg(args[j], XtNleft, XtChainLeft); j++;
868 XtSetArg(args[j], XtNright, XtChainLeft); j++;
870 XtCreateManagedWidget(_("OK"), commandWidgetClass, form, args, j);
871 XtAddCallback(b_close, XtNcallback, GameListOptionsCallback, client_data);
873 safeStrCpy(lpUserGLT, appData.gameListTags, LPUSERGLT_SIZE);
874 GLT_TagsToList(lpUserGLT);
876 XtRealizeWidget(shell);
877 CatchDeleteWindow(shell, "GameListOptionsPopDown");
883 GameListOptionsPopUp (Widget w, XEvent *event, String *prms, Cardinal *nprms)
885 if (gameListOptShell == NULL)
886 gameListOptShell = GameListOptionsCreate();
888 XtPopup(gameListOptShell, XtGrabNone);