From 633dead36dfc080b418eae030ce860fc276d91ab Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Thu, 30 Mar 2023 10:39:16 +0600 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20"=D0=9F=D0=B0=D1=80=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D1=80=D1=8B=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B8:"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-bootloader.cc | 53 +++++++++++++++++++++---------- source/ubl-settings-bootloader.h | 2 ++ 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index 5c34eb3..e3e564b 100755 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -125,9 +125,11 @@ 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, path, list_store_kernel); - string str_flags = this->dynamic_update_entry(map_cmd_selection, vec_Option_kernel); - entryKernel->set_text(str_flags); + if (flag_blocked_tree_view == false) { + 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); + } } void MainWindow::item_selected_OTT(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&) { @@ -135,9 +137,11 @@ 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 , path, list_store_OTT); - string str_flags = this->dynamic_update_entry(map_cmd_selection, vec_Option_OTT); - entryOTT->set_text(str_flags); + if (flag_blocked_tree_view == false) { + 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); + } } @@ -146,9 +150,11 @@ 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 , path, list_store_IPT); - string str_flags = this->dynamic_update_entry(map_cmd_selection, vec_Option_IPT); - entryIPT->set_text(str_flags); + if (flag_blocked_tree_view == false) { + 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); + } } @@ -204,13 +210,6 @@ void MainWindow::view_add_cell(Gtk::TreeModel::Row &row, Glib::RefPtrappend()); 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(name.c_str()); row[m_columns.description] = gettext(arr_view[1][index].c_str()); @@ -330,15 +329,33 @@ vector MainWindow::get_setting_entry_all(string cmd, Gtk::Entry &entry_t } bool MainWindow::focus_out_txt_kernel(GdkEventFocus*) { + this->set_entry_to_tree_view(list_store_kernel, *entryKernel, vec_Option_kernel, size_kernel); return true; } + bool MainWindow::focus_out_txt_IPT(GdkEventFocus*) { + this->set_entry_to_tree_view(list_store_IPT, *entryIPT, vec_Option_IPT, size_IPT); return true; } bool MainWindow::focus_out_txt_OTT(GdkEventFocus*) { + this->set_entry_to_tree_view(list_store_OTT, *entryOTT, vec_Option_OTT, size_OTT); return true; } +void MainWindow::set_entry_to_tree_view(Glib::RefPtr &list_store, Gtk::Entry &entry, std::vector &vec_Option, int size) { + flag_blocked_tree_view = true; + vector vec_params; + std::string text = entry.get_text(); + str_replace_all(text, " ", ""); + vec_params = split(text, ','); + for (auto &name: vec_Option) { + this->set_row(list_store, size, name, false); + } + for (auto &name: vec_params) { + this->set_row(list_store, size, name, true); + } + flag_blocked_tree_view = false; +} void MainWindow::get_menu_boot(string cmd) { struct Result res_response = this->wrapper_call(cmd); @@ -401,6 +418,9 @@ void MainWindow::event(){ treeViewIPTModel->signal_row_changed().connect(sigc::mem_fun(*this, &MainWindow::item_selected_IPT)); Glib::RefPtr treeViewOTTModel = treeViewOTT->get_model(); treeViewOTTModel->signal_row_changed().connect(sigc::mem_fun(*this, &MainWindow::item_selected_OTT)); + entryKernel->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_kernel)); + entryIPT->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_IPT)); + entryOTT->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_OTT)); } } @@ -514,7 +534,6 @@ void MainWindow::download_local_cfg() { this->set_row_all(map_local_cmd_selection,list_store_kernel , vec_Option_kernel, size_kernel); this->set_row_all(map_local_cmd_selection,list_store_IPT , vec_Option_IPT, size_IPT); this->set_row_all(map_local_cmd_selection,list_store_OTT , vec_Option_OTT, size_OTT); - info_warning_error(0); } diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index 23f4090..fe7b57b 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -99,6 +99,7 @@ class MainWindow : public Gtk::ApplicationWindow { Glib::RefPtr list_store_kernel; Glib::RefPtr list_store_IPT; Glib::RefPtr list_store_OTT; + void set_entry_to_tree_view(Glib::RefPtr &list_store, Gtk::Entry &entry, std::vector &vec_Option, int size); Gtk::TreeModel::Row row_kernel; Gtk::TreeModel::Row row_IPT; Gtk::TreeModel::Row row_OTT; @@ -114,6 +115,7 @@ class MainWindow : public Gtk::ApplicationWindow { bool flag_save_all = false; bool flag_save_global = false; bool flag_save_local = false; + bool flag_blocked_tree_view = false; size_t size_kernel = 0; size_t size_IPT = 0; size_t size_OTT = 0;