Добавлен функционал поля статуса сообщений

pull/11/head
Igor Belitskiy 3 years ago
parent e184af14fe
commit f3d85a338e

@ -44,6 +44,15 @@ SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> build
show_all_children(); show_all_children();
} }
int MainWindow::check_root() {
if (geteuid() != 0) {
//lblMessageSudo->set_text(_("The program must be run with \nsuperuser privileges!"));
//mess_sudo->show();
return 1;
}
return 0;
}
MainWindow::MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder) MainWindow::MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder)
: Gtk::ApplicationWindow(obj), builder{builder} { : Gtk::ApplicationWindow(obj), builder{builder} {
this->builder = builder; this->builder = builder;
@ -59,9 +68,20 @@ void MainWindow::settings(){
map_cmd_error[""] = ""; map_cmd_error[""] = "";
this->get_builder(); this->get_builder();
this->localization(); this->localization();
ubl_make_plugs(boxSave,boxButton, socket_ext_id_I, socket_trd_id_I);
this->add_CSS(); this->add_CSS();
this->event(); this->event();
ubl_make_plugs(boxSave,boxButton, socket_ext_id_I, socket_trd_id_I);
if (this->check_root() == 0) {
}
else{
imgInfo->set("/usr/share/icons/hicolor/scalable/status/warning.svg");
info_status_app("boxInfoMessError");
lblWarning->set_text(_("The program must be run with superuser privileges!"));
}
} }
void MainWindow::get_monitor_size(){ void MainWindow::get_monitor_size(){
@ -138,65 +158,68 @@ void MainWindow::get_builder(){
builder->get_widget("btnSave", btnSave); builder->get_widget("btnSave", btnSave);
builder->get_widget("boxButton", boxButton); builder->get_widget("boxButton", boxButton);
builder->get_widget("boxSave", boxSave); builder->get_widget("boxSave", boxSave);
builder->get_widget("boxInfoError", boxInfoError);
builder->get_widget("lblWarning", lblWarning);
builder->get_widget("imgInfo", imgInfo);
} }
void MainWindow::localization(){ void MainWindow::localization(){
time_t now = time(0); time_t now = time(0);
tm *ltm = localtime(&now); tm *ltm = localtime(&now);
unsigned int year = 1900+ ltm->tm_year; unsigned int year = 1900+ ltm->tm_year;
string str_authors = string(gettext("Copyright © UBSoft LLC, 2022 - ")) + to_string(year); string str_authors = string(_("Copyright © UBSoft LLC, 2022 - ")) + to_string(year);
aboutWindows->set_copyright(str_authors); aboutWindows->set_copyright(str_authors);
aboutWindows->set_comments(gettext("ubl-settings-bootloader")); aboutWindows->set_comments(_("ubl-settings-bootloader"));
aboutWindows->set_website(gettext("https://wiki.ublinux.com")); aboutWindows->set_website(_("https://wiki.ublinux.com"));
aboutWindows->set_version(gettext(version_application.c_str())); aboutWindows->set_version(_(version_application.c_str()));
aboutWindows->set_website_label(gettext("Project Home Page")); aboutWindows->set_website_label(_("Project Home Page"));
lblInfoHead->set_text(gettext("Configuring system boot parameters")); lblInfoHead->set_text(_("Configuring system boot parameters"));
lblHeaderName->set_text(gettext("UBConfig - Loading")); lblHeaderName->set_text(_("UBConfig - Loading"));
aboutWindows->set_comments(gettext("Setting bootloader")); aboutWindows->set_comments(_("Setting bootloader"));
aboutWindows->set_website_label(gettext("Project Home Page")); aboutWindows->set_website_label(_("Project Home Page"));
lblInfoCommand->set_text(gettext("Command line parameters:")); lblInfoCommand->set_text(_("Command line parameters:"));
lblInfoCommand1->set_text(gettext("Command line parameters:")); lblInfoCommand1->set_text(_("Command line parameters:"));
lblInfoCommand2->set_text(gettext("Command line parameters:")); lblInfoCommand2->set_text(_("Command line parameters:"));
lblInfoDefaultDonw->set_text(gettext("Default download")); lblInfoDefaultDonw->set_text(_("Default download"));
lblInfoSeconds->set_text(gettext("Seconds")); lblInfoSeconds->set_text(_("Seconds"));
lblDownloadMenu->set_text(gettext("Download menu")); lblDownloadMenu->set_text(_("Download menu"));
lblInfoInputTerminal->set_text(gettext("Input terminal")); lblInfoInputTerminal->set_text(_("Input terminal"));
lblInfoOutputTerminal->set_text(gettext("Output terminal")); lblInfoOutputTerminal->set_text(_("Output terminal"));
chbLoadVariantSelectionTimer->set_label(gettext("Load variant selection timer")); chbLoadVariantSelectionTimer->set_label(_("Load variant selection timer"));
chbLastSelectionWillBecome->set_label(gettext("The last selection will become the default boot choice")); chbLastSelectionWillBecome->set_label(_("The last selection will become the default boot choice"));
chbQuiet->set_label(gettext("quiet (Downloading without text messages)")); chbQuiet->set_label(_("quiet (Downloading without text messages)"));
chbSplash->set_label(gettext("splash (Show welcome window)")); chbSplash->set_label(_("splash (Show welcome window)"));
chbPlymouth->set_label(gettext("no plymouth (Disable Plymouth)")); chbPlymouth->set_label(_("no plymouth (Disable Plymouth)"));
chbAcpi->set_label(gettext("acpi=off (Disable ACPI)")); chbAcpi->set_label(_("acpi=off (Disable ACPI)"));
chbNоapic->set_label(gettext("nоapic (Disable APIC)")); chbNоapic->set_label(_("nоapic (Disable APIC)"));
chbNolapic->set_label(gettext("nolapic (Disable local APIC)")); chbNolapic->set_label(_("nolapic (Disable local APIC)"));
chbSingle->set_label(gettext("single (Single User Mode)")); chbSingle->set_label(_("single (Single User Mode)"));
chbHomodeset->set_label(gettext("nomodeset (Disable kernel selection and loading of video drivers)")); chbHomodeset->set_label(_("nomodeset (Disable kernel selection and loading of video drivers)"));
chbI915Enable->set_label(gettext("i915.enable_dc=0 (Disable GPU power management)")); chbI915Enable->set_label(_("i915.enable_dc=0 (Disable GPU power management)"));
chbAhci->set_label(gettext("ahci.mobile_jpm_policy=1 (Maximum performance, power management)")); chbAhci->set_label(_("ahci.mobile_jpm_policy=1 (Maximum performance, power management)"));
chbSndIntel->set_label(gettext("snd-intel-dspcfg.dsp_driver=1 (Forced selection of a sound device driver from Intel)")); chbSndIntel->set_label(_("snd-intel-dspcfg.dsp_driver=1 (Forced selection of a sound device driver from Intel)"));
chbintelMax1->set_label(gettext("intel_idle max_cstate=1 (Prevents the processor from going into a deep sleep state)")); chbintelMax1->set_label(_("intel_idle max_cstate=1 (Prevents the processor from going into a deep sleep state)"));
chbintelMax4->set_label(gettext("intel_idle.max_cstate=4 (Eliminates flickering laptop display on processors Ultra Voltage)")); chbintelMax4->set_label(_("intel_idle.max_cstate=4 (Eliminates flickering laptop display on processors Ultra Voltage)"));
chbconsoleIT->set_label(gettext("console (PC BIOS & console EFI)")); chbconsoleIT->set_label(_("console (PC BIOS & console EFI)"));
chbSerialIT->set_label(gettext("serial (Serial terminal)")); chbSerialIT->set_label(_("serial (Serial terminal)"));
chbofConsoleIT->set_label(gettext("ofconsole (Console Open Firmware)")); chbofConsoleIT->set_label(_("ofconsole (Console Open Firmware)"));
chbAtKeyboard ->set_label(gettext("at_keyboard (Keyboard PC AT (Coreboot))")); chbAtKeyboard ->set_label(_("at_keyboard (Keyboard PC AT (Coreboot))"));
chbUsbKeyboard->set_label(gettext("usb_keyboard (Keyboard USB Keyboard (protocol HID Boot))")); chbUsbKeyboard->set_label(_("usb_keyboard (Keyboard USB Keyboard (protocol HID Boot))"));
chbofConsoleOT->set_label(gettext("ofconsole (Console Open Firmware)")); chbofConsoleOT->set_label(_("ofconsole (Console Open Firmware)"));
chbSerialOT->set_label(gettext("serial (Serial terminal)")); chbSerialOT->set_label(_("serial (Serial terminal)"));
chbconsoleOT->set_label(gettext("console (PC BIOS & console EFI)")); chbconsoleOT->set_label(_("console (PC BIOS & console EFI)"));
chbGfxterm->set_label(gettext("gfxterm (Output in graphical mode)")); chbGfxterm->set_label(_("gfxterm (Output in graphical mode)"));
chbVgaText->set_label(gettext("chbVgaText")); chbVgaText->set_label(_("chbVgaText"));
btnSynopsis->set_label(gettext("Help")); btnSynopsis->set_label(_("Help"));
btnAbout->set_label(gettext("About")); btnAbout->set_label(_("About"));
btnSaveLocalGlob->set_label(gettext("Save to global and local configuration")); btnSaveLocalGlob->set_label(_("Save to global and local configuration"));
btnSaveLocal->set_label(gettext("Save local configuration")); btnSaveLocal->set_label(_("Save local configuration"));
btnSaveGlob->set_label(gettext("Save global configuration")); btnSaveGlob->set_label(_("Save global configuration"));
btnDonwlolGlob->set_label(gettext("Load global configuration")); btnDonwlolGlob->set_label(_("Load global configuration"));
btnDonwlodLocal->set_label(gettext("Load local configuration")); btnDonwlodLocal->set_label(_("Load local configuration"));
btnSave->set_label(gettext("Save")); btnSave->set_label(_("Save"));
btnDownload->set_label(gettext("Donwload")); btnDownload->set_label(_("Donwload"));
} }
@ -215,23 +238,23 @@ void MainWindow::event(){
} }
void MainWindow::save_global_local_cfg(){ void MainWindow::save_global_local_cfg(){
info_warning_error(4);
}
void MainWindow::save_local_cfg(){
} }
void MainWindow::save_global_cfg(){ void MainWindow::save_global_cfg(){
info_warning_error(3);
} }
void MainWindow::download_local_cfg(){ void MainWindow::save_local_cfg(){
info_warning_error(2);
} }
void MainWindow::download_globl_cfg(){ void MainWindow::download_globl_cfg(){
info_warning_error(1);
}
void MainWindow::download_local_cfg(){
info_warning_error(0);
} }
@ -244,7 +267,63 @@ void MainWindow::wrapper_system(string cmd, string thread_str = "") {
int response_cmd = system(cmd_new.c_str()); int response_cmd = system(cmd_new.c_str());
if (response_cmd != 0) { if (response_cmd != 0) {
index_error += 1; index_error += 1;
//this->log_mess_error(cmd); this->log_mess_error(cmd);
}
}
void MainWindow::info_status_app(string stule) {
Glib::RefPtr<Gtk::StyleContext> boxInfo = boxInfoError->get_style_context();
boxInfo->remove_class("boxInfoMessOK");
boxInfo->remove_class("boxInfoMessError");
boxInfo->add_class(stule);
}
void MainWindow::info_warning_error(int mess) {
if (index_error > 0) {
info_status_app("boxInfoMessError");
imgInfo->set("/usr/share/icons/hicolor/scalable/status/warning.svg");
index_error = 0;
string mess_error = "";
if (mess == 0) {
mess_error = string(_("Local configuration reading error")) + str_cmd_error;
lblWarning->set_text(mess_error);
}
else if (mess == 1) {
mess_error = string(_("Global configuration read error")) + str_cmd_error;
lblWarning->set_text(mess_error);
}
else if (mess == 2) {
mess_error = string(_("Local configuration write error")) + str_cmd_error;
lblWarning->set_text(mess_error);
}
else if (mess == 3) {
mess_error = string(_("Global configuration write error")) + str_cmd_error;
lblWarning->set_text(mess_error);
}
else if (mess == 4) {
mess_error = string(_("Error saved local and global configuration")) + str_cmd_error;
lblWarning->set_text(mess_error);
}
str_cmd_error = "";
}
else {
info_status_app("boxInfoMessOK");
imgInfo->set("/usr/share/icons/hicolor/scalable/status/checked.svg");
if (mess == 0) {
lblWarning->set_text(_("Local configuration downloaded successfully"));
}
else if (mess == 1) {
lblWarning->set_text(_("Global configuration downloaded successfully"));
}
else if (mess == 2) {
lblWarning->set_text(_("Local configuration successfully written"));
}
else if (mess == 3) {
lblWarning->set_text(_("Global configuration successfully written"));
}
else if (mess == 4) {
lblWarning->set_text(_("Successfully saved local and global configuration"));
}
} }
} }

