X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=dialogs.c;h=586e62895853d42d1922e5dd0d015798541bf885;hb=94cd32222362d41e436ac6d9d308b397e61c91b8;hp=df8750ab0d76fe2d5ef47b1b8077da2e38f8cfea;hpb=9d455a7f4ce66cc25d540d4dc5a65fdb1895cc2e;p=xboard.git diff --git a/dialogs.c b/dialogs.c index df8750a..586e628 100644 --- a/dialogs.c +++ b/dialogs.c @@ -1838,15 +1838,15 @@ static void PMSelect (int n) { // user callback for board context menus if (pmFromX < 0 || pmFromY < 0) return; - if(n == 25) DropMenuEvent(dropMenuTranslation[values[n]], pmFromX, pmFromY); - else EditPositionMenuEvent(pieceMenuTranslation[n-23][values[n]], pmFromX, pmFromY); + if(n == W_DROP) DropMenuEvent(dropMenuTranslation[values[n]], pmFromX, pmFromY); + else EditPositionMenuEvent(pieceMenuTranslation[n - W_MENUW][values[n]], pmFromX, pmFromY); } int CCB (int n) { shiftKey = (ShiftKeys() & 3) != 0; - ClockClick(n == 12); + ClockClick(n == W_BLACK); } Option mainOptions[] = { // description of main window in terms of generic dialog creator @@ -2067,6 +2067,7 @@ static char *FileTypes[] = { "Chess Positions", "Tournaments", "Opening Books", +"Sound files", "Settings (*.ini)", "Log files", "All files", @@ -2084,6 +2085,7 @@ static char *Extensions[] = { ".fen .epd .pos", ".trn", ".bin", +".wav", ".ini", ".log", "", @@ -2101,6 +2103,7 @@ void FileSelProc P((int n, int sel)); void SetTypeFilter P((int n)); int BrowseOK P((int n)); void Switch P((int n)); +void CreateDir P((int n)); Option browseOptions[] = { { 0, LR|T2T, 500, NULL, NULL, NULL, NULL, Label, title }, @@ -2110,7 +2113,8 @@ Option browseOptions[] = { { 0, R2R|TT|SAME_ROW, 70, NULL, (void*) &Switch, NULL, NULL, Button, N_("by type") }, { 300, L2L|TB, 250, NULL, (void*) folderList, (char*) &DirSelProc, NULL, ListBox, "" }, { 300, R2R|TB|SAME_ROW,250, NULL, (void*) fileList, (char*) &FileSelProc, NULL, ListBox, "" }, -{ 0, 0, 350, NULL, (void*) &fileName, NULL, NULL, TextBox, N_("Filename:") }, +{ 0, 0, 300, NULL, (void*) &fileName, NULL, NULL, TextBox, N_("Filename:") }, +{ 0, SAME_ROW, 120, NULL, (void*) &CreateDir, NULL, NULL, Button, N_("New directory") }, { 0, COMBO_CALLBACK, 150, NULL, (void*) &SetTypeFilter, NULL, FileTypes, ComboBox, N_("File type:") }, { 0, SAME_ROW, 0, NULL, (void*) &BrowseOK, "", NULL, EndMark , "" } }; @@ -2228,6 +2232,21 @@ Refresh (int pathFlag) ListDir(pathFlag); // and make new one LoadListBox(&browseOptions[5], ""); LoadListBox(&browseOptions[6], ""); + SetWidgetLabel(&browseOptions[0], title); +} + +void +CreateDir (int n) +{ + char *name, *errmsg = ""; + GetWidgetText(&browseOptions[n-1], &name); + if(!name[0]) errmsg = _("FIRST TYPE DIRECTORY NAME HERE"); else + if(mkdir(name, 0755)) errmsg = _("TRY ANOTHER NAME"); + else { + chdir(name); + Refresh(-1); + } + SetWidgetText(&browseOptions[n-1], errmsg, BrowserDlg); } void @@ -2256,7 +2275,6 @@ DirSelProc (int n, int sel) { if(!chdir(folderList[sel])) { // cd succeeded, so we are in new directory now Refresh(-1); - SetWidgetLabel(&browseOptions[0], title); } } @@ -2264,19 +2282,19 @@ FILE * Browse (DialogClass dlg, char *label, char *proposed, char *ext, Boolean pathFlag, char *mode, char **name, FILE **fp) { int j=0; - savFP = fp; savMode = mode, namePtr = name, savCps = currentCps, oldVal = values[8]; // save params, for use in callback + savFP = fp; savMode = mode, namePtr = name, savCps = currentCps, oldVal = values[9]; // save params, for use in callback ASSIGN(extFilter, ext); ASSIGN(fileName, proposed ? proposed : ""); for(j=0; Extensions[j]; j++) // look up actual value in list of possible values, to get selection nr if(extFilter && !strcmp(extFilter, Extensions[j])) break; if(Extensions[j] == NULL) { j++; ASSIGN(FileTypes[j], extFilter); } - browseOptions[8].value = j; + browseOptions[9].value = j; browseOptions[6].textValue = (char*) (pathFlag ? NULL : &FileSelProc); // disable file listbox during path browsing ListDir(pathFlag); currentCps = NULL; if(GenericPopUp(browseOptions, label, BrowserDlg, dlg, MODAL, 0)) { } - SetWidgetLabel(&browseOptions[8], FileTypes[j]); + SetWidgetLabel(&browseOptions[9], FileTypes[j]); }