]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Client/src/menu_bar.cpp
algunos cambios menores
[z.facultad/75.42/plaqui.git] / Client / src / menu_bar.cpp
1
2 #include "menu_bar.h"
3 #include <iostream>
4 #include "dlg_conectar.h"
5
6 MiMenuBar::MiMenuBar(BaseObjectType *co, const Glib::RefPtr<Gnome::Glade::Xml> &rg):Gtk::MenuBar(co),refXml(rg)
7 {
8         Gtk::MenuItem *conect=0, *exit=0, *about=0;
9         rg->get_widget("mnu_file_connect", conect);
10         rg->get_widget("mnu_file_exit", exit);
11         rg->get_widget("mnu_help_about", about);
12         conect->signal_activate().connect( SigC::slot(*this, &MiMenuBar::on_mnu_file_connect));
13         exit->signal_activate().connect( SigC::slot(*this, &MiMenuBar::on_mnu_file_exit));
14         about->signal_activate().connect( SigC::slot(*this, &MiMenuBar::on_mnu_help_about));
15 }
16
17 MiMenuBar::~MiMenuBar()
18 {
19 }
20
21 void MiMenuBar::on_mnu_file_exit()
22 {
23         Gtk::Main::quit();
24 }
25
26 void MiMenuBar::on_mnu_file_connect()
27 {
28         // preparo para leer el archivo ChangeLog
29         Glib::RefPtr<Gnome::Glade::Xml> xml;
30
31         try {
32                 xml = Gnome::Glade::Xml::create("client.glade", "dlgConectar");
33         }
34         catch(const Gnome::Glade::XmlError &ex) {
35                 std::cerr << ex.what() << std::endl;
36                 return;
37         }
38         DlgConectar *dlg = 0;
39         xml->get_widget_derived("dlgConectar", dlg);
40         dlg->show();
41 }
42
43 void MiMenuBar::on_mnu_help_about()
44 {
45         // preparo para leer el archivo ChangeLog
46         Glib::RefPtr<Gnome::Glade::Xml> xml;
47         Glib::ustring line;
48         Glib::RefPtr<Gtk::TextBuffer> log_buffer;
49         Glib::RefPtr<Glib::IOChannel> log_io;
50
51         log_buffer = Gtk::TextBuffer::create();
52         log_io = Glib::IOChannel::create_from_file("../ChangeLog", "r");
53         while (log_io->read_line(line) != Glib::IO_STATUS_EOF) {
54                 log_buffer->insert_at_cursor(line);
55         }
56
57         try {
58                 xml = Gnome::Glade::Xml::create("client.glade", "dlgAbout");
59         }
60         catch(const Gnome::Glade::XmlError &ex) {
61                 std::cerr << ex.what() << std::endl;
62                 return;
63         }
64         Gtk::Window *dlg = 0;
65         Gtk::Button *btn_cerrar = 0;
66         Gtk::TextView *txt_changelog = 0;
67         xml->get_widget("dlgAbout", dlg);
68         xml->get_widget("btn_close", btn_cerrar);
69         xml->get_widget("txt_changelog", txt_changelog);
70         btn_cerrar->signal_clicked().connect(SigC::slot(*dlg, &Gtk::Dialog::hide));
71         txt_changelog->set_buffer(log_buffer);
72         dlg->show();
73 }
74