From: H.G.Muller Date: Sat, 20 Dec 2014 19:47:05 +0000 (+0100) Subject: Implement -positionDir option GTK X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=54def5260846784eea25fad94a8ef0c34dcf807b;p=xboard.git Implement -positionDir option GTK This volatile option determines where Load Position starts browsing. --- diff --git a/args.h b/args.h index 270baf5..f0e6423 100644 --- a/args.h +++ b/args.h @@ -284,6 +284,7 @@ ArgDescriptor argDescriptors[] = { { "lpf", ArgFilename, (void *) &appData.loadPositionFile, FALSE, INVALID }, { "loadPositionIndex", ArgInt, (void *) &appData.loadPositionIndex, FALSE, (ArgIniType) 1 }, { "lpi", ArgInt, (void *) &appData.loadPositionIndex, FALSE, INVALID }, + { "positionDir", ArgFilename, (void *) &appData.positionDir, FALSE, (ArgIniType) "" }, { "savePositionFile", ArgFilename, (void *) &appData.savePositionFile, FALSE, (ArgIniType) "" }, { "spf", ArgFilename, (void *) &appData.savePositionFile, FALSE, INVALID }, { "matchMode", ArgBoolean, (void *) &appData.matchMode, FALSE, (ArgIniType) FALSE }, diff --git a/common.h b/common.h index a082aa2..492c507 100644 --- a/common.h +++ b/common.h @@ -486,6 +486,7 @@ typedef struct { char *pgnName[ENGINES]; Boolean firstPlaysBlack; Boolean noChessProgram; + char *positionDir; char *host[ENGINES]; char *themeNames; char *pieceDirectory; diff --git a/gtk/xboard.c b/gtk/xboard.c index 8a2b887..ef35f2a 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -2317,6 +2317,12 @@ void FileNamePopUpWrapper(label, def, filter, proc, pathFlag, openMode, name, fp char fileext[10] = ""; char *result = NULL; char *cp; + char curDir[MSG_SIZ]; + + if(def && *def && def[strlen(def)-1] == '/') { + getcwd(curDir, MSG_SIZ); + chdir(def); + } /* make a copy of the filter string, so that strtok can work with it*/ cp = strdup(filter); @@ -2396,6 +2402,8 @@ void FileNamePopUpWrapper(label, def, filter, proc, pathFlag, openMode, name, fp gtk_widget_destroy (dialog); ModeHighlight(); + if(def && *def && def[strlen(def)-1] == '/') chdir(curDir); + free(cp); return; diff --git a/menus.c b/menus.c index 086c9b4..653d978 100644 --- a/menus.c +++ b/menus.c @@ -173,10 +173,12 @@ ReloadPositionProc () void LoadPositionProc() { + static char buf[MSG_SIZ]; if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) { Reset(FALSE, TRUE); } - FileNamePopUp(_("Load position file name?"), "", ".fen .epd .pos", LoadPosition, "rb"); + snprintf(buf, MSG_SIZ, "%s/", appData.positionDir); + FileNamePopUp(_("Load position file name?"), buf, ".fen .epd .pos", LoadPosition, "rb"); } void