OK, I tried another approach. I just pushed a commit for that to hgm.nubati.net.
I noticed that SVGDIR was used only in 3 places in the entire source: in draw.c to load piece images, in xboard.c to load the taskbar icons, and in xengineoutput.c to load the Engine Output icons. The latter two tasks were basically identical, except that in xengineoutput.c the icons were stored in an array iconsGTK[], while in xboard.c they were stored in separate variables WhiteIcon and BlackIcon. I now combined the code for that in a new routine LoadIconFile(), put in xboard.c, which can be called from the two places with the basename of the icon file to load, so that the caller can the store it where it wants. LoadIconFile appends the extension to the basename, so it can be easily made dependent on the __APPLE__ switch for #defining IMG as either .svg or .png .
Due to this change SVGDIR is used nowhere anymore as a string concatenation (like SVGDIR "/something"), which is a C construct processed at compile time, which would only be possible if SVGDIR was a litteral string constant (like "/usr/local/share/games/xboard/themes/defaults"). So I replaced SVGDIR everywhere in the source (well, only two places now) by a
variable svgDir, which is
initialized to SVGDIR. In Linux that has the same effect. But it gives us the opportunity to
overwrite it at run time, after we retrieved the bundle path. To this end I added a line in the __APPLE__ patch at the top of main():
- Code: Select all
snprintf(svgDir, MSG_SIZ, "%s/Contents/Resources/themes/defaults", path);
which constructs the SVGDIR name from 'path' (the path name of the bundle root).
Please check if the filename this constructs is indeed where you store pieces and icons in the bundle.This should solve both the icon problem and the reading of default pieces regardless of the -pid setting.