X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xoptions.c;h=e823a395baf8d7f82640c7524e52c5081d70189d;hb=971e8861ca82286fa3d6e850dd80277875cee983;hp=f297ab4713acd820ddfdc01099e945c418461f70;hpb=ca4e429b35c3b392bce777857c921307eac3b666;p=xboard.git diff --git a/xoptions.c b/xoptions.c index f297ab4..e823a39 100644 --- a/xoptions.c +++ b/xoptions.c @@ -155,7 +155,7 @@ void SpinCallback(w, client_data, call_data) String name, val; Arg args[16]; char buf[MSG_SIZ], *p; - int j; + int j = 0; // Initialiasation is necessary because the text value may be non-numeric causing the scanf conversion to fail int data = (intptr_t) client_data; XtSetArg(args[0], XtNlabel, &name); @@ -838,6 +838,7 @@ int GenericReadout(int selected) case Fractional: XtSetArg(args[0], XtNstring, &val); XtGetValues(currentOption[i].handle, args, 1); + x = 0.0; // Initialise because sscanf() will fail if non-numeric text is entered sscanf(val, "%f", &x); if(x > currentOption[i].max) x = currentOption[i].max; if(x < currentOption[i].min) x = currentOption[i].min; @@ -935,7 +936,8 @@ GenericPopUp(Option *option, char *title, int dlgNr) unsigned int mask; char def[MSG_SIZ], *msg; static char pane[6] = "paneX"; - Widget texts[100], forelast = NULL, anchor, widest, lastrow = NULL; + Widget texts[100], forelast = NULL, anchor, widest, lastrow = NULL, browse = NULL; + Dimension bWidth = 50; if(shellUp[dlgNr]) return 0; // already up if(dlgNr && shells[dlgNr]) { @@ -1044,7 +1046,7 @@ GenericPopUp(Option *option, char *title, int dlgNr) XtSetArg(args[j], XtNleft, XtChainRight); j++; XtSetArg(args[j], XtNright, XtChainRight); j++; if(option[i].type == FileName || option[i].type == PathName) { - msg = _("browse"); + msg = _("browse"); w = 0; /* automatically scale to width of text */ XtSetArg(args[j], XtNwidth, (XtArgVal) NULL ); j++; } else { @@ -1054,6 +1056,7 @@ GenericPopUp(Option *option, char *title, int dlgNr) } edit = XtCreateManagedWidget(msg, commandWidgetClass, form, args, j); XtAddCallback(edit, XtNcallback, SpinCallback, (XtPointer)(intptr_t) i); + if(w == 0) browse = edit; if(option[i].type != Spin) break; @@ -1161,6 +1164,11 @@ GenericPopUp(Option *option, char *title, int dlgNr) // make an attempt to align all spins and textbox controls maxWidth = maxTextWidth = 0; + if(browse != NULL) { + j=0; + XtSetArg(args[j], XtNwidth, &bWidth); j++; + XtGetValues(browse, args, j); + } for(h=0; h