56 lines
1.5 KiB
C++
56 lines
1.5 KiB
C++
#include "view_loggin.h"
|
|
#include "vista.h"
|
|
#include "controlador.h"
|
|
|
|
#include <gtkmm/messagedialog.h>
|
|
|
|
view_loggin::view_loggin(conexion *con):button("check"),box(Gtk::ORIENTATION_VERTICAL),
|
|
box_user(Gtk::ORIENTATION_HORIZONTAL), box_pass(Gtk::ORIENTATION_HORIZONTAL)
|
|
{
|
|
this->con=con;
|
|
|
|
set_title("loggin");
|
|
set_border_width(5);
|
|
|
|
this->user.set_text("user");
|
|
this->pass.set_text("pass");
|
|
|
|
this->button.signal_clicked().connect(sigc::mem_fun(this,
|
|
&view_loggin::on_button_clicked));
|
|
|
|
this->box_user.add(user);
|
|
this->box_user.add(entry_user);
|
|
this->entry_user.set_hexpand(true);
|
|
this->box_user.set_spacing(10);
|
|
|
|
this->box_pass.add(pass);
|
|
this->box_pass.add(entry_pass);
|
|
this->entry_pass.set_visibility(false);
|
|
this->entry_pass.set_hexpand(true);
|
|
this->box_pass.set_spacing(10);
|
|
|
|
this->box.add(box_user);
|
|
this->box.add(box_pass);
|
|
this->box.add(button);
|
|
this->box.set_spacing(10);
|
|
|
|
this->add(box);
|
|
|
|
show_all_children();
|
|
}
|
|
|
|
void view_loggin::on_button_clicked(){
|
|
std::string user=this->entry_user.get_text();//this->m_refTextBufferUser->get_text();
|
|
std::string pass=this->entry_pass.get_text();//this->m_refTextBufferPass->get_text();
|
|
|
|
if(con->check_pass(user,pass)){
|
|
this->login=true;
|
|
this->hide();
|
|
}else{
|
|
this->login=false;
|
|
Gtk::MessageDialog err(*this,"error", false, Gtk::MessageType::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
|
|
err.set_secondary_text("Bad password or username");
|
|
err.run();
|
|
}
|
|
}
|