diff --git a/source/save.cc b/source/save.cc index 0c753f1..584e7ea 100644 --- a/source/save.cc +++ b/source/save.cc @@ -34,31 +34,24 @@ bool Save::check_save(string flag_save, string key_name) { } iter_map_data = (*map_gui).find(key_name); iter_map_data_old = (*map_data_old).find(key_name); - //cout << (*map_local)[key_name] << " || " << (*map_gui)[key_name] << " || " << (*map_global)[key_name] << endl; if ((*map_local).find(key_name) != (*map_local).end() && (*map_global).find(key_name) != (*map_global).end()) { if ((*map_local)[key_name] != (*map_global)[key_name]) { - //cout << 1 << endl; return true; } } if (iter_map_data_old == (*map_data_old).end() && iter_map_data != (*map_gui).end()) { - //cout << 3 << endl; return true; } else if (iter_map_data->second != iter_map_data_old->second) { - //cout << 4 << endl; return true; } else if (iter_map_data->second.length() == 0 && iter_map_data_old->second.length() == 0) { - //cout << 5 << endl; return false; } else if (iter_map_data->second == iter_map_data_old->second) { - //cout << 6 << endl; return false; } else { - //cout << 7 << endl; return true; } return true; @@ -114,4 +107,49 @@ void Save::save(string sections, string str_flag_save) { } } +void Save::save_all(string sections, string str_flag_save) { + string key = ""; + string value = ""; + string cmd_all = "ubconfig --target " + str_flag_save + " set " + sections; + size_t len_start_cmd_all = cmd_all.length(); + string str_error = ""; + this->flag_no_save = true; + string cmd = ""; + string cmd_remove = ""; + for (const auto &key: *vec_param_names) { + if (map_gui->find(key) != map_gui->end()) { + value = (*map_gui)[key]; + if (this->check_save(str_flag_save, key)) { + if (value.length() != 0) { + cmd_all += " " + key + "=\"" + value + "\""; + } + else if (value.length() == 0) { + cmd = "ubconfig --target " + str_flag_save + " remove " + sections + " " + key; + } + else { + cmd = ""; + } + if (cmd.length() != 0) { + process.call(cmd, ""); + this->flag_no_save = false; + str_error = process.get_cmd_error(); + if (str_error.length() != 0) { + this->vec_errors.push_back(str_error); + str_error = ""; + } + } + } + } + + } + if (len_start_cmd_all != cmd_all.length()) { + process.call(cmd, ""); + this->flag_no_save = false; + str_error = process.get_cmd_error(); + if (str_error.length() != 0) { + this->vec_errors.push_back(str_error); + str_error = ""; + } + } +} } diff --git a/source/save.h b/source/save.h index 1730a80..bdc2f56 100644 --- a/source/save.h +++ b/source/save.h @@ -21,6 +21,7 @@ public: bool get_state_save(); int get_count_error(); string get_cmd_error(); + void save_all(string sections, string str_flag_save); void set_count_error(int count_error); void set_vec_params(vector& vec_param_names); void save(string sections, string str_flag_save) ; diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index a1d91b0..871bb8c 100755 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -472,10 +472,14 @@ vector MainWindow::get_setting_entry_all(string key, std::map get_text().length() == 0) { info_status_app("boxInfoMessError"); + imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.warning", Gtk::ICON_SIZE_MENU); lblWarning->set_text(_("Enter your password")); boxSave->set_sensitive(false); } else { + info_status_app("boxInfoMessOK"); + imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.checked", Gtk::ICON_SIZE_MENU); + lblWarning->set_text(""); boxSave->set_sensitive(true); string key = entryPasswordProtecc->get_text(); if (key != "************") { @@ -488,10 +492,14 @@ bool MainWindow::focus_out_txt_password(GdkEventFocus*) { bool MainWindow::focus_out_txt_login(GdkEventFocus*) { if (entrySecurityLogin->get_text().length() == 0) { info_status_app("boxInfoMessError"); + imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.warning", Gtk::ICON_SIZE_MENU); lblWarning->set_text(_("Enter login")); boxSave->set_sensitive(false); } else { + info_status_app("boxInfoMessOK"); + imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.checked", Gtk::ICON_SIZE_MENU); + lblWarning->set_text(""); map_cmd_selection["GRUB_USER"] = entrySecurityLogin->get_text(); boxSave->set_sensitive(true); } @@ -607,6 +615,9 @@ void MainWindow::change_security_login() { entrySecurityLogin->set_sensitive(false); entrySecurityLogin->set_text(""); boxSave->set_sensitive(true); + info_status_app("boxInfoMessOK"); + imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.checked", Gtk::ICON_SIZE_MENU); + lblWarning->set_text(""); } else if (index == 1) { entrySecurityLogin->set_sensitive(true); @@ -643,6 +654,9 @@ void MainWindow::change_password_protecc() { entryPasswordProtecc->set_sensitive(false); entryPasswordProtecc->set_text(""); boxSave->set_sensitive(true); + info_status_app("boxInfoMessOK"); + imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.checked", Gtk::ICON_SIZE_MENU); + lblWarning->set_text(""); } else if (index == 1) { entryPasswordProtecc->set_sensitive(true);