Implement -positionDir option GTK
[xboard.git] / gtk / xboard.c
index 8958e3c..ef35f2a 100644 (file)
@@ -890,6 +890,7 @@ main (int argc, char **argv)
        snprintf(svgDir, MSG_SIZ, "%s/themes/default", dataDir);
        suppress = (argc == 1 || argc > 1 && argv[1][00] != '-'); // OSX sends signal even if name was already argv[1]!
        g_signal_connect(theApp, "NSApplicationOpenFile", G_CALLBACK(StartNewXBoard), NULL);
+       g_signal_connect(theApp, "NSApplicationWillTerminate", G_CALLBACK(ExitEvent), NULL);
        // we must call application ready before we can get the signal,
        // and supply a (dummy) menu bar before that, to avoid problems with dual apples in it
        gtkosx_application_set_menu_bar(theApp, GTK_MENU_SHELL(gtk_menu_bar_new()));
@@ -1691,7 +1692,7 @@ ReSize (WindowPlacement *wp)
        h = BOARD_HEIGHT * (squareSize + lineGap) + lineGap;
        if(optList[W_BOARD].max   > w) optList[W_BOARD].max = w;
        if(optList[W_BOARD].value > h) optList[W_BOARD].value = h;
-       first = 0;
+       first = appData.fixedSize;
 }
 
 static guint delayedDragTag = 0;
@@ -2316,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);
@@ -2395,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;