summaryrefslogtreecommitdiffstats
path: root/src/Instance.cpp
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2008-04-06 16:11:00 +0200
committerneoraider <devnull@localhost>2008-04-06 16:11:00 +0200
commitcbc867ee44137b24e2549271499a9d211cd6b000 (patch)
tree9ccfa703082acd0bbe4df3e4b0a57b89e810a968 /src/Instance.cpp
parent356efaf89afdad141b313767e1a2b89de3c08d0a (diff)
downloadzoomedit-cbc867ee44137b24e2549271499a9d211cd6b000.tar
zoomedit-cbc867ee44137b24e2549271499a9d211cd6b000.zip
zoomedit: Moved source to extra dir.
Diffstat (limited to 'src/Instance.cpp')
-rw-r--r--src/Instance.cpp66
1 files changed, 66 insertions, 0 deletions
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 <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;
+}
+
+}