From fc857d5e0130bdf0dd948f805ed8d70f1c018dee Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 25 Mar 2007 15:44:49 +0000 Subject: Added missing file. git-svn-id: http://svn.drobilla.net/lad/machina@376 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/GladeXml.hpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/gui/GladeXml.hpp diff --git a/src/gui/GladeXml.hpp b/src/gui/GladeXml.hpp new file mode 100644 index 0000000..eb3f278 --- /dev/null +++ b/src/gui/GladeXml.hpp @@ -0,0 +1,56 @@ +/* This file is part of Machina. + * Copyright (C) 2007 Dave Robillard + * + * Machina 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. + * + * Machina 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 Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include + +class GladeXml +{ +public: + static Glib::RefPtr create() { + Glib::RefPtr xml; + + // Check for the .glade file in current directory + std::string glade_filename = "./machina.glade"; + std::ifstream fs(glade_filename.c_str()); + if (fs.fail()) { // didn't find it, check PKGDATADIR + fs.clear(); + glade_filename = PKGDATADIR; + glade_filename += "/machina.glade"; + + fs.open(glade_filename.c_str()); + if (fs.fail()) { + std::cerr << "Unable to find machina.glade in current directory or " + << PKGDATADIR << "." << std::endl; + exit(EXIT_FAILURE); + } + fs.close(); + } + + try { + xml = Gnome::Glade::Xml::create(glade_filename); + } catch(const Gnome::Glade::XmlError& ex) { + std::cerr << ex.what() << std::endl; + throw ex; + } + + return xml; + } +}; + -- cgit v1.2.1