From 33bd148f2ca5f09b9f67b8d90912e311de541332 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Tue, 25 Apr 2023 11:03:10 +0600 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=9E=D0=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/my_cmd_and_path.h | 2 ++ source/save.cc | 1 - source/ubl-settings-bootloader.cc | 29 +++++++++++++++++++++++++++++ source/ubl-settings-bootloader.h | 5 ++++- source/ubl-settings-bootloader.h.in | 1 - 5 files changed, 35 insertions(+), 3 deletions(-) delete mode 100644 source/ubl-settings-bootloader.h.in diff --git a/source/my_cmd_and_path.h b/source/my_cmd_and_path.h index 5e65601..116fca4 100644 --- a/source/my_cmd_and_path.h +++ b/source/my_cmd_and_path.h @@ -25,4 +25,6 @@ #define app_name "ubl-settings-bootloader" #define path_resources "/usr/share/ubl-settings-bootloader" #define path_img_head_background "/usr/share/ubl-settings-bootloader/images/logo-background.png" +#define cmd_pars_list_os "/usr/lib/ublinux/scripts/grub-functions exec_get_all_menuentry" +#define cmd_last_launched_os "/usr/lib/ublinux/scripts/grub-functions exec_get_last_menuentry" #endif \ No newline at end of file diff --git a/source/save.cc b/source/save.cc index 1b9949f..c824093 100644 --- a/source/save.cc +++ b/source/save.cc @@ -138,7 +138,6 @@ void Save::save_one_cmd(string cmd1, string cmd_remove, string str_flag_save) { void Save::template_save(string cmd) { string str_error = ""; - cout << cmd << endl; process.call(cmd, ""); this->flag_no_save = false; str_error = process.get_cmd_error(); diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index 6531511..833c202 100755 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -100,6 +100,10 @@ void MainWindow::settings(){ this->change_password_protecc(); this->change_security_login(); this->set_active_boot_second(); + this->str_last_launched_os = this->pars_last_launched_os(); + vector os_control_list; + this->pars_os(os_control_list); + this->write_list_entry_os(os_control_list); this->download_local_cfg(); this->download_globl_cfg(); } @@ -116,6 +120,23 @@ void MainWindow::settings(){ this->event(); } +vector MainWindow::pars_os(vector &os_control_list) { + string str_list_os = obj_process_call.call_all_sections(cmd_pars_list_os); + os_control_list = Utils::split(str_list_os, '\n'); + return os_control_list; +} +string MainWindow::pars_last_launched_os() { + string str_list_os = obj_process_call.call_all_sections(cmd_last_launched_os); + Utils::str_replace_all(str_list_os, "\n" , ""); + return str_list_os; +} + +void MainWindow::write_list_entry_os(vector &os_control_list) { + for (string &name_os: os_control_list) { + cmbDefaultDonw->append(name_os); + } +} + void MainWindow::flag_block_gui() { if (flag_load_global == true) { btnLoadGlob->set_sensitive(false); @@ -851,6 +872,14 @@ void MainWindow::load_template(std::map* map_temp, string cmd) { 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"); + string str_last_launched_os_ubconfig = (*map_temp)["GRUB_DEFAULT"]; + if (str_last_launched_os_ubconfig.length() != 0) { + cmbDefaultDonw->set_active_text(str_last_launched_os_ubconfig); + } + else { + cmbDefaultDonw->set_active_text(str_last_launched_os); + } + } void MainWindow::set_entry(Gtk::Entry* entry , std::map &map_temp, string key) { diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index 3e5beb6..54c1da5 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -17,7 +17,6 @@ #include "util.h" #include "save.h" #include "load.h" -#include "ubl-settings-bootloader-cm.h" #include #ifdef WEBKIT_FOUND #include @@ -148,6 +147,7 @@ class MainWindow : public Gtk::ApplicationWindow { bool flag_blocked_tree_view = false; bool flag_save_block = false; bool flag_open_browser = false; + string str_last_launched_os = ""; int index_error = 0; size_t size_kernel = 0; size_t size_IPT = 0; @@ -176,7 +176,10 @@ class MainWindow : public Gtk::ApplicationWindow { void localization(); void event(); void settings(); + string pars_last_launched_os(); + vector pars_os(vector &os_control_list); void fn_event_intelMax1(); + void write_list_entry_os(vector &os_control_list); void fn_event_intelMax4(); void synopsis_show(); void set_data_cfg(); diff --git a/source/ubl-settings-bootloader.h.in b/source/ubl-settings-bootloader.h.in deleted file mode 100644 index 17ba454..0000000 --- a/source/ubl-settings-bootloader.h.in +++ /dev/null @@ -1 +0,0 @@ -#cmakedefine WEBKIT_FOUND \ No newline at end of file