Updated copyright notice to 2012
[xboard.git] / xgamelist.c
index abccb04..ecdc915 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * xgamelist.c -- Game list window, part of X front end for XBoard
  *
- * Copyright 1995, 2009, 2010, 2011 Free Software Foundation, Inc.
+ * Copyright 1995, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
  * ------------------------------------------------------------------------
  *
  * GNU XBoard is free software: you can redistribute it and/or modify
@@ -326,19 +326,25 @@ GameListCreate(name, callback, client_data)
     return shell;
 }
 
+extern int soughtCounts[];
+extern Board soughtBoard;
+
 static int
 GameListPrepare(int byPos)
 {   // [HGM] filter: put in separate routine, to make callable from call-back
     int nstrings;
     ListGame *lg;
     char **st, *line;
+    TimeMark t, t2;
 
+    GetTimeMark(&t);
     if(st = glc->strings) while(*st) free(*st++);
     nstrings = ((ListGame *) gameList.tailPred)->number;
     glc->strings = (char **) malloc((nstrings + 1) * sizeof(char *));
     st = glc->strings;
     lg = (ListGame *) gameList.head;
     listLength = wins = losses = draws = 0;
+    if(byPos) InitSearch();
     while (nstrings--) {
        int pos = -1;
        line = GameListLine(lg->number, &lg->gameInfo);
@@ -357,12 +363,14 @@ GameListPrepare(int byPos)
        lg->position = pos;
        lg = (ListGame *) lg->node.succ;
      }
+GetTimeMark(&t2);printf("GameListPrepare %ld msec\n", SubtractTimeMarks(&t2,&t));
      DisplayTitle("XBoard");
     *st = NULL;
     return listLength;
 }
 
 static char *list[1003];
+int listEnd;
 
 static void
 GameListReplace(int page)
@@ -374,7 +382,8 @@ GameListReplace(int page)
   int i;
 
   if(page) *st++ = _("previous page"); else if(listLength > 1000) *st++ = "";
-  for(i=0; i<1000; i++) if( !(*st++ = glc->strings[page+i]) ) break;
+  for(i=0; i<1000; i++) if( !(*st++ = glc->strings[page+i]) ) { st--; break; }
+  listEnd = st - list;
   if(page + 1000 <= listLength) *st++ = _("next page");
   *st = NULL;
 
@@ -383,7 +392,7 @@ GameListReplace(int page)
   XawListChange(listwidg, list, 0, 0, True);
   XtSetValues(listwidg, &arg, 1);
   XawListHighlight(listwidg, 0);
-  snprintf(buf, MSG_SIZ, "%s- %d/%d games (%d-%d-%d)", glc->filename, listLength, ((ListGame *) gameList.tailPred)->number, wins, losses, draws);
+  snprintf(buf, MSG_SIZ, _("%s - %d/%d games (%d-%d-%d)"), glc->filename, listLength, ((ListGame *) gameList.tailPred)->number, wins, losses, draws);
   XtSetArg(arg, XtNtitle, buf);
   XtSetValues(glc->shell, &arg, 1);
 }
@@ -470,6 +479,8 @@ GameListPopUp(fp, filename)
     if (glc == NULL) {
        glc = (GameListClosure *) calloc(1, sizeof(GameListClosure));
        glc->x = glc->y = -1;
+       glc->filename = NULL;
+       glc->shell = NULL;
     }
 
     GameListPrepare(False); // [HGM] filter: code put in separate routine
@@ -479,7 +490,6 @@ GameListPopUp(fp, filename)
     if (glc->filename != NULL) free(glc->filename);
     glc->filename = StrSave(filename);
 
-
     if (glc->shell == NULL) {
        glc->shell = GameListCreate(filename, GameListCallback, glc);
     } else {
@@ -576,8 +586,8 @@ LoadSelectedProc(w, event, prms, nprms)
        if(doLoad) direction /= 3;
        index += direction;
        if(direction == -2) index = 0;
-       if(direction == 2) index = listLength-1;
-       if(index < 0 || index >= listLength) return;
+       if(direction == 2) index = listEnd-1;
+       if(index < 0 || index >= listEnd) return;
        XawListHighlight(listwidg, index);
        if(!doLoad) return;
     }
@@ -665,7 +675,7 @@ int SaveGameListAsText(FILE *f)
     int nItem;
 
     if( !glc || ((ListGame *) gameList.tailPred)->number <= 0 ) {
-        DisplayError("Game list not loaded or empty", 0);
+      DisplayError(_("Game list not loaded or empty"), 0);
         return False;
     }
 
@@ -801,7 +811,7 @@ GameListOptionsCreate()
     XtSetArg(args[j], XtNresizable, True);  j++;
     XtSetArg(args[j], XtNallowShellResize, True);  j++;
     shell = gameListOptShell =
-      XtCreatePopupShell("Game-list options", transientShellWidgetClass,
+      XtCreatePopupShell(_("Game-list options"), transientShellWidgetClass,
                         shellWidget, args, j);
     layout =
       XtCreateManagedWidget(layoutName, formWidgetClass, shell,