diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2011-12-28 15:57:36 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2011-12-28 15:57:36 -0800 |
commit | 565736a471e9ba66cbc68ce76c90d5e0c2fa57cf (patch) | |
tree | acc50192d0b27d0e48dd6dcd958dd2b15a5f5d10 /macos.c | |
parent | a8676438a72f3016daa74984def979797ded635a (diff) | |
download | subsurface-565736a471e9ba66cbc68ce76c90d5e0c2fa57cf.tar.gz |
Make icon file name OS helper function
This way we can load the correct icon on the Mac without ugly hacks in the
OS independent code.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'macos.c')
-rw-r--r-- | macos.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -2,6 +2,7 @@ /* implements Mac OS X specific functions */ #include "display-gtk.h" #include <CoreFoundation/CoreFoundation.h> +#include <mach-o/dyld.h> static CFURLRef fileURL; static CFPropertyListRef propertyList; @@ -94,3 +95,23 @@ const char *subsurface_USB_name() { return "/dev/tty.SLAB_USBtoUART"; } + +#define REL_ICON_PATH "Resources/Subsurface.icns" +const char *subsurface_icon_name() +{ + static char path[1024]; + char *ptr1, *ptr2; + uint32_t size = sizeof(path); /* need extra space to copy icon path */ + if (_NSGetExecutablePath(path, &size) == 0) { + ptr1 = strcasestr(path,"MacOS/subsurface"); + ptr2 = strcasestr(path,"Contents"); + if (ptr1 && ptr2) { + /* we are running as installed app from a bundle */ + if (ptr1 - path < size - strlen(REL_ICON_PATH)) { + strcpy(ptr1,REL_ICON_PATH); + return path; + } + } + } + return "packaging/macosx/Subsurface.icns"; +} |