summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-10-20 02:02:27 +0000
committerDavid Robillard <d@drobilla.net>2008-10-20 02:02:27 +0000
commitaa3af28d1e3a05f3e495bd08f07fef8427e1ca48 (patch)
tree6e6dd9c4975ebcdbcc22e0e8a896140fe2bd200e /src
parentf95a985e72031f92bff95e24cc4ff82d6358f74e (diff)
downloadpatchage-aa3af28d1e3a05f3e495bd08f07fef8427e1ca48.tar.gz
patchage-aa3af28d1e3a05f3e495bd08f07fef8427e1ca48.tar.bz2
patchage-aa3af28d1e3a05f3e495bd08f07fef8427e1ca48.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/GladeFile.hpp32
1 files changed, 18 insertions, 14 deletions
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 <sstream>
#include <stdexcept>
#include <libglademm/xml.h>
+#include "config.h"
+#include "binary_location.h"
class GladeFile {
public:
static Glib::RefPtr<Gnome::Glade::Xml> 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);
}