Fix glade loading
This commit is contained in:
parent
bead1adfa3
commit
e05140226f
|
@ -1,61 +0,0 @@
|
|||
/* This file is part of Patchage.
|
||||
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
|
||||
*
|
||||
* Patchage is free software; you can redistribute it and/or modify it under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* Patchage is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef PATCHAGE_GLADEFILE_HPP
|
||||
#define PATCHAGE_GLADEFILE_HPP
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#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 ./src/
|
||||
std::string glade_filename = std::string("./src/").append(base_name).append(".glade");
|
||||
std::ifstream fs(glade_filename.c_str());
|
||||
if (fs.fail()) { // didn't find it, check DATA_PATH
|
||||
fs.clear();
|
||||
|
||||
#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
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
return Gnome::Glade::Xml::create(glade_filename);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // PATCHAGE_GLADEFILE_HPP
|
|
@ -1,6 +1,8 @@
|
|||
/* This file is part of Patchage.
|
||||
/*
|
||||
* This file is part of LADI session handler.
|
||||
*
|
||||
* Copyright (C) 2008, 2009 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
|
||||
* Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
* Patchage is free software; you can redistribute it and/or modify it under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
|
@ -120,7 +122,7 @@ Patchage::Patchage(int argc, char** argv)
|
|||
g_app = this;
|
||||
|
||||
_settings_filename = getenv("HOME");
|
||||
_settings_filename += "/." PATCHAGE_APPNAME "rc";
|
||||
_settings_filename += "/.gladishrc";
|
||||
_state_manager = new StateManager();
|
||||
_canvas = boost::shared_ptr<PatchageCanvas>(new PatchageCanvas(this, 1600*2, 1200*2));
|
||||
|
||||
|
@ -138,8 +140,8 @@ Patchage::Patchage(int argc, char** argv)
|
|||
|
||||
Glib::set_application_name("Patchage");
|
||||
_about_win->property_program_name() = "Patchage";
|
||||
_about_win->property_logo_icon_name() = PATCHAGE_APPNAME;
|
||||
gtk_window_set_default_icon_name(PATCHAGE_APPNAME);
|
||||
_about_win->property_logo_icon_name() = "gladish";
|
||||
gtk_window_set_default_icon_name("gladish");
|
||||
|
||||
gtkmm_set_width_for_given_text(*_buffer_size_combo, "4096 frames", 40);
|
||||
|
||||
|
|
42
gui/main.cpp
42
gui/main.cpp
|
@ -1,4 +1,7 @@
|
|||
/* This file is part of Patchage.
|
||||
/*
|
||||
* This file is part of LADI session handler.
|
||||
*
|
||||
* Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
* Copyright (C) 2007 Dave Robillard <http://drobilla.net>
|
||||
*
|
||||
* Patchage is free software; you can redistribute it and/or modify it under the
|
||||
|
@ -21,12 +24,45 @@
|
|||
#include <libgnomecanvasmm.h>
|
||||
#include <glibmm/exception.h>
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <libglademm/xml.h>
|
||||
#include "config.h"
|
||||
#include "binary_location.h"
|
||||
|
||||
#include "Patchage.hpp"
|
||||
#include "GladeFile.hpp"
|
||||
#include "globals.hpp"
|
||||
|
||||
Glib::RefPtr<Gnome::Glade::Xml> g_xml;
|
||||
|
||||
static
|
||||
Glib::RefPtr<Gnome::Glade::Xml>
|
||||
glade_open()
|
||||
{
|
||||
// Check for the .glade file in ./src/
|
||||
std::string glade_filename = std::string("./gui/gui.glade");
|
||||
std::ifstream fs(glade_filename.c_str());
|
||||
if (fs.fail())
|
||||
{ // didn't find it, check DATA_PATH
|
||||
fs.clear();
|
||||
|
||||
glade_filename = DATA_DIR "/gui.glade";
|
||||
|
||||
fs.open(glade_filename.c_str());
|
||||
if (fs.fail())
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "Unable to find gui.glade file" << std::endl;
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
fs.close();
|
||||
}
|
||||
|
||||
return Gnome::Glade::Xml::create(glade_filename);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
try {
|
||||
|
@ -34,7 +70,7 @@ int main(int argc, char** argv)
|
|||
Gnome::Canvas::init();
|
||||
Gtk::Main app(argc, argv);
|
||||
|
||||
g_xml = GladeFile::open("patchage");
|
||||
g_xml = glade_open();
|
||||
|
||||
Patchage patchage(argc, argv);
|
||||
app.run(*patchage.window());
|
||||
|
|
5
wscript
5
wscript
|
@ -110,10 +110,7 @@ def configure(conf):
|
|||
conf.check_tool('boost')
|
||||
conf.check_boost()
|
||||
|
||||
conf.define('PATCHAGE_APPNAME', "gladish")
|
||||
conf.env['PATCHAGE_VERSION'] = VERSION
|
||||
conf.define('PATCHAGE_DATA_DIR', os.path.normpath(os.path.join(conf.env['PREFIX'], 'share', "gladish")))
|
||||
|
||||
conf.define('DATA_DIR', os.path.normpath(os.path.join(conf.env['PREFIX'], 'share', APPNAME)))
|
||||
conf.define('DEFAULT_PROJECT_DIR', "audio-projects")
|
||||
conf.define('PACKAGE_VERSION', VERSION)
|
||||
conf.define('DBUS_NAME_BASE', DBUS_NAME_BASE)
|
||||
|
|
Loading…
Reference in New Issue