From ea59b3a8d2887e963b806c5f595f5d4e6460fc55 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 10 Jan 2015 02:53:31 +0000 Subject: More Mac integration work. git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@5511 a436a847-0d15-0410-975c-d299462d15a1 --- src/Patchage.cpp | 6 ++++++ src/UIFile.hpp | 3 +-- src/binary_location.h | 11 +++++++++++ src/main.cpp | 3 +-- 4 files changed, 19 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Patchage.cpp b/src/Patchage.cpp index d561feb..1944ef3 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -160,6 +160,12 @@ Patchage::Patchage(int argc, char** argv) _about_win->property_program_name() = "Patchage"; _about_win->property_logo_icon_name() = "patchage"; gtk_window_set_default_icon_name("patchage"); +#ifdef __APPLE__ + // This doesn't seem to work after bundleification for some reason... + _about_win->set_logo( + Gdk::Pixbuf::create_from_file( + bundle_location() + "/Resources/Patchage.icns")); +#endif _main_scrolledwin->add(_canvas->widget()); diff --git a/src/UIFile.hpp b/src/UIFile.hpp index 561cb0f..f1ab5f8 100644 --- a/src/UIFile.hpp +++ b/src/UIFile.hpp @@ -41,9 +41,8 @@ public: static Glib::RefPtr open(const std::string& base_name) { std::string ui_filename; #ifdef PATCHAGE_BINLOC - std::string bundle = binary_location(); + const std::string bundle = bundle_location(); if (!bundle.empty()) { - bundle = bundle.substr(0, bundle.find_last_of("/")); ui_filename = bundle + "/" + base_name + ".ui"; if (is_readable(ui_filename)) { std::cout << "Loading UI file " << ui_filename << std::endl; diff --git a/src/binary_location.h b/src/binary_location.h index 91e8b29..303a3bd 100644 --- a/src/binary_location.h +++ b/src/binary_location.h @@ -41,3 +41,14 @@ binary_location() } return loc; } + +/** Return the absolute path of the bundle (binary parent directory). */ +static std::string +bundle_location() +{ + const std::string binary = binary_location(); + if (binary.empty()) { + return ""; + } + return binary.substr(0, binary.find_last_of('/')); +} diff --git a/src/main.cpp b/src/main.cpp index 81f7ba5..a83c8ad 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,8 +32,7 @@ void set_bundle_environment() { - const std::string binary = binary_location(); - const std::string bundle = binary.substr(0, binary.find_last_of('/')); + const std::string bundle = bundle_location(); 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 -- cgit v1.2.1