X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xoptions.c;h=37e6838c4a13e653a8c412ed881d2e4bded97bec;hb=d0b1d703d860216be661b8b2db99817e9fdb09bf;hp=04198cae681488ec11521e55231a59b8ea1269b1;hpb=5679f357b11ddeae09d5d3ba6613b6bda1dc00e9;p=xboard.git diff --git a/xoptions.c b/xoptions.c index 04198ca..37e6838 100644 --- a/xoptions.c +++ b/xoptions.c @@ -727,6 +727,7 @@ void CreateComboPopup(parent, name, n, mb) typedef void ButtonCallback(int n); +extern WindowPlacement wpComment, wpTags; char *trialSound; static int oldCores, oldPonder; int MakeColors P((void)); @@ -737,7 +738,7 @@ void GenericReadout(); Widget shells[10]; Widget marked[10]; Boolean shellUp[10]; -WindowPlacement *wp[10]; +WindowPlacement *wp[10] = { NULL, &wpComment, &wpTags }; Option *dialogOptions[10]; void MarkMenu(char *item, int dlgNr) @@ -1327,7 +1328,7 @@ GenericPopUp(Option *option, char *title, int dlgNr) static char pane[6] = "paneX"; Widget texts[100], forelast = NULL, anchor, widest, lastrow = NULL; - if(shellUp[dlgNr]) return 0; // already up + if(shellUp[dlgNr]) return 0; // already up if(dlgNr && shells[dlgNr]) { XtPopup(shells[dlgNr], XtGrabNone); shellUp[dlgNr] = True; @@ -1797,6 +1798,92 @@ void IcsTextProc(w, event, prms, nprms) GenericPopUp(textOptions, _("ICS text menu"), 3); } +static char *commentText; +static int commentIndex; +void ClearComment P((int n)); +extern char commentTranslations[]; + +void NewComCallback(int n) +{ + ReplaceComment(commentIndex, commentText); +} + +void SaveChanges(int n) +{ + Arg args[16]; + XtSetArg(args[0], XtNstring, &commentText); + XtGetValues(currentOption[0].handle, args, 1); + ReplaceComment(commentIndex, commentText); +} + +Option commentOptions[] = { +{ 0xD, 200, 300, NULL, (void*) &commentText, "", NULL, TextBox, "" }, +{ 0, 0, 0, NULL, (void*) &ClearComment, NULL, NULL, Button, "clear" }, +{ 0, 1, 0, NULL, (void*) &SaveChanges, NULL, NULL, Button, "save changes" }, +{ 0, 1, 0, NULL, (void*) &NewComCallback, "", NULL, EndMark , "" } +}; + +void ClearComment(int n) +{ + XtCallActionProc(commentOptions[0].handle, "select-all", NULL, NULL, 0); + XtCallActionProc(commentOptions[0].handle, "kill-selection", NULL, NULL, 0); +} + +void NewCommentPopup(char *title, char *text, int index) +{ + Widget edit; + Arg args[16]; + + if(shells[1]) { // if already exists, alter title and content + XtSetArg(args[0], XtNtitle, title); + XtSetValues(shells[1], args, 1); + XtSetArg(args[0], XtNstring, text); + XtSetValues(commentOptions[0].handle, args, 1); + } + commentText = text; + commentIndex = index; + MarkMenu("menuView.Show Comments", 1); + if(GenericPopUp(commentOptions, title, 1)) + XtOverrideTranslations(commentOptions[0].handle, XtParseTranslationTable(commentTranslations)); +} + +static char *tagsText, *msgText; + +void NewTagsCallback(int n) +{ + ReplaceTags(tagsText, &gameInfo); +} + +void changeTags(int n) +{ + Arg args[16]; + XtSetArg(args[0], XtNstring, &tagsText); + XtGetValues(currentOption[0].handle, args, 1); + ReplaceTags(tagsText, &gameInfo); +} + +Option tagsOptions[] = { +{ 0xD, 200, 250, NULL, (void*) &tagsText, "", NULL, TextBox, "" }, +{ 0, 0, 0, NULL, NULL, NULL, NULL, Label, "" }, +{ 0, 0, 0, NULL, (void*) &changeTags, NULL, NULL, Button, "save changes" }, +{ 0, 1, 0, NULL, (void*) &NewTagsCallback, "", NULL, EndMark , "" } +}; + +void NewTagsPopup(char *text, char *msg) +{ + Widget edit; + Arg args[16]; + + if(shells[2]) { // if already exists, alter title and content + XtSetArg(args[0], XtNstring, text); + XtSetValues(tagsOptions[0].handle, args, 1); + } + tagsText = text; + tagsOptions[1].textValue = msg; + MarkMenu("menuView.Show Tags", 2); + GenericPopUp(tagsOptions, _("Tags"), 2); +} + extern char ICSInputTranslations[]; char *icsText;