From: Ricardo Markiewicz Date: Sat, 18 Oct 2003 18:11:08 +0000 (+0000) Subject: - Agrego el dialogo de conectar X-Git-Tag: svn_import~407 X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/commitdiff_plain/8cd57f66ca12d475f479f0f816270f9833926088 - Agrego el dialogo de conectar - Agrego una clase Menu para encapsular todos los items del menu en lugar de hacer una clase por item. - Actualizo la interfaz --- diff --git a/Client/ChangeLog b/Client/ChangeLog index 8bf1e0e..4d125da 100644 --- a/Client/ChangeLog +++ b/Client/ChangeLog @@ -1,3 +1,7 @@ +18-10-2003 Ricardo Markiewicz + * Encapsulo los handlers de los items del menu en una sola clase + menu. + 17-10-2003 Ricardo Markiewicz * Agrego la carga del archivo ChangeLog en el dialogo "Acerca de ..." diff --git a/Client/include/dlg_conectar.h b/Client/include/dlg_conectar.h new file mode 100644 index 0000000..3c75234 --- /dev/null +++ b/Client/include/dlg_conectar.h @@ -0,0 +1,32 @@ + + +#ifndef _DLG_CONECTAR_H_ +#define _DLG_CONECTAR_H_ + +#include +#include + +/** Dialogo de Inicio de conexión + * + * Este diálogo deja al usuario ingresar el nombre del servidor y + * el puerto para inicializar una simulación. + */ +class DlgConectar:public Gtk::Window { +public: + /// Constructor + DlgConectar(BaseObjectType *co, const Glib::RefPtr &rg); + /// Destructor + virtual ~DlgConectar(); + +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(); +}; + +#endif + diff --git a/Client/include/menu_bar.h b/Client/include/menu_bar.h new file mode 100644 index 0000000..23ef6e6 --- /dev/null +++ b/Client/include/menu_bar.h @@ -0,0 +1,23 @@ + +#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/mnu_file_exit.h b/Client/include/mnu_file_exit.h deleted file mode 100644 index 448950d..0000000 --- a/Client/include/mnu_file_exit.h +++ /dev/null @@ -1,18 +0,0 @@ - -/* Maneja el Archivo->Salir */ - -#include -#include - -class MnuFileExit:public Gtk::MenuItem { -public: - MnuFileExit(BaseObjectType* cobject, const Glib::RefPtr& refGlade):Gtk::MenuItem(cobject) { - } - virtual ~MnuFileExit() {} - -protected: - virtual void on_activate() { - Gtk::Main::quit(); - } -}; - diff --git a/Client/include/mnu_help_about.h b/Client/include/mnu_help_about.h deleted file mode 100644 index 168bd3d..0000000 --- a/Client/include/mnu_help_about.h +++ /dev/null @@ -1,47 +0,0 @@ - -/* Maneja el Ayuda->Acerca de */ - -#include -#include -#include - -class MnuHelpAbout:public Gtk::MenuItem { -public: - MnuHelpAbout(BaseObjectType* cobject, const Glib::RefPtr& refGlade):Gtk::MenuItem(cobject) { - } - virtual ~MnuHelpAbout() {} - -protected: - Glib::RefPtr refXml; - - virtual void on_activate() { - // preparo para leer el archivo ChangeLog - Glib::ustring line; - Glib::RefPtr log_buffer; - Glib::RefPtr log_io; - - log_buffer = Gtk::TextBuffer::create(); - log_io = Glib::IOChannel::create_from_file("../ChangeLog", "r"); - while (log_io->read_line(line) != Glib::IO_STATUS_EOF) { - log_buffer->insert_at_cursor(line); - } - - try { - refXml = Gnome::Glade::Xml::create("client.glade", "dlgAbout"); - } - catch(const Gnome::Glade::XmlError &ex) { - std::cerr << ex.what() << std::endl; - return; - } - Gtk::Window *dlg = 0; - Gtk::Button *btn_cerrar = 0; - Gtk::TextView *txt_changelog = 0; - refXml->get_widget("dlgAbout", dlg); - refXml->get_widget("btn_close", btn_cerrar); - refXml->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(); - } -}; - diff --git a/Client/src/Makefile.am b/Client/src/Makefile.am index 25f41fd..5d24ed9 100644 --- a/Client/src/Makefile.am +++ b/Client/src/Makefile.am @@ -8,7 +8,9 @@ INCLUDES = \ bin_PROGRAMS = plaqui-client -plaqui_client_SOURCES = main.cpp +plaqui_client_SOURCES = main.cpp \ + menu_bar.cpp \ + dlg_conectar.cpp plaqui_client_LDADD = @PACKAGE_LIBS@ diff --git a/Client/src/client.glade b/Client/src/client.glade index 6d9e49c..8314b28 100644 --- a/Client/src/client.glade +++ b/Client/src/client.glade @@ -21,7 +21,7 @@ 0 - + True @@ -34,7 +34,7 @@ - + True _Conectar True @@ -238,22 +238,6 @@ True - - - - 368 - 96 - True - True - Este boton es para ver si se mueve el scroll!! - True - GTK_RELIEF_NORMAL - - - 224 - 120 - - @@ -438,7 +422,7 @@ GTK_UPDATE_ALWAYS False False - 1234 0 100 1 10 10 + 1234 0 65365 1 10 10 1 @@ -504,7 +488,7 @@ 23 - + True True True @@ -515,7 +499,7 @@ - + True True True diff --git a/Client/src/dlg_conectar.cpp b/Client/src/dlg_conectar.cpp new file mode 100644 index 0000000..8af1482 --- /dev/null +++ b/Client/src/dlg_conectar.cpp @@ -0,0 +1,32 @@ + +#include "dlg_conectar.h" + +DlgConectar::DlgConectar(BaseObjectType *co, const Glib::RefPtr &rg):Gtk::Window(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); + + 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) ); +} + +DlgConectar::~DlgConectar() +{ +} + +void DlgConectar::on_btn_ok_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 + */ +} + +void DlgConectar::on_btn_cancel_clicked() +{ + hide(); +} + diff --git a/Client/src/main.cpp b/Client/src/main.cpp index b9fe630..e1cb336 100644 --- a/Client/src/main.cpp +++ b/Client/src/main.cpp @@ -2,8 +2,7 @@ #include #include #include -#include "mnu_file_exit.h" -#include "mnu_help_about.h" +#include "menu_bar.h" int main (int argc, char **argv) { @@ -21,14 +20,12 @@ int main (int argc, char **argv) } Gtk::Window* pWindow = 0; - MnuFileExit *mnu_file_exit = 0; - MnuHelpAbout *mnu_help_about = 0; Gtk::Button *bar_exit; Gtk::Fixed *work_place; + MiMenuBar *menu_bar; refXml->get_widget("Principal", pWindow); - refXml->get_widget_derived("mnu_file_exit", mnu_file_exit); - refXml->get_widget_derived("mnu_help_about", mnu_help_about); + 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); diff --git a/Client/src/menu_bar.cpp b/Client/src/menu_bar.cpp new file mode 100644 index 0000000..0ca75bc --- /dev/null +++ b/Client/src/menu_bar.cpp @@ -0,0 +1,74 @@ + +#include "menu_bar.h" +#include +#include "dlg_conectar.h" + +MiMenuBar::MiMenuBar(BaseObjectType *co, const Glib::RefPtr &rg):Gtk::MenuBar(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)); +} + +MiMenuBar::~MiMenuBar() +{ +} + +void MiMenuBar::on_mnu_file_exit() +{ + Gtk::Main::quit(); +} + +void MiMenuBar::on_mnu_file_connect() +{ + // preparo para leer el archivo ChangeLog + Glib::RefPtr xml; + + 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 MiMenuBar::on_mnu_help_about() +{ + // preparo para leer el archivo ChangeLog + Glib::RefPtr xml; + Glib::ustring line; + Glib::RefPtr log_buffer; + Glib::RefPtr log_io; + + log_buffer = Gtk::TextBuffer::create(); + log_io = Glib::IOChannel::create_from_file("../ChangeLog", "r"); + while (log_io->read_line(line) != Glib::IO_STATUS_EOF) { + log_buffer->insert_at_cursor(line); + } + + try { + xml = Gnome::Glade::Xml::create("client.glade", "dlgAbout"); + } + catch(const Gnome::Glade::XmlError &ex) { + std::cerr << ex.what() << std::endl; + return; + } + Gtk::Window *dlg = 0; + Gtk::Button *btn_cerrar = 0; + Gtk::TextView *txt_changelog = 0; + xml->get_widget("dlgAbout", dlg); + xml->get_widget("btn_close", btn_cerrar); + 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(); +} +