Частично исправлены баги с загрузкой

pull/11/head
Igor Belitskiy 3 years ago
parent 0562684db6
commit fbac0ac4d3

@ -94,8 +94,8 @@ void MainWindow::settings(){
this->change_security_login();
this->set_active_boot_second();
this->download_local_cfg();
this->download_globl_cfg();
this->event();
//this->download_globl_cfg();
}
else{
@ -106,8 +106,8 @@ void MainWindow::settings(){
info_status_app("boxInfoMessError");
lblWarning->set_text(_("The program must be run as root"));
this->set_active_boot_second();
this->event();
}
this->event();
}
void MainWindow::fill_in_view() {
@ -129,37 +129,48 @@ void MainWindow::fill_in_view() {
this->view_add_colums(*treeViewOTT);
}
void MainWindow::item_selected_kernel(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&) {
void MainWindow::item_selected_kernel(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&) {
auto selection_IPT = treeViewIPT->get_selection();
auto selection_OTT = treeViewOTT->get_selection();
selection_IPT->unselect_all();
selection_OTT->unselect_all();
if (flag_blocked_tree_view == false) {
template_item_selected("GRUB_CMDLINE_LINUX", map_cmd_selection, path, list_store_kernel);
string str_flags = this->dynamic_update_entry("GRUB_CMDLINE_LINUX", map_cmd_selection, vec_Option_kernel);
string str_flags = template_item_selected(size_kernel, list_store_kernel);
Utils::str_replace_all(str_flags, " \"", "\"");
Utils::str_replace_all(str_flags, "\"", "");
map_cmd_selection["GRUB_CMDLINE_LINUX"] = str_flags;
Utils::str_replace_all(str_flags, " ", ", ");
entryKernel->set_text(str_flags);
}
}
void MainWindow::item_selected_OTT(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&) {
void MainWindow::item_selected_OTT(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&) {
auto selection_kernel = treeViewKernel->get_selection();
auto selection_IPT = treeViewIPT->get_selection();
selection_kernel->unselect_all();
selection_IPT->unselect_all();
if (flag_blocked_tree_view == false) {
template_item_selected("GRUB_TERMINAL_OUTPUT", map_cmd_selection , path, list_store_OTT);
string str_flags = this->dynamic_update_entry("GRUB_TERMINAL_OUTPUT", map_cmd_selection, vec_Option_OTT);
string str_flags = template_item_selected(size_OTT, list_store_OTT);
Utils::str_replace_all(str_flags, " \"", "\"");
Utils::str_replace_all(str_flags, "\"", "");
map_cmd_selection["GRUB_TERMINAL_OUTPUT"] = str_flags;
Utils::str_replace_all(str_flags, " ", ",");
entryOTT->set_text(str_flags);
}
}
void MainWindow::item_selected_IPT(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&) {
void MainWindow::item_selected_IPT(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&) {
// TODO
// Баг
auto selection_kernel = treeViewKernel->get_selection();
auto selection_OTT = treeViewOTT->get_selection();
selection_kernel->unselect_all();
selection_OTT->unselect_all();
if (flag_blocked_tree_view == false) {
template_item_selected("GRUB_TERMINAL_INPUT", map_cmd_selection , path, list_store_IPT);
string str_flags = this->dynamic_update_entry("GRUB_TERMINAL_INPUT", map_cmd_selection, vec_Option_IPT);
if (flag_blocked_tree_view == false) {
string str_flags = template_item_selected(size_IPT, list_store_IPT);
Utils::str_replace_all(str_flags, " \"", "\"");
Utils::str_replace_all(str_flags, "\"", "");
map_cmd_selection["GRUB_TERMINAL_INPUT"] = str_flags;
Utils::str_replace_all(str_flags, " ", ",");
entryIPT->set_text(str_flags);
}
}
@ -298,37 +309,18 @@ void MainWindow::get_password_protec(std::map <string, string> &map_temp) {
}
}
void MainWindow::template_item_selected(string key, std::map<string, string> &map_view, const Gtk::TreeModel::Path& path, Glib::RefPtr<Gtk::ListStore> &list_store) {
const auto iter = list_store->get_iter(path);
if(iter) {
const auto row = *iter;
Glib::ustring cmd;
bool check_btn = row[m_columns.check_button];
if (check_btn) {
cmd = "1";
}
else {
cmd = "0";
}
Glib::ustring name = row[m_columns.name];
cout << key + "_" + name << endl;
map_view[name] = cmd;
}
}
string MainWindow::dynamic_update_entry(string key,std::map<string, string> &map_view, vector<string> &vec_allowed) {
string keys = "";
cout << key << endl;
for (auto &key_local: vec_allowed) {
if (map_view.find(key_local) != map_view.end()) {
if (map_view[key_local] == "1") {
keys += string(key_local) + ", ";
string MainWindow::template_item_selected(int size, Glib::RefPtr<Gtk::ListStore> &list_store) {
string cmds = "";
for (int index = 0; index < size; index++) {
Gtk::TreeModel::Row row = list_store->children()[index];
if(row) {
if (row[m_columns.check_button] == true) {
cmds += row[m_columns.name] + " ";
}
}
}
return keys;
cmds = "\"" + cmds + "\"";
return cmds;
}
@ -461,7 +453,7 @@ void MainWindow::localization(){
cmbDefaultDonw->append(_("Last Successful Download"));
}
vector<string> MainWindow::get_setting_entry_all(string key, Gtk::Entry &entry_text, std::map <string, string> &map_temp) {
vector<string> MainWindow::get_setting_entry_all(string key, std::map <string, string> &map_temp) {
vector<string> vec_params;
std::map <string, string>:: iterator iter_map_data;
iter_map_data = map_temp.find(key);
@ -471,24 +463,10 @@ vector<string> MainWindow::get_setting_entry_all(string key, Gtk::Entry &entry_t
Utils::str_replace_all(value, "\"", "");
vec_params = Utils::split(value, ' ');
Utils::str_replace_all(value, " ", ", ");
cout << value << endl;
for (auto &param: vec_params) {
map_cmd_selection[param] = "1";
map_temp[param] = "1";
}
entry_text.set_text(value);
Utils::str_remove(value, ",");
map_temp[key] = value;
}
else {
entry_text.set_text("");
}
}
else {
entry_text.set_text("");
}
return vec_params;
}
@ -793,9 +771,9 @@ void MainWindow::load_template(std::map<string, string>* map_temp, string str_lo
obj_load.set_sections(vec_sections);
*map_temp = obj_load.get_load_data(*map_temp, str_load);
this->get_menu_boot(*map_temp);
this->get_setting_entry_all("GRUB_CMDLINE_LINUX", *entryKernel, *map_temp);
this->get_setting_entry_all("GRUB_TERMINAL_INPUT", *entryIPT, *map_temp);
this->get_setting_entry_all("GRUB_TERMINAL_OUTPUT", *entryOTT, *map_temp);
this->get_setting_entry_all("GRUB_CMDLINE_LINUX", *map_temp);
this->get_setting_entry_all("GRUB_TERMINAL_INPUT", *map_temp);
this->get_setting_entry_all("GRUB_TERMINAL_OUTPUT", *map_temp);
this->set_row_all(*map_temp, list_store_kernel, vec_Option_kernel, size_kernel, "GRUB_CMDLINE_LINUX");
this->set_row_all(*map_temp, list_store_IPT, vec_Option_IPT, size_IPT, "GRUB_TERMINAL_INPUT");
this->set_row_all(*map_temp, list_store_OTT, vec_Option_OTT, size_OTT, "GRUB_TERMINAL_OUTPUT");
@ -803,21 +781,40 @@ void MainWindow::load_template(std::map<string, string>* map_temp, string str_lo
this->get_security_login(*map_temp);
this->get_password_protec(*map_temp);
this->get_default_load(*map_temp);
this->set_entry(entryKernel, *map_temp, "GRUB_CMDLINE_LINUX");
this->set_entry(entryIPT, *map_temp, "GRUB_TERMINAL_INPUT");
this->set_entry(entryOTT, *map_temp, "GRUB_TERMINAL_OUTPUT");
info_warning_error(1);
map_cmd_selection = *map_temp;
}
void MainWindow::set_entry(Gtk::Entry* entry , std::map<string, string> &map_temp, string key) {
if (map_temp.find(key) != map_temp.end()) {
string value = map_temp[key];
Utils::str_replace_all(value, "\"", "");
Utils::str_replace_all(value, " ", ", ");
cout << value << endl;
entry->set_text(value);
}
else {
entry->set_text("");
}
}
void MainWindow::init_dict() {
map_cmd_selection["GRUB_TIMEOUT"] = "";
map_cmd_selection["GRUB_CMDLINE_LINUX"] = "";
map_cmd_selection["GRUB_TERMINAL_INPUT"] = "";
map_cmd_selection["GRUB_TERMINAL_OUTPUT"] = "";
map_cmd_selection["GRUB_BOOT_SILENT"] = "";
map_cmd_selection["GRUB_USER"] = "";
map_cmd_selection["GRUB_PASSWORD"] = "";
map_cmd_selection["GRUB_DEFAULT"] = "";
map_global_cmd_selection = map_cmd_selection;
map_local_cmd_selection = map_cmd_selection;
std::map<std::string, std::string> map_cmd_selection_n;
map_cmd_selection_n["GRUB_TIMEOUT"] = "";
map_cmd_selection_n["GRUB_CMDLINE_LINUX"] = "";
map_cmd_selection_n["GRUB_TERMINAL_INPUT"] = "";
map_cmd_selection_n["GRUB_TERMINAL_OUTPUT"] = "";
map_cmd_selection_n["GRUB_BOOT_SILENT"] = "";
map_cmd_selection_n["GRUB_USER"] = "";
map_cmd_selection_n["GRUB_PASSWORD"] = "";
map_cmd_selection_n["GRUB_DEFAULT"] = "";
map_cmd_selection = map_cmd_selection_n;
map_global_cmd_selection = map_cmd_selection_n;
map_local_cmd_selection = map_cmd_selection_n;
}
void MainWindow::set_row_all(std::map <string, string> &map_cmd, Glib::RefPtr<Gtk::ListStore> &list_store, vector<string> &list_params, size_t size,string key="") {
@ -828,6 +825,7 @@ void MainWindow::set_row_all(std::map <string, string> &map_cmd, Glib::RefPtr<Gt
for (auto &name: list_params) {
if (map_cmd.find(name) != map_cmd.end()) {
if (map_cmd[name] == "1") {
cout << name << "|||" << endl;
this->set_row(list_store, size, name, true);
}
else {

@ -191,14 +191,14 @@ class MainWindow : public Gtk::ApplicationWindow {
bool focus_out_txt_password(GdkEventFocus*);
void get_password_protec(std::map <string, string> &map_temp);
void set_password_protec();
void set_entry(Gtk::Entry* entry , std::map<string, string> &map_temp, string key);
void load_template(std::map<string, string>* map_temp, string str_load);
vector<string> get_setting_entry_all(string key, Gtk::Entry &entry_text, std::map <string, string> &map_temp);
vector<string> get_setting_entry_all(string key, std::map <string, string> &map_temp);
void cmd_entry_all(Gtk::Entry &entry, string cmd_settings, string cmd_remove);
string dynamic_update_entry(string key, std::map<string, string> &map_view, vector<string> &vec_allowed);
void item_selected_kernel(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&);
void item_selected_OTT(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&);
void item_selected_IPT(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&);
void template_item_selected(string key, std::map<string, string> &map_view, const Gtk::TreeModel::Path& path, Glib::RefPtr<Gtk::ListStore> &list_store);
void item_selected_kernel(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&);
void item_selected_OTT(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&);
void item_selected_IPT(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&);
string template_item_selected(int size, Glib::RefPtr<Gtk::ListStore> &list_store);
};
class SettingsPlug : public Gtk::Plug{

Loading…
Cancel
Save