X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=blobdiff_plain;f=ngamelist.c;h=3d2b417e45d20fc3d7b561f55b196be7be5be762;hp=f3ef1d977bbd069ac4779fc2c92e5797e82cd8de;hb=HEAD;hpb=26897ecf6be30b8ccc64285e1e293ab76df38ab9 diff --git a/ngamelist.c b/ngamelist.c index f3ef1d9..3d2b417 100644 --- a/ngamelist.c +++ b/ngamelist.c @@ -1,7 +1,7 @@ /* * ngamelist.c -- Game list window, Xt-independent front-end code for XBoard * - * Copyright 1995, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. + * Copyright 1995, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation, Inc. * ------------------------------------------------------------------------ * * GNU XBoard is free software: you can redistribute it and/or modify @@ -81,8 +81,8 @@ static int GameListPrepare P((int byPos, int narrow)); static void GameListReplace P((int page)); static void GL_Button P((int n)); -static Option gamesOptions[] = { -{ 200, LR|TB, 400, NULL, (void*) list, "", NULL, ListBox, "" }, +Option gamesOptions[] = { +{ 200, LR|TB, 400, NULL, (void*) list, NULL, NULL, ListBox, "", &appData.gameListFont }, { 0, 0, 100, NULL, (void*) &filterPtr, "", NULL, TextBox, "" }, { 4, SAME_ROW, 0, NULL, (void*) &GL_Button, NULL, NULL, Button, N_("find position") }, { 2, SAME_ROW, 0, NULL, (void*) &GL_Button, NULL, NULL, Button, N_("narrow") }, // buttons referred to by ID in value (=first) field! @@ -151,9 +151,9 @@ static int GameListCreate (char *name) { int new; - if(new = GenericPopUp(gamesOptions, name, GameListDlg, BoardWindow, NONMODAL, 1)) - AddHandler(&gamesOptions[1], 4), - AddHandler(&gamesOptions[0], 5); + if(new = GenericPopUp(gamesOptions, name, GameListDlg, BoardWindow, NONMODAL, appData.topLevel)) + AddHandler(&gamesOptions[1], GameListDlg, 4), + AddHandler(&gamesOptions[0], GameListDlg, 5); FocusOnWidget(&gamesOptions[0], GameListDlg); return new; } @@ -190,12 +190,12 @@ GameListPrepare (int byPos, int narrow) if(lg->number % 2000 == 0) { char buf[MSG_SIZ]; snprintf(buf, MSG_SIZ, _("Scanning through games (%d)"), lg->number); - DisplayTitle(buf); + DisplayTitle(buf); DoEvents(); } lg->position = pos; lg = (ListGame *) lg->node.succ; } -GetTimeMark(&t2);printf("GameListPrepare %ld msec\n", SubtractTimeMarks(&t2,&t)); + if(appData.debugMode) { GetTimeMark(&t2);printf("GameListPrepare %ld msec\n", SubtractTimeMarks(&t2,&t)); } DisplayTitle("XBoard"); *st = NULL; return listLength; @@ -214,13 +214,21 @@ GameListReplace (int page) if(page + 1000 <= listLength) *st++ = _("next page"); *st = NULL; - LoadListBox(&gamesOptions[0], _("no games matched your request")); + LoadListBox(&gamesOptions[0], _("no games matched your request"), -1, -1); HighlightWithScroll(&gamesOptions[0], listEnd > 1000, listEnd); snprintf(buf, MSG_SIZ, _("%s - %d/%d games (%d-%d-%d)"), glc->filename, listLength, ((ListGame *) gameList.tailPred)->number, wins, losses, draws); SetDialogTitle(GameListDlg, buf); } void +GameListUpdate () +{ + if(!DialogExists(GameListDlg)) return; + GameListPrepare(False, False); + GameListReplace(0); +} + +void GameListPopUp (FILE *fp, char *filename) { if (glc == NULL) { @@ -242,12 +250,20 @@ GameListPopUp (FILE *fp, char *filename) page = 0; GameListReplace(0); // [HGM] filter: code put in separate routine, and also called to set title MarkMenu("View.GameList", GameListDlg); + EnableNamedMenuItem("File.SaveSelected", TRUE); +} + +FILE * +GameFile () +{ + return glc ? glc->fp : NULL; } void GameListDestroy () { if (glc == NULL) return; + EnableNamedMenuItem("File.SaveSelected", FALSE); PopDown(GameListDlg); if (glc->strings != NULL) { char **st; @@ -272,7 +288,7 @@ ShowGameListProc () PopDown(GameListDlg); return; } - GenericPopUp(NULL, NULL, GameListDlg, BoardWindow, NONMODAL, 1); // first two args ignored when shell exists! + GenericPopUp(NULL, NULL, GameListDlg, BoardWindow, NONMODAL, appData.topLevel); // first two args ignored when shell exists! MarkMenu("View.GameList", GameListDlg); GameListHighlight(lastLoadGameNumber); } @@ -352,7 +368,7 @@ SaveGameListAsText (FILE *f) /* Copy the list into the global memory block */ if( f != NULL ) { - + lg = (ListGame *) gameList.head; for (nItem = 0; nItem < ((ListGame *) gameList.tailPred)->number; nItem++){ @@ -369,4 +385,3 @@ SaveGameListAsText (FILE *f) } return False; } -