From aa3af28d1e3a05f3e495bd08f07fef8427e1ca48 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 20 Oct 2008 02:02:27 +0000 Subject: Make Ingen and Patchage relocatable binaries when built as a bundle. git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@1690 a436a847-0d15-0410-975c-d299462d15a1 --- src/GladeFile.hpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/GladeFile.hpp') diff --git a/src/GladeFile.hpp b/src/GladeFile.hpp index 48a0062..2d868ed 100644 --- a/src/GladeFile.hpp +++ b/src/GladeFile.hpp @@ -23,26 +23,30 @@ #include #include #include +#include "config.h" +#include "binary_location.h" class GladeFile { public: static Glib::RefPtr open(const std::string& base_name) { - // Check for the .glade file in current directory - std::string glade_filename = std::string("./").append(base_name).append(".glade"); + std::string glade_filename; +#ifdef BUNDLE + char* loc = binary_location(); + std::string bundle = loc; + bundle = bundle.substr(0, bundle.find_last_of("/")); + glade_filename = bundle + "/" + PATCHAGE_DATA_DIR + "/" + base_name + ".glade"; + free(loc); +#else + glade_filename = std::string(PATCHAGE_DATA_DIR) + "/" + base_name + ".glade"; +#endif std::ifstream fs(glade_filename.c_str()); - if (fs.fail()) { // didn't find it, check DATA_PATH - fs.clear(); - glade_filename = std::string(PATCHAGE_DATA_DIR).append("/").append(base_name).append(".glade"); - - fs.open(glade_filename.c_str()); - if (fs.fail()) { - std::ostringstream ss; - ss << "Unable to find " << base_name << "glade in current directory or " - << PATCHAGE_DATA_DIR << std::endl; - throw std::runtime_error(ss.str()); - } - fs.close(); + if (fs.fail()) { + std::ostringstream ss; + ss << "Unable to find " << base_name << ".glade in " << PATCHAGE_DATA_DIR << std::endl; + throw std::runtime_error(ss.str()); } + + fs.close(); return Gnome::Glade::Xml::create(glade_filename); } -- cgit v1.2.1