3 This file is part of R²C²
4 Copyright © 2009-2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #include <gtkmm/scrolledwindow.h>
9 #include <gtkmm/separator.h>
10 #include <msp/net/resolve.h>
11 #include <msp/time/units.h>
13 #include "trainpanel.h"
18 Application::RegApp<Remote> Remote::reg;
20 Remote::Remote(int argc, char **argv):
25 throw UsageError("No address given");
27 DataFile::load(catalogue, "locos.dat");
29 client.use_event_dispatcher(event_disp);
30 client.signal_train_added.connect(sigc::mem_fun(this, &Remote::train_added));
31 string addr_str = argv[1];
32 if(addr_str.find(':')==string::npos)
34 Net::SockAddr *addr = Net::resolve(addr_str);
35 client.connect(*addr);
38 window.signal_hide().connect(sigc::bind(sigc::mem_fun(this, &Remote::exit), 0));
39 window.set_default_size(300, 200);
40 window.set_border_width(5);
42 Gtk::ScrolledWindow *scroll = new Gtk::ScrolledWindow;
43 window.add(*manage(scroll));
44 scroll->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
46 train_box = new Gtk::VBox(false, 5);
47 scroll->add(*manage(train_box));
54 event_disp.tick(Time::zero);
58 void Remote::train_added(R2C2::NetTrain &t)
60 TrainPanel *panel = new TrainPanel(*this, client, t);
61 if(!train_panels.empty())
63 Gtk::HSeparator *sep = new Gtk::HSeparator;
64 train_box->pack_start(*manage(sep), false, true);
67 train_box->pack_start(*manage(panel), false, true);
68 train_panels.push_back(panel);