From 039ec08b2e0355d7fdd1cc496f7aa800be51bab3 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Fri, 3 Dec 2010 09:27:58 +0100 Subject: [PATCH] Provide menus for editing WinBoard engine and server lists The Edit Tags dialog in the WB front-end is adapted to act as a general edit for string variables, by giving it an extra parameter to indicate where to store the edited result. Menu items are added to invoke this dialog for editing the /first, /secondChessProgramNames and /icsNames options. This solves the problem that people would have to edit an ini file that they can no longer locate (because the %APPDATA% folder has different names and locations in the various Windows versions, and is often a hidden folder on top of that). There is a slight memory leak here, as the memory for the previous value of the altered string option is not freed. --- backend.c | 2 +- frontend.h | 2 +- winboard/resource.h | 3 +++ winboard/wedittags.c | 8 +++++--- winboard/winboard.c | 12 ++++++++++++ winboard/winboard.rc | 3 +++ xedittags.c | 3 ++- 7 files changed, 27 insertions(+), 6 deletions(-) diff --git a/backend.c b/backend.c index 847b609..410488b 100644 --- a/backend.c +++ b/backend.c @@ -11641,7 +11641,7 @@ void EditTagsEvent() { char *tags = PGNTags(&gameInfo); - EditTagsPopUp(tags); + EditTagsPopUp(tags, NULL); free(tags); } diff --git a/frontend.h b/frontend.h index 8e57e58..0946e3b 100644 --- a/frontend.h +++ b/frontend.h @@ -177,7 +177,7 @@ void GameListHighlight P((int index)); void GameListDestroy P((void)); /* these are in wedittags.c */ -void EditTagsPopUp P((char *tags)); +void EditTagsPopUp P((char *tags, char **dest)); void TagsPopUp P((char *tags, char *msg)); void TagsPopDown P((void)); diff --git a/winboard/resource.h b/winboard/resource.h index cee0fec..e063e42 100644 --- a/winboard/resource.h +++ b/winboard/resource.h @@ -49,11 +49,14 @@ #define IDM_ReloadCMailMsg 165 #define IDM_Book 166 #define IDM_AboutGame 167 +#define IDM_EditServers 169 #define IDM_ShowGameList 170 #define IDM_EditTags 171 #define IDM_Tags 172 #define IDM_Comment 173 #define IDM_Debug 174 +#define IDM_EditProgs1 175 +#define IDM_EditProgs2 176 #define IDM_AnalysisMode 177 #define IDM_AnalyzeFile 178 #define IDM_Annotate 179 diff --git a/winboard/wedittags.c b/winboard/wedittags.c index 0cf3ca3..f6782bb 100644 --- a/winboard/wedittags.c +++ b/winboard/wedittags.c @@ -42,7 +42,7 @@ #define _(s) T_(s) /* Module globals */ -static char *editTagsText; +static char *editTagsText, **resPtr; BOOL editTagsUp = FALSE; BOOL canEditTags = FALSE; @@ -122,12 +122,13 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) GetWindowText(hwndText, str, len + 1); p = q = str; while (*q) { - if (*q == '\r'|| *q == '\n') + if (*q == '\r') q++; else *p++ = *q++; } *p = NULLCHAR; + if(resPtr) *resPtr = strdup(str), err = 0; else err = ReplaceTags(str, &gameInfo); if (err) DisplayError(_("Error replacing tags."), err); @@ -221,8 +222,9 @@ VOID TagsPopUp(char *tags, char *msg) SetActiveWindow(hwnd); } -VOID EditTagsPopUp(char *tags) +VOID EditTagsPopUp(char *tags, char **dest) { + resPtr = dest; EitherTagsPopUp(tags, "", TRUE); } diff --git a/winboard/winboard.c b/winboard/winboard.c index 12bd085..24fa20e 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -4921,6 +4921,18 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ShowGameListProc(); break; + case IDM_EditProgs1: + EditTagsPopUp(firstChessProgramNames, &firstChessProgramNames); + break; + + case IDM_EditProgs2: + EditTagsPopUp(secondChessProgramNames, &secondChessProgramNames); + break; + + case IDM_EditServers: + EditTagsPopUp(icsNames, &icsNames); + break; + case IDM_EditTags: case IDM_Tags: EditTagsProc(); diff --git a/winboard/winboard.rc b/winboard/winboard.rc index 235f622..ca8624f 100644 --- a/winboard/winboard.rc +++ b/winboard/winboard.rc @@ -1204,6 +1204,8 @@ BEGIN END POPUP "E&ngine" BEGIN + MENUITEM "Install 1st...", IDM_EditProgs1 + MENUITEM "Install 2nd...", IDM_EditProgs2 MENUITEM SEPARATOR MENUITEM "Engine #&1 Settings...", IDM_Engine1Options MENUITEM "Engine #&2 Settings...", IDM_Engine2Options @@ -1229,6 +1231,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Soun&ds...", IDM_Sounds MENUITEM "&ICS...", IDM_IcsOptions, GRAYED + MENUITEM "Add ICS...", IDM_EditServers MENUITEM "Comm&unications...", IDM_CommPort MENUITEM SEPARATOR MENUITEM "Save Settings &Now", IDM_SaveSettings diff --git a/xedittags.c b/xedittags.c index 331f401..e9484f4 100644 --- a/xedittags.c +++ b/xedittags.c @@ -349,8 +349,9 @@ void TagsPopUp(tags, msg) } -void EditTagsPopUp(tags) +void EditTagsPopUp(tags, dest) char *tags; + char **dest; { Widget textw; Arg args[16]; -- 1.7.0.4