From: H.G. Muller Date: Mon, 2 Apr 2012 12:09:15 +0000 (+0200) Subject: Use ListBox in stead of ComboBox in Load Engine dialog X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=71d96ad96e11224c77a9a4e3735661e020beeee1 Use ListBox in stead of ComboBox in Load Engine dialog Make Load Engine listbox sensitive to double-clicking --- diff --git a/dialogs.c b/dialogs.c index 5f269a6..91a2e5a 100644 --- a/dialogs.c +++ b/dialogs.c @@ -1177,19 +1177,15 @@ SecondSettingsProc () //----------------------------------------------- Load Engine -------------------------------------- char *engineDir, *engineLine, *nickName, *params; -Boolean isUCI, hasBook, storeVariant, v1, addToList, useNick; -static char *engineNr[] = { N_("First Engine"), N_("Second Engine"), NULL }; +Boolean isUCI, hasBook, storeVariant, v1, addToList, useNick, secondEng; -static int -InstallOK (int n) -{ - PopDown(TransientDlg); // early popdown, to allow FreezeUI to instate grab - if(engineChoice[0] == engineNr[0][0]) Load(&first, 0); else Load(&second, 1); - return FALSE; // no double PopDown! -} +static void EngSel P((int n, int sel)); +static int InstallOK P((int n)); static Option installOptions[] = { -{ 0, NO_GETTEXT, 0, NULL, (void*) &engineLine, (char*) engineList, engineMnemonic, ComboBox, N_("Select engine from list:") }, +{ 0,LR|T2T, 0, NULL, NULL, NULL, NULL, Label, N_("Select engine from list:") }, +{ 300,LR|TB,200, NULL, (void*) engineMnemonic, (char*) &EngSel, NULL, ListBox, "" }, +{ 0,SAME_ROW, 0, NULL, NULL, NULL, NULL, Break, NULL }, { 0, LR, 0, NULL, NULL, NULL, NULL, Label, N_("or specify one below:") }, { 0, 0, 0, NULL, (void*) &nickName, NULL, NULL, TextBox, N_("Nickname (optional):") }, { 0, 0, 0, NULL, (void*) &useNick, NULL, NULL, CheckBox, N_("Use nickname in PGN player tags of engine-engine games") }, @@ -1201,21 +1197,51 @@ static Option installOptions[] = { { 0, 0, 0, NULL, (void*) &hasBook, NULL, NULL, CheckBox, N_("Must not use GUI book") }, { 0, 0, 0, NULL, (void*) &addToList, NULL, NULL, CheckBox, N_("Add this engine to the list") }, { 0, 0, 0, NULL, (void*) &storeVariant, NULL, NULL, CheckBox, N_("Force current variant with this engine") }, -{ 0, 0, 0, NULL, (void*) &engineChoice, (char*) engineNr, engineNr, ComboBox, N_("Load mentioned engine as") }, -{ 0,SAME_ROW, 0, NULL, (void*) &InstallOK, "", NULL, EndMark , "" } +{ 0, 0, 0, NULL, (void*) &InstallOK, "", NULL, EndMark , "" } }; -void -LoadEngineProc () +static int +InstallOK (int n) +{ + if(n && (n = SelectedListBoxItem(&installOptions[1])) > 0) { // called by pressing OK, and engine selected + ASSIGN(engineLine, engineList[n]); + } + PopDown(TransientDlg); // early popdown, to allow FreezeUI to instate grab + if(!secondEng) Load(&first, 0); else Load(&second, 1); + return FALSE; // no double PopDown! +} + +static void +EngSel (int n, int sel) +{ + if(sel < 1) return; + ASSIGN(engineLine, engineList[sel]); + InstallOK(0); +} + +static void +LoadEngineProc (int engineNr, char *title) { isUCI = storeVariant = v1 = useNick = False; addToList = hasBook = True; // defaults - if(engineChoice) free(engineChoice); engineChoice = strdup(engineNr[0]); + secondEng = engineNr; if(engineLine) free(engineLine); engineLine = strdup(""); if(engineDir) free(engineDir); engineDir = strdup(""); if(nickName) free(nickName); nickName = strdup(""); if(params) free(params); params = strdup(""); NamesToList(firstChessProgramNames, engineList, engineMnemonic, "all"); - GenericPopUp(installOptions, _("Load engine"), TransientDlg, BoardWindow, MODAL, 0); + GenericPopUp(installOptions, title, TransientDlg, BoardWindow, MODAL, 0); +} + +void +LoadEngine1Proc () +{ + LoadEngineProc (0, _("Load first engine")); +} + +void +LoadEngine2Proc () +{ + LoadEngineProc (1, _("Load second engine")); } //----------------------------------------------------- Edit Book ----------------------------------------- diff --git a/menus.c b/menus.c index 6f0aebb..f0c7afa 100644 --- a/menus.c +++ b/menus.c @@ -752,7 +752,8 @@ MenuItem actionMenu[] = { }; MenuItem engineMenu[] = { - {N_("Load New Engine ..."), "LoadEngine", LoadEngineProc}, + {N_("Load New 1st Engine ..."), "LoadEngine", LoadEngine1Proc}, + {N_("Load New 2nd Engine ..."), "LoadEngine", LoadEngine2Proc}, {"----", NULL, NothingProc}, {N_("Engine #1 Settings ..."), "Engine#1Settings", FirstSettingsProc}, {N_("Engine #2 Settings ..."), "Engine#2Settings", SecondSettingsProc}, diff --git a/menus.h b/menus.h index e053d91..47920a7 100644 --- a/menus.h +++ b/menus.h @@ -144,7 +144,8 @@ void TimeControlProc P((void)); void OptionsProc P((void)); void NewVariantProc P((void)); void IcsTextProc P((void)); -void LoadEngineProc P((void)); +void LoadEngine1Proc P((void)); +void LoadEngine2Proc P((void)); void FirstSettingsProc P((void)); void SecondSettingsProc P((void)); void GameListOptionsProc P((void));