--- /dev/null
+/* $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());
+}
--- /dev/null
+/* $Id$
+
+This file is part of R²C²
+Copyright © 2011 Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
+#ifndef MAINPANEL_H_
+#define MAINPANEL_H_
+
+#include <gtkmm/box.h>
+#include <gtkmm/checkbutton.h>
+#include <gtkmm/label.h>
+#include "network/client.h"
+
+class Remote;
+
+class MainPanel: public Gtk::VBox
+{
+private:
+ Remote &remote;
+ R2C2::Client &client;
+ Gtk::CheckButton *chk_power;
+ Gtk::CheckButton *chk_halt;
+ Gtk::Label *lbl_status;
+
+public:
+ MainPanel(Remote &, R2C2::Client &);
+
+private:
+ void power_changed(bool);
+ void halt_changed(bool);
+ void emergency(const std::string &);
+ void ui_power_changed();
+ void ui_halt_changed();
+};
+
+#endif