@ -9,6 +9,7 @@
#include <gtkmm/plug.h> #include <gtkmm/plug.h>
#include <locale.h> #include <locale.h>
#include <libintl.h> #include <libintl.h>
#include <glibmm/i18n.h>
#include "ubl-util-standard.c" #include "ubl-util-standard.c"
using namespace std; using namespace std;
@ -93,7 +94,9 @@ class MainWindow : public Gtk::ApplicationWindow {
Gtk::Button *btnSettings; Gtk::Button *btnSettings;
Gtk::Widget *boxButton; Gtk::Widget *boxButton;
Gtk::Widget *boxSave; Gtk::Widget *boxSave;
Gtk::Box *boxInfoError;
Gtk::Label *lblWarning;
Gtk::Image *imgInfo;
private: private:
int width; int width;
@ -132,6 +135,9 @@ class MainWindow : public Gtk::ApplicationWindow {
void save_global_cfg(); void save_global_cfg();
void download_local_cfg(); void download_local_cfg();
void download_globl_cfg(); void download_globl_cfg();
void info_status_app(string stule);
void info_warning_error(int mess);
int check_root();
}; };
class SettingsPlug : public Gtk::Plug{ class SettingsPlug : public Gtk::Plug{

@ -166,3 +166,9 @@ msgstr "Успешно записана глобальная конфигура
msgid "Local configuration successfully written" msgid "Local configuration successfully written"
msgstr "Успешно записана локальная конфигурация" msgstr "Успешно записана локальная конфигурация"
msgid "The program must be run with \nsuperuser privileges!"
msgstr "Программа должна быть запущена с правами \nсуперпользователя!"
msgid "The program must be run with superuser privileges!"
msgstr "Программа должна быть запущена с правами суперпользователя!"

Loading…
Cancel
Save