9 Principal::Principal(BaseObjectType *co, const Glib::RefPtr<Gnome::Glade::Xml> &rg):Gtk::Window(co),refXml(rg)
11 Gtk::MenuItem *conect=0, *exit=0, *about=0;
12 Gtk::Button *btn_get=0, *bar_connect=0;
14 txt_target = txt_command = txt_args = 0;
16 rg->get_widget("mnu_file_connect", conect);
17 rg->get_widget("mnu_file_exit", exit);
18 rg->get_widget("mnu_help_about", about);
19 rg->get_widget_derived("dlgConectar", dlg_conectar);
20 rg->get_widget("btn_get", btn_get);
21 rg->get_widget("txt_view", txt_view);
22 rg->get_widget("txt_target", txt_target);
23 rg->get_widget("txt_command", txt_command);
24 rg->get_widget("txt_args", txt_args);
25 rg->get_widget("bar_connect", bar_connect);
27 dlg_conectar->get_ok_button()->signal_clicked().connect( SigC::slot(*this, &Principal::on_dlg_connect_ok) );
28 conect->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_connect));
29 bar_connect->signal_clicked().connect( SigC::slot(*this, &Principal::on_mnu_file_connect));
30 exit->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_exit));
31 about->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_help_about));
32 btn_get->signal_clicked().connect( SigC::slot(*this, &Principal::on_get_clicked) );
37 Principal::~Principal()
42 void Principal::on_dlg_connect_ok()
44 if (conexion == NULL) {
45 std::cout << "Conectando ..." << std::endl;
48 conexion = new PlaQui::Server::ControlClient(dlg_conectar->get_server_name(), dlg_conectar->get_server_port());
51 txt_view->get_buffer()->insert_at_cursor("NO SE PUDO CREAR OBJETO\n");
55 // Conecto las señales
56 conexion->signal_ok_received().connect( SigC::slot(*this, &Principal::on_conexion_ok) );
57 conexion->signal_error_received().connect( SigC::slot(*this, &Principal::on_conexion_error) );
64 txt_view->get_buffer()->insert_at_cursor("no se puede correr ->run()!!!\n");
67 std::cout << "Ya estas conectado" << std::endl;
72 void Principal::on_mnu_file_exit()
77 void Principal::on_mnu_file_connect()
82 void Principal::on_mnu_help_about()
84 // preparo para leer el archivo ChangeLog
85 /* Glib::RefPtr<Gnome::Glade::Xml> xml;
87 Glib::RefPtr<Gtk::TextBuffer> log_buffer;
88 Glib::RefPtr<Glib::IOChannel> log_io;
90 log_buffer = Gtk::TextBuffer::create();
91 log_io = Glib::IOChannel::create_from_file("../ChangeLog", "r");
92 while (log_io->read_line(line) != Glib::IO_STATUS_EOF) {
93 log_buffer->insert_at_cursor(line);
97 xml = Gnome::Glade::Xml::create("client.glade", "dlgAbout");
99 catch(const Gnome::Glade::XmlError &ex) {
100 std::cerr << ex.what() << std::endl;
103 Gtk::Window *dlg = 0;
104 Gtk::Button *btn_cerrar = 0;
105 Gtk::TextView *txt_changelog = 0;
106 xml->get_widget("dlgAbout", dlg);
107 xml->get_widget("btn_close", btn_cerrar);
108 xml->get_widget("txt_changelog", txt_changelog);
109 btn_cerrar->signal_clicked().connect(SigC::slot(*dlg, &Gtk::Dialog::hide));
110 txt_changelog->set_buffer(log_buffer);
114 void Principal::on_conexion_ok()
116 txt_view->get_buffer()->insert_at_cursor("El server dice que ta' todo ok!\n");
119 void Principal::on_conexion_error(unsigned code)
125 txt_view->get_buffer()->insert_at_cursor("El server dice que hay error : ");
126 txt_view->get_buffer()->insert_at_cursor(s);
127 txt_view->get_buffer()->insert_at_cursor("\n");
131 void Principal::on_get_clicked()
133 if (conexion == NULL) {
134 txt_view->get_buffer()->insert_at_cursor("SIN CONEXION\n");
138 PlaQui::Server::Command command(txt_target->get_text(), txt_command->get_text());
139 command.add_arg( txt_args->get_text() );
140 txt_view->get_buffer()->insert_at_cursor("Enviando comando\n");
142 conexion->send(command);
145 txt_view->get_buffer()->insert_at_cursor("EXCEPTION EN conexion->send !!\n");