diff --git a/ClienteTFG.pro b/ClienteTFG.pro index 2fe31a8..4bc575d 100644 --- a/ClienteTFG.pro +++ b/ClienteTFG.pro @@ -17,7 +17,6 @@ SOURCES += \ container_window.cpp \ view_install.cpp \ controller_install.cpp \ - view_remove.cpp \ controller_remove.cpp \ view_info.cpp \ controller_info.cpp \ @@ -35,7 +34,6 @@ HEADERS += \ container_window.h \ view_install.h \ controller_install.h \ - view_remove.h \ controller_remove.h \ view_info.h \ controller_info.h \ diff --git a/container_window.cpp b/container_window.cpp index ce6a8b8..3a84bdf 100644 --- a/container_window.cpp +++ b/container_window.cpp @@ -7,14 +7,12 @@ container_window::container_window(conexion *con, Glib::RefPtr< Gtk::Application this->app->run(loggin); if(this->loggin.login){ this->cont_inst=new controller_install(&install, sesion.get()); - this->cont_rem=new controller_remove(&remove, sesion.get()); this->cont_info=new controller_info(&info, sesion.get()); this->con_uinfo=new controller_user_info(&uinfo, sesion.get(), this); this->app.reset(); this->app=Gtk::Application::create( "org.gtkmm.examples.base"); this->add(this->book); this->book.append_page(install,"build"); - this->book.append_page(remove,"remove"); this->book.append_page(this->info,"info"); this->book.append_page(this->uinfo,"users"); this->show_all_children(); diff --git a/container_window.h b/container_window.h index 2f7e9d1..08918a8 100644 --- a/container_window.h +++ b/container_window.h @@ -5,8 +5,6 @@ #include "controller_install.h" #include "conexion.h" #include "session_manager.h" -#include "view_remove.h" -#include "controller_remove.h" #include "view_info.h" #include "controller_info.h" #include "view_user_info.h" @@ -24,11 +22,9 @@ private: std::unique_ptr sesion; view_loggin loggin; view_install install; - view_remove remove; view_info info; view_user_info uinfo; controller_install *cont_inst; - controller_remove *cont_rem; controller_info *cont_info; controller_user_info *con_uinfo; Gtk::Notebook book; diff --git a/controller_info.cpp b/controller_info.cpp index 8b3b538..e9cde45 100644 --- a/controller_info.cpp +++ b/controller_info.cpp @@ -6,6 +6,7 @@ controller_info::controller_info(view_info *view, session_manager *sesion) this->view=view; this->sesion=sesion; this->load_info(); + this->add_controlers(); } void controller_info::load_info(){ @@ -25,3 +26,18 @@ std::string controller_info::get_first(std::string &info){ info=info.substr(pos+1, info.size()+1); return ret; } + +void controller_info::add_controlers(){ + this->view->b_remove.signal_clicked().connect(sigc::mem_fun(this, + &controller_info::on_button_clicked)); +} + +void controller_info::on_button_clicked(){ + Gtk::TreeModel::Row row = *this->view->tree.get_selection()->get_selected(); + std::string name=row.get_value(this->view->m_Columns.r_name); + if(name.find("Gtk-CRITICAL **:")==std::string::npos){ + this->sesion->remove_command(name); + } + this->view->restart_table(); + this->load_info(); +} diff --git a/controller_info.h b/controller_info.h index 9055108..e7cfabc 100644 --- a/controller_info.h +++ b/controller_info.h @@ -13,6 +13,8 @@ private: session_manager *sesion; void load_info(); std::string get_first(std::string &info); + void on_button_clicked(); + void add_controlers(); }; #endif // CONTROLLER_INFO_H diff --git a/controller_install.cpp b/controller_install.cpp index a9a4295..d80e884 100644 --- a/controller_install.cpp +++ b/controller_install.cpp @@ -13,11 +13,5 @@ void controller_install::add_controlers(){ } void controller_install::on_button_clicked(){ - std::string text = vis->m_refTextBuffer1->get_text(); - /*std::cout << text << std::endl; - this->con->write_string("exec"); - this->con->write_string(text); - this->con->read_string(text,10); - std::cout << text << std::endl;*/ - this->sesi->install_command(text); + this->sesi->install_command(vis->entry.get_text()); } diff --git a/view_info.cpp b/view_info.cpp index 4c0e1eb..e2bf586 100644 --- a/view_info.cpp +++ b/view_info.cpp @@ -1,6 +1,7 @@ #include "view_info.h" -view_info::view_info() +view_info::view_info():Gtk::Box(Gtk::ORIENTATION_VERTICAL), + b_remove("remove") { this->m_refTreeModel = Gtk::ListStore::create(this->m_Columns); this->tree.set_model(this->m_refTreeModel); @@ -10,4 +11,11 @@ view_info::view_info() tree.append_column("config", m_Columns.r_config); tree.append_column("user", m_Columns.r_user); this->add(this->tree); + this->b_box.add(this->b_remove); + this->add(this->b_box); +} + +void view_info::restart_table(){ + this->m_refTreeModel = Gtk::ListStore::create(this->m_Columns); + this->tree.set_model(this->m_refTreeModel); } diff --git a/view_info.h b/view_info.h index 1a0c109..cc6f140 100644 --- a/view_info.h +++ b/view_info.h @@ -2,6 +2,7 @@ #define VIEW_INFO_H #include +#include #include #include @@ -21,9 +22,11 @@ public: Gtk::TreeModelColumn r_user; Gtk::TreeModelColumn r_config; }; - - ModelColumns m_Columns; + ModelColumns m_Columns; Glib::RefPtr m_refTreeModel; + Gtk::ButtonBox b_box; + Gtk::Button b_remove; + void restart_table(); }; #endif // VIEW_INFO_H diff --git a/view_install.cpp b/view_install.cpp index dbd059e..e7a165c 100644 --- a/view_install.cpp +++ b/view_install.cpp @@ -6,20 +6,14 @@ view_install::view_install():m_button("build"),m_VBox(Gtk::ORIENTATION_VERTICAL) set_border_width(5); add(m_VBox); - m_ScrolledWindow.add(m_TextView); - m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - m_VBox.pack_start(m_ScrolledWindow); + m_VBox.pack_start(this->entry); - //Add buttons: m_VBox.pack_start(m_ButtonBox, Gtk::PACK_SHRINK); m_ButtonBox.pack_start(m_button, Gtk::PACK_SHRINK); m_ButtonBox.set_border_width(5); m_ButtonBox.set_spacing(5); m_ButtonBox.set_layout(Gtk::BUTTONBOX_END); - m_refTextBuffer1 = Gtk::TextBuffer::create(); - //m_refTextBuffer1->set_text("This is the text from TextBuffer #1."); - m_TextView.set_buffer(m_refTextBuffer1); show_all_children(); } diff --git a/view_install.h b/view_install.h index 62d9a6a..37e49c3 100644 --- a/view_install.h +++ b/view_install.h @@ -1,7 +1,7 @@ #ifndef VISTA_H #define VISTA_H #include -#include +#include #include #include #include @@ -12,10 +12,8 @@ public: view_install(); Gtk::Button m_button; Gtk::Box m_VBox; - Gtk::ScrolledWindow m_ScrolledWindow; - Gtk::TextView m_TextView; + Gtk::Entry entry; Gtk::ButtonBox m_ButtonBox; - Glib::RefPtr m_refTextBuffer1; }; #endif // VISTA_H diff --git a/view_remove.cpp b/view_remove.cpp deleted file mode 100644 index 0f5b1e2..0000000 --- a/view_remove.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "view_remove.h" - -view_remove::view_remove():m_button("remove"),m_VBox(Gtk::ORIENTATION_VERTICAL) -{ - set_border_width(5); - add(m_VBox); - m_VBox.pack_start(this->entry); - //Add buttons: - m_VBox.pack_start(m_ButtonBox, Gtk::PACK_SHRINK); - m_ButtonBox.pack_start(m_button, Gtk::PACK_SHRINK); - m_ButtonBox.set_border_width(5); - m_ButtonBox.set_spacing(5); - m_ButtonBox.set_layout(Gtk::BUTTONBOX_END); -} diff --git a/view_remove.h b/view_remove.h deleted file mode 100644 index e1d4b8c..0000000 --- a/view_remove.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef VIEW_REMOVE_H -#define VIEW_REMOVE_H -#include -#include -#include -#include - -class view_remove :public Gtk::Box -{ -public: - view_remove(); - Gtk::Button m_button; - Gtk::Box m_VBox; - Gtk::ButtonBox m_ButtonBox; - Gtk::Entry entry; -}; - -#endif // VIEW_REMOVE_H diff --git a/view_user_info.cpp b/view_user_info.cpp index 0fd4ecf..5af9ade 100644 --- a/view_user_info.cpp +++ b/view_user_info.cpp @@ -10,8 +10,9 @@ view_user_info::view_user_info() tree.append_column("user", m_Columns.r_user); tree.append_column("config", m_Columns.r_admin); this->add(this->tree); - this->add(this->b_add_user); - this->add(this->b_dell_user); + this->b_box.add(this->b_add_user); + this->b_box.add(this->b_dell_user); + this->add(this->b_box); } void view_user_info::restart_table(){ diff --git a/view_user_info.h b/view_user_info.h index 8f06635..c08e6ae 100644 --- a/view_user_info.h +++ b/view_user_info.h @@ -2,6 +2,7 @@ #define VIEW_USER_INFO_H #include +#include #include #include @@ -21,6 +22,8 @@ public: ModelColumns m_Columns; Glib::RefPtr m_refTreeModel; + + Gtk::ButtonBox b_box; Gtk::Button b_add_user; Gtk::Button b_dell_user;