From a7b46a0695acfa55d591b0e5ce585d9f92fdad3e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 8 Jan 2011 19:11:13 +0000 Subject: Support via waf for running from the build directory. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2799 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/GladeFactory.cpp | 35 ++++++++++++++++++++++++----------- src/gui/ingen_gui.glade | 4 +++- src/gui/wscript | 11 +++++++---- 3 files changed, 34 insertions(+), 16 deletions(-) (limited to 'src/gui') diff --git a/src/gui/GladeFactory.cpp b/src/gui/GladeFactory.cpp index df000cd8..6036d359 100644 --- a/src/gui/GladeFactory.cpp +++ b/src/gui/GladeFactory.cpp @@ -30,24 +30,37 @@ namespace GUI { Glib::ustring GladeFactory::glade_filename = ""; +inline static bool +is_readable(const std::string& filename) +{ + std::ifstream fs(filename.c_str()); + const bool fail = fs.fail(); + fs.close(); + return !fail; +} void GladeFactory::find_glade_file() { - char* env_path = getenv("INGEN_GLADE_PATH"); - if (env_path) - glade_filename = env_path; - else - glade_filename = Shared::data_file_path("ingen_gui.glade"); + // Try file in bundle (directory where executable resides) + glade_filename = Shared::bundle_file_path("ingen_gui.glade"); + if (is_readable(glade_filename)) + return; - ifstream fs(glade_filename.c_str()); - if (fs.fail()) { - error << "[GladeFactory] Unable to find ingen_gui.glade in " << INGEN_DATA_DIR << endl; - throw; + // Try ENGINE_GLADE_PATH from the environment + const char* const env_path = getenv("INGEN_GLADE_PATH"); + if (env_path && is_readable(env_path)) { + glade_filename = env_path; + return; } - fs.close(); - info << "[GladeFactory] Loading widgets from " << glade_filename.c_str() << endl; + // Try the default system installed path + glade_filename = Shared::data_file_path("ingen_gui.glade"); + if (is_readable(glade_filename)) + return; + + error << "[GladeFactory] Unable to find ingen_gui.glade in " << INGEN_DATA_DIR << endl; + throw std::runtime_error("Unable to find glade file"); } diff --git a/src/gui/ingen_gui.glade b/src/gui/ingen_gui.glade index 39e5f8bd..6b135a2a 100644 --- a/src/gui/ingen_gui.glade +++ b/src/gui/ingen_gui.glade @@ -1829,7 +1829,9 @@ True normal - Copyright (C) 2005-2008 David Robillard <http://drobilla.net> + Ingen + @INGEN_VERSION@ + Copyright (C) 2005-2010 David Robillard <http://drobilla.net> http://drobilla.net/software/ingen Licensed under the GNU GPL, Version 2. diff --git a/src/gui/wscript b/src/gui/wscript index 5ae04233..40c6a270 100644 --- a/src/gui/wscript +++ b/src/gui/wscript @@ -66,7 +66,10 @@ def build(bld): XML2 ''') - # GUI runtime files - bld.install_files('${DATADIR}/ingen', 'ingen_gui.glade') - - + # Glade XML UI definition + bld(features = 'subst', + source = 'ingen_gui.glade', + target = '../../ingen_gui.glade', + install_path = '${DATADIR}/ingen', + chmod = 0755, + INGEN_VERSION = bld.env['INGEN_VERSION']) -- cgit v1.2.1