From c9cc3f7ba2112294c69c111082223da91554c095 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Tue, 11 Nov 2003 22:59:35 +0000 Subject: [PATCH] Se reestructura las clases del cliente para comenzar su desarrollo definitivo --- Client/include/dlg_conectar.h | 14 +- Client/include/menu_bar.h | 23 -- Client/include/principal.h | 30 ++ Client/src/Makefile.am | 2 +- Client/src/client.glade | 310 +++++++++++---------- Client/src/dlg_conectar.cpp | 38 ++- Client/src/main.cpp | 18 +- Client/src/{menu_bar.cpp => principal.cpp} | 49 ++-- 8 files changed, 252 insertions(+), 232 deletions(-) delete mode 100644 Client/include/menu_bar.h create mode 100644 Client/include/principal.h rename Client/src/{menu_bar.cpp => principal.cpp} (55%) diff --git a/Client/include/dlg_conectar.h b/Client/include/dlg_conectar.h index 3c75234..834fff3 100644 --- a/Client/include/dlg_conectar.h +++ b/Client/include/dlg_conectar.h @@ -11,21 +11,23 @@ * Este diĆ”logo deja al usuario ingresar el nombre del servidor y * el puerto para inicializar una simulaciĆ³n. */ -class DlgConectar:public Gtk::Window { +class DlgConectar:public Gtk::Dialog { public: /// Constructor DlgConectar(BaseObjectType *co, const Glib::RefPtr &rg); /// Destructor virtual ~DlgConectar(); + Gtk::Button *get_ok_button(); + + Glib::ustring get_server_name(); + int get_server_port(); + + virtual void on_cancel_clicked(); protected: /// Referencia al XML desde donde fue creada la ventana Glib::RefPtr refXml; - - /// Handler del boton OK - virtual void on_btn_ok_clicked(); - /// Handler del boton CANCEL - virtual void on_btn_cancel_clicked(); + Gtk::Button *ok, *cancel; }; #endif diff --git a/Client/include/menu_bar.h b/Client/include/menu_bar.h deleted file mode 100644 index 23ef6e6..0000000 --- a/Client/include/menu_bar.h +++ /dev/null @@ -1,23 +0,0 @@ - -#ifndef _MENU_BAR_H_ -#define _MENU_BAR_H_ - -#include -#include - -class MiMenuBar:public Gtk::MenuBar { -public: - MiMenuBar(BaseObjectType *co, const Glib::RefPtr &rg); - virtual ~MiMenuBar(); - -protected: - // Archivo XML del Padre - Glib::RefPtr refXml; - // Callbacks de los items del menu - virtual void on_mnu_file_exit(); - virtual void on_mnu_file_connect(); - virtual void on_mnu_help_about(); -}; - -#endif - diff --git a/Client/include/principal.h b/Client/include/principal.h new file mode 100644 index 0000000..d4270a8 --- /dev/null +++ b/Client/include/principal.h @@ -0,0 +1,30 @@ + + +#ifndef _PRINCIPAL_H_ +#define _PRINCIPAL_H_ + +#include +#include +#include "dlg_conectar.h" + +class Principal:public Gtk::Window { +public: + Principal(BaseObjectType *co, const Glib::RefPtr &rg); + virtual ~Principal(); + +protected: + // Archivo XML del Padre + Glib::RefPtr refXml; + + // Dialogo de Conectar + DlgConectar *dlg_conectar; + + // Callbacks del menu y la barra + virtual void on_mnu_file_exit(); + virtual void on_mnu_file_connect(); + virtual void on_mnu_help_about(); + virtual void on_dlg_connect_ok(); +}; + +#endif // _PRINCIPAL_H_ + diff --git a/Client/src/Makefile.am b/Client/src/Makefile.am index 5d24ed9..a2f4a93 100644 --- a/Client/src/Makefile.am +++ b/Client/src/Makefile.am @@ -9,7 +9,7 @@ INCLUDES = \ bin_PROGRAMS = plaqui-client plaqui_client_SOURCES = main.cpp \ - menu_bar.cpp \ + principal.cpp \ dlg_conectar.cpp plaqui_client_LDADD = @PACKAGE_LIBS@ diff --git a/Client/src/client.glade b/Client/src/client.glade index 8314b28..52fc899 100644 --- a/Client/src/client.glade +++ b/Client/src/client.glade @@ -373,156 +373,7 @@ - - True - Conectar ... - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - True - False - - - - True - 3 - 2 - False - 0 - 0 - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 0 - 1 - - - - - - - True - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 1234 0 65365 1 10 10 - - - 1 - 2 - 1 - 2 - - - - - - - True - Puerto : - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - expand - - - - - - True - Servidor : - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - expand - - - - - - True - GTK_BUTTONBOX_END - 23 - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - - - - - 0 - 2 - 2 - 3 - shrink|fill - - - - - - - True Acerca de ... GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -667,4 +518,165 @@ + + Conectar + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + 2 + 2 + False + 0 + 0 + + + + True + Servidor : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Puerto : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + True + True + True + 0 + localhost + True + * + False + + + 1 + 2 + 0 + 1 + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1234 1 65535 1 10 10 + + + 1 + 2 + 1 + 2 + + + + + + 0 + True + True + + + + + + diff --git a/Client/src/dlg_conectar.cpp b/Client/src/dlg_conectar.cpp index 8af1482..47d2c86 100644 --- a/Client/src/dlg_conectar.cpp +++ b/Client/src/dlg_conectar.cpp @@ -1,32 +1,40 @@ #include "dlg_conectar.h" -DlgConectar::DlgConectar(BaseObjectType *co, const Glib::RefPtr &rg):Gtk::Window(co),refXml(rg) +DlgConectar::DlgConectar(BaseObjectType *co, const Glib::RefPtr &rg):Gtk::Dialog(co),refXml(rg) { - Gtk::Button *btn_ok=0, *btn_cancel=0; - refXml->get_widget("btn_ok", btn_ok); - refXml->get_widget("btn_cancel", btn_cancel); + ok = cancel = 0; + refXml->get_widget("btn_cancel", cancel); + refXml->get_widget("btn_ok", ok); - btn_ok->signal_clicked().connect( SigC::slot(*this, &DlgConectar::on_btn_ok_clicked) ); - btn_cancel->signal_clicked().connect( SigC::slot(*this, &DlgConectar::on_btn_cancel_clicked) ); + cancel->signal_clicked().connect( SigC::slot(*this, &DlgConectar::on_cancel_clicked) ); } DlgConectar::~DlgConectar() { } -void DlgConectar::on_btn_ok_clicked() +void DlgConectar::on_cancel_clicked() { - /* Aca tengo que iniciarl el thread que se trata de conectar - * al servidor, que descarga el modelo e inicia la - * actualizacion. - * - * Tendre que ver como se hara toda la comunicacion - */ + hide(); } -void DlgConectar::on_btn_cancel_clicked() +Gtk::Button *DlgConectar::get_ok_button() { - hide(); + return ok; +} + +Glib::ustring DlgConectar::get_server_name() +{ + Gtk::Entry *server_name = 0; + refXml->get_widget("server_name", server_name); + return server_name->get_text(); +} + +int DlgConectar::get_server_port() +{ + Gtk::SpinButton *server_port = 0; + refXml->get_widget("server_port", server_port); + return server_port->get_value_as_int(); } diff --git a/Client/src/main.cpp b/Client/src/main.cpp index e1cb336..11bce6b 100644 --- a/Client/src/main.cpp +++ b/Client/src/main.cpp @@ -2,7 +2,7 @@ #include #include #include -#include "menu_bar.h" +#include "principal.h" int main (int argc, char **argv) { @@ -11,25 +11,17 @@ int main (int argc, char **argv) //Load the Glade file and instiate its widgets: Glib::RefPtr refXml; try { - refXml = Gnome::Glade::Xml::create("client.glade", "Principal"); + refXml = Gnome::Glade::Xml::create("client.glade"); } catch(const Gnome::Glade::XmlError& ex) { - std::cerr << "(main.cpp:18) : "; + std::cerr << "(main.cpp:17) : "; std::cerr << ex.what() << std::endl; return 1; } - Gtk::Window* pWindow = 0; - Gtk::Button *bar_exit; - Gtk::Fixed *work_place; - MiMenuBar *menu_bar; + Principal* pWindow = 0; - refXml->get_widget("Principal", pWindow); - refXml->get_widget_derived("menu_bar", menu_bar); - refXml->get_widget("bar_exit", bar_exit); - refXml->get_widget("work_place", work_place); - work_place->set_size_request(10000, 10000); - bar_exit->signal_clicked().connect( SigC::slot(Gtk::Main::quit) ); + refXml->get_widget_derived("Principal", pWindow); client.run(*pWindow); return 0; diff --git a/Client/src/menu_bar.cpp b/Client/src/principal.cpp similarity index 55% rename from Client/src/menu_bar.cpp rename to Client/src/principal.cpp index 0ca75bc..062aa4b 100644 --- a/Client/src/menu_bar.cpp +++ b/Client/src/principal.cpp @@ -1,49 +1,48 @@ -#include "menu_bar.h" + + +#include "principal.h" #include -#include "dlg_conectar.h" -MiMenuBar::MiMenuBar(BaseObjectType *co, const Glib::RefPtr &rg):Gtk::MenuBar(co),refXml(rg) +Principal::Principal(BaseObjectType *co, const Glib::RefPtr &rg):Gtk::Window(co),refXml(rg) { Gtk::MenuItem *conect=0, *exit=0, *about=0; rg->get_widget("mnu_file_connect", conect); rg->get_widget("mnu_file_exit", exit); rg->get_widget("mnu_help_about", about); - conect->signal_activate().connect( SigC::slot(*this, &MiMenuBar::on_mnu_file_connect)); - exit->signal_activate().connect( SigC::slot(*this, &MiMenuBar::on_mnu_file_exit)); - about->signal_activate().connect( SigC::slot(*this, &MiMenuBar::on_mnu_help_about)); + rg->get_widget_derived("dlgConectar", dlg_conectar); + + dlg_conectar->get_ok_button()->signal_clicked().connect( SigC::slot(*this, &Principal::on_dlg_connect_ok) ); + conect->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_connect)); + exit->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_file_exit)); + about->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_help_about)); } -MiMenuBar::~MiMenuBar() +Principal::~Principal() { } -void MiMenuBar::on_mnu_file_exit() +void Principal::on_dlg_connect_ok() { - Gtk::Main::quit(); + std::cout << "Conectando ..." << std::endl; + std::cout << dlg_conectar->get_server_name() << ":" << dlg_conectar->get_server_port() << std::endl; + dlg_conectar->hide(); } -void MiMenuBar::on_mnu_file_connect() +void Principal::on_mnu_file_exit() { - // preparo para leer el archivo ChangeLog - Glib::RefPtr xml; + Gtk::Main::quit(); +} - try { - xml = Gnome::Glade::Xml::create("client.glade", "dlgConectar"); - } - catch(const Gnome::Glade::XmlError &ex) { - std::cerr << ex.what() << std::endl; - return; - } - DlgConectar *dlg = 0; - xml->get_widget_derived("dlgConectar", dlg); - dlg->show(); +void Principal::on_mnu_file_connect() +{ + dlg_conectar->show(); } -void MiMenuBar::on_mnu_help_about() +void Principal::on_mnu_help_about() { // preparo para leer el archivo ChangeLog - Glib::RefPtr xml; +/* Glib::RefPtr xml; Glib::ustring line; Glib::RefPtr log_buffer; Glib::RefPtr log_io; @@ -69,6 +68,6 @@ void MiMenuBar::on_mnu_help_about() xml->get_widget("txt_changelog", txt_changelog); btn_cerrar->signal_clicked().connect(SigC::slot(*dlg, &Gtk::Dialog::hide)); txt_changelog->set_buffer(log_buffer); - dlg->show(); + dlg->show();*/ } -- 2.43.0