Make SVGDIR a variable
[xboard.git] / gtk / xboard.c
index 5befaa3..2c51e01 100644 (file)
@@ -172,6 +172,7 @@ extern char *getenv();
    // 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 '-'
+#  define IMG ".png"
    // redefine some defaults
 #  undef ICS_LOGON
 #  undef DATADIR
@@ -183,6 +184,7 @@ extern char *getenv();
    char masterSettings[MSG_SIZ];
 #else
 #  define SLASH '/'
+#  define IMG ".svg"
 #endif
 
 #ifdef __EMX__
@@ -386,9 +388,10 @@ ParseFont (char *name, int number)
     //       defer processing it until we know if it matches our board size
     if(!strstr(name, "-*-") &&       // ignore X-fonts
        size >= 0 && size<MAX_SIZE) { // for now, fixed limit
-       fontTable[number][size] = name = strdup(strchr(name, ':')+1);
+       fontTable[number][size] = strdup(strchr(name, ':')+1);
        fontValid[number][size] = True;
-    } else return;
+    }
+    return;
   }
   switch(number) {
     case 0: // CLOCK_FONT
@@ -659,10 +662,16 @@ InitializeFonts (int clockFontPxlSize, int coordFontPxlSize, int fontPxlSize)
        appData.coordFont = fontTable[COORD_FONT][squareSize];
     if(!fontIsSet[CONSOLE_FONT] && fontValid[CONSOLE_FONT][squareSize])
        appData.icsFont = fontTable[CONSOLE_FONT][squareSize];
+    if(!fontIsSet[EDITTAGS_FONT] && fontValid[EDITTAGS_FONT][squareSize])
+       appData.tagsFont = fontTable[EDITTAGS_FONT][squareSize];
     if(!fontIsSet[COMMENT_FONT] && fontValid[COMMENT_FONT][squareSize])
        appData.commentFont = fontTable[COMMENT_FONT][squareSize];
+    if(!fontIsSet[MOVEHISTORY_FONT] && fontValid[MOVEHISTORY_FONT][squareSize])
+       appData.historyFont = fontTable[MOVEHISTORY_FONT][squareSize];
+    if(!fontIsSet[GAMELIST_FONT] && fontValid[GAMELIST_FONT][squareSize])
+       appData.gameListFont = fontTable[GAMELIST_FONT][squareSize];
 
-    appData.font = InsertPxlSize(appData.font, fontPxlSize);
+    appData.font = InsertPxlSize(appData.font, coordFontPxlSize);
     appData.clockFont = InsertPxlSize(appData.clockFont, clockFontPxlSize);
     appData.coordFont = InsertPxlSize(appData.coordFont, coordFontPxlSize);
     appData.icsFont = InsertPxlSize(appData.icsFont, coordFontPxlSize);
@@ -799,6 +808,15 @@ SlaveResize (Option *opt)
   gtk_window_resize(GTK_WINDOW(shells[DummyDlg]), slaveW + opt->max, slaveH + opt->value);
 }
 
+GdkPixbuf *
+LoadIconFile (gchar *svgFilename)
+{
+    char buf[MSG_SIZ];
+
+    snprintf(buf, MSG_SIZ, "%s/%s" IMG, svgDir, svgFilename);
+    return gdk_pixbuf_new_from_file(buf, NULL);
+}
+
 #ifdef __APPLE__
 static char clickedFile[MSG_SIZ];
 static int suppress;
@@ -851,6 +869,7 @@ main (int argc, char **argv)
        theApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
        strncpy(dataDir, path, MSG_SIZ);
        snprintf(masterSettings, MSG_SIZ, "%s/Contents/Resources/etc/xboard.conf", path);
+       snprintf(svgDir, MSG_SIZ, "%s/Contents/Resources/share/xboard/themes/default", path);
        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);
        // we must call application ready before we can get the signal,
@@ -1118,8 +1137,8 @@ main (int argc, char **argv)
     /*
      * Create an icon. (Use two icons, to indicate whther it is white's or black's turn.)
      */
-    WhiteIcon  = gdk_pixbuf_new_from_file(SVGDIR "/icon_white.svg", NULL);
-    BlackIcon  = gdk_pixbuf_new_from_file(SVGDIR "/icon_black.svg", NULL);
+    WhiteIcon  = LoadIconFile("icon_white");
+    BlackIcon  = LoadIconFile("icon_black");
     SetClockIcon(0); // sets white icon