]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
Se reestructura las clases del cliente para comenzar su desarrollo definitivo
authorRicardo Markiewicz <gazer.arg@gmail.com>
Tue, 11 Nov 2003 22:59:35 +0000 (22:59 +0000)
committerRicardo Markiewicz <gazer.arg@gmail.com>
Tue, 11 Nov 2003 22:59:35 +0000 (22:59 +0000)
Client/include/dlg_conectar.h
Client/include/menu_bar.h [deleted file]
Client/include/principal.h [new file with mode: 0644]
Client/src/Makefile.am
Client/src/client.glade
Client/src/dlg_conectar.cpp
Client/src/main.cpp
Client/src/principal.cpp [moved from Client/src/menu_bar.cpp with 55% similarity]

index 3c75234fc3b500a396603c4bd3d3f34c77bd600e..834fff30a8256763e5324bcbfd47dea7c36a7927 100644 (file)
  *  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<Gnome::Glade::Xml> &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<Gnome::Glade::Xml> 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 (file)
index 23ef6e6..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-
-#ifndef _MENU_BAR_H_
-#define _MENU_BAR_H_
-
-#include <gtkmm.h>
-#include <libglademm.h>
-
-class MiMenuBar:public Gtk::MenuBar {
-public:
-       MiMenuBar(BaseObjectType *co, const Glib::RefPtr<Gnome::Glade::Xml> &rg);
-       virtual ~MiMenuBar();
-
-protected:
-       // Archivo XML del Padre
-       Glib::RefPtr<Gnome::Glade::Xml> 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 (file)
index 0000000..d4270a8
--- /dev/null
@@ -0,0 +1,30 @@
+
+
+#ifndef _PRINCIPAL_H_
+#define _PRINCIPAL_H_
+
+#include <gtkmm.h>
+#include <libglademm.h>
+#include "dlg_conectar.h"
+
+class Principal:public Gtk::Window {
+public:
+       Principal(BaseObjectType *co, const Glib::RefPtr<Gnome::Glade::Xml> &rg);
+       virtual ~Principal();
+
+protected:
+       // Archivo XML del Padre
+       Glib::RefPtr<Gnome::Glade::Xml> 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_
+
index 5d24ed904c2b9671769631e0a11ec52de3db7497..a2f4a9394e8673a987dd80346442da1ca7f9257a 100644 (file)
@@ -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@
index 8314b2871c4641bad26815bbdf1ec2e03a528a0f..52fc899168627299b3d6deaf574573b3c3aadc9f 100644 (file)
   </child>
 </widget>
 
-<widget class="GtkWindow" id="dlgConectar">
-  <property name="visible">True</property>
-  <property name="title" translatable="yes">Conectar ...</property>
-  <property name="type">GTK_WINDOW_TOPLEVEL</property>
-  <property name="window_position">GTK_WIN_POS_CENTER</property>
-  <property name="modal">False</property>
-  <property name="resizable">True</property>
-  <property name="destroy_with_parent">False</property>
-
-  <child>
-    <widget class="GtkTable" id="table1">
-      <property name="visible">True</property>
-      <property name="n_rows">3</property>
-      <property name="n_columns">2</property>
-      <property name="homogeneous">False</property>
-      <property name="row_spacing">0</property>
-      <property name="column_spacing">0</property>
-
-      <child>
-       <widget class="GtkEntry" id="entry1">
-         <property name="visible">True</property>
-         <property name="can_focus">True</property>
-         <property name="editable">True</property>
-         <property name="visibility">True</property>
-         <property name="max_length">0</property>
-         <property name="text" translatable="yes"></property>
-         <property name="has_frame">True</property>
-         <property name="invisible_char" translatable="yes">*</property>
-         <property name="activates_default">False</property>
-       </widget>
-       <packing>
-         <property name="left_attach">1</property>
-         <property name="right_attach">2</property>
-         <property name="top_attach">0</property>
-         <property name="bottom_attach">1</property>
-         <property name="y_options"></property>
-       </packing>
-      </child>
-
-      <child>
-       <widget class="GtkSpinButton" id="spinbutton1">
-         <property name="visible">True</property>
-         <property name="can_focus">True</property>
-         <property name="climb_rate">1</property>
-         <property name="digits">0</property>
-         <property name="numeric">False</property>
-         <property name="update_policy">GTK_UPDATE_ALWAYS</property>
-         <property name="snap_to_ticks">False</property>
-         <property name="wrap">False</property>
-         <property name="adjustment">1234 0 65365 1 10 10</property>
-       </widget>
-       <packing>
-         <property name="left_attach">1</property>
-         <property name="right_attach">2</property>
-         <property name="top_attach">1</property>
-         <property name="bottom_attach">2</property>
-         <property name="y_options"></property>
-       </packing>
-      </child>
-
-      <child>
-       <widget class="GtkLabel" id="label5">
-         <property name="visible">True</property>
-         <property name="label" translatable="yes">Puerto :</property>
-         <property name="use_underline">False</property>
-         <property name="use_markup">False</property>
-         <property name="justify">GTK_JUSTIFY_LEFT</property>
-         <property name="wrap">False</property>
-         <property name="selectable">False</property>
-         <property name="xalign">0</property>
-         <property name="yalign">0.5</property>
-         <property name="xpad">0</property>
-         <property name="ypad">0</property>
-       </widget>
-       <packing>
-         <property name="left_attach">0</property>
-         <property name="right_attach">1</property>
-         <property name="top_attach">1</property>
-         <property name="bottom_attach">2</property>
-         <property name="x_options">fill</property>
-         <property name="y_options">expand</property>
-       </packing>
-      </child>
-
-      <child>
-       <widget class="GtkLabel" id="label4">
-         <property name="visible">True</property>
-         <property name="label" translatable="yes">Servidor :</property>
-         <property name="use_underline">False</property>
-         <property name="use_markup">False</property>
-         <property name="justify">GTK_JUSTIFY_LEFT</property>
-         <property name="wrap">False</property>
-         <property name="selectable">False</property>
-         <property name="xalign">0</property>
-         <property name="yalign">0.5</property>
-         <property name="xpad">0</property>
-         <property name="ypad">0</property>
-       </widget>
-       <packing>
-         <property name="left_attach">0</property>
-         <property name="right_attach">1</property>
-         <property name="top_attach">0</property>
-         <property name="bottom_attach">1</property>
-         <property name="x_options">fill</property>
-         <property name="y_options">expand</property>
-       </packing>
-      </child>
-
-      <child>
-       <widget class="GtkHButtonBox" id="hbuttonbox1">
-         <property name="visible">True</property>
-         <property name="layout_style">GTK_BUTTONBOX_END</property>
-         <property name="spacing">23</property>
-
-         <child>
-           <widget class="GtkButton" id="btn_cancel">
-             <property name="visible">True</property>
-             <property name="can_default">True</property>
-             <property name="can_focus">True</property>
-             <property name="label">gtk-cancel</property>
-             <property name="use_stock">True</property>
-             <property name="relief">GTK_RELIEF_NORMAL</property>
-           </widget>
-         </child>
-
-         <child>
-           <widget class="GtkButton" id="btn_ok">
-             <property name="visible">True</property>
-             <property name="can_default">True</property>
-             <property name="can_focus">True</property>
-             <property name="label">gtk-ok</property>
-             <property name="use_stock">True</property>
-             <property name="relief">GTK_RELIEF_NORMAL</property>
-           </widget>
-         </child>
-       </widget>
-       <packing>
-         <property name="left_attach">0</property>
-         <property name="right_attach">2</property>
-         <property name="top_attach">2</property>
-         <property name="bottom_attach">3</property>
-         <property name="x_options">shrink|fill</property>
-       </packing>
-      </child>
-    </widget>
-  </child>
-</widget>
-
 <widget class="GtkWindow" id="dlgAbout">
-  <property name="visible">True</property>
   <property name="title" translatable="yes">Acerca de ...</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
   <property name="window_position">GTK_WIN_POS_CENTER</property>
   </child>
 </widget>
 
+<widget class="GtkDialog" id="dlgConectar">
+  <property name="title" translatable="yes">Conectar</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="has_separator">True</property>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="dialog-vbox1">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+       <widget class="GtkHButtonBox" id="dialog-action_area1">
+         <property name="visible">True</property>
+         <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+         <child>
+           <widget class="GtkButton" id="btn_cancel">
+             <property name="visible">True</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-cancel</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="response_id">-6</property>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkButton" id="btn_ok">
+             <property name="visible">True</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-ok</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="response_id">-5</property>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">True</property>
+         <property name="pack_type">GTK_PACK_END</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkTable" id="table1">
+         <property name="visible">True</property>
+         <property name="n_rows">2</property>
+         <property name="n_columns">2</property>
+         <property name="homogeneous">False</property>
+         <property name="row_spacing">0</property>
+         <property name="column_spacing">0</property>
+
+         <child>
+           <widget class="GtkLabel" id="label10">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">Servidor :</property>
+             <property name="use_underline">False</property>
+             <property name="use_markup">False</property>
+             <property name="justify">GTK_JUSTIFY_LEFT</property>
+             <property name="wrap">False</property>
+             <property name="selectable">False</property>
+             <property name="xalign">0</property>
+             <property name="yalign">0.5</property>
+             <property name="xpad">0</property>
+             <property name="ypad">0</property>
+           </widget>
+           <packing>
+             <property name="left_attach">0</property>
+             <property name="right_attach">1</property>
+             <property name="top_attach">0</property>
+             <property name="bottom_attach">1</property>
+             <property name="x_options">fill</property>
+             <property name="y_options"></property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkLabel" id="label11">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">Puerto :</property>
+             <property name="use_underline">False</property>
+             <property name="use_markup">False</property>
+             <property name="justify">GTK_JUSTIFY_LEFT</property>
+             <property name="wrap">False</property>
+             <property name="selectable">False</property>
+             <property name="xalign">0</property>
+             <property name="yalign">0.5</property>
+             <property name="xpad">0</property>
+             <property name="ypad">0</property>
+           </widget>
+           <packing>
+             <property name="left_attach">0</property>
+             <property name="right_attach">1</property>
+             <property name="top_attach">1</property>
+             <property name="bottom_attach">2</property>
+             <property name="x_options">fill</property>
+             <property name="y_options"></property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkEntry" id="server_name">
+             <property name="visible">True</property>
+             <property name="can_focus">True</property>
+             <property name="editable">True</property>
+             <property name="visibility">True</property>
+             <property name="max_length">0</property>
+             <property name="text" translatable="yes">localhost</property>
+             <property name="has_frame">True</property>
+             <property name="invisible_char" translatable="yes">*</property>
+             <property name="activates_default">False</property>
+           </widget>
+           <packing>
+             <property name="left_attach">1</property>
+             <property name="right_attach">2</property>
+             <property name="top_attach">0</property>
+             <property name="bottom_attach">1</property>
+             <property name="y_options"></property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkSpinButton" id="server_port">
+             <property name="visible">True</property>
+             <property name="can_focus">True</property>
+             <property name="climb_rate">1</property>
+             <property name="digits">0</property>
+             <property name="numeric">False</property>
+             <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+             <property name="snap_to_ticks">False</property>
+             <property name="wrap">False</property>
+             <property name="adjustment">1234 1 65535 1 10 10</property>
+           </widget>
+           <packing>
+             <property name="left_attach">1</property>
+             <property name="right_attach">2</property>
+             <property name="top_attach">1</property>
+             <property name="bottom_attach">2</property>
+             <property name="y_options"></property>
+           </packing>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">True</property>
+         <property name="fill">True</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>
index 8af1482256427e73646cfbda05fa9e027dfceb84..47d2c8615fec2510c746b4ddf377765c28821ae3 100644 (file)
@@ -1,32 +1,40 @@
 
 #include "dlg_conectar.h"
 
-DlgConectar::DlgConectar(BaseObjectType *co, const Glib::RefPtr<Gnome::Glade::Xml> &rg):Gtk::Window(co),refXml(rg)
+DlgConectar::DlgConectar(BaseObjectType *co, const Glib::RefPtr<Gnome::Glade::Xml> &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();
 }
 
index e1cb3364ab9fdbc10d0f94c2cfb415dced58310b..11bce6b33fef3eb25c0501798899a29d47d49920 100644 (file)
@@ -2,7 +2,7 @@
 #include <gtkmm.h>
 #include <libglademm.h>
 #include <iostream>
-#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<Gnome::Glade::Xml> 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;
similarity index 55%
rename from Client/src/menu_bar.cpp
rename to Client/src/principal.cpp
index 0ca75bcd33e8f6a4e62c32acebca89cc7bf0c2a6..062aa4b7455769b8c302ae2d0cfb4e606bb889bc 100644 (file)
@@ -1,49 +1,48 @@
 
-#include "menu_bar.h"
+
+
+#include "principal.h"
 #include <iostream>
-#include "dlg_conectar.h"
 
-MiMenuBar::MiMenuBar(BaseObjectType *co, const Glib::RefPtr<Gnome::Glade::Xml> &rg):Gtk::MenuBar(co),refXml(rg)
+Principal::Principal(BaseObjectType *co, const Glib::RefPtr<Gnome::Glade::Xml> &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<Gnome::Glade::Xml> 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<Gnome::Glade::Xml> xml;
+/*     Glib::RefPtr<Gnome::Glade::Xml> xml;
        Glib::ustring line;
        Glib::RefPtr<Gtk::TextBuffer> log_buffer;
        Glib::RefPtr<Glib::IOChannel> 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();*/
 }