From 312789af174681d48997c30a6f6fe53d5a707105 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Fri, 7 Apr 2023 11:48:13 +0600 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D0=B0=20be?= =?UTF-8?q?ta=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/load.cc | 31 ++++++-------- source/load.h | 4 +- source/save.cc | 14 +++--- source/ubl-settings-bootloader.cc | 71 +++++++++++++++---------------- source/ubl-settings-bootloader.h | 7 ++- ubl-settings-bootloader.desktop | 10 ++--- ubl-settings-bootloader.glade | 4 +- ubl-settings-bootloader_ru.po | 7 ++- 8 files changed, 74 insertions(+), 74 deletions(-) diff --git a/source/load.cc b/source/load.cc index 87f438a..e336dce 100644 --- a/source/load.cc +++ b/source/load.cc @@ -1,30 +1,27 @@ #include "load.h" namespace Lib_Load{ - void Load::set_sections(vector vec_sections){ - this->vec_sections = vec_sections; + void Load::set_sections(string sections){ + this->sections = sections; } map& Load::get_load_data(std::map &map_temp, string str_flag_load) { string cmd = ""; string response = ""; string key = ""; string value = ""; - for (const string §ion: this->vec_sections) { - cmd = "ubconfig --default --source " + str_flag_load + " get " + section; - response = process.call_all_sections(cmd); - vector vec_str_key_value = Utils::split(response, '\n'); - for (const string ¶m: vec_str_key_value) { - if ((param.find("(null)") == std::string::npos) && (param.length() != 0 )) { - if (param.find("=") != std::string::npos) { - size_t index = param.find("="); - key = param.substr(0, index); - value = param.substr(index + 1, param.length()); - Utils::str_replace_all(value, " \"",""); - Utils::str_replace_all(value, "\"",""); - map_temp[key] = value; - } + cmd = "ubconfig --default --source " + str_flag_load + " get " + this->sections; + response = process.call_all_sections(cmd); + vector vec_str_key_value = Utils::split(response, '\n'); + for (const string ¶m: vec_str_key_value) { + if ((param.find("(null)") == std::string::npos) && (param.length() != 0 )) { + if (param.find("=") != std::string::npos) { + size_t index = param.find("="); + key = param.substr(0, index); + value = param.substr(index + 1, param.length()); + Utils::str_replace_all(value, " \"",""); + Utils::str_replace_all(value, "\"",""); + map_temp[key] = value; } - } } return map_temp; diff --git a/source/load.h b/source/load.h index 0ec7cac..d7eb473 100644 --- a/source/load.h +++ b/source/load.h @@ -6,10 +6,10 @@ namespace Lib_Load{ class Load { private: - vector vec_sections; + string sections; My_Process::My_Process_call process = My_Process::My_Process_call(); public: - void set_sections(vector vec_sections); + void set_sections(string sections); map& get_load_data(std::map &map_temp, string str_flag_load); }; diff --git a/source/save.cc b/source/save.cc index 4f7044c..e9617e8 100644 --- a/source/save.cc +++ b/source/save.cc @@ -34,27 +34,31 @@ 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 (iter_map_data->second != iter_map_data_old->second) { + if ((*map_local)[key_name] != (*map_global)[key_name]) { + //cout << 1 << endl; return true; } - else { - return false; - } } - else if (iter_map_data_old == (*map_data_old).end() && iter_map_data != (*map_gui).end()) { + 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; diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index ea99067..d596e64 100755 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -416,13 +416,13 @@ void MainWindow::localization(){ aboutWindows->set_website_label(_("Project Home Page")); lblInfoHead->set_text(_("Configuring system boot parameters")); lblHeaderName->set_text(_("ubl-settings-bootloader")); - aboutWindows->set_comments(_("Setting bootloader")); + aboutWindows->set_comments(_("System boot")); aboutWindows->set_website_label(_("Project Home Page")); lblInfoCommand->set_text(_("Command line parameters:")); lblInfoCommand1->set_text(_("Command line parameters:")); lblInfoCommand2->set_text(_("Command line parameters:")); lblInfoDefaultDonw->set_text(_("Load default:")); - lblInfoSeconds->set_text(_("Seconds")); + lblInfoSeconds->set_text(_("seconds")); lblLoadMenu->set_text(_("Download menu")); lblInfoInputTerminal->set_text(_("Terminal for input")); lblInfoOutputTerminal->set_text(_("Terminal for output")); @@ -452,18 +452,18 @@ void MainWindow::localization(){ cmbDefaultDonw->append(_("Last Successful Download")); } -vector MainWindow::get_setting_entry_all(string key, std::map &map_temp) { +vector MainWindow::get_setting_entry_all(string key, std::map * map_temp) { vector vec_params; std::map :: iterator iter_map_data; - iter_map_data = map_temp.find(key); - if (iter_map_data != map_temp.end()) { + iter_map_data = (*map_temp).find(key); + if (iter_map_data != (*map_temp).end()) { string value = iter_map_data->second; if (value.length() != 0) { Utils::str_replace_all(value, "\"", ""); vec_params = Utils::split(value, ' '); Utils::str_replace_all(value, " ", ", "); Utils::str_remove(value, ","); - map_temp[key] = value; + (*map_temp)[key] = value; } } return vec_params; @@ -663,63 +663,55 @@ void MainWindow::set_active_boot_second() { void MainWindow::wrapper_save_all_cfg() { this->set_data_cfg(); - bool _flag_save_global = this->save_global_cfg(); - bool _flag_save_local = this->save_local_cfg(); + bool _flag_save_global = this->save_template("boot", "global");; + bool _flag_save_local = this->save_template("boot", "system"); if (_flag_save_global && _flag_save_local) { this->info_warning_error(5); } else { info_warning_error(4); } + map_global_cmd_selection = map_cmd_selection; + map_local_cmd_selection = map_cmd_selection; } void MainWindow::wrapper_save_global_cfg() { this->set_data_cfg(); - if (this->save_global_cfg()) { + if (this->save_template("boot", "global")) { this->info_warning_error(5); } else { info_warning_error(3); } + map_global_cmd_selection = map_cmd_selection; + } -bool MainWindow::save_global_cfg() { +bool MainWindow::save_template(string section, string flag_save) { bool flag_no_save = true; obj_save.set_data_local(map_local_cmd_selection); obj_save.set_data_global(map_global_cmd_selection); obj_save.set_data_gui(map_cmd_selection); obj_save.set_vec_params(vec_param_names); - obj_save.save("boot", "global"); + obj_save.save(section, flag_save); vector obj_vec_error = obj_save.get_error(); flag_no_save = obj_save.get_state_save(); - map_global_cmd_selection = map_cmd_selection; return flag_no_save; } void MainWindow::wrapper_save_local_cfg() { this->set_data_cfg(); - if (this->save_local_cfg()) { + if (this->save_template("boot", "system")) { this->info_warning_error(5); } else { info_warning_error(2); } -} - -bool MainWindow::save_local_cfg() { - bool flag_no_save = true; - obj_save.set_data_local(map_local_cmd_selection); - obj_save.set_data_global(map_global_cmd_selection); - obj_save.set_data_gui(map_cmd_selection); - obj_save.set_vec_params(vec_param_names); - obj_save.save("boot", "system"); - vector obj_vec_error = obj_save.get_error(); - flag_no_save = obj_save.get_state_save(); map_local_cmd_selection = map_cmd_selection; - return flag_no_save; } + void MainWindow::set_data_cfg() { string str_flags = entryKernel->get_text(); Utils::str_remove(str_flags, ","); @@ -755,26 +747,28 @@ void MainWindow::set_data_cfg() { void MainWindow::download_globl_cfg() { this->load_template(&map_global_cmd_selection, "global"); info_warning_error(1); + map_cmd_selection = map_global_cmd_selection; } void MainWindow::download_local_cfg() { this->load_template(&map_local_cmd_selection, "system"); info_warning_error(0); + map_cmd_selection = map_local_cmd_selection; } void MainWindow::load_template(std::map* map_temp, string str_load) { - this->init_dict(); + this->init_dict(str_load); entryKernel->set_text(""); entryOTT->set_text(""); entryIPT->set_text(""); - vector vec_sections; - vec_sections.push_back("boot"); - obj_load.set_sections(vec_sections); + string sections; + sections = "boot"; + obj_load.set_sections(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", *map_temp); - this->get_setting_entry_all("GRUB_TERMINAL_INPUT", *map_temp); - this->get_setting_entry_all("GRUB_TERMINAL_OUTPUT", *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"); @@ -785,7 +779,6 @@ void MainWindow::load_template(std::map* map_temp, string str_lo 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"); - map_cmd_selection = *map_temp; } void MainWindow::set_entry(Gtk::Entry* entry , std::map &map_temp, string key) { @@ -801,7 +794,7 @@ void MainWindow::set_entry(Gtk::Entry* entry , std::map &map_tem } -void MainWindow::init_dict() { +void MainWindow::init_dict(string flag_load) { std::map map_cmd_selection_n; map_cmd_selection_n["GRUB_TIMEOUT"] = ""; map_cmd_selection_n["GRUB_CMDLINE_LINUX"] = ""; @@ -812,8 +805,12 @@ void MainWindow::init_dict() { 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; + if (flag_load == "global") { + map_global_cmd_selection = map_cmd_selection_n; + } + else if (flag_load == "system") { + map_local_cmd_selection = map_cmd_selection_n; + } } void MainWindow::set_row_all(std::map &map_cmd, Glib::RefPtr &list_store, vector &list_params, size_t size,string key) { @@ -856,7 +853,7 @@ void MainWindow::info_status_app(string stule) { } void MainWindow::info_warning_error(int mess) { - if (index_error > 0) { + if (obj_process_system.get_count_error() > 0 || obj_process_call.get_count_error() > 0) { info_status_app("boxInfoMessError"); imgInfo->set_from_icon_name("com.ublinux.ubl-settings-bootloader.warning", Gtk::ICON_SIZE_MENU); index_error = 0; diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index ede6a38..dc79fc7 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -147,7 +147,7 @@ class MainWindow : public Gtk::ApplicationWindow { void set_row_all(std::map &map_cmd, Glib::RefPtr &list_store, vector &list_params, size_t size,string key); void set_row(Glib::RefPtr &list_store, int size, std::string name, bool flag_chbox); void get_builder(); - void init_dict(); + void init_dict(string flag_load); void add_CSS(); void show_pass(); void localization(); @@ -164,11 +164,10 @@ class MainWindow : public Gtk::ApplicationWindow { struct Result wrapper_call(string cmd); void log_mess_error(string &cmd); void wrapper_save_all_cfg(); - bool save_local_cfg(); void wrapper_save_local_cfg(); void wrapper_save_global_cfg(); + bool save_template(string section, string flag_save); void view_add_colums(Gtk::TreeView &treeView); - bool save_global_cfg(); vector read_file_and_view(string file_name ,Gtk::TreeModel::Row &row, Glib::RefPtr list_store_m); void download_local_cfg(); void download_globl_cfg(); @@ -193,7 +192,7 @@ class MainWindow : public Gtk::ApplicationWindow { void set_password_protec(); void set_entry(Gtk::Entry* entry , std::map &map_temp, string key); void load_template(std::map* map_temp, string str_load); - vector get_setting_entry_all(string key, std::map &map_temp); + vector get_setting_entry_all(string key, std::map * map_temp); void cmd_entry_all(Gtk::Entry &entry, string cmd_settings, string cmd_remove); void item_selected_kernel(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&); void item_selected_OTT(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&); diff --git a/ubl-settings-bootloader.desktop b/ubl-settings-bootloader.desktop index b279ca8..6e5f0d7 100644 --- a/ubl-settings-bootloader.desktop +++ b/ubl-settings-bootloader.desktop @@ -1,11 +1,11 @@ [Desktop Entry] Encoding=UTF-8 Name=ubl-settings-bootloader -Name[ru]=Загрузчик -GenericName=Загрузчик -GenericName[ru]=Загрузчик -Comment=ubl-settings-bootloader -Comment[ru]=Загрузчик +Name[ru]=Настройка загрузчика +GenericName=Настройка загрузчика +GenericName[ru]=Настройка загрузчика +Comment=Bootloader setup application +Comment[ru]=Приложение для настройки загрузчика Type=Application Exec=pkexec ubl-settings-bootloader Icon=com.ublinux.ubl-settings-bootloader diff --git a/ubl-settings-bootloader.glade b/ubl-settings-bootloader.glade index 20eb89c..7943ab0 100644 --- a/ubl-settings-bootloader.glade +++ b/ubl-settings-bootloader.glade @@ -321,9 +321,9 @@ specified priority True True False - 5 + 3 5 - 5 + 3 5 6 6 diff --git a/ubl-settings-bootloader_ru.po b/ubl-settings-bootloader_ru.po index 9f561ea..d67001a 100644 --- a/ubl-settings-bootloader_ru.po +++ b/ubl-settings-bootloader_ru.po @@ -261,8 +261,11 @@ msgid "Save to global and local configuration" msgstr "Сохранить глобальную и локальную конфигурацию" #: source/ubl-settings-bootloader.cc:293 -msgid "Seconds" -msgstr "Секунд" +msgid "seconds" +msgstr "секунд" + +msgid "System boot" +msgstr "Загрузка системы" msgid "Serial terminal" msgstr "Последовательный терминал"