|
|
|
|
@ -80,9 +80,10 @@ void MainWindow::settings(){
|
|
|
|
|
if (this->check_root() == 0) {
|
|
|
|
|
spbSecond->set_range(0, 100000000000);
|
|
|
|
|
spbSecond->set_increments(1.0, 1.0);
|
|
|
|
|
this->fill_in_view();
|
|
|
|
|
|
|
|
|
|
this->download_local_cfg();
|
|
|
|
|
this->download_globl_cfg();
|
|
|
|
|
this->fill_in_view();
|
|
|
|
|
this->event();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@ -105,9 +106,9 @@ void MainWindow::fill_in_view() {
|
|
|
|
|
treeViewIPT->set_model(list_store_IPT);
|
|
|
|
|
treeViewOTT->set_model(list_store_OTT);
|
|
|
|
|
|
|
|
|
|
this->read_file_and_view("boot-options.csv", row_kernel, list_store_kernel);
|
|
|
|
|
this->read_file_and_view("input-options.csv", row_IPT, list_store_IPT);
|
|
|
|
|
this->read_file_and_view("output-options.csv", row_OTT, list_store_OTT);
|
|
|
|
|
vec_Option_kernel = this->read_file_and_view("boot-options.csv", row_kernel, list_store_kernel);
|
|
|
|
|
vec_Option_IPT = this->read_file_and_view("input-options.csv", row_IPT, list_store_IPT);
|
|
|
|
|
vec_Option_OTT = this->read_file_and_view("output-options.csv", row_OTT, list_store_OTT);
|
|
|
|
|
this->view_add_colums(*treeViewKernel);
|
|
|
|
|
this->view_add_colums(*treeViewIPT);
|
|
|
|
|
this->view_add_colums(*treeViewOTT);
|
|
|
|
|
@ -121,8 +122,8 @@ void MainWindow::item_selected_kernel(const Gtk::TreeModel::Path& path, const Gt
|
|
|
|
|
auto selection_OTT = treeViewOTT->get_selection();
|
|
|
|
|
selection_IPT->unselect_all();
|
|
|
|
|
selection_OTT->unselect_all();
|
|
|
|
|
template_item_selected(map_cmd_selection_kernel, path, list_store_kernel);\
|
|
|
|
|
string str_flags = this->dynamic_update_entry(map_cmd_selection_kernel,map_global_cmd_selection_kernel,map_local_cmd_selection_kernel);
|
|
|
|
|
template_item_selected(map_cmd_selection, path, list_store_kernel);
|
|
|
|
|
string str_flags = this->dynamic_update_entry(map_cmd_selection, vec_Option_kernel);
|
|
|
|
|
entryKernel->set_text(str_flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -131,8 +132,8 @@ void MainWindow::item_selected_OTT(const Gtk::TreeModel::Path& path, const Gtk::
|
|
|
|
|
auto selection_IPT = treeViewIPT->get_selection();
|
|
|
|
|
selection_kernel->unselect_all();
|
|
|
|
|
selection_IPT->unselect_all();
|
|
|
|
|
template_item_selected(map_cmd_selection_OTT , path, list_store_OTT);
|
|
|
|
|
string str_flags = this->dynamic_update_entry(map_cmd_selection_OTT, map_global_cmd_selection_OTT,map_local_cmd_selection_OTT);
|
|
|
|
|
template_item_selected(map_cmd_selection , path, list_store_OTT);
|
|
|
|
|
string str_flags = this->dynamic_update_entry(map_cmd_selection, vec_Option_OTT);
|
|
|
|
|
entryOTT->set_text(str_flags);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -142,8 +143,8 @@ void MainWindow::item_selected_IPT(const Gtk::TreeModel::Path& path, const Gtk::
|
|
|
|
|
auto selection_OTT = treeViewOTT->get_selection();
|
|
|
|
|
selection_kernel->unselect_all();
|
|
|
|
|
selection_OTT->unselect_all();
|
|
|
|
|
template_item_selected(map_cmd_selection_IPT , path, list_store_IPT);
|
|
|
|
|
string str_flags = this->dynamic_update_entry(map_cmd_selection_IPT, map_global_cmd_selection_IPT,map_local_cmd_selection_IPT);
|
|
|
|
|
template_item_selected(map_cmd_selection , path, list_store_IPT);
|
|
|
|
|
string str_flags = this->dynamic_update_entry(map_cmd_selection, vec_Option_IPT);
|
|
|
|
|
entryIPT->set_text(str_flags);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@ -155,30 +156,25 @@ void MainWindow::template_item_selected(std::map<string, string> &map_view, con
|
|
|
|
|
Glib::ustring cmd;
|
|
|
|
|
bool check_btn = row[m_columns.check_button];
|
|
|
|
|
if (check_btn) {
|
|
|
|
|
cmd = row[m_columns.cmd_set_true];
|
|
|
|
|
cmd = "1";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cmd = row[m_columns.cmd_set_false];
|
|
|
|
|
cmd = "0";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Glib::ustring name = row[m_columns.name];
|
|
|
|
|
cout << cmd << " " << name << endl;
|
|
|
|
|
|
|
|
|
|
map_view[name] = cmd;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string MainWindow::dynamic_update_entry(std::map<string, string> &map_view, std::map<string, string> &map_global_view, std::map<string, string> &map_local_view) {
|
|
|
|
|
string MainWindow::dynamic_update_entry(std::map<string, string> &map_view, vector<string> &vec_allowed) {
|
|
|
|
|
string keys = "";
|
|
|
|
|
for(auto &it: map_view) {
|
|
|
|
|
string key = it.first;
|
|
|
|
|
if (flag_load == true && map_global_view.find(key) != map_global_view.end()) {
|
|
|
|
|
if (map_global_view[key] != map_view[key]){
|
|
|
|
|
keys += string(key) + ", ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (flag_load == false && map_local_view.find(key) != map_local_view.end()) {
|
|
|
|
|
if (map_local_view[key] != map_view[key]){
|
|
|
|
|
for (auto &key: vec_allowed) {
|
|
|
|
|
if (map_view.find(key) != map_view.end()) {
|
|
|
|
|
if (map_view[key] == "1") {
|
|
|
|
|
keys += string(key) + ", ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -187,14 +183,14 @@ string MainWindow::dynamic_update_entry(std::map<string, string> &map_view, std:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::read_file_and_view(string file_name ,Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> list_store_m) {
|
|
|
|
|
vector<string> MainWindow::read_file_and_view(string file_name ,Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> list_store_m) {
|
|
|
|
|
std::array<std::vector<std::string>, 5> arr_view = read_csv(path_resources + "/" + file_name);
|
|
|
|
|
std::vector<std::string> vec_Option = arr_view[3];
|
|
|
|
|
std::vector<std::string> vec_Description = arr_view[4];
|
|
|
|
|
std::vector<std::string> vec_Option = arr_view[0];
|
|
|
|
|
for (size_t index = 0; index < vec_Option.size(); index++) {
|
|
|
|
|
|
|
|
|
|
this->view_add_cell(row, list_store_m , arr_view, index);
|
|
|
|
|
}
|
|
|
|
|
return vec_Option;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::view_add_colums(Gtk::TreeView &treeView) {
|
|
|
|
|
@ -205,23 +201,21 @@ void MainWindow::view_add_colums(Gtk::TreeView &treeView) {
|
|
|
|
|
|
|
|
|
|
void MainWindow::view_add_cell(Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> list_store_m , std::array<std::vector<std::string>, 5> &arr_view , size_t index) {
|
|
|
|
|
row = *(list_store_m->append());
|
|
|
|
|
bool flag_chb = true;
|
|
|
|
|
row[m_columns.cmd_get] = arr_view[0][index];
|
|
|
|
|
row[m_columns.cmd_set_true] = arr_view[1][index];
|
|
|
|
|
row[m_columns.cmd_set_false] = arr_view[2][index];
|
|
|
|
|
bool flag_chb = false;
|
|
|
|
|
string name = arr_view[0][index];
|
|
|
|
|
if (map_cmd_selection.find(name) != map_cmd_selection.end()) {
|
|
|
|
|
if (map_cmd_selection[name] == "1"){
|
|
|
|
|
flag_chb = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
row[m_columns.check_button] = flag_chb;
|
|
|
|
|
row[m_columns.name] = gettext(arr_view[3][index].c_str());
|
|
|
|
|
row[m_columns.description] = gettext(arr_view[4][index].c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
row[m_columns.name] = gettext(name.c_str());
|
|
|
|
|
row[m_columns.description] = gettext(arr_view[1][index].c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::get_builder(){
|
|
|
|
|
builder->get_widget("chbLoadVariantSelectionTimer", chbLoadVariantSelectionTimer);
|
|
|
|
|
builder->get_widget("chbLastSelectionWillBecome", chbLastSelectionWillBecome);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
builder->get_widget("lblInfoCommand", lblInfoCommand);
|
|
|
|
|
builder->get_widget("lblInfoCommand1", lblInfoCommand1);
|
|
|
|
|
builder->get_widget("lblInfoCommand2", lblInfoCommand2);
|
|
|
|
|
@ -264,6 +258,9 @@ void MainWindow::get_builder(){
|
|
|
|
|
builder->get_widget("treeViewIPT", treeViewIPT);
|
|
|
|
|
builder->get_widget("imgBG", imgBG);
|
|
|
|
|
builder->get_widget("overHead", overHead);
|
|
|
|
|
builder->get_widget("lblDownloadMode", lblDownloadMode);
|
|
|
|
|
builder->get_widget("lblSecurityLogin", lblSecurityLogin);
|
|
|
|
|
builder->get_widget("lblPasswordProtec", lblPasswordProtec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::localization(){
|
|
|
|
|
@ -286,8 +283,8 @@ void MainWindow::localization(){
|
|
|
|
|
lblInfoDefaultDonw->set_text(gettext("Default download"));
|
|
|
|
|
lblInfoSeconds->set_text(gettext("Seconds"));
|
|
|
|
|
lblLoadMenu->set_text(gettext("Download menu"));
|
|
|
|
|
lblInfoInputTerminal->set_text(gettext("Input terminal"));
|
|
|
|
|
lblInfoOutputTerminal->set_text(gettext("Output terminal"));
|
|
|
|
|
lblInfoInputTerminal->set_text(gettext("Terminal for input"));
|
|
|
|
|
lblInfoOutputTerminal->set_text(gettext("Terminal for output"));
|
|
|
|
|
|
|
|
|
|
chbLoadVariantSelectionTimer->set_label(gettext("Load variant selection timer"));
|
|
|
|
|
chbLastSelectionWillBecome->set_label(gettext("The last selection will become the default boot choice"));
|
|
|
|
|
@ -301,22 +298,32 @@ void MainWindow::localization(){
|
|
|
|
|
btnSave->set_label(gettext("Save"));
|
|
|
|
|
btnLoad->set_label(gettext("Load"));
|
|
|
|
|
this->set_title(gettext("ubl-settings-bootloader"));
|
|
|
|
|
|
|
|
|
|
lblDownloadMode->set_text(gettext("Download mode:"));
|
|
|
|
|
lblSecurityLogin->set_text(gettext("Security login:"));
|
|
|
|
|
lblPasswordProtec->set_text(gettext("Password protection:"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::get_setting_entry_all(string cmd, Gtk::Entry &entry_text) {
|
|
|
|
|
vector<string> MainWindow::get_setting_entry_all(string cmd, Gtk::Entry &entry_text, std::map <string, string> &map_temp) {
|
|
|
|
|
vector<string> vec_params;
|
|
|
|
|
struct Result<string> res_response = this->wrapper_call(cmd);
|
|
|
|
|
if (res_response.error == 0) {
|
|
|
|
|
vector<string> vec_cmd_kernel = split(res_response.response, ' ');
|
|
|
|
|
str_replace_all(res_response.response, " ", ", ");
|
|
|
|
|
str_replace_all(res_response.response, "\"", "");
|
|
|
|
|
vec_params = split(res_response.response, ' ');
|
|
|
|
|
str_replace_all(res_response.response, " ", ", ");
|
|
|
|
|
entry_text.set_text(res_response.response);
|
|
|
|
|
for (auto ¶m: vec_params) {
|
|
|
|
|
map_cmd_selection[param] = "1";
|
|
|
|
|
map_temp[param] = "1";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (res_response.error == 3) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return vec_params;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::get_menu_boot(string cmd) {
|
|
|
|
|
@ -461,11 +468,11 @@ void MainWindow::download_globl_cfg() {
|
|
|
|
|
std::string cmd_boot_time = "sudo ubconfig --default --source global get boot GRUB_TIMEOUT";
|
|
|
|
|
this->get_menu_boot(cmd_boot_time);
|
|
|
|
|
string cmd_kernel_entry = "sudo ubconfig --default --source global get boot GRUB_BOOT_SILENT";
|
|
|
|
|
this->get_setting_entry_all(cmd_kernel_entry, *entryKernel);
|
|
|
|
|
this->get_setting_entry_all(cmd_kernel_entry, *entryKernel, map_global_cmd_selection);
|
|
|
|
|
string cmd_ipt_entry = "sudo ubconfig --default --source global get boot GRUB_TERMINAL_INPUT";
|
|
|
|
|
this->get_setting_entry_all(cmd_ipt_entry, *entryIPT);
|
|
|
|
|
this->get_setting_entry_all(cmd_ipt_entry, *entryIPT, map_global_cmd_selection);
|
|
|
|
|
string cmd_opt_entry = "sudo ubconfig --default --source global get boot GRUB_TERMINAL_OUTPUT";
|
|
|
|
|
this->get_setting_entry_all(cmd_opt_entry, *entryOTT);
|
|
|
|
|
this->get_setting_entry_all(cmd_opt_entry, *entryOTT, map_global_cmd_selection);
|
|
|
|
|
info_warning_error(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -480,11 +487,11 @@ void MainWindow::download_local_cfg() {
|
|
|
|
|
std::string cmd_boot_time = "sudo ubconfig --default --source system get boot GRUB_TIMEOUT";
|
|
|
|
|
this->get_menu_boot(cmd_boot_time);
|
|
|
|
|
string cmd_kernel_entry = "sudo ubconfig --default --source system get boot GRUB_BOOT_SILENT";
|
|
|
|
|
this->get_setting_entry_all(cmd_kernel_entry, *entryKernel);
|
|
|
|
|
this->get_setting_entry_all(cmd_kernel_entry, *entryKernel, map_local_cmd_selection);
|
|
|
|
|
string cmd_ipt_entry = "sudo ubconfig --default --source system get boot GRUB_TERMINAL_INPUT";
|
|
|
|
|
this->get_setting_entry_all(cmd_ipt_entry, *entryIPT);
|
|
|
|
|
this->get_setting_entry_all(cmd_ipt_entry, *entryIPT, map_local_cmd_selection);
|
|
|
|
|
string cmd_opt_entry = "sudo ubconfig --default --source system get boot GRUB_TERMINAL_OUTPUT";
|
|
|
|
|
this->get_setting_entry_all(cmd_opt_entry, *entryOTT);
|
|
|
|
|
this->get_setting_entry_all(cmd_opt_entry, *entryOTT, map_local_cmd_selection);
|
|
|
|
|
info_warning_error(0);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|