X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/0bf4e9e2336a15ee267bd39b6ac325326fb10d9d..e36a4e9f6b04998cc8f92a8808abac66e670a01d:/Client/src/principal.cpp?ds=inline diff --git a/Client/src/principal.cpp b/Client/src/principal.cpp index c6a4760..27ebd52 100644 --- a/Client/src/principal.cpp +++ b/Client/src/principal.cpp @@ -5,6 +5,7 @@ #include #include #include +#include "plaqui/server/string.h" #include "item_codo.h" #include "item_conduct.h" #include "item_exclusa.h" @@ -15,7 +16,7 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr &rg):Gtk::Window(co),refXml(rg) { - Gtk::MenuItem *conect=0, *exit=0, *about=0, *mnu_prop=0; + Gtk::MenuItem *conect=0, *exit=0, *about=0, *mnu_prop=0, *mnu_disconnect; Gtk::Button *btn_get=0, *bar_connect=0; txt_view = 0; txt_target = txt_command = txt_args = 0; @@ -24,6 +25,7 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr & rg->get_widget("lbl_nombre", lbl_nombre); rg->get_widget("mnu_file_connect", conect); + rg->get_widget("mnu_file_disconnect", mnu_disconnect); rg->get_widget("mnu_file_exit", exit); rg->get_widget("mnu_help_about", about); rg->get_widget("mnu_prop", mnu_prop); @@ -39,6 +41,7 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr & dlg_conectar->get_ok_button()->signal_clicked().connect( SigC::slot(*this, &Principal::on_dlg_connect_ok) ); mnu_prop->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_prop)); + mnu_disconnect->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_disconnect)); conect->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_connect)); bar_connect->signal_clicked().connect( SigC::slot(*this, &Principal::on_mnu_file_connect)); exit->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_exit)); @@ -90,6 +93,16 @@ void Principal::on_mnu_file_exit() Gtk::Main::quit(); } +void Principal::on_mnu_file_disconnect() +{ + if (conexion == NULL) return; + + PlaQui::Server::Command c("connection", "stop"); + c.add_arg(conexion->get_host()); + c.add_arg(conexion->get_port()); + conexion->send(c); +} + void Principal::on_mnu_file_connect() { dlg_conectar->show(); @@ -148,9 +161,12 @@ void Principal::on_conexion_finished() conexion = NULL; } -void Principal::on_conexion_ok() +void Principal::on_conexion_ok(const std::string &body) { - txt_view->get_buffer()->insert_at_cursor("El server dice que ta' todo ok!\n"); + std::cout << body << std::endl; + txt_view->get_buffer()->insert_at_cursor("\n"); + txt_view->get_buffer()->insert_at_cursor(Glib::locale_to_utf8(body)); + txt_view->get_buffer()->insert_at_cursor("\n"); } void Principal::on_conexion_error(unsigned code)