refactor interface

This commit is contained in:
Guillermo Roche 2020-05-26 18:09:22 +02:00
parent c4e2ec96dd
commit 90a76301f2
14 changed files with 42 additions and 63 deletions

View File

@ -17,7 +17,6 @@ SOURCES += \
container_window.cpp \ container_window.cpp \
view_install.cpp \ view_install.cpp \
controller_install.cpp \ controller_install.cpp \
view_remove.cpp \
controller_remove.cpp \ controller_remove.cpp \
view_info.cpp \ view_info.cpp \
controller_info.cpp \ controller_info.cpp \
@ -35,7 +34,6 @@ HEADERS += \
container_window.h \ container_window.h \
view_install.h \ view_install.h \
controller_install.h \ controller_install.h \
view_remove.h \
controller_remove.h \ controller_remove.h \
view_info.h \ view_info.h \
controller_info.h \ controller_info.h \

View File

@ -7,14 +7,12 @@ container_window::container_window(conexion *con, Glib::RefPtr< Gtk::Application
this->app->run(loggin); this->app->run(loggin);
if(this->loggin.login){ if(this->loggin.login){
this->cont_inst=new controller_install(&install, sesion.get()); 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->cont_info=new controller_info(&info, sesion.get());
this->con_uinfo=new controller_user_info(&uinfo, sesion.get(), this); this->con_uinfo=new controller_user_info(&uinfo, sesion.get(), this);
this->app.reset(); this->app.reset();
this->app=Gtk::Application::create( "org.gtkmm.examples.base"); this->app=Gtk::Application::create( "org.gtkmm.examples.base");
this->add(this->book); this->add(this->book);
this->book.append_page(install,"build"); this->book.append_page(install,"build");
this->book.append_page(remove,"remove");
this->book.append_page(this->info,"info"); this->book.append_page(this->info,"info");
this->book.append_page(this->uinfo,"users"); this->book.append_page(this->uinfo,"users");
this->show_all_children(); this->show_all_children();

View File

@ -5,8 +5,6 @@
#include "controller_install.h" #include "controller_install.h"
#include "conexion.h" #include "conexion.h"
#include "session_manager.h" #include "session_manager.h"
#include "view_remove.h"
#include "controller_remove.h"
#include "view_info.h" #include "view_info.h"
#include "controller_info.h" #include "controller_info.h"
#include "view_user_info.h" #include "view_user_info.h"
@ -24,11 +22,9 @@ private:
std::unique_ptr<session_manager> sesion; std::unique_ptr<session_manager> sesion;
view_loggin loggin; view_loggin loggin;
view_install install; view_install install;
view_remove remove;
view_info info; view_info info;
view_user_info uinfo; view_user_info uinfo;
controller_install *cont_inst; controller_install *cont_inst;
controller_remove *cont_rem;
controller_info *cont_info; controller_info *cont_info;
controller_user_info *con_uinfo; controller_user_info *con_uinfo;
Gtk::Notebook book; Gtk::Notebook book;

View File

@ -6,6 +6,7 @@ controller_info::controller_info(view_info *view, session_manager *sesion)
this->view=view; this->view=view;
this->sesion=sesion; this->sesion=sesion;
this->load_info(); this->load_info();
this->add_controlers();
} }
void controller_info::load_info(){ 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); info=info.substr(pos+1, info.size()+1);
return ret; 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();
}

View File

@ -13,6 +13,8 @@ private:
session_manager *sesion; session_manager *sesion;
void load_info(); void load_info();
std::string get_first(std::string &info); std::string get_first(std::string &info);
void on_button_clicked();
void add_controlers();
}; };
#endif // CONTROLLER_INFO_H #endif // CONTROLLER_INFO_H

View File

@ -13,11 +13,5 @@ void controller_install::add_controlers(){
} }
void controller_install::on_button_clicked(){ void controller_install::on_button_clicked(){
std::string text = vis->m_refTextBuffer1->get_text(); this->sesi->install_command(vis->entry.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);
} }

View File

@ -1,6 +1,7 @@
#include "view_info.h" #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->m_refTreeModel = Gtk::ListStore::create(this->m_Columns);
this->tree.set_model(this->m_refTreeModel); 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("config", m_Columns.r_config);
tree.append_column("user", m_Columns.r_user); tree.append_column("user", m_Columns.r_user);
this->add(this->tree); 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);
} }

View File

@ -2,6 +2,7 @@
#define VIEW_INFO_H #define VIEW_INFO_H
#include <gtkmm/box.h> #include <gtkmm/box.h>
#include <gtkmm/buttonbox.h>
#include <gtkmm/treeview.h> #include <gtkmm/treeview.h>
#include <gtkmm/liststore.h> #include <gtkmm/liststore.h>
@ -21,9 +22,11 @@ public:
Gtk::TreeModelColumn<std::string> r_user; Gtk::TreeModelColumn<std::string> r_user;
Gtk::TreeModelColumn<bool> r_config; Gtk::TreeModelColumn<bool> r_config;
}; };
ModelColumns m_Columns;
ModelColumns m_Columns;
Glib::RefPtr<Gtk::ListStore> m_refTreeModel; Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
Gtk::ButtonBox b_box;
Gtk::Button b_remove;
void restart_table();
}; };
#endif // VIEW_INFO_H #endif // VIEW_INFO_H

View File

@ -6,20 +6,14 @@ view_install::view_install():m_button("build"),m_VBox(Gtk::ORIENTATION_VERTICAL)
set_border_width(5); set_border_width(5);
add(m_VBox); 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_VBox.pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
m_ButtonBox.pack_start(m_button, Gtk::PACK_SHRINK); m_ButtonBox.pack_start(m_button, Gtk::PACK_SHRINK);
m_ButtonBox.set_border_width(5); m_ButtonBox.set_border_width(5);
m_ButtonBox.set_spacing(5); m_ButtonBox.set_spacing(5);
m_ButtonBox.set_layout(Gtk::BUTTONBOX_END); 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(); show_all_children();
} }

View File

@ -1,7 +1,7 @@
#ifndef VISTA_H #ifndef VISTA_H
#define VISTA_H #define VISTA_H
#include <gtkmm/button.h> #include <gtkmm/button.h>
#include <gtkmm/textview.h> #include <gtkmm/entry.h>
#include <gtkmm/buttonbox.h> #include <gtkmm/buttonbox.h>
#include <gtkmm/scrolledwindow.h> #include <gtkmm/scrolledwindow.h>
#include <gtkmm/box.h> #include <gtkmm/box.h>
@ -12,10 +12,8 @@ public:
view_install(); view_install();
Gtk::Button m_button; Gtk::Button m_button;
Gtk::Box m_VBox; Gtk::Box m_VBox;
Gtk::ScrolledWindow m_ScrolledWindow; Gtk::Entry entry;
Gtk::TextView m_TextView;
Gtk::ButtonBox m_ButtonBox; Gtk::ButtonBox m_ButtonBox;
Glib::RefPtr<Gtk::TextBuffer> m_refTextBuffer1;
}; };
#endif // VISTA_H #endif // VISTA_H

View File

@ -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);
}

View File

@ -1,18 +0,0 @@
#ifndef VIEW_REMOVE_H
#define VIEW_REMOVE_H
#include <gtkmm/button.h>
#include <gtkmm/buttonbox.h>
#include <gtkmm/box.h>
#include <gtkmm/entry.h>
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

View File

@ -10,8 +10,9 @@ view_user_info::view_user_info()
tree.append_column("user", m_Columns.r_user); tree.append_column("user", m_Columns.r_user);
tree.append_column("config", m_Columns.r_admin); tree.append_column("config", m_Columns.r_admin);
this->add(this->tree); this->add(this->tree);
this->add(this->b_add_user); this->b_box.add(this->b_add_user);
this->add(this->b_dell_user); this->b_box.add(this->b_dell_user);
this->add(this->b_box);
} }
void view_user_info::restart_table(){ void view_user_info::restart_table(){

View File

@ -2,6 +2,7 @@
#define VIEW_USER_INFO_H #define VIEW_USER_INFO_H
#include <gtkmm/box.h> #include <gtkmm/box.h>
#include <gtkmm/buttonbox.h>
#include <gtkmm/treeview.h> #include <gtkmm/treeview.h>
#include <gtkmm/liststore.h> #include <gtkmm/liststore.h>
@ -21,6 +22,8 @@ public:
ModelColumns m_Columns; ModelColumns m_Columns;
Glib::RefPtr<Gtk::ListStore> m_refTreeModel; Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
Gtk::ButtonBox b_box;
Gtk::Button b_add_user; Gtk::Button b_add_user;
Gtk::Button b_dell_user; Gtk::Button b_dell_user;