From bff08fcbd085cf7af81cc5ac4e4edcb74bb3deb4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 11 Jan 2011 19:57:52 +0000 Subject: Build a proper .app on OSX. git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@2827 a436a847-0d15-0410-975c-d299462d15a1 --- src/main.cpp | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 7c90ea5..a691210 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,6 +15,16 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#ifdef __APPLE__ +#include +#include +#include +#include +#include "binary_location.h" +#endif + +#include + #include #include @@ -22,9 +32,35 @@ #include "Patchage.hpp" +#ifdef __APPLE__ +void +set_bundle_environment() +{ + char* binloc_c = binary_location(); + std::string binloc(binloc_c); + free(binloc_c); + + const std::string bundle_path = binloc.substr(0, binloc.find_last_of('/')); + + const std::string gtk_path(bundle_path + "/lib"); + setenv("GTK_PATH", gtk_path.c_str(), 1); + std::cout << "GTK PATH " << gtk_path << std::endl; + + chdir(bundle_path.c_str()); + const std::string pangorc_path(bundle_path + "/Resources/pangorc"); + setenv("PANGO_RC_FILE", pangorc_path.c_str(), 1); + + gtk_rc_parse((bundle_path + "/Resources/gtkrc").c_str()); +} +#endif + int main(int argc, char** argv) { +#ifdef __APPLE__ + set_bundle_environment(); +#endif + try { Glib::thread_init(); @@ -34,7 +70,7 @@ main(int argc, char** argv) Patchage patchage(argc, argv); app.run(*patchage.window()); - + } catch (std::exception& e) { Raul::error << "patchage: error: " << e.what() << std::endl; return 1; -- cgit v1.2.1