Relocate OS X' LOCALEDIR
[xboard.git] / gtk / xboard.c
index 0d04c5b..68d8757 100644 (file)
@@ -176,12 +176,15 @@ extern char *getenv();
    // redefine some defaults
 #  undef ICS_LOGON
 #  undef DATADIR
+#  undef LOCALEDIR
 #  undef SETTINGS_FILE
 #  define ICS_LOGON "Library/Preferences/XboardICS.conf"
 #  define DATADIR dataDir
+#  define LOCALEDIR localeDir
 #  define SETTINGS_FILE masterSettings
 #  define SYNC_MENUBAR gtkosx_application_sync_menubar(theApp)
    char dataDir[MSG_SIZ]; // for expanding ~~
+   char localeDir[MSG_SIZ];
    char masterSettings[MSG_SIZ];
 #else
 #  define SLASH '/'
@@ -639,7 +642,12 @@ void
 ResizeBoardWindow (int w, int h, int inhibit)
 {
     GtkAllocation a;
+    int bw;
 //    if(clockKludge) return; // ignore as long as clock does not have final height
+    gtk_widget_get_allocation(optList[W_BOARD].handle, &a);
+    bw = a.width;
+    gtk_widget_get_allocation(shellWidget, &a);
+    marginW = a.width - bw;
     gtk_widget_get_allocation(optList[W_WHITE].handle, &a);
     w += marginW + 1; // [HGM] not sure why the +1 is (sometimes) needed...
     h += marginH + a.height + 1;
@@ -868,6 +876,10 @@ main (int argc, char **argv)
 #ifdef __APPLE__
     {   // prepare to catch OX OpenFile signal, which will tell us the clicked file
        char *path = gtkosx_application_get_bundle_path();
+#ifdef ENABLE_NLS
+       char *res_path = gtkosx_application_get_resource_path();
+       snprintf(localeDir, MSG_SIZ, "%s/share/locale", res_path); // redefine locale dir for OSX bundle
+#endif
        theApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
        strncpy(dataDir, path, MSG_SIZ);
        snprintf(masterSettings, MSG_SIZ, "%s/Contents/Resources/etc/xboard.conf", path);
@@ -1179,7 +1191,7 @@ main (int argc, char **argv)
        gtk_widget_get_allocation(optList[W_WHITE].handle, &a);
        clockKludge = hc = a.height;
        gtk_widget_get_allocation(boardWidget, &a);
-       marginW =  w - boardWidth; // [HGM] needed to set new shellWidget size when we resize board
+//     marginW =  w - boardWidth; // [HGM] needed to set new shellWidget size when we resize board
        marginH =  h - a.height - hc; // subtract current clock height, so it can be added back dynamically
     }
 
@@ -1647,10 +1659,13 @@ ReSize (WindowPlacement *wp)
        if(sqy < sqx) sqx = sqy;
         if(sqx < 20) return;
        if(appData.overrideLineGap < 0) { // do second iteration with adjusted lineGap
+           int oldSqx = sqx;
            lg = lineGap = sqx < 37 ? 1 : sqx < 59 ? 2 : sqx < 116 ? 3 : 4;
            sqx = (wp->width  - lg - marginW) / BOARD_WIDTH - lg;
            sqy = (wp->height - lg - marginH - hc) / BOARD_HEIGHT - lg;
            if(sqy < sqx) sqx = sqy;
+           lg = sqx < 37 ? 1 : sqx < 59 ? 2 : sqx < 116 ? 3 : 4;
+           if(sqx == oldSqx + 1 && lg == lineGap + 1) sqx = oldSqx, squareSize = 0; // prevent oscillations, force resize by kludge
        }
        if(sqx != squareSize) {
            squareSize = sqx; // adopt new square size