]> git.tdb.fi Git - r2c2.git/blobdiff - source/remote/mainpanel.cpp
Add missing files
[r2c2.git] / source / remote / mainpanel.cpp
diff --git a/source/remote/mainpanel.cpp b/source/remote/mainpanel.cpp
new file mode 100644 (file)
index 0000000..62c9208
--- /dev/null
@@ -0,0 +1,60 @@
+/* $Id$
+
+This file is part of R²C²
+Copyright © 2011  Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
+#include "mainpanel.h"
+
+using namespace std;
+using namespace R2C2;
+
+MainPanel::MainPanel(Remote &r, R2C2::Client &c):
+       remote(r),
+       client(c)
+{
+       client.signal_power_changed.connect(sigc::mem_fun(this, &MainPanel::power_changed));
+       client.signal_halt_changed.connect(sigc::mem_fun(this, &MainPanel::halt_changed));
+       client.signal_emergency.connect(sigc::mem_fun(this, &MainPanel::emergency));
+
+       Gtk::HBox *hbox = new Gtk::HBox(false, 5);
+       pack_start(*manage(hbox), false, true);
+
+       hbox->pack_start(*manage(chk_power = new Gtk::CheckButton("Power")), false, true);
+       chk_power->signal_toggled().connect(sigc::mem_fun(this, &MainPanel::ui_power_changed));
+
+       hbox->pack_start(*manage(chk_halt = new Gtk::CheckButton("Halt")), false, true);
+       chk_halt->signal_toggled().connect(sigc::mem_fun(this, &MainPanel::ui_power_changed));
+
+       pack_start(*manage(lbl_status = new Gtk::Label), false, true);
+
+       show_all();
+}
+
+void MainPanel::power_changed(bool p)
+{
+       chk_power->set_active(p);
+}
+
+void MainPanel::halt_changed(bool h)
+{
+       chk_halt->set_active(h);
+       if(!h)
+               lbl_status->set_text(string());
+}
+
+void MainPanel::emergency(const string &msg)
+{
+       lbl_status->set_text(msg);
+}
+
+void MainPanel::ui_power_changed()
+{
+       client.set_power(chk_power->get_active());
+}
+
+void MainPanel::ui_halt_changed()
+{
+       client.set_halt(chk_halt->get_active());
+}