Expand ~~/ to bundle path (OSX)
[xboard.git] / gtk / xboard.c
index b76faef..16d7a9f 100644 (file)
@@ -169,7 +169,7 @@ extern char *getenv();
 
 #ifdef OSX
 #  include "gtkmacintegration/gtkosxapplication.h"
-   // prevent pathname of positional file argument provided by OSx being be mistaken for option name
+   // prevent pathname of positional file argument provided by OS X being be mistaken for option name
    // (price is that we won't recognize Windows option format anymore).
 #  define SLASH '-'
    // redefine some defaults
@@ -177,8 +177,11 @@ extern char *getenv();
 #  undef SYSCONFDIR
 #  define ICS_LOGON "Library/Preferences/XboardICS.conf"
 #  define SYSCONFDIR "../etc"
+#  define DATADIR dataDir
+   char *dataDir; // for expanding ~~
 #else
 #  define SLASH '/'
+#  define DATADIR "~~"
 #endif
 
 #ifdef __EMX__
@@ -772,6 +775,7 @@ main (int argc, char **argv)
 #ifdef OSX
     {   // prepare to catch OX OpenFile signal, which will tell us the clicked file
        GtkosxApplication *theApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
+       dataDir = gtkosx_application_get_bundle_path();
        g_signal_connect(theApp, "NSApplicationOpenFile", G_CALLBACK(StartNewXBoard), 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
@@ -1776,26 +1780,15 @@ TempForwardProc (Widget w, XEvent *event, String *prms, Cardinal *nprms)
     ForwardEvent();
        TempBackwardActive = False;
 }
-
-void
-ManInner (Widget w, XEvent *event, String *prms, Cardinal *nprms)
-{   // called as key binding
-    char buf[MSG_SIZ];
-    String name;
-    if (nprms && *nprms > 0)
-      name = prms[0];
-    else
-      name = "xboard";
-    snprintf(buf, sizeof(buf), "xterm -e man %s &", name);
-    system(buf);
-}
 #endif
 
 void
 ManProc ()
 {   // called from menu
-#ifdef TODO_GTK
-    ManInner(NULL, NULL, NULL, NULL);
+#ifdef OSX
+    system("%s ./man.command", appData.sysOpen);
+#else
+    system("xterm -e man xboard &");
 #endif
 }