}
void
+StartDir (char *filter, char *newName)
+{
+ static char *gamesDir, *trnDir, *imgDir, *bookDir;
+ static char curDir[MSG_SIZ];
+ char **res = NULL;
+ if(!filter || !*filter) return;
+ if(strstr(filter, "pgn")) res = &gamesDir; else
+ if(strstr(filter, "bin")) res = &bookDir; else
+ if(strstr(filter, "png")) res = &imgDir; else
+ if(strstr(filter, "trn")) res = &trnDir; else
+ if(strstr(filter, "fen")) res = &appData.positionDir;
+ if(res) {
+ if(newName) {
+ char *p, *q;
+ if(*newName) {
+ ASSIGN(*res, newName);
+ for(p=*res; q=strchr(p, '/');) p = q + 1; *p = NULLCHAR;
+ }
+ if(*curDir) chdir(curDir);
+ *curDir = NULLCHAR;
+ } else {
+ getcwd(curDir, MSG_SIZ);
+ if(*res && **res) chdir(*res);
+ }
+ }
+}
+
+void
Browse (DialogClass dlg, char *label, char *proposed, char *ext, Boolean pathFlag, char *mode, char **name, FILE **fp)
{
int j=0;
void AddHandler P((Option *opt, DialogClass dlg, int nr));
void SendText P((int n));
void DisplayLogos P((Option *left, Option *right));
+void StartDir P((char *filter, char *newName));
void Browse P((DialogClass dlg, char *label, char *proposed, char *ext,
Boolean pathFlag, char *mode, char **name, FILE **fp));
void FileNamePopUpWrapper P((char *label, char *def, char *filter, FileProc proc,
char *cp;
char curDir[MSG_SIZ];
- if(def && *def && def[strlen(def)-1] == '/') {
- getcwd(curDir, MSG_SIZ);
- chdir(def);
- }
+ StartDir(filter, NULL); // change to start directory for this file type
/* make a copy of the filter string, so that strtok can work with it*/
cp = strdup(filter);
ASSIGN(*name, filename);
ScheduleDelayedEvent(DelayedLoad, 50);
}
+ StartDir(filter, filename);
g_free (filename);
- };
+ }
+ else StartDir(filter, "");
gtk_widget_destroy (dialog);
ModeHighlight();
gtkfilter = gtk_file_filter_new();
gtkfilter_all = gtk_file_filter_new();
- char fileext[MSG_SIZ];
+ char fileext[MSG_SIZ], *filter = currentOption[opt_i].textValue;
+
+ StartDir(filter, NULL); // change to start directory for this file type
/* select file or folder depending on option_type */
if (currentOption[opt_i].type == PathName)
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
entry = currentOption[opt_i].handle;
gtk_entry_set_text (GTK_ENTRY (entry), filename);
+ StartDir(filter, filename); // back to original, and remember this one
g_free (filename);
-
}
+ else StartDir(filter, ""); // change back to original directory
gtk_widget_destroy (dialog);
dialog = NULL;
}
char *gameCopyFilename, *gamePasteFilename;
Boolean saveSettingsOnExit;
char *settingsFileName;
+char gamesDir[MSG_SIZ], positionsDir[MSG_SIZ], textureDir[MSG_SIZ], bookDir[MSG_SIZ], piecesDir[MSG_SIZ];
static int
LoadGamePopUp (FILE *f, int gameNumber, char *title)
void
LoadPositionProc()
{
- static char buf[MSG_SIZ];
if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
Reset(FALSE, TRUE);
}
- snprintf(buf, MSG_SIZ, "%s/", appData.positionDir);
- FileNamePopUp(_("Load position file name?"), buf, ".fen .epd .pos", LoadPosition, "rb");
+ FileNamePopUp(_("Load position file name?"), "", ".fen .epd .pos", LoadPosition, "rb");
}
void