summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-01-11 19:57:52 +0000
committerDavid Robillard <d@drobilla.net>2011-01-11 19:57:52 +0000
commitbff08fcbd085cf7af81cc5ac4e4edcb74bb3deb4 (patch)
tree785d255f1f8e810fd14703793b84092b6bb41600 /src/main.cpp
parent8ad8594ef42af57e9e566b3ea9b9e13f01c5dc53 (diff)
downloadpatchage-bff08fcbd085cf7af81cc5ac4e4edcb74bb3deb4.tar.gz
patchage-bff08fcbd085cf7af81cc5ac4e4edcb74bb3deb4.tar.bz2
patchage-bff08fcbd085cf7af81cc5ac4e4edcb74bb3deb4.zip
Build a proper .app on OSX.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@2827 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp38
1 files changed, 37 insertions, 1 deletions
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 <stdlib.h>
+#include <unistd.h>
+#include <string>
+#include <gtk/gtk.h>
+#include "binary_location.h"
+#endif
+
+#include <iostream>
+
#include <libgnomecanvasmm.h>
#include <glibmm/exception.h>
@@ -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;