From cbc867ee44137b24e2549271499a9d211cd6b000 Mon Sep 17 00:00:00 2001 From: neoraider Date: Sun, 6 Apr 2008 14:11:00 +0000 Subject: zoomedit: Moved source to extra dir. --- src/Instance.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/Instance.cpp (limited to 'src/Instance.cpp') diff --git a/src/Instance.cpp b/src/Instance.cpp new file mode 100644 index 0000000..6c658ba --- /dev/null +++ b/src/Instance.cpp @@ -0,0 +1,66 @@ +#include +#include "Instance.h" + +namespace ZoomEdit { + +guint Instance::instances = 0; + +Instance::Instance() : window(NULL) { + instances++; + +#ifdef GLIBMM_EXCEPTIONS_ENABLED + try + { + xml = Gnome::Glade::Xml::create("zoomedit.glade"); + } + catch(const Gnome::Glade::XmlError& ex) + { + std::cerr << ex.what() << std::endl; + return; + } +#else + std::auto_ptr error; + xml = Gnome::Glade::Xml::create("zoomedit.glade", "", "", error); + if(error.get()) + { + std::cerr << error->what() << std::endl; + return; + } +#endif + + xml->get_widget_derived("WindowMain", window); + if(!window) { + xml.clear(); + return; + } + + window->signal_hide().connect(sigc::mem_fun(this, &Instance::destroy)); + + window->show(); +} + +Instance::~Instance() { + if(window) + delete window; + + instances--; + if(!instances) + Gtk::Main::quit(); +} + +bool Instance::create() { + Instance *instance = new Instance(); + + if(!instance->xml) { + delete instance; + return false; + } + + return true; +} + +void Instance::destroy() { + delete this; +} + +} -- cgit v1.2.3