From b608165e9162d2d429de47bbc430ecae136d3455 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 10 Jan 2015 02:37:55 +0000 Subject: More Mac integration work. git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@5510 a436a847-0d15-0410-975c-d299462d15a1 --- osx/Info.plist.in | 4 ++++ src/main.cpp | 39 +++++++++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/osx/Info.plist.in b/osx/Info.plist.in index 4a6cf95..a32c38d 100644 --- a/osx/Info.plist.in +++ b/osx/Info.plist.in @@ -30,6 +30,10 @@ lib GTK_PATH lib + GTK_DATA_PREFIX + Resources + XDG_DATA_DIRS + Resources FONTCONFIG_FILE Resources/fonts.conf PANGO_RC_FILE diff --git a/src/main.cpp b/src/main.cpp index 0e870b9..81f7ba5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,16 +28,43 @@ #include "Patchage.hpp" -int -main(int argc, char** argv) -{ #ifdef __APPLE__ - const std::string binary = binary_location(); - const std::string bundle = binary.substr(0, binary.find_last_of('/')); - const std::string gtkrc_path = bundle + "/Resources/gtkrc"; +void +set_bundle_environment() +{ + const std::string binary = binary_location(); + const std::string bundle = binary.substr(0, binary.find_last_of('/')); + const std::string lib_path = bundle + "/lib"; + if (!Glib::file_test(lib_path, Glib::FILE_TEST_EXISTS)) { + // If lib does not exist, we have not been bundleified, do nothing + return; + } + + setenv("GTK_PATH", lib_path.c_str(), 1); + setenv("DYLD_LIBRARY_PATH", lib_path.c_str(), 1); + + const std::string pangorc_path(bundle + "/Resources/pangorc"); + if (Glib::file_test(pangorc_path, Glib::FILE_TEST_EXISTS)) { + setenv("PANGO_RC_FILE", pangorc_path.c_str(), 1); + } + + const std::string fonts_conf_path(bundle + "/Resources/fonts.conf"); + if (Glib::file_test(fonts_conf_path, Glib::FILE_TEST_EXISTS)) { + setenv("FONTCONFIG_FILE", fonts_conf_path.c_str(), 1); + } + + const std::string gtkrc_path(bundle + "/Resources/gtkrc"); if (Glib::file_test(gtkrc_path, Glib::FILE_TEST_EXISTS)) { gtk_rc_parse(gtkrc_path.c_str()); } +} +#endif + +int +main(int argc, char** argv) +{ +#ifdef __APPLE__ + set_bundle_environment(); #endif try { -- cgit v1.2.1