diff options
author | David Robillard <d@drobilla.net> | 2015-01-10 02:37:55 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-01-10 02:37:55 +0000 |
commit | b608165e9162d2d429de47bbc430ecae136d3455 (patch) | |
tree | 0b005b3fe0e638ebcbbedf8ab2a7fdbb07328d83 | |
parent | 639a935bd7d06a5996ad76f11c6836e20c410c12 (diff) | |
download | patchage-b608165e9162d2d429de47bbc430ecae136d3455.tar.gz patchage-b608165e9162d2d429de47bbc430ecae136d3455.tar.bz2 patchage-b608165e9162d2d429de47bbc430ecae136d3455.zip |
More Mac integration work.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@5510 a436a847-0d15-0410-975c-d299462d15a1
-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 { |