From: H.G. Muller Date: Mon, 13 Jan 2014 16:09:01 +0000 (+0100) Subject: Allow popup of TC and Common Engine from Tournament dialog X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=df677030bcbab764120077e20f356ed244838710;p=xboard.git Allow popup of TC and Common Engine from Tournament dialog A new dialog class MasterDlg was added, similar to TransientDlg, but to allow two dialogs to be up simultaneously. The Tournament Options dialog was migrated to this class, so it can now get buttons to pop up the Time Control and Common Engine dialog, like WinBoard. It even has a button for the General options dialog. Special care had to be taken to prevent popdown of the MasterDlg when a Transient child is still up (similar to browser or error childs). --- diff --git a/dialogs.c b/dialogs.c index 57b7142..30fea55 100644 --- a/dialogs.c +++ b/dialogs.c @@ -253,11 +253,29 @@ MatchOK (int n) { ASSIGN(appData.participants, engineName); if(!CreateTourney(tfName) || matchMode) return matchMode || !appData.participants[0]; - PopDown(TransientDlg); // early popdown to prevent FreezeUI called through MatchEvent from causing XtGrab warning + PopDown(MasterDlg); // early popdown to prevent FreezeUI called through MatchEvent from causing XtGrab warning MatchEvent(2); // start tourney return FALSE; // no double PopDown! } +static void +DoTimeControl(int n) +{ + TimeControlProc(); +} + +static void +DoCommonEngine(int n) +{ + UciMenuProc(); +} + +static void +DoGeneral(int n) +{ + OptionsProc(); +} + static Option matchOptions[] = { { 0, 0, 0, NULL, (void*) &tfName, ".trn", NULL, FileName, N_("Tournament file: ") }, { 0, 0, 0, NULL, NULL, "", NULL, Label, N_("For concurrent playing of tourney with multiple XBoards:") }, @@ -283,6 +301,9 @@ static Option matchOptions[] = { { 0, -2, 1000000000, NULL, (void*) &appData.loadPositionIndex, "", NULL, Spin, N_("Position Number (-1 or -2 = Auto-Increment):") }, { 0, 0, 1000000000, NULL, (void*) &appData.rewindIndex, "", NULL, Spin, N_("Rewind Index after this many Games (0 = never):") }, { 0, 0, 0, NULL, (void*) &appData.defNoBook, "", NULL, CheckBox, N_("Disable own engine books by default") }, +{ 0, 0, 0, NULL, (void*) &DoTimeControl, NULL, NULL, Button, N_("Time Control") }, +{ 0, SAME_ROW, 0, NULL, (void*) &DoCommonEngine, NULL, NULL, Button, N_("Common Engine") }, +{ 0, SAME_ROW, 0, NULL, (void*) &DoGeneral, NULL, NULL, Button, N_("General Options") }, { 0, 0, 0, NULL, (void*) &ReplaceParticipant, NULL, NULL, Button, N_("Replace Engine") }, { 0, SAME_ROW, 0, NULL, (void*) &UpgradeParticipant, NULL, NULL, Button, N_("Upgrade Engine") }, { 0, SAME_ROW, 0, NULL, (void*) &CloneTourney, NULL, NULL, Button, N_("Clone Tourney") }, @@ -343,7 +364,7 @@ MatchOptionsProc () ASSIGN(tfName, appData.tourneyFile[0] ? appData.tourneyFile : MakeName(appData.defName)); ASSIGN(engineName, appData.participants); ASSIGN(engineMnemonic[0], ""); - GenericPopUp(matchOptions, _("Tournament Options"), TransientDlg, BoardWindow, MODAL, 0); + GenericPopUp(matchOptions, _("Tournament Options"), MasterDlg, BoardWindow, MODAL, 0); } // ------------------------------------------- General Options -------------------------------------------------- diff --git a/dialogs.h b/dialogs.h index ab51fef..f4f56a5 100644 --- a/dialogs.h +++ b/dialogs.h @@ -107,6 +107,7 @@ AskDlg, // this and beyond do grab mouse events (and are destroyed) FatalDlg, BoardWindow, BrowserDlg, +MasterDlg, NrOfDialogs // dummy for total } DialogClass; diff --git a/gtk/xoptions.c b/gtk/xoptions.c index b618013..68eb638 100644 --- a/gtk/xoptions.c +++ b/gtk/xoptions.c @@ -739,7 +739,8 @@ gboolean GenericPopDown(w, resptype, gdata) // I guess BrowserDlg will be abandoned, as GTK has a better browser of its own if(shellUp[BrowserDlg] && dlg != BrowserDlg || dialogError) return True; // prevent closing dialog when it has an open file-browse daughter #else - if(browserUp || dialogError && dlg != FatalDlg) return True; // prevent closing dialog when it has an open file-browse or error-popup daughter + if(browserUp || dialogError && dlg != FatalDlg || dlg == MasterDlg && shellUp[TransientDlg]) + return True; // prevent closing dialog when it has an open file-browse, transient or error-popup daughter #endif shells[dlg] = w; // make sure we pop down the right one in case of multiple instances @@ -1138,6 +1139,7 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent if(wp[dlgNr]) gtk_window_move(GTK_WINDOW(shells[dlgNr]), wp[dlgNr]->x, wp[dlgNr]->y); return 0; } + if(dlgNr == TransientDlg && parent == BoardWindow && shellUp[MasterDlg]) parent = MasterDlg; // MasterDlg can always take role of main window dialogOptions[dlgNr] = option; // make available to callback // post currentOption globally, so Spin and Combo callbacks can already use it diff --git a/xaw/xoptions.c b/xaw/xoptions.c index 1f406cb..8d9141e 100644 --- a/xaw/xoptions.c +++ b/xaw/xoptions.c @@ -333,7 +333,7 @@ SpinCallback (Widget w, XtPointer client_data, XtPointer call_data) if(--j < opt->min) return; } else return; snprintf(buf, MSG_SIZ, "%d", j); - SetWidgetText(opt, buf, TransientDlg); + SetWidgetText(opt, buf, shellUp[TransientDlg] ? TransientDlg : MasterDlg); } static void @@ -626,7 +626,8 @@ GenericPopDown (Widget w, XEvent *event, String *prms, Cardinal *nprms) { // to cause popdown through a translation (Delete Window button!) int dlg = atoi(prms[0]); Widget sh = shells[dlg]; - if(shellUp[BrowserDlg] && dlg != BrowserDlg || dialogError) return; // prevent closing dialog when it has an open file-browse daughter + if(shellUp[BrowserDlg] && dlg != BrowserDlg || dialogError || dlg == MasterDlg && shellUp[TransientDlg]) + return; // prevent closing dialog when it has an open file-browse or transient daughter shells[dlg] = w; PopDown(dlg); shells[dlg] = sh; // restore @@ -920,6 +921,7 @@ GenericPopUp (Option *option, char *title, DialogClass dlgNr, DialogClass parent shellUp[dlgNr] = True; return 0; } + if(dlgNr == TransientDlg && parent == BoardWindow && shellUp[MasterDlg]) parent = MasterDlg; // MasterDlg can always take role of main window dialogOptions[dlgNr] = option; // make available to callback // post currentOption globally, so Spin and Combo callbacks can already use it