]> git.tdb.fi Git - r2c2.git/blobdiff - source/remote/connectdialog.cpp
Add a new remote control program with GLtk-based UI
[r2c2.git] / source / remote / connectdialog.cpp
diff --git a/source/remote/connectdialog.cpp b/source/remote/connectdialog.cpp
new file mode 100644 (file)
index 0000000..40a8bb3
--- /dev/null
@@ -0,0 +1,25 @@
+#include <msp/core/maputils.h>
+#include <msp/net/inet.h>
+#include <msp/net/resolve.h>
+#include "connectdialog.h"
+
+using namespace Msp;
+using namespace R2C2;
+
+ConnectDialog::ConnectDialog(Client &c):
+       client(c)
+{
+       Loader::WidgetMap widgets;
+       DataFile::load(*this, "data/remote/connectdialog.ui", widgets);
+
+       ent_host = dynamic_cast<GLtk::Entry *>(get_item(widgets, "ent_host"));
+       ent_port = dynamic_cast<GLtk::Entry *>(get_item(widgets, "ent_port"));
+       ent_port->set_text("8315");
+}
+
+void ConnectDialog::on_response(int)
+{
+       Net::SockAddr *addr = Net::resolve(ent_host->get_text(), ent_port->get_text(), Net::INET);
+       client.connect(*addr);
+       delete addr;
+}