extern void subsurface_close_conf(void);
extern const char *subsurface_USB_name(void);
+extern const char *subsurface_icon_name(void);
extern visible_cols_t visible_cols;
GdkPixbuf *logo = NULL;
if (need_icon) {
-#if defined __linux__ || defined __APPLE__
- GtkWidget *image = gtk_image_new_from_file("subsurface.svg");
-#elif defined WIN32
- GtkWidget *image = gtk_image_new_from_file("subsurface.ico");
-#endif
+ GtkWidget *image = gtk_image_new_from_file(subsurface_icon_name());
if (image) {
logo = gtk_image_get_pixbuf(GTK_IMAGE(image));
}
}
if (need_icon)
-#if defined __linux__ || defined __APPLE__
- gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.svg", NULL);
-#elif defined WIN32
- gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.ico", NULL);
-#endif
+ gtk_window_set_icon_from_file(GTK_WINDOW(win), subsurface_icon_name(), NULL);
g_signal_connect(G_OBJECT(win), "delete-event", G_CALLBACK(on_delete), NULL);
g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(on_destroy), NULL);
main_window = win;
{
return "/dev/ttyUSB0";
}
+
+const char *subsurface_icon_name()
+{
+ return "subsurface.svg";
+}
/* 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;
{
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";
+}
{
return "COM3";
}
+
+const char *subsurface_icon_name()
+{
+ return "subsurface.ico";
+}