From 236e632e0a384edeb8386bf2f4639ae99b5f4c8f Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 3 May 2023 12:53:04 +0600 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B3=D0=B0=D0=BB=D0=BA=D0=B0=D0=BC=D0=B8=20TreeView=20"=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D0=B5=D0=B9"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- grub-music.csv => grub-beeplist.csv | 0 source/ubl-settings-bootloader.cc | 64 ++++++++++++++++++++++++----- source/ubl-settings-bootloader.h | 3 ++ 4 files changed, 57 insertions(+), 12 deletions(-) rename grub-music.csv => grub-beeplist.csv (100%) diff --git a/Makefile b/Makefile index f6d42e7..b5911fa 100644 --- a/Makefile +++ b/Makefile @@ -126,7 +126,7 @@ install: check uninstall @install -Dm644 -t /usr/share/${PKGNAME}/ cmdline-linux.csv @install -Dm644 -t /usr/share/${PKGNAME}/ grub-terminal-input.csv @install -Dm644 -t /usr/share/${PKGNAME}/ grub-terminal-output.csv - @install -Dm644 -t /usr/share/${PKGNAME}/ grub-music.csv + @install -Dm644 -t /usr/share/${PKGNAME}/ grub-beeplist.csv @if [ -z ${DESTDIR} ]; then \ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \ diff --git a/grub-music.csv b/grub-beeplist.csv similarity index 100% rename from grub-music.csv rename to grub-beeplist.csv diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index 30302cb..e83475d 100755 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -75,6 +75,7 @@ void MainWindow::settings(){ vec_param_names.push_back("GRUB_PASSWORD"); vec_param_names.push_back("GRUB_DEFAULT"); vec_param_names.push_back("GRUB_PLAY"); + vec_param_names.push_back("GRUB_SUPERUSERS"); this->get_builder(); this->localization(); this->add_CSS(); @@ -105,6 +106,7 @@ void MainWindow::settings(){ this->download_local_cfg(); this->download_globl_cfg(); this->view_add_colums_music(*treeViewMusic); + this->view_add_colums_user(*treeViewUser); std::map> map_list_os = format_os_list(os_control_list); obj_menu_os.set_builder(builder, path_glade); obj_menu_os.set_map(map_list_os); @@ -200,13 +202,9 @@ void MainWindow::fill_in_view() { list_store_kernel = Gtk::ListStore::create(m_columns); list_store_IPT = Gtk::ListStore::create(m_columns); list_store_OTT = Gtk::ListStore::create(m_columns); - list_store_user = Gtk::ListStore::create(m_columns_user); treeViewKernel->set_model(list_store_kernel); treeViewIPT->set_model(list_store_IPT); treeViewOTT->set_model(list_store_OTT); - treeViewUser->set_model(list_store_user); - - vec_Option_kernel = this->read_file_and_view(kernel_csv, row_kernel, list_store_kernel); vec_Option_IPT = this->read_file_and_view(IPT_csv, row_IPT, list_store_IPT); vec_Option_OTT = this->read_file_and_view(OTT_csv, row_OTT, list_store_OTT); @@ -216,7 +214,6 @@ void MainWindow::fill_in_view() { this->view_add_colums(*treeViewKernel); this->view_add_colums(*treeViewIPT); this->view_add_colums(*treeViewOTT); - this->view_add_colums_user(*treeViewUser); } void MainWindow::view_add_colums_user(Gtk::TreeView &treeView) { @@ -439,7 +436,6 @@ string MainWindow::template_item_selected(int size, Glib::RefPtr } } cmds = "\"" + cmds + "\""; - cout << cmds << endl; return cmds; } @@ -733,7 +729,6 @@ void MainWindow::set_entry_to_tree_view(Glib::RefPtr &list_store } map_cmd_selection[key] = text; - cout << text << endl; } void MainWindow::get_menu_boot(std::map &map_temp) { @@ -845,25 +840,69 @@ void get_tree_view_music() { } */ +void MainWindow::set_init_data_user(std::map &map_temp) { + treeViewUser->reset_expander_column(); + list_store_user = Gtk::ListStore::create(m_columns_user); + treeViewUser->set_model(list_store_user); + vector vec_users; + string buf_key = ""; + string password = ""; + for (auto& [key, value]: map_temp) { + if (key.find("GRUB_PASSWORD[") != string::npos) { + buf_key = key; + vec_param_names.push_back(buf_key); + Utils::str_remove(buf_key,"GRUB_PASSWORD["); + Utils::str_remove(buf_key,"]"); + if (value.length() != 0) { + password = "************"; + } + else { + password = ""; + } + this->set_add_data_user(row_user, false, buf_key, password); + } + } + +} + +void MainWindow::set_init_data_superuser(std::map &map_temp) { + Glib::RefPtr treeViewKernelUser = treeViewUser->get_model(); + string names_superusers = map_temp["GRUB_SUPERUSERS"]; + vector vec_superusers = Utils::split(names_superusers, ','); + Gtk::TreeModel::Children children = treeViewKernelUser->children(); + for (string& str_superuser: vec_superusers) { + for(Gtk::TreeModel::iterator iter = children.begin(); iter != children.end(); ++iter){ + Gtk::TreeModel::Row row = *iter; + if (row[m_columns_user.name] == str_superuser) { + row[m_columns_user.check_button] = true; + } + + } + } +} + +void MainWindow::set_add_data_user(Gtk::TreeModel::Row &row, bool flag, string &name, string &password) { + row = *(list_store_user->append()); + row[m_columns_user.check_button] = flag; + row[m_columns_user.name] = name; + row[m_columns_user.password] = password; +} void MainWindow::set_init_data_music(std::map &map_temp) { treeViewMusic->reset_expander_column(); list_store_music = Gtk::ListStore::create(m_columns_music); treeViewMusic->set_model(list_store_music); string path_name = ""; - path_name = path_name + path_resources + "/" + "grub-music.csv"; + path_name = path_name + path_resources + "/" + "grub-beeplist.csv"; vector> vec_music = Utils::read_csv_music(path_name); bool flag = false; string cgf_code_music = map_temp["GRUB_PLAY"]; - cout << cgf_code_music << endl; for (tuple& tuple_music: vec_music) { string name = get<0>(tuple_music); string code = get<1>(tuple_music); flag = (cgf_code_music == code); this->set_add_data_music(row_music, flag, name, code); } - - } void MainWindow::set_add_data_music(Gtk::TreeModel::Row &row, bool flag, string &name, string &code) { @@ -1112,7 +1151,9 @@ void MainWindow::load_template(std::map* map_temp, string cmd) { this->set_entry(entryIPT, *map_temp, "GRUB_TERMINAL_INPUT"); this->set_entry(entryOTT, *map_temp, "GRUB_TERMINAL_OUTPUT"); string str_last_launched_os_ubconfig = (*map_temp)["GRUB_DEFAULT"]; + this->set_init_data_user(*map_temp); this->set_init_data_music(*map_temp); + this->set_init_data_superuser(*map_temp); if (str_last_launched_os_ubconfig.length() != 0) { entrListOS->set_text(str_last_launched_os_ubconfig); } @@ -1146,6 +1187,7 @@ void MainWindow::init_dict(string flag_load) { map_cmd_selection_n["GRUB_PASSWORD"] = ""; map_cmd_selection_n["GRUB_DEFAULT"] = ""; map_cmd_selection_n["GRUB_PLAY"] = ""; + map_cmd_selection_n["GRUB_SUPERUSERS"] = ""; map_cmd_selection = map_cmd_selection_n; if (flag_load == "global") { map_global_cmd_selection = map_cmd_selection_n; diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index 3c70b89..cb4eb09 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -399,6 +399,9 @@ public: void view_add_line_music(Gtk::TreeModel::Row &row, Glib::RefPtr list_store_m); void set_add_data_music(Gtk::TreeModel::Row &row, bool flag, string &name, string &code); void set_init_data_music(std::map &map_temp); + void set_add_data_user(Gtk::TreeModel::Row &row, bool flag, string &name, string &password); + void set_init_data_user(std::map &map_temp); + void set_init_data_superuser(std::map &map_temp); }; class SettingsPlug : public Gtk::Plug