66 lines
1.1 KiB
C++
66 lines
1.1 KiB
C++
#include <iostream>
|
|
#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<Gnome::Glade::XmlError> 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;
|
|
}
|
|
|
|
}
|