X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/f61a5ebd00d4620af70c3780ba821f5af68def1c..be1908f8097dbbc871bfd7c55432de43d25647b7:/Client/src/principal.cpp?ds=inline diff --git a/Client/src/principal.cpp b/Client/src/principal.cpp index 1ccf645..d5959a9 100644 --- a/Client/src/principal.cpp +++ b/Client/src/principal.cpp @@ -22,6 +22,7 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr & work_place = 0; lbl_cap_flujo = lbl_cap_extra = lbl_extra = lbl_nombre = lbl_color = lbl_flujo = 0; + rg->get_widget("btn_activar", btn_activar); rg->get_widget("color_preview", color_preview); rg->get_widget("lbl_nombre", lbl_nombre); rg->get_widget("lbl_extra", lbl_extra); @@ -50,6 +51,7 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr & exit->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_exit)); about->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_help_about)); btn_get->signal_clicked().connect( SigC::slot(*this, &Principal::on_get_clicked) ); + btn_activar->signal_clicked().connect( SigC::slot(*this, &Principal::on_btn_activar_clicked) ); conexion = NULL; is_xml_loaded = false; @@ -60,8 +62,13 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr & Principal::~Principal() { - if (conexion != NULL) - delete conexion; + if (conexion) { + conexion->finish(); + } + // Espera a que termine realmente. + while (conexion) { + Glib::usleep(10000); // 10 milisegundos + } } void Principal::on_dlg_connect_ok() @@ -73,8 +80,9 @@ void Principal::on_dlg_connect_ok() } catch (...) { txt_view->get_buffer()->insert_at_cursor("NO SE PUDO CREAR OBJETO\n"); - delete conexion; - conexion == NULL; + //delete conexion; XXX Si no me equivoco, si falla el + //constructor, no se reserva la memoria (el delete no va). + conexion = NULL; return; } @@ -97,13 +105,30 @@ void Principal::on_mnu_file_exit() Gtk::Main::quit(); } +void Principal::on_btn_activar_clicked() +{ + if ((conexion == NULL) || (last_selected == NULL)) return; + + PlaQui::Server::Command c("plant", "set"); + c.add_arg("default"); + c.add_arg(last_selected->get_name()); + c.add_arg("open"); + + if (last_selected->get_open()) + c.add_arg("false"); + else + c.add_arg("true"); + + conexion->send(c); +} + 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("7522"); + c.add_arg(conexion->get_port()); conexion->send(c); } @@ -168,8 +193,6 @@ void Principal::update_items_prop() color_preview->modify_bg(Gtk::STATE_NORMAL, last_selected->get_color()); color_preview->queue_draw(); - - std::cout << last_selected->get_name() << " " << last_selected->get_color().get_red() << std::endl; } void Principal::on_conexion_connected() @@ -287,6 +310,8 @@ void Principal::loadXML() } } + xmlFreeDoc(document); + // Ya cargado el XML, mando un msg para empezar a recibir los frames! PlaQui::Server::Command c("transmission", "start"); c.add_arg("default"); @@ -555,6 +580,7 @@ void Principal::read_status_xml(const std::string &frame) items = items->next; } + xmlFreeDoc(document); // Actualizo la UI update_ui(); }