From dd94bfa89dd6dd1238c3f7063e532ab3ed2d0858 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Sat, 20 Dec 2014 20:47:05 +0100 Subject: [PATCH] Implement -positionDir option GTK This volatile option determines where Load Position starts browsing. --- args.h | 1 + common.h | 1 + gtk/xboard.c | 8 ++++++++ menus.c | 4 +++- 4 files changed, 13 insertions(+), 1 deletions(-) diff --git a/args.h b/args.h index 1ceb1a4..8e824a5 100644 --- a/args.h +++ b/args.h @@ -283,6 +283,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 2b0ddf0..b271821 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 -- 1.7.0.4