From: H.G. Muller Date: Sat, 11 Feb 2012 11:59:04 +0000 (+0100) Subject: Put front-end support for -recentEngines in XBoard X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=2af7c68549b9aeb85ddce753062604f54f0b0b49;p=xboard.git Put front-end support for -recentEngines in XBoard The engines are added to the menu. Problem is still that in XBoard startup engines are given by command, rather than selected by combobox, so the command rather than the nickname ends up in the menu. If this is then selected, it cannot be found in the list. To limit the damage, Fairy-Max is now pre-installed without nickname. -recentEngines is now configured to 4. --- diff --git a/xboard.c b/xboard.c index f9ba5cc..e4aec19 100644 --- a/xboard.c +++ b/xboard.c @@ -3891,6 +3891,39 @@ MenuBarSelect (Widget w, caddr_t addr, caddr_t index) (proc)(NULL, NULL, NULL, NULL); } +static void +MenuEngineSelect (Widget w, caddr_t addr, caddr_t index) +{ + RecentEngineEvent((int) addr); +} + +void +AppendEnginesToMenu (Widget menu, char *list) +{ + int i=0, j; + Widget entry; + MenuItem *mi; + Arg args[16]; + char *p; + + if(appData.recentEngines <= 0) return; + recentEngines = strdup(list); + j = 0; + XtSetArg(args[j], XtNleftMargin, 20); j++; + XtSetArg(args[j], XtNrightMargin, 20); j++; + while (*list) { + p = strchr(list, '\n'); if(p == NULL) break; + if(i == 0) XtCreateManagedWidget(_("----"), smeLineObjectClass, menu, args, j); // at least one valid item to add + *p = 0; + XtSetArg(args[j], XtNlabel, XtNewString(list)); + entry = XtCreateManagedWidget("engine", smeBSBObjectClass, menu, args, j+1); + XtAddCallback(entry, XtNcallback, + (XtCallbackProc) MenuEngineSelect, + (caddr_t) i); + i++; *p = '\n'; list = p + 1; + } +} + void CreateMenuBarPopup (Widget parent, String name, Menu *mb) { @@ -3919,6 +3952,7 @@ CreateMenuBarPopup (Widget parent, String name, Menu *mb) } mi++; } + if(!strcmp(mb->name, "Engine")) AppendEnginesToMenu(menu, appData.recentEngineList); } Widget diff --git a/xboard.conf.in b/xboard.conf.in index ea719ee..c2a47a8 100644 --- a/xboard.conf.in +++ b/xboard.conf.in @@ -29,7 +29,7 @@ -darkBackTextureFile "@pixmapsdir@/wood_d.xpm" -overrideLineGap 1 -highlightMoveWithArrow true --recentEngines 0 +-recentEngines 4 ; ; Behavior ; @@ -62,7 +62,7 @@ ; -firstChessProgram fairymax -secondChessProgram fairymax --firstChessProgramNames {"Fairy-Max" -fcp fairymax +-firstChessProgramNames {fairymax "Fruit 2.1" -fcp fruit -fUCI "Crafty" -fcp crafty "GNU Chess" -fcp gnuchess