summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/GladeFile.hpp32
-rw-r--r--wscript8
2 files changed, 24 insertions, 16 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);
}
diff --git a/wscript b/wscript
index b84ff9d..439e9cf 100644
--- a/wscript
+++ b/wscript
@@ -76,8 +76,12 @@ def configure(conf):
conf.env['APP_INSTALL_NAME'] = Params.g_options.app_install_name
conf.env['APP_HUMAN_NAME'] = Params.g_options.app_human_name
- conf.define('PATCHAGE_DATA_DIR', os.path.normpath(
- conf.env['DATADIR'] + conf.env['APP_INSTALL_NAME']))
+ if conf.env['BUNDLE']:
+ conf.define('PATCHAGE_DATA_DIR', os.path.normpath(
+ conf.env['DATADIRNAME'] + conf.env['APP_INSTALL_NAME']))
+ else:
+ conf.define('PATCHAGE_DATA_DIR', os.path.normpath(
+ conf.env['DATADIR'] + conf.env['APP_INSTALL_NAME']))
conf.write_config_header('config.h')