#include "controller_user_info.h" #include "dialog_add_user.h" #include #include controller_user_info::controller_user_info(view_user_info *view, session_manager *sesion, Gtk::Window *container) { this->view=view; this->sesion=sesion; this->container=container; this->load_info(); this->add_controlers(); } void controller_user_info::load_info(){ std::list list=this->sesion->get_users_info(); for(std::string data:list){ Gtk::TreeModel::Row row = *(this->view->m_refTreeModel->append()); row[this->view->m_Columns.r_user]=get_first(data); row[this->view->m_Columns.r_admin]=(get_first(data)=="t"); } } void controller_user_info::add_controlers(){ this->view->b_add_user.signal_clicked().connect(sigc::mem_fun(this, &controller_user_info::on_button_clicked_add)); this->view->b_dell_user.signal_clicked().connect(sigc::mem_fun(this, &controller_user_info::on_button_clicked_remove)); } void controller_user_info::on_button_clicked_add(){ dialog_add_user dialog(this->container, sesion); dialog.run(); this->view->restart_table(); this->load_info(); } void controller_user_info::on_button_clicked_remove(){ Gtk::TreeModel::Row row = *this->view->tree.get_selection()->get_selected(); std::string name=row.get_value(this->view->m_Columns.r_user); if(name.find("Gtk-CRITICAL **:")==std::string::npos){ this->sesion->remove_user(name); } this->view->restart_table(); this->load_info(); } std::string controller_user_info::get_first(std::string &info){ int pos = info.find(":"); std::string ret = info.substr(0, pos); info=info.substr(pos+1, info.size()+1); return ret; }