Сделана beta версия

pull/11/head
Igor Belitskiy 3 years ago
parent 7431cc1a36
commit 312789af17

@ -1,16 +1,15 @@
#include "load.h"
namespace Lib_Load{
void Load::set_sections(vector<string> vec_sections){
this->vec_sections = vec_sections;
void Load::set_sections(string sections){
this->sections = sections;
}
map<string, string>& Load::get_load_data(std::map <string, string> &map_temp, string str_flag_load) {
string cmd = "";
string response = "";
string key = "";
string value = "";
for (const string &section: this->vec_sections) {
cmd = "ubconfig --default --source " + str_flag_load + " get " + section;
cmd = "ubconfig --default --source " + str_flag_load + " get " + this->sections;
response = process.call_all_sections(cmd);
vector<string> vec_str_key_value = Utils::split(response, '\n');
for (const string &param: vec_str_key_value) {
@ -24,8 +23,6 @@ namespace Lib_Load{
map_temp[key] = value;
}
}
}
}
return map_temp;
}

@ -6,10 +6,10 @@ namespace Lib_Load{
class Load {
private:
vector<string> vec_sections;
string sections;
My_Process::My_Process_call process = My_Process::My_Process_call();
public:
void set_sections(vector<string> vec_sections);
void set_sections(string sections);
map<string, string>& get_load_data(std::map <string, string> &map_temp, string str_flag_load);
};

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

@ -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<string> MainWindow::get_setting_entry_all(string key, 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);
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<string> 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<string> 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<string, string>* map_temp, string str_load) {
this->init_dict();
this->init_dict(str_load);
entryKernel->set_text("");
entryOTT->set_text("");
entryIPT->set_text("");
vector<string> 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<string, string>* 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<string, string> &map_temp, string key) {
@ -801,7 +794,7 @@ void MainWindow::set_entry(Gtk::Entry* entry , std::map<string, string> &map_tem
}
void MainWindow::init_dict() {
void MainWindow::init_dict(string flag_load) {
std::map<std::string, std::string> map_cmd_selection_n;
map_cmd_selection_n["GRUB_TIMEOUT"] = "";
map_cmd_selection_n["GRUB_CMDLINE_LINUX"] = "";
@ -812,9 +805,13 @@ void MainWindow::init_dict() {
map_cmd_selection_n["GRUB_PASSWORD"] = "";
map_cmd_selection_n["GRUB_DEFAULT"] = "";
map_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 <string, string> &map_cmd, Glib::RefPtr<Gtk::ListStore> &list_store, vector<string> &list_params, size_t size,string key) {
for (auto &name: list_params) {
@ -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;

@ -147,7 +147,7 @@ class MainWindow : public Gtk::ApplicationWindow {
void set_row_all(std::map <string, string> &map_cmd, Glib::RefPtr<Gtk::ListStore> &list_store, vector<string> &list_params, size_t size,string key);
void set_row(Glib::RefPtr<Gtk::ListStore> &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<string> 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<string> read_file_and_view(string file_name ,Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> 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<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, 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);
void item_selected_kernel(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&);
void item_selected_OTT(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&);

@ -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

@ -321,9 +321,9 @@ specified priority</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="margin-left">5</property>
<property name="margin-left">3</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-start">3</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>

@ -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 "Последовательный терминал"

Loading…
Cancel
Save