@ -54,8 +54,6 @@ SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> build
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 ;
@ -111,9 +109,9 @@ void MainWindow::settings(){
boxWidgetAll - > set_sensitive ( false ) ;
btnLoad - > set_sensitive ( false ) ;
btnSave - > set_sensitive ( false ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-bootloader.warning " , Gtk : : ICON_SIZE_MENU ) ;
imgInfo - > set_from_icon_name ( icon_warning , Gtk : : ICON_SIZE_MENU ) ;
info_status_app ( " boxInfoMessError " ) ;
lblWarning - > set_text ( _( " The program must be run as root " ) ) ;
lblWarning - > set_text ( program_as_root ) ;
this - > set_active_boot_second ( ) ;
this - > fill_in_view ( ) ;
}
@ -358,9 +356,9 @@ vector<string> MainWindow::read_file_and_view(string file_name ,Gtk::TreeModel::
}
void MainWindow : : view_add_colums ( Gtk : : TreeView & treeView ) {
treeView . append_column_editable ( _( " Active " ) , m_columns . check_button ) ;
treeView . append_column ( _( " Option " ) , m_columns . name ) ;
treeView . append_column ( _( " Description " ) , m_columns . description ) ;
treeView . append_column_editable ( str_active , m_columns . check_button ) ;
treeView . append_column ( str_option , m_columns . name ) ;
treeView . append_column ( str_description , m_columns . description ) ;
}
void MainWindow : : view_add_cell ( Gtk : : TreeModel : : Row & row , Glib : : RefPtr < Gtk : : ListStore > list_store_m , std : : array < std : : vector < std : : string > , 5 > & arr_view , size_t index ) {
@ -443,59 +441,58 @@ void MainWindow::localization(){
time_t now = time ( 0 ) ;
tm * ltm = localtime ( & now ) ;
unsigned int year = 1900 + ltm - > tm_year ;
string str_authors = string ( _( " Copyright © UBSoft LLC, 2022 - " ) ) + to_string ( year ) ;
aboutWindows - > set_program_name ( gettext( " ubl-settings-bootloader " ) ) ;
string str_authors = string ( copyright ) + to_string ( year ) ;
aboutWindows - > set_program_name ( name_app ) ;
aboutWindows - > set_copyright ( str_authors ) ;
aboutWindows - > set_comments ( _( " ubl-settings-bootloader " ) ) ;
aboutWindows - > set_website ( _( " https://wiki.ublinux.com " ) ) ;
aboutWindows - > set_comments ( name_app ) ;
aboutWindows - > set_website ( web_url ) ;
aboutWindows - > set_version ( _ ( version_application . c_str ( ) ) ) ;
aboutWindows - > set_website_label ( _( " Project Home Page " ) ) ;
lblInfoHead - > set_text ( _( " Configuring system boot parameters " ) ) ;
lblHeaderName - > set_text ( _( " ubl-settings-bootloader " ) ) ;
aboutWindows - > set_comments ( _( " System boot " ) ) ;
lblHeaderAboutTopic - > set_label ( gettext( " About ubl-settings-bootloader " ) ) ;
aboutWindows - > set_website_label ( _( " Project Home Page " ) ) ;
lblInfoCommand - > set_text ( _( " Command line parameters: " ) ) ;
lblInfoCommand1 - > set_text ( _( " Command line parameters: " ) ) ;
lblInfoCommand2 - > set_text ( _( " Command line parameters: " ) ) ;
lblInfoDefaultDonw - > set_text ( _( " Load default: " ) ) ;
lblInfoSeconds - > set_text ( _( " seconds" ) ) ;
lblLoadMenu - > set_text ( _( " Download menu " ) ) ;
lblInfoInputTerminal - > set_text ( _( " Terminal for input " ) ) ;
lblInfoOutputTerminal - > set_text ( _( " Terminal for output " ) ) ;
chbLoadVariantSelectionTimer - > set_label ( _( " Boot selection menu timer " ) ) ;
btnSynopsis - > set_label ( _( " Help " ) ) ;
btnAbout - > set_label ( _( " About " ) ) ;
lblHeadeWndWeb - > set_text ( _( " ubl-settings-bootloader " ) ) ;
btnSaveLocalGlob - > set_label ( _( " Save to global and local configuration " ) ) ;
btnSaveLocal - > set_label ( _( " Save local configuration " ) ) ;
btnSaveGlob - > set_label ( _( " Save global configuration " ) ) ;
btnLoadGlob - > set_label ( _( " Load global configuration " ) ) ;
btnLoadLocal - > set_label ( _( " Load local configuration " ) ) ;
btnSave - > set_label ( _( " Save " ) ) ;
btnLoad - > set_label ( _( " Load " ) ) ;
this - > set_title ( _( " ubl-settings-bootloader " ) ) ;
aboutWindows - > set_website_label ( project_Home_page ) ;
lblInfoHead - > set_text ( configuring_system_boot ) ;
lblHeaderName - > set_text ( name_app ) ;
aboutWindows - > set_comments ( system_boot ) ;
lblHeaderAboutTopic - > set_label ( str_about ) ;
aboutWindows - > set_website_label ( project_Home_page ) ;
lblInfoCommand - > set_text ( command_line_parameters ) ;
lblInfoCommand1 - > set_text ( command_line_parameters ) ;
lblInfoCommand2 - > set_text ( command_line_parameters ) ;
lblInfoDefaultDonw - > set_text ( str_about ) ;
lblInfoSeconds - > set_text ( seconds) ;
lblLoadMenu - > set_text ( download_menu ) ;
lblInfoInputTerminal - > set_text ( terminal_for_input ) ;
lblInfoOutputTerminal - > set_text ( terminal_for_output ) ;
chbLoadVariantSelectionTimer - > set_label ( boot_selection_menu_timer ) ;
btnSynopsis - > set_label ( str_help ) ;
btnAbout - > set_label ( str_about_1 ) ;
lblHeadeWndWeb - > set_text ( name_app ) ;
btnSaveLocalGlob - > set_label ( save_all ) ;
btnSaveLocal - > set_label ( save_local ) ;
btnSaveGlob - > set_label ( save_global ) ;
btnLoadGlob - > set_label ( load_global ) ;
btnLoadLocal - > set_label ( load_local ) ;
btnSave - > set_label ( str_save ) ;
btnLoad - > set_label ( str_load ) ;
this - > set_title ( name_app ) ;
// Todo: check
entrySecurityLogin - > set_tooltip_text ( gettext ( " User name to enter boot configuration editing mode " ) ) ;
entryPasswordProtecc - > set_tooltip_text ( gettext ( " User password to enter boot configuration edit mode " ) ) ;
chbSecurityLogin - > set_tooltip_text ( gettext ( " User name to enter boot configuration editing mode " ) ) ;
chbPasswordProtecc - > set_tooltip_text ( gettext ( " User password to enter boot configuration edit mode " ) ) ;
lblDownloadMode - > set_text ( _ ( " Boot screen display mode: " ) ) ;
chbSecurityLogin - > set_label ( _ ( " Boot menu user name: " ) ) ;
chbPasswordProtecc - > set_label ( _ ( " Boot menu user password: " ) ) ;
cmbDownloadMode - > append ( _ ( " Loading animation with the magazine " ) ) ;
cmbDownloadMode - > append ( _ ( " Loading animation without a magazine " ) ) ;
cmbDownloadMode - > append ( _ ( " Нет анимации загрузки, полный журнал " ) ) ;
cmbDownloadMode - > append ( _ ( " Lack of loading animation with the output of the abbreviated log " ) ) ;
cmbDefaultDonw - > append ( _ ( " Last successful upload " ) ) ;
lblhelpHeader - > set_text ( _ ( " Would you like to read documentation in the Web? " ) ) ;
lblhelpText - > set_text ( _ ( " You will be redirected to documentation site, where user help pages are "
" translated and supported by community. " ) ) ;
btnReadHelp - > set_label ( _ ( " Read online " ) ) ;
btnCancelHelp - > set_label ( _ ( " Cancel " ) ) ;
chkAlwaysOpenHelp - > set_label ( _ ( " Always redirect " ) ) ;
lblwebHeaderName - > set_label ( _ ( " ubl-settings-bootloader " ) ) ;
entrySecurityLogin - > set_tooltip_text ( loading_animation_without ) ;
entryPasswordProtecc - > set_tooltip_text ( user_password_configuration_edit_mode ) ;
chbSecurityLogin - > set_tooltip_text ( loading_animation_without ) ;
chbPasswordProtecc - > set_tooltip_text ( user_password_configuration_edit_mode ) ;
lblDownloadMode - > set_text ( boot_screen_display_mode ) ;
chbSecurityLogin - > set_label ( boot_screen_display_mode ) ;
chbPasswordProtecc - > set_label ( boot_menu_user_password ) ;
cmbDownloadMode - > append ( loading_animation_with ) ;
cmbDownloadMode - > append ( loading_animation_without ) ;
cmbDownloadMode - > append ( no_loading_animation ) ;
cmbDownloadMode - > append ( lack_loading_animation ) ;
cmbDefaultDonw - > append ( last_successful_upload ) ;
lblhelpHeader - > set_text ( read_documentation_web ) ;
lblhelpText - > set_text ( _ ( redirected_documentation ) ) ;
btnReadHelp - > set_label ( read_online ) ;
btnCancelHelp - > set_label ( cancel ) ;
chkAlwaysOpenHelp - > set_label ( always_redirect ) ;
lblwebHeaderName - > set_label ( name_app ) ;
}
vector < string > MainWindow : : get_setting_entry_all ( string key , std : : map < string , string > * map_temp ) {
@ -518,13 +515,13 @@ vector<string> MainWindow::get_setting_entry_all(string key, std::map <string, s
bool MainWindow : : focus_out_txt_password ( GdkEventFocus * ) {
if ( entryPasswordProtecc - > get_text ( ) . length ( ) = = 0 ) {
info_status_app ( " boxInfoMessError " ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-bootloader.warning " , Gtk : : ICON_SIZE_MENU ) ;
lblWarning - > set_text ( _( " Enter your password " ) ) ;
imgInfo - > set_from_icon_name ( icon_warning , Gtk : : ICON_SIZE_MENU ) ;
lblWarning - > set_text ( enter_password ) ;
boxSave - > set_sensitive ( false ) ;
}
else {
info_status_app ( " boxInfoMessOK " ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-bootloader.checked " , Gtk : : ICON_SIZE_MENU ) ;
imgInfo - > set_from_icon_name ( icon_checked , Gtk : : ICON_SIZE_MENU ) ;
lblWarning - > set_text ( " " ) ;
boxSave - > set_sensitive ( true ) ;
string key = entryPasswordProtecc - > get_text ( ) ;
@ -538,13 +535,13 @@ bool MainWindow::focus_out_txt_password(GdkEventFocus*) {
bool MainWindow : : focus_out_txt_login ( GdkEventFocus * ) {
if ( entrySecurityLogin - > get_text ( ) . length ( ) = = 0 ) {
info_status_app ( " boxInfoMessError " ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-bootloader.warning " , Gtk : : ICON_SIZE_MENU ) ;
lblWarning - > set_text ( _( " Enter login " ) ) ;
imgInfo - > set_from_icon_name ( icon_warning , Gtk : : ICON_SIZE_MENU ) ;
lblWarning - > set_text ( enter_login ) ;
boxSave - > set_sensitive ( false ) ;
}
else {
info_status_app ( " boxInfoMessOK " ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-bootloader.checked " , Gtk : : ICON_SIZE_MENU ) ;
imgInfo - > set_from_icon_name ( icon_checked , Gtk : : ICON_SIZE_MENU ) ;
lblWarning - > set_text ( " " ) ;
map_cmd_selection [ " GRUB_USER " ] = entrySecurityLogin - > get_text ( ) ;
boxSave - > set_sensitive ( true ) ;
@ -665,7 +662,7 @@ void MainWindow::change_security_login() {
entrySecurityLogin - > set_text ( " " ) ;
boxSave - > set_sensitive ( true ) ;
info_status_app ( " boxInfoMessOK " ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-bootloader.checked " , Gtk : : ICON_SIZE_MENU ) ;
imgInfo - > set_from_icon_name ( icon_checked , Gtk : : ICON_SIZE_MENU ) ;
lblWarning - > set_text ( " " ) ;
}
else if ( index = = true ) {
@ -700,7 +697,7 @@ void MainWindow::change_password_protecc() {
entryPasswordProtecc - > set_text ( " " ) ;
boxSave - > set_sensitive ( true ) ;
info_status_app ( " boxInfoMessOK " ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-bootloader.checked " , Gtk : : ICON_SIZE_MENU ) ;
imgInfo - > set_from_icon_name ( icon_checked , Gtk : : ICON_SIZE_MENU ) ;
lblWarning - > set_text ( " " ) ;
}
else if ( index = = true ) {
@ -924,7 +921,7 @@ void MainWindow::open_browser() {
webkit_web_view_load_uri ( one , link_doc ) ;
wndWeb - > show_all ( ) ;
# else
string cmd = cmd_xdg + string ( gettext ( link_doc ) ) + " & " ;
string cmd = cmd_xdg + string ( _ ( link_doc ) ) + " & " ;
string buf = " " ;
if ( geteuid ( ) = = 0 ) {
string response_user = getlogin ( ) ;
@ -947,26 +944,26 @@ void MainWindow::info_status_app(string stule) {
void MainWindow : : info_warning_error ( int mess ) {
if ( obj_load . get_count_error ( ) > 0 | | obj_save . get_count_error ( ) > 0 ) {
info_status_app ( " boxInfoMessError " ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-bootloader.warning " , Gtk : : ICON_SIZE_MENU ) ;
imgInfo - > set_from_icon_name ( icon_warning , Gtk : : ICON_SIZE_MENU ) ;
string mess_error = " " ;
if ( mess = = 0 ) {
mess_error = string ( _( " Local configuration reading error " ) ) + str_cmd_error ;
mess_error = string ( local_read_error ) + str_cmd_error ;
lblWarning - > set_text ( mess_error ) ;
}
else if ( mess = = 1 ) {
mess_error = string ( _( " Global configuration read error " ) ) + str_cmd_error ;
mess_error = string ( global_read_error ) + str_cmd_error ;
lblWarning - > set_text ( mess_error ) ;
}
else if ( mess = = 2 ) {
mess_error = string ( _( " Local configuration write error " ) ) + str_cmd_error ;
mess_error = string ( local_write_error ) + str_cmd_error ;
lblWarning - > set_text ( mess_error ) ;
}
else if ( mess = = 3 ) {
mess_error = string ( _( " Global configuration write error " ) ) + str_cmd_error ;
mess_error = string ( global_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 ;
mess_error = string ( error_save_all ) + str_cmd_error ;
lblWarning - > set_text ( mess_error ) ;
}
str_cmd_error = " " ;
@ -975,24 +972,24 @@ void MainWindow::info_warning_error(int mess) {
}
else {
info_status_app ( " boxInfoMessOK " ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-bootloader.checked " , Gtk : : ICON_SIZE_MENU ) ;
imgInfo - > set_from_icon_name ( icon_checked , Gtk : : ICON_SIZE_MENU ) ;
if ( mess = = 0 ) {
lblWarning - > set_text ( _( " Local configuration downloaded successfully " ) ) ;
lblWarning - > set_text ( local_load_ok ) ;
}
else if ( mess = = 1 ) {
lblWarning - > set_text ( _( " Global configuration downloaded successfully " ) ) ;
lblWarning - > set_text ( global_load_ok ) ;
}
else if ( mess = = 2 ) {
lblWarning - > set_text ( _( " Local configuration successfully written " ) ) ;
lblWarning - > set_text ( local_ok_written ) ;
}
else if ( mess = = 3 ) {
lblWarning - > set_text ( _( " Global configuration successfully written " ) ) ;
lblWarning - > set_text ( global_ok_written ) ;
}
else if ( mess = = 4 ) {
lblWarning - > set_text ( _( " Successfully saved local and global configuration " ) ) ;
lblWarning - > set_text ( successfully_save_all ) ;
}
else if ( mess = = 5 ) {
lblWarning - > set_text ( _( " Nothing to save! " ) ) ;
lblWarning - > set_text ( nothing_save ) ;
}
}
}
@ -1001,6 +998,7 @@ MainWindow::~MainWindow() {
free ( one ) ;
# endif
}
void MainWindow : : add_CSS ( ) {
Glib : : RefPtr < Gtk : : CssProvider > cssProvider = Gtk : : CssProvider : : create ( ) ;
cssProvider - > load_from_path ( path_css ) ;
@ -1020,21 +1018,10 @@ void MainWindow::add_CSS(){
}
void help ( ) {
string version = string ( _( " ubl-settings-bootloader version: " ) ) + version_application + " \n " ;
cout < < version .c_str ( ) ;
string version = string ( str_version ) + version_application + " \n " ;
cout < < version ;
string help ;
help = " GTK settings bootloader for UBLinux \n "
" \n "
" Usage: ubl-settings-bootloader [OPTIONS...] \n "
" Options: \n "
" -h, --help \t Show this help \n "
" -V, --version \t Show package version \n "
" --lock-help Lock utility help \n "
" --lock-save Lock saving local and global configuration \n "
" --lock-save-local Lock save global configuration \n "
" --lock-save-global Lock load global configuration \n "
" --lock-load-global Lock load global configuration \n " ;
cout < < _ ( help . c_str ( ) ) ;
cout < < str_help_h ;
}