diff options
-rw-r--r-- | osx/Info.plist.in | 4 | ||||
-rw-r--r-- | 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 @@ <string>lib</string> <key>GTK_PATH</key> <string>lib</string> + <key>GTK_DATA_PREFIX</key> + <string>Resources</string> + <key>XDG_DATA_DIRS</key> + <string>Resources</string> <key>FONTCONFIG_FILE</key> <string>Resources/fonts.conf</string> <key>PANGO_RC_FILE</key> 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 { |