From d084e6f369a829f41086d1f7f9befa52d0392d58 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 19 Feb 2011 21:28:38 +0000 Subject: [PATCH] Add missing files Fix copyright messages --- source/remote/mainpanel.cpp | 60 +++++++++++++++++++++++++++++++++++++ source/remote/mainpanel.h | 38 +++++++++++++++++++++++ source/remote/remote.cpp | 2 +- source/remote/remote.h | 2 +- 4 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 source/remote/mainpanel.cpp create mode 100644 source/remote/mainpanel.h diff --git a/source/remote/mainpanel.cpp b/source/remote/mainpanel.cpp new file mode 100644 index 0000000..62c9208 --- /dev/null +++ b/source/remote/mainpanel.cpp @@ -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()); +} diff --git a/source/remote/mainpanel.h b/source/remote/mainpanel.h new file mode 100644 index 0000000..05c0984 --- /dev/null +++ b/source/remote/mainpanel.h @@ -0,0 +1,38 @@ +/* $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 +#include +#include +#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 diff --git a/source/remote/remote.cpp b/source/remote/remote.cpp index 2168986..e538477 100644 --- a/source/remote/remote.cpp +++ b/source/remote/remote.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of R²C² -Copyright © 2009-2010 Mikkosoft Productions, Mikko Rasa +Copyright © 2009-2011 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ diff --git a/source/remote/remote.h b/source/remote/remote.h index a9ab92b..14e9ef6 100644 --- a/source/remote/remote.h +++ b/source/remote/remote.h @@ -1,7 +1,7 @@ /* $Id$ This file is part of R²C² -Copyright © 2009-2010 Mikkosoft Productions, Mikko Rasa +Copyright © 2009-2011 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ -- 2.43.0