Implement -positionDir option GTK
[xboard.git] / gtk / xboard.c
index 8a2b887..ef35f2a 100644 (file)
@@ -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;