From fa533884f48fb3159b072557cd43544dbd23baae Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Tue, 14 Mar 2023 14:32:12 +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=D0=BE=20=D0=BE=D0=BA=D0=BD=D0=BE=20=D0=BE=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D0=B5,=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D1=84=D1=83=D0=BD?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D0=B2=D1=8B?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=D0=B0=D0=BD=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- #ubl-settings-bootloader.glade# | 1298 ----------------------------- Makefile | 7 +- VERSION.md | 1 + source/ubl-settings-bootloader.cc | 103 ++- source/ubl-settings-bootloader.h | 149 ++-- ubl-settings-bootloader.glade | 40 +- ubl-settings-bootloader_ru.po | 8 +- 7 files changed, 235 insertions(+), 1371 deletions(-) delete mode 100644 #ubl-settings-bootloader.glade# create mode 100644 VERSION.md diff --git a/#ubl-settings-bootloader.glade# b/#ubl-settings-bootloader.glade# deleted file mode 100644 index 41c24f5..0000000 --- a/#ubl-settings-bootloader.glade# +++ /dev/null @@ -1,1298 +0,0 @@ - - - - - - False - О Программе - False - True - center - ubl-settings-datetime - dialog - True - ubl-settings-bootloader - 1.0 - Copyright © 2023 - UBSoft Software LLC - Setting the bootloader - https://ublinux.ru/ - Project Home Page - Это приложение распространяется без каких-либо гарантий. -Подробнее в <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, версии 2 или позднее</a>. - UBGroup - UBGroup - ublexec - True - gpl-2-0 - - - False - vertical - 2 - - - False - end - - - - - - False - False - 0 - - - - - - - - - - 750 - 550 - False - - - True - False - vertical - - - True - False - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 69 - ublexec - - - False - True - 0 - - - - - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - Running applications as a user with a -specified priority - - - - - - - - True - True - 1 - - - - - False - True - 0 - - - - - True - False - vertical - - - True - True - in - - - True - False - - - True - False - vertical - - - True - True - both - True - - - - - - False - True - 0 - - - - - True - False - 0.019999999552965164 - in - - - True - False - 12 - - - True - False - vertical - - - True - False - - - Load variant selection timer - True - True - False - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 0 - - - - - True - True - 5 - 5 - 5 - 5 - 6 - 6 - - - False - True - 1 - - - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Seconds - - - False - True - 2 - - - - - False - True - 0 - - - - - True - False - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Default download - - - False - True - 0 - - - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - - - False - True - 1 - - - - - False - True - 1 - - - - - The last selection will become the default boot choice - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 2 - - - - - - - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Download menu - - - - - False - True - 1 - - - - - True - False - 0.019999999552965164 - in - - - True - False - 12 - - - True - False - vertical - - - True - False - vertical - - - True - False - - - splash (Show welcome window) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 0 - - - - - quiet (Downloading without text messages) - 362 - True - True - False - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - - - nоapic (Disable APIC) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 0 - - - - - nolapic (Disable local APIC) - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 1 - - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - vertical - - - True - False - - - no plymouth (Disable Plymouth) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 0 - - - - - True - False - - - False - True - 1 - - - - - single (Single User Mode) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 2 - - - - - False - True - 0 - - - - - True - False - - - acpi=off (Disable ACPI) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 0 - - - - - True - False - - - False - True - 1 - - - - - nomodeset (Disable kernel selection and loading of video drivers) - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 2 - - - - - False - True - 1 - - - - - False - True - 1 - - - - - True - False - vertical - - - i915.enable_dc=0 (Disable GPU power management) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 0 - - - - - ahci.mobile_jpm_policy=1 (Maximum performance, power management) - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 1 - - - - - False - True - 6 - - - - - snd-intel-dspcfg.dsp_driver=1 (Forced selection of a sound device driver from Intel) - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 7 - - - - - intel_idle max_cstate=1 (Prevents the processor from going into a deep sleep state) - True - True - False - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 8 - - - - - intel_idle.max_cstate=4 (Eliminates flickering laptop display on processors Ultra Voltage) - True - True - False - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 9 - - - - - True - False - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Command line parameters: - - - False - True - 0 - - - - - True - True - 5 - 5 - 5 - 5 - 6 - 6 - - - True - True - 1 - - - - - False - True - 10 - - - - - - - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Parameters passed to the kernel - - - - - False - True - 2 - - - - - True - False - 0.019999999552965164 - in - - - True - False - 12 - - - True - False - vertical - - - True - False - vertical - - - console (PC BIOS & console EFI) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 0 - - - - - serial (Serial terminal) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 1 - - - - - ofconsole (Console Open Firmware) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 2 - - - - - False - True - 0 - - - - - True - False - vertical - - - at_keyboard (Keyboard PC AT (Coreboot)) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 0 - - - - - usb_keyboard (Keyboard USB Keyboard (protocol HID Boot)) - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 1 - - - - - False - True - 6 - - - - - True - False - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Command line parameters: - - - False - True - 0 - - - - - True - True - 5 - 5 - 5 - 5 - 6 - 6 - - - True - True - 1 - - - - - False - True - 7 - - - - - - - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Input terminal - - - - - False - True - 3 - - - - - True - False - 0.019999999552965164 - in - - - True - False - 12 - - - True - False - vertical - - - True - False - - - ofconsole (Console Open Firmware) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 0 - - - - - serial (Serial terminal) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 1 - - - - - console (PC BIOS & console EFI) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 2 - - - - - False - True - 0 - - - - - True - False - vertical - - - gfxterm (Output in graphical mode) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 0 - - - - - vga_text (Text output VGA (Coreboot)) - 362 - True - True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - True - - - False - True - 1 - - - - - False - True - 6 - - - - - True - False - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Command line parameters: - - - False - True - 0 - - - - - True - True - 5 - 5 - 5 - 5 - 6 - 6 - - - True - True - 1 - - - - - False - True - 7 - - - - - - - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Output terminal - - - - - False - True - 4 - - - - - - - - - True - True - 0 - - - - - True - True - 1 - - - - - - - True - False - True - - - True - False - UBConfig - Loading - - - - - True - False - 32 - ublexec - - - - - True - False - - - True - True - False - True - True - none - - - - - - False - True - 0 - - - - - end - 1 - - - - - - diff --git a/Makefile b/Makefile index 1341c01..ca08828 100644 --- a/Makefile +++ b/Makefile @@ -20,8 +20,13 @@ all: init build init: @echo "Initialize ..."; \ + version="$$(cat VERSION.md)"; \ + version=$${version:8}; \ + search="s/string version_application.*$&"; \ + replace="string version_application = \"$${version}\";"; \ + sed -i -e "$$search/$$replace/gi" source/ubl-settings-bootloader.h; \ echo "-- Build path: ${CMAKE_BUILD_DIR}" - + depend: @echo "Check depends ..."; \ if [ ! -f /bin/${DEPENDS} ]; then \ diff --git a/VERSION.md b/VERSION.md new file mode 100644 index 0000000..12ebd01 --- /dev/null +++ b/VERSION.md @@ -0,0 +1 @@ +VERSION 1.0 diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index 7179203..60aa7d8 100644 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -41,6 +41,7 @@ MainWindow::MainWindow(Glib::RefPtr const& builder) { } void MainWindow::settings(){ + map_cmd_error[""] = ""; this->get_builder(); this->localization(); this->event(); @@ -106,9 +107,13 @@ void MainWindow::get_builder(){ builder->get_widget("boxKernel", boxKernel); builder->get_widget("boxKernel1", boxKernel1); builder->get_widget("boxKernel2", boxKernel2); - builder->get_widget("aboutWindows", aboutWindows); builder->get_widget("boxColor", boxColor); + builder->get_widget("aboutWindows", aboutWindows); + builder->get_widget("btnSynopsis", btnSynopsis); + builder->get_widget("btnAbout", btnAbout); + + @@ -116,6 +121,15 @@ void MainWindow::get_builder(){ } void MainWindow::localization(){ + time_t now = time(0); + tm *ltm = localtime(&now); + unsigned int year = 1900+ ltm->tm_year; + string str_authors = string(gettext("Copyright © UBSoft LLC, 2022 - ")) + to_string(year); + aboutWindows->set_copyright(str_authors); + aboutWindows->set_comments(gettext("Date and Time")); + aboutWindows->set_website(gettext("https://wiki.ublinux.com")); + aboutWindows->set_version(gettext(version_application.c_str())); + aboutWindows->set_website_label(gettext("Project Home Page")); lblInfoHead->set_text(gettext("Configuring system boot parameters")); lblHeaderName->set_text(gettext("UBConfig - Loading")); aboutWindows->set_comments(gettext("Setting bootloader")); @@ -154,6 +168,8 @@ void MainWindow::localization(){ chbconsoleOT->set_label(gettext("console (PC BIOS & console EFI)")); chbGfxterm->set_label(gettext("gfxterm (Output in graphical mode)")); chbVgaText->set_label(gettext("chbVgaText")); + btnSynopsis->set_label(gettext("Help")); + btnAbout->set_label(gettext("About")); //set_label(gettext("Command line parameters:")); } @@ -164,6 +180,91 @@ void MainWindow::event(){ chbintelMax1->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::fn_event_intelMax1)); chbintelMax4->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::fn_event_intelMax4)); signal_configure_event().connect(sigc::mem_fun(*this, &MainWindow::gui_set_orientation), false); + btnSynopsis->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::synopsis_show)); + btnAbout->signal_activate().connect([&]() {aboutWindows->show();}); +} + +void MainWindow::synopsis_show() { + wrapper_system("xdg-open https://wiki.ublinux.ru/ru/home", "&"); +} + +void MainWindow::wrapper_system(string cmd, string thread_str = "") { + string cmd_new = cmd + " " + thread_str; + int response_cmd = system(cmd_new.c_str()); + if (response_cmd != 0) { + index_error += 1; + //this->log_mess_error(cmd); + } +} + +struct MainWindow::Result MainWindow::wrapper_call(string cmd) { + struct Result obj_result; + string response = this->call(cmd); + if ((response.find("(null)") == std::string::npos) && (response.length() != 0 )) { + if (response.find("=") != std::string::npos) { + if (response.find("\n") != std::string::npos) { + response = response.substr(response.find("=")+1,response.length()); + response = response.substr(0,response.find("\n")); + obj_result.response = response; + obj_result.error = 0; + } + else { + obj_result.response = response; + obj_result.error = 1; + index_error += 1; + this->log_mess_error(cmd); + } + } + else { + obj_result.response = response; + obj_result.error = 2; + index_error += 1; + str_cmd_error = cmd; + this->log_mess_error(cmd); + } + } + else { + obj_result.response = response; + obj_result.error = 3; + index_error += 1; + str_cmd_error = cmd; + this->log_mess_error(cmd); + } + return obj_result; +} + +string MainWindow::call(string cmd) { + FILE *fp; + int status; + char path[PATH_MAX] = {0}; + fp = popen(cmd.c_str(), "r"); + if (fp == NULL) { + exit(1); + } + while (fgets(path, PATH_MAX, fp) != NULL) { + break; + } + status = pclose(fp); + if (status == -1) { + exit(1); + } + return path; +} + +void MainWindow::log_mess_error(string &cmd){ + string key = ""; + if (map_cmd_error.find(cmd) != map_cmd_error.end()){ + str_cmd_error = map_cmd_error[cmd]; + } + else { + for ( const auto &map_iter: map_cmd_error ) { + key = map_iter.first; + if (cmd.find(key) != std::string::npos){ + str_cmd_error = map_iter.second; + break; + } + } + } } void MainWindow::fn_event_intelMax1(){ diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index e3865c5..6a23357 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -29,74 +29,91 @@ private: }; class MainWindow : public Gtk::ApplicationWindow { -public: - MainWindow(BaseObjectType* obj, Glib::RefPtr const& builder); - MainWindow(Glib::RefPtr const& builder); - void get_builder(); - void add_CSS(); - void localization(); - void event(); - void settings(); - void fn_event_intelMax1(); - void fn_event_intelMax4(); - void get_monitor_size(); - bool gui_set_orientation(GdkEventConfigure* configure_event); - public: - Glib::RefPtr builder; - Gtk::SpinButton *spbSecond; + public: + Glib::RefPtr builder; + Gtk::SpinButton *spbSecond; + Gtk::Label *lblInfoSeconds; + Gtk::Label *lblInfoDefaultDonw; + Gtk::Label *lblInfoCommand; + Gtk::Label *lblInfoCommand1; + Gtk::Label *lblInfoCommand2; + Gtk::Label *lblDownloadMenu; + Gtk::Label *lblInfoInputTerminal; + Gtk::Label *lblInfoOutputTerminal; + Gtk::Label *lblHeaderName; + Gtk::Label *lblInfoHead; + Gtk::CheckButton *chbLoadVariantSelectionTimer; + Gtk::CheckButton *chbofConsoleOT; + Gtk::CheckButton *chbSerialOT; + Gtk::CheckButton *chbconsoleOT; + Gtk::CheckButton *chbGfxterm; + Gtk::CheckButton *chbVgaText; + Gtk::CheckButton *chbconsoleIT; + Gtk::CheckButton *chbSerialIT; + Gtk::CheckButton *chbofConsoleIT; + Gtk::CheckButton *chbAtKeyboard; + Gtk::CheckButton *chbUsbKeyboard; + Gtk::CheckButton *chbintelMax4; + Gtk::CheckButton *chbintelMax1; + Gtk::CheckButton *chbSndIntel; + Gtk::CheckButton *chbAhci; + Gtk::CheckButton *chbI915Enable; + Gtk::CheckButton *chbAcpi; + Gtk::CheckButton *chbPlymouth; + Gtk::CheckButton *chbSplash; + Gtk::CheckButton *chbQuiet; + Gtk::CheckButton *chbNоapic; + Gtk::CheckButton *chbNolapic; + Gtk::CheckButton *chbSingle; + Gtk::CheckButton *chbHomodeset; + Gtk::CheckButton *chbLastSelectionWillBecome; + Gtk::Entry *entryKernel; + Gtk::Entry *entryIT; + Gtk::Entry *entryOT; + Gtk::Box *boxOtput1; + Gtk::Box *boxOtput2; + Gtk::Box *boxInput1; + Gtk::Box *boxInput2; + Gtk::Box *boxKernel; + Gtk::Box *boxKernel1; + Gtk::Box *boxKernel2; + Gtk::Box *boxColor; + Gtk::AboutDialog *aboutWindows; + Gtk::MenuItem *btnAbout; + Gtk::MenuItem *btnSynopsis; - Gtk::Label *lblInfoSeconds; - Gtk::Label *lblInfoDefaultDonw; - Gtk::Label *lblInfoCommand; - Gtk::Label *lblInfoCommand1; - Gtk::Label *lblInfoCommand2; - Gtk::Label *lblDownloadMenu; - Gtk::Label *lblInfoInputTerminal; - Gtk::Label *lblInfoOutputTerminal; - Gtk::Label *lblHeaderName; - Gtk::Label *lblInfoHead; + private: + int width; + int heigh; + int screen_width; + int screen_hight; + string version_application = "1.0"; + int index_error = 0; + string str_cmd_error = ""; + template + struct Result{ + Type response; + int error; + }; + std::map map_cmd_error; - Gtk::CheckButton *chbLoadVariantSelectionTimer; - Gtk::CheckButton *chbofConsoleOT; - Gtk::CheckButton *chbSerialOT; - Gtk::CheckButton *chbconsoleOT; - Gtk::CheckButton *chbGfxterm; - Gtk::CheckButton *chbVgaText; - Gtk::CheckButton *chbconsoleIT; - Gtk::CheckButton *chbSerialIT; - Gtk::CheckButton *chbofConsoleIT; - Gtk::CheckButton *chbAtKeyboard; - Gtk::CheckButton *chbUsbKeyboard; - Gtk::CheckButton *chbintelMax4; - Gtk::CheckButton *chbintelMax1; - Gtk::CheckButton *chbSndIntel; - Gtk::CheckButton *chbAhci; - Gtk::CheckButton *chbI915Enable; - Gtk::CheckButton *chbAcpi; - Gtk::CheckButton *chbPlymouth; - Gtk::CheckButton *chbSplash; - Gtk::CheckButton *chbQuiet; - Gtk::CheckButton *chbNоapic; - Gtk::CheckButton *chbNolapic; - Gtk::CheckButton *chbSingle; - Gtk::CheckButton *chbHomodeset; - Gtk::CheckButton *chbLastSelectionWillBecome; - Gtk::Entry *entryKernel; - Gtk::Entry *entryIT; - Gtk::Entry *entryOT; - Gtk::Box *boxOtput1; - Gtk::Box *boxOtput2; - Gtk::Box *boxInput1; - Gtk::Box *boxInput2; - Gtk::Box *boxKernel; - Gtk::Box *boxKernel1; - Gtk::Box *boxKernel2; - Gtk::Box *boxColor; - Gtk::AboutDialog *aboutWindows; - int width; - int heigh; - int screen_width; - int screen_hight; + public: + MainWindow(BaseObjectType* obj, Glib::RefPtr const& builder); + MainWindow(Glib::RefPtr const& builder); + void get_builder(); + void add_CSS(); + void localization(); + void event(); + void settings(); + void fn_event_intelMax1(); + void fn_event_intelMax4(); + void get_monitor_size(); + bool gui_set_orientation(GdkEventConfigure* configure_event); + void synopsis_show(); + string call(string cmd); + void wrapper_system(string cmd, string thread_str); + struct Result wrapper_call(string cmd); + void log_mess_error(string &cmd); diff --git a/ubl-settings-bootloader.glade b/ubl-settings-bootloader.glade index 71a945c..d1d7a08 100644 --- a/ubl-settings-bootloader.glade +++ b/ubl-settings-bootloader.glade @@ -11,10 +11,10 @@ ubl-settings-datetime dialog True - ubl-settings-bootloader - 1.0 + ubl-settings-datetime + 1.2 Copyright © 2023 - UBSoft Software LLC - Setting the bootloader + ubl-settings-bootloader https://ublinux.ru/ Project Home Page Это приложение распространяется без каких-либо гарантий. @@ -49,6 +49,33 @@ + + True + False + False + False + 4 + + + True + False + Help + + + + + + True + False + About + + + + 750 550 @@ -1259,9 +1286,14 @@ specified priority False True True + menu1 none - + + True + False + open-menu-symbolic + diff --git a/ubl-settings-bootloader_ru.po b/ubl-settings-bootloader_ru.po index d8fc7db..db88110 100644 --- a/ubl-settings-bootloader_ru.po +++ b/ubl-settings-bootloader_ru.po @@ -5,7 +5,7 @@ # msgid "" msgstr "" -"Project-Id-Version: ubconfig 1.0\n" +"Project-Id-Version: ubl-settings-bootloader 1.0\n" "Report-Msgid-Bugs-To: info@ublinux.ru\n" "POT-Creation-Date: 2020-02-22 23:22+0600\n" "PO-Revision-Date: 2020-02-22 23:28+0600\n" @@ -114,3 +114,9 @@ msgstr "gfxterm (Вывод в графическом режиме)" msgid "vga_text (Text output VGA (Coreboot))" msgstr "vga_text (Текстовый вывод VGA (Coreboot))" + +msgid "About" +msgstr "О программе" + +msgid "Help" +msgstr "Справка"