From: H.G. Muller Date: Mon, 2 Apr 2012 17:19:30 +0000 (+0200) Subject: Fix recent-engines menu X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=a86bdfbfc0c5d1b734b918f5a1727cae4056c36a;p=xboard.git Fix recent-engines menu A new primitive to create an item in a given menu was added to do this. --- diff --git a/menus.c b/menus.c index f802215..9d78f4c 100644 --- a/menus.c +++ b/menus.c @@ -872,17 +872,15 @@ AppendEnginesToMenu (char *list) { int i=0; char *p; -#if 0 if(appData.icsActive || appData.recentEngines <= 0) return; recentEngines = strdup(list); while (*list) { p = strchr(list, '\n'); if(p == NULL) break; - if(i == 0) AppendMenuItem("----", "----", NULL); // at least one valid item to add + if(i == 0) AppendMenuItem("----", 0); // at least one valid item to add *p = 0; - AppendMenuItem(list, "recent", (MenuProc *) i); + AppendMenuItem(list, i); i++; *p = '\n'; list = p + 1; } -#endif } Enables icsEnables[] = { diff --git a/menus.h b/menus.h index fc3d8a3..cacb22c 100644 --- a/menus.h +++ b/menus.h @@ -73,6 +73,7 @@ typedef struct { extern Menu menuBar[]; +void AppendEnginesToMenu P((char *list)); void LoadGameProc P((void)); void LoadNextGameProc P((void)); void LoadPrevGameProc P((void)); @@ -163,7 +164,7 @@ void EngineOutputProc P((void)); void EvalGraphProc P((void)); void CreateMainMenus P((Menu *mb)); -void AppendMenuItem P((char *text, char *name, MenuProc *action)); +void AppendMenuItem P((char *text, int n)); void CreateMenuButton P((char *name, Menu *mb)); MenuItem *MenuNameToItem P((char *menuName)); void SetMenuEnables P((Enables *enab)); diff --git a/xboard.c b/xboard.c index 538d55e..fa5a4c4 100644 --- a/xboard.c +++ b/xboard.c @@ -1410,6 +1410,7 @@ XBoard square size (hint): %d\n\ XtSetArg(args[1], XtNforeground, &buttonForegroundPixel); XtGetValues(optList[18].handle, args, 2); } + AppendEnginesToMenu(appData.recentEngineList); xBoardWindow = XtWindow(boardWidget); @@ -2330,6 +2331,12 @@ MenuEngineSelect (Widget w, caddr_t addr, caddr_t index) } void +AppendMenuItem (char *msg, int n) +{ + CreateMenuItem((Widget) optList[6].textValue, msg, (XtCallbackProc) MenuEngineSelect, n); +} + +void SetupDropMenu () { int i, j, count; diff --git a/xboard.h b/xboard.h index 55ca7dc..6af4b11 100644 --- a/xboard.h +++ b/xboard.h @@ -145,6 +145,7 @@ void SendToICS P((char *buf)); void SendToProgram P((char *message, ChessProgramState *cps)); void SetFocus(Widget w, XtPointer data, XEvent *event, Boolean *b); // from xoptions.c void TypeInProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +Widget CreateMenuItem P((Widget menu, char *msg, XtCallbackProc CB, int n)); void WheelProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void TabProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void GenericMenu P((Widget w, XEvent *event, String *prms, Cardinal *nprms));