X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwedittags.c;h=bd340380dde70ffd9c6797806525dde1ccc5d751;hb=5deaf4dafd42e67ed6c9037d40b9c7d777870e33;hp=965e7237b0caf6282834e379f1f4e70b3347592b;hpb=d5c36d4669c2f625af7c280c5a4ebdc4ba284e95;p=xboard.git diff --git a/winboard/wedittags.c b/winboard/wedittags.c index 965e723..bd34038 100644 --- a/winboard/wedittags.c +++ b/winboard/wedittags.c @@ -1,7 +1,7 @@ /* * wedittags.c -- EditTags window for WinBoard * - * Copyright 1995,2009 Free Software Foundation, Inc. + * Copyright 1995, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. * * Enhancements Copyright 2005 Alessandro Scotti * @@ -39,8 +39,10 @@ #include "backend.h" #include "winboard.h" +#define _(s) T_(s) + /* Module globals */ -static char *editTagsText; +static char *editTagsText, **resPtr; BOOL editTagsUp = FALSE; BOOL canEditTags = FALSE; @@ -63,18 +65,23 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_INITDIALOG: /* message: initialize dialog box */ /* Initialize the dialog items */ - hwndText = GetDlgItem(hDlg, OPT_TagsText); + Translate(hDlg, DLG_EditTags); + hwndText = GetDlgItem(hDlg, OPT_TagsText); SendMessage(hwndText, WM_SETFONT, (WPARAM)font[boardSize][EDITTAGS_FONT]->hf, MAKELPARAM(FALSE, 0)); SetDlgItemText(hDlg, OPT_TagsText, editTagsText); EnableWindow(GetDlgItem(hDlg, OPT_TagsCancel), canEditTags); EnableWindow(GetDlgItem(hDlg, OPT_EditTags), !canEditTags); SendMessage(hwndText, EM_SETREADONLY, !canEditTags, 0); + if (bookUp) { + SetWindowText(hDlg, _("Edit Book")); + SetFocus(hwndText); + } else if (canEditTags) { - SetWindowText(hDlg, "Edit Tags"); + SetWindowText(hDlg, _("Edit Tags")); SetFocus(hwndText); } else { - SetWindowText(hDlg, "Tags"); + SetWindowText(hDlg, _("Tags")); SetFocus(GetDlgItem(hDlg, IDOK)); } if (!editTagsDialog) { @@ -111,6 +118,7 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: + case OPT_TagsSave: if (canEditTags) { char *p, *q; /* Read changed options from the dialog box */ @@ -119,18 +127,20 @@ 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; + *p = NULLCHAR; err = 0; + if(resPtr) *resPtr = strdup(str); else + if(bookUp) SaveToBook(str), DisplayBook(currentMove); else err = ReplaceTags(str, &gameInfo); - if (err) DisplayError("Error replacing tags.", err); + if (err) DisplayError(_("Error replacing tags."), err); free(str); } - TagsPopDown(); + if(LOWORD(wParam) == IDOK) TagsPopDown(); return TRUE; case IDCANCEL: @@ -168,8 +178,8 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) VOID TagsPopDown(void) { if (editTagsDialog) ShowWindow(editTagsDialog, SW_HIDE); - CheckMenuItem(GetMenu(hwndMain), IDM_EditTags, MF_UNCHECKED); - editTagsUp = FALSE; + CheckMenuItem(GetMenu(hwndMain), IDM_Tags, MF_UNCHECKED); + editTagsUp = bookUp = FALSE; } @@ -198,10 +208,11 @@ VOID EitherTagsPopUp(char *tags, char *msg, BOOLEAN edit) editTagsText = p; canEditTags = edit; - CheckMenuItem(GetMenu(hwndMain), IDM_EditTags, MF_CHECKED); + CheckMenuItem(GetMenu(hwndMain), IDM_Tags, MF_CHECKED); if (editTagsDialog) { SendMessage(editTagsDialog, WM_INITDIALOG, 0, 0); ShowWindow(editTagsDialog, SW_SHOW); + if(bookUp) SetFocus(hwndMain); } else { lpProc = MakeProcInstance((FARPROC)EditTagsDialog, hInst); CreateDialog(hInst, MAKEINTRESOURCE(DLG_EditTags), @@ -218,14 +229,15 @@ VOID TagsPopUp(char *tags, char *msg) SetActiveWindow(hwnd); } -VOID EditTagsPopUp(char *tags) +VOID EditTagsPopUp(char *tags, char **dest) { + resPtr = dest; EitherTagsPopUp(tags, "", TRUE); } VOID EditTagsProc() { - if (editTagsUp) { + if (editTagsUp && !bookUp) { TagsPopDown(); } else { EditTagsEvent();