@ -7,6 +7,7 @@ const string path_glade = "/usr/share/ubl-settings-datetime/ui/";
const string app_name = " ubl-settings-datetime " ;
const string path_locale = " /usr/share/locale/ " ;
const string path_css = " /usr/share/ubl-settings-datetime/css/ubl-settings-datetime.css " ;
const string path_img_head_background = " /usr/share/ubl-settings-datetime/images/logo-background.png " ;
bool flag_datetime = false ;
bool flag_timezone = false ;
bool flag_ntp_mode = false ;
@ -15,6 +16,7 @@ bool flag_save = false;
bool flag_save_local = false ;
bool flag_save_global = false ;
bool flag_load_global = false ;
bool flag_sync_hwclock = false ;
int socket_ext_id_I = 0 ;
int socket_trd_id_I = 0 ;
string version_application = " 1.5 " ;
@ -53,41 +55,46 @@ MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
}
void MainWindow : : settings ( ) {
map_error [ " xdg-open https://wiki.ublinux.ru/ru/home " ] = string ( _ ( " : \" xdg-open \" " ) ) ;
map_error [ " ubconfig --default --source system get clock ZONE " ] = string ( _ ( " : \" Time Zone \" " ) ) ;
map_error [ " hwclock --systohc " ] = string ( _ ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --default --source system get network NTPSERVERS " ] = string ( _ ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --source=default get NTPSERVERS_DEFAULT " ] = string ( _ ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --default --source system get clock HWCLOCK_SYNC " ] = string ( _ ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --default --source global get network NTPSERVERS " ] = string ( _ ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --default --source global get clock ZONE " ] = string ( _ ( " : \" Time Zone \" " ) ) ;
map_error [ " ubconfig --default --source global get clock HWCLOCK_SYNC " ] = string ( _ ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --source global get clock HWCLOCK_SYNC " ] = string ( _ ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --target system set clock ZONE= " ] = string ( _ ( " : \" Time Zone \" " ) ) ;
map_error [ " ubconfig --target system set network NTPSERVERS=default " ] = string ( _ ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target system set network NTPSERVERS=dhcp " ] = string ( _ ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target system set network NTPSERVERS= \" " ] = string ( _ ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target system remove network NTPSERVERS " ] = string ( _ ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target system set clock HWCLOCK_SYNC=localtime " ] = string ( _ ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --target system set clock HWCLOCK_SYNC=utc " ] = string ( _ ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --target global set clock ZONE= " ] = string ( _ ( " : \" Time Zone \" " ) ) ;
map_error [ " ubconfig --target global set network NTPSERVERS=default " ] = string ( _ ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target global set network NTPSERVERS=dhcp " ] = string ( _ ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target global set network NTPSERVERS= \" " ] = string ( _ ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target global remove network NTPSERVERS " ] = string ( _ ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target global set clock HWCLOCK_SYNC=localtime " ] = string ( _ ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --target global set clock HWCLOCK_SYNC=utc " ] = string ( _ ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --source default get [] NTPSERVERS_DEFAULT " ] = string ( _ ( " : \" NTP \" " ) ) ;
map_error [ " date +%Y%m%d -s \" " ] = string ( _ ( " : \" Date \" " ) ) ;
map_error [ " date +%T -s \" " ] = string ( _ ( " : \" Date \" " ) ) ;
map_error [ " ubconfig --source default get clock HWCLOCK_SYNC " ] = string ( _ ( " : \" Hardware time \" " ) ) ;
map_error [ " xdg-open https://wiki.ublinux.ru/ru/home " ] = string ( gettext ( " : \" xdg-open \" " ) ) ;
map_error [ " ubconfig --default --source system get clock ZONE " ] = string ( gettext ( " : \" Time Zone \" " ) ) ;
map_error [ " hwclock --systohc " ] = string ( gettext ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --default --source system get network NTPSERVERS " ] = string ( gettext ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --source=default get NTPSERVERS_DEFAULT " ] = string ( gettext ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --default --source system get clock HWCLOCK_SYNC " ] = string ( gettext ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --default --source global get network NTPSERVERS " ] = string ( gettext ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --default --source global get clock ZONE " ] = string ( gettext ( " : \" Time Zone \" " ) ) ;
map_error [ " ubconfig --default --source global get clock HWCLOCK_SYNC " ] = string ( gettext ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --source global get clock HWCLOCK_SYNC " ] = string ( gettext ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --target system set clock ZONE= " ] = string ( gettext ( " : \" Time Zone \" " ) ) ;
map_error [ " ubconfig --target system set network NTPSERVERS=default " ] = string ( gettext ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target system set network NTPSERVERS=dhcp " ] = string ( gettext ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target system set network NTPSERVERS= \" " ] = string ( gettext ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target system remove network NTPSERVERS " ] = string ( gettext ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target system set clock HWCLOCK_SYNC=localtime " ] = string ( gettext ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --target system set clock HWCLOCK_SYNC=utc " ] = string ( gettext ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --target global set clock ZONE= " ] = string ( gettext ( " : \" Time Zone \" " ) ) ;
map_error [ " ubconfig --target global set network NTPSERVERS=default " ] = string ( gettext ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target global set network NTPSERVERS=dhcp " ] = string ( gettext ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target global set network NTPSERVERS= \" " ] = string ( gettext ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target global remove network NTPSERVERS " ] = string ( gettext ( " : \" NTP \" " ) ) ;
map_error [ " ubconfig --target global set clock HWCLOCK_SYNC=localtime " ] = string ( gettext ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --target global set clock HWCLOCK_SYNC=utc " ] = string ( gettext ( " : \" Hardware time \" " ) ) ;
map_error [ " ubconfig --source default get [] NTPSERVERS_DEFAULT " ] = string ( gettext ( " : \" NTP \" " ) ) ;
map_error [ " date +%Y%m%d -s \" " ] = string ( gettext ( " : \" Date \" " ) ) ;
map_error [ " date +%T -s \" " ] = string ( gettext ( " : \" Date \" " ) ) ;
map_error [ " ubconfig --source default get clock HWCLOCK_SYNC " ] = string ( gettext ( " : \" Hardware time \" " ) ) ;
this - > get_builder ( ) ;
this - > add_CSS ( ) ;
Gtk : : Widget * boxWidget ;
builder - > get_widget ( " boxColor " , boxWidget ) ;
overHead - > add_overlay ( * boxWidget ) ;
ubl_make_plugs ( boxSave , boxButton , socket_ext_id_I , socket_trd_id_I ) ;
year = 0 ;
month = 0 ;
day = 0 ;
this - > lacalization ( ) ;
btnBoxAboutDialog - > set_visible ( false ) ;
if ( geteuid ( ) = = 0 ) {
numTimeHrs - > set_range ( 0 , 23 ) ;
numTimeMin - > set_range ( 0 , 59 ) ;
@ -95,7 +102,6 @@ void MainWindow::settings() {
numTimeMin - > set_increments ( 1.0 , 1.0 ) ;
this - > get_config ( ) ;
this - > flag_block_gui ( ) ;
btnBoxAboutDialog - > set_visible ( false ) ;
this - > event ( ) ;
this - > parse_text_date ( ) ;
this - > load_local_cfg ( ) ;
@ -111,7 +117,7 @@ void MainWindow::settings() {
this - > event ( ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-datetime.warning " , Gtk : : ICON_SIZE_MENU ) ;
info_status_app ( " boxInfoMessError " ) ;
lblWarning - > set_text ( _ ( " The program must be run as root " ) ) ;
lblWarning - > set_text ( gettext ( " The program must be run as root " ) ) ;
}
}
@ -119,35 +125,35 @@ void MainWindow::lacalization() {
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 ) ;
string str_authors = string ( gettext ( " Copyright © UBSoft LLC, 2022 - " ) ) + to_string ( year ) ;
aboutWindows - > set_copyright ( str_authors ) ;
aboutWindows - > set_comments ( _ ( " Date and Time " ) ) ;
aboutWindows - > set_website ( _ ( " https://wiki.ublinux.com " ) ) ;
aboutWindows - > set_version ( _ ( version_application . c_str ( ) ) ) ;
aboutWindows - > set_website_label ( _ ( " Project Home Page " ) ) ;
lblSave - > set_label ( _ ( " Save " ) ) ;
lblLoad - > set_label ( _ ( " Load " ) ) ;
txtDate - > set_tooltip_text ( _ ( " Date of \n Format: DD.MM.YYYY " ) ) ;
txtNtpServer - > set_tooltip_text ( _ ( " Enter the name of the ntp-server or its ip-address. \n When entering multiple addresses, separate them with commas. " ) ) ;
lblSynchronizebChkGLob - > set_text ( _ ( " Synchronize via NTP " ) ) ;
cbDhcp - > append ( _ ( " Default " ) ) ;
cbDhcp - > append ( _ ( " DHCP " ) ) ;
cbDhcp - > append ( _ ( " Manual " ) ) ;
cbDhcp - > append ( _ ( " Disabled " ) ) ;
lblDateTimeSetting - > set_text ( _ ( " Current date and time " ) ) ;
lblHead - > set_text ( _ ( " Setting the date and time " ) ) ;
lblTime - > set_text ( _ ( " Time: " ) ) ;
lblData - > set_text ( _ ( " Date: " ) ) ;
lblTimeZone - > set_text ( _ ( " Time zone " ) ) ;
lblReg - > set_text ( _ ( " Region: " ) ) ;
lblZone - > set_text ( _ ( " Zone: " ) ) ;
lblSynchronizeBtn - > set_text ( _ ( " Sync by " ) ) ;
lblHeader - > set_text ( _ ( " ubl-settings-datetime " ) ) ;
windowMessDchp - > set_title ( _ ( " Warning! " ) ) ;
lblTimeBios - > set_text ( _ ( " Synchronize hardware time " ) ) ;
lblHW - > set_text ( _ ( " Synchronize hardware time: " ) ) ;
array_hw_local [ 0 ] = _ ( " UTC time " ) ;
array_hw_local [ 1 ] = _ ( " Local time " ) ;
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 " ) ) ;
lblSave - > set_label ( gettext ( " Save " ) ) ;
lblLoad - > set_label ( gettext ( " Load " ) ) ;
txtDate - > set_tooltip_text ( gettext ( " Date of \n Format: DD.MM.YYYY " ) ) ;
txtNtpServer - > set_tooltip_text ( gettext ( " Enter the name of the ntp-server or its ip-address. \n When entering multiple addresses, separate them with commas. " ) ) ;
lblSynchronizebChkGLob - > set_text ( gettext ( " Synchronize via NTP " ) ) ;
cbDhcp - > append ( gettext ( " Default " ) ) ;
cbDhcp - > append ( gettext ( " DHCP " ) ) ;
cbDhcp - > append ( gettext ( " Manual " ) ) ;
cbDhcp - > append ( gettext ( " Disabled " ) ) ;
lblDateTimeSetting - > set_text ( gettext ( " Current date and time " ) ) ;
lblHead - > set_text ( gettext ( " Setting the date and time " ) ) ;
lblTime - > set_text ( gettext ( " Time: " ) ) ;
lblData - > set_text ( gettext ( " Date: " ) ) ;
lblTimeZone - > set_text ( gettext ( " Time zone " ) ) ;
lblReg - > set_text ( gettext ( " Region: " ) ) ;
lblZone - > set_text ( gettext ( " Zone: " ) ) ;
lblSynchronizeBtn - > set_text ( gettext ( " Sync by " ) ) ;
lblHeader - > set_text ( gettext ( " ubl-settings-datetime " ) ) ;
windowMessDchp - > set_title ( gettext ( " Warning! " ) ) ;
lblTimeBios - > set_text ( gettext ( " Synchronize hardware time " ) ) ;
lblHW - > set_text ( gettext ( " Synchronize hardware time: " ) ) ;
array_hw_local [ 0 ] = gettext ( " UTC time " ) ;
array_hw_local [ 1 ] = gettext ( " Local time " ) ;
array_hw [ 0 ] = " utc " ;
array_hw [ 1 ] = " localtime " ;
this - > bubble_sort ( array_hw , array_hw_local , 2 ) ;
@ -182,6 +188,10 @@ void MainWindow::flag_block_gui() {
lblTime - > set_sensitive ( false ) ;
lblData - > set_sensitive ( false ) ;
}
if ( flag_sync_hwclock = = true ) {
lblHW - > set_sensitive ( false ) ;
cbHw - > set_sensitive ( false ) ;
}
if ( flag_timezone = = true ) {
cbRegion - > set_sensitive ( false ) ;
cbZone - > set_sensitive ( false ) ;
@ -219,8 +229,7 @@ void MainWindow::add_CSS() {
Glib : : RefPtr < Gtk : : StyleContext > styleContext = Gtk : : StyleContext : : create ( ) ;
Glib : : RefPtr < Gdk : : Screen > screen = Gdk : : Screen : : get_default ( ) ; //get default screen
styleContext - > add_provider_for_screen ( screen , cssProvider , GTK_STYLE_PROVIDER_PRIORITY_APPLICATION ) ; //add provider for screen in all application
Glib : : RefPtr < Gtk : : StyleContext > boxColor_css = boxColor - > get_style_context ( ) ;
boxColor_css - > add_class ( " cssboxColor1 " ) ;
imgHeadBackground - > set ( path_img_head_background ) ;
Glib : : RefPtr < Gtk : : StyleContext > lblHead_css = lblHead - > get_style_context ( ) ;
Glib : : RefPtr < Gtk : : StyleContext > boxButton_css = boxButton - > get_style_context ( ) ;
Glib : : RefPtr < Gtk : : StyleContext > boxSave_css = boxSave - > get_style_context ( ) ;
@ -241,6 +250,7 @@ void MainWindow::info_status_app(string stule) {
boxInfo - > add_class ( stule ) ;
}
void MainWindow : : get_builder ( ) {
builder - > set_translation_domain ( path_app ) ;
builder - > get_widget ( " boxColor " , boxColor ) ;
@ -302,6 +312,8 @@ void MainWindow::get_builder() {
builder - > get_widget ( " imgSettings " , imgSettings ) ;
builder - > get_widget ( " imgSave " , imgSave ) ;
builder - > get_widget ( " boxWidgetFunc " , boxWidgetFunc ) ;
builder - > get_widget ( " overHead " , overHead ) ;
builder - > get_widget ( " imgHeadBackground " , imgHeadBackground ) ;
}
@ -326,11 +338,64 @@ void MainWindow::event() {
btnSaveLocalGlob - > signal_activate ( ) . connect ( [ & ] ( ) { save_global_local_cfg ( ) ; } ) ;
btnSaveLocal - > signal_activate ( ) . connect ( [ & ] ( ) { save_local_cfg ( ) ; } ) ;
btnSaveGlob - > signal_activate ( ) . connect ( [ & ] ( ) { save_global_cfg ( ) ; } ) ;
cbZone - > signal_changed ( ) . connect ( sigc : : mem_fun ( * this , & MainWindow : : event_zone ) ) ;
cbHw - > signal_changed ( ) . connect ( sigc : : mem_fun ( * this , & MainWindow : : event_log_hw ) ) ;
txtNtpServer - > signal_focus_out_event ( ) . connect ( sigc : : mem_fun ( * this , & MainWindow : : focus_ntp ) ) ;
}
bool MainWindow : : focus_ntp ( GdkEventFocus * event ) {
if ( event ! = NULL ) {
}
if ( flag_ntp_edit = = false ) {
this - > focus_ntp_text ( ) ;
}
return true ;
}
void MainWindow : : event_log_hw ( ) {
string str_hw = cbHw - > get_active_text ( ) ;
if ( str_hw . length ( ) > 0 ) {
int size_hw = sizeof ( array_hw ) / sizeof ( array_hw [ 0 ] ) ;
for ( int i = 0 ; i < size_hw ; i + + ) {
if ( str_hw = = array_hw_local [ i ] ) {
this - > write_config ( array_hw [ i ] , " hw " ) ;
}
}
}
}
void MainWindow : : event_zone ( ) {
int activ_index_reg = cbRegion - > get_active_row_number ( ) ;
if ( activ_index_reg = = - 1 ) {
this - > write_config ( " error " , " zone " ) ;
return ;
}
string reg_text = array_region [ activ_index_reg ] ;
int activ_index = cbZone - > get_active_row_number ( ) ;
if ( activ_index = = - 1 ) {
this - > write_config ( " error " , " zone " ) ;
return ;
}
string zone_text = " " ;
if ( ! ( reg_text . empty ( ) ) ) {
int index = 0 ;
for ( const auto & zone : time_reg_map . at ( reg_text ) ) {
if ( index = = activ_index ) {
zone_text = zone ;
}
index + = 1 ;
}
}
this - > write_config ( zone_text , " zone " ) ;
}
void MainWindow : : synopsis_show ( ) {
int start_error = error_info ;
string cmd = " xdg-open " + string ( _ ( " https://wiki.ublinux.com/ru/Пр о г р а ммно е _о б е с пе че ние /Пр о г р а ммы_и_у тилиты/В с е / " ) ) + app_name ;
string cmd = " xdg-open " + string ( gettext ( " https://wiki.ublinux.com/ru/Пр о г р а ммно е _о б е с пе че ние /Пр о г р а ммы_и_у тилиты/В с е / " ) ) + app_name ;
if ( geteuid ( ) = = 0 ) {
string response_user = getlogin ( ) ;
cmd = " su -l " + response_user + " -c \" DISPLAY=$DISPLAY " + cmd + " \" " ;
}
wrapper_system ( cmd , " & " ) ;
if ( start_error ! = error_info ) {
error_info = start_error ;
@ -338,8 +403,9 @@ void MainWindow::synopsis_show() {
}
void MainWindow : : load_local_cfg ( ) {
string cmd = " ubconfig --default --source system get clock ZONE " ;
this - > fill_in_reg_zone ( cmd ) ;
flag_load = false ;
string cmd_zone = " ubconfig --default --source system get clock ZONE " ;
this - > fill_in_reg_zone ( cmd_zone ) ;
this - > update_hour_minute ( ) ;
this - > update_calendar ( ) ;
string cmd_get_dhcp = " ubconfig --default --source system get network NTPSERVERS " ;
@ -347,11 +413,14 @@ void MainWindow::load_local_cfg() {
this - > entry_dhcp_mess ( cmd_get_dhcp , cmd_default_get_dhcp ) ;
string hw = " ubconfig --default --source system get clock HWCLOCK_SYNC " ;
this - > get_hardware_clock ( hw ) ;
flag_load = false ;
info_warning_error ( 0 ) ;
map_config_data_global_local_old = map_config_data_global_local ;
map_config_data_global_old = map_config_data_global ;
map_config_data_local_old = map_config_data_local ;
}
void MainWindow : : load_globl_cfg ( ) {
flag_load = true ;
string cmd_get_dhcp = " ubconfig --default --source global get network NTPSERVERS " ;
string cmd_default_get_dhcp = " ubconfig --source default get [] NTPSERVERS_DEFAULT " ;
this - > entry_dhcp_mess ( cmd_get_dhcp , cmd_default_get_dhcp ) ;
@ -359,36 +428,220 @@ void MainWindow::load_globl_cfg() {
this - > fill_in_reg_zone ( cmd_zone ) ;
string hw = " ubconfig --source global get clock HWCLOCK_SYNC " ;
this - > get_hardware_clock ( hw ) ;
flag_load = true ;
info_warning_error ( 1 ) ;
map_config_data_global_local_old = map_config_data_global_local ;
map_config_data_global_old = map_config_data_global ;
map_config_data_local_old = map_config_data_local ;
}
void MainWindow : : save_local_cfg ( ) {
string cmd_zone = " ubconfig --target system set clock ZONE= " ;
this - > enter_zone ( cmd_zone ) ;
string cmd_default = " ubconfig --target system set network NTPSERVERS=default " ;
string cmd_dhcp = " ubconfig --target system set network NTPSERVERS=dhcp " ;
string cmd_set_ntp = " ubconfig --target system set network NTPSERVERS= \" " ;
string remove_ntp = " ubconfig --target system remove network NTPSERVERS " ;
this - > save_Dhcp ( cmd_default , cmd_dhcp , remove_ntp , cmd_set_ntp ) ;
string local = " ubconfig --target system set clock HWCLOCK_SYNC=localtime " ;
string hw = " ubconfig --target system set clock HWCLOCK_SYNC=utc " ;
this - > set_hardware_clock ( local , hw ) ;
info_warning_error ( 2 ) ;
if ( ( this - > check_config ( " region " , 0 ) & & this - > check_config ( " zone " , 0 ) & &
this - > check_config ( " dhcp " , 0 ) & & this - > check_config ( " hw " , 0 ) ) ) {
lblWarning - > set_text ( gettext ( " Nothing to save! " ) ) ;
}
else {
string cmd_zone = " ubconfig --target system set clock ZONE= " ;
string cmd_default = " ubconfig --target system set network NTPSERVERS=default " ;
string cmd_dhcp = " ubconfig --target system set network NTPSERVERS=dhcp " ;
string cmd_set_ntp = " ubconfig --target system set network NTPSERVERS= \" " ;
string remove_ntp = " ubconfig --target system remove network NTPSERVERS " ;
string local = " ubconfig --target system set clock HWCLOCK_SYNC=localtime " ;
string hw = " ubconfig --target system set clock HWCLOCK_SYNC=utc " ;
if ( ( this - > check_config ( " region " , 0 ) = = false | | this - > check_config ( " zone " , 0 ) = = false ) ) {
this - > enter_zone ( cmd_zone ) ;
}
if ( this - > check_config ( " dhcp " , 0 ) = = false ) {
this - > save_Dhcp ( cmd_default , cmd_dhcp , remove_ntp , cmd_set_ntp ) ;
}
if ( this - > check_config ( " hw " , 0 ) = = false ) {
this - > set_hardware_clock ( local , hw ) ;
}
info_warning_error ( 2 ) ;
map_config_data_local_old = map_config_data_local ;
flag_local = true ;
if ( flag_global and flag_local ) {
map_config_data_global_local_old = map_config_data_global_local ;
}
}
}
void MainWindow : : save_global_cfg ( ) {
string cmd = " ubconfig --target global set clock ZONE= " ;
this - > enter_zone ( cmd ) ;
string cmd_default = " ubconfig --target global set network NTPSERVERS=default " ;
string cmd_dhcp = " ubconfig --target global set network NTPSERVERS=dhcp " ;
string cmd_set_ntp = " ubconfig --target global set network NTPSERVERS= \" " ;
string remove_ntp = " ubconfig --target global remove network NTPSERVERS " ;
this - > save_Dhcp ( cmd_default , cmd_dhcp , remove_ntp , cmd_set_ntp ) ;
string local = " ubconfig --target global set clock HWCLOCK_SYNC=localtime " ;
string hw = " ubconfig --target global set clock HWCLOCK_SYNC=utc " ;
this - > set_hardware_clock ( local , hw ) ;
info_warning_error ( 3 ) ;
if ( ( this - > check_config ( " region " , 1 ) & & this - > check_config ( " zone " , 1 ) & &
this - > check_config ( " dhcp " , 1 ) & & this - > check_config ( " hw " , 1 ) ) ) {
lblWarning - > set_text ( gettext ( " Nothing to save! " ) ) ;
}
else {
string cmd = " ubconfig --target global set clock ZONE= " ;
string cmd_default = " ubconfig --target global set network NTPSERVERS=default " ;
string cmd_dhcp = " ubconfig --target global set network NTPSERVERS=dhcp " ;
string cmd_set_ntp = " ubconfig --target global set network NTPSERVERS= \" " ;
string remove_ntp = " ubconfig --target global remove network NTPSERVERS " ;
string local = " ubconfig --target global set clock HWCLOCK_SYNC=localtime " ;
string hw = " ubconfig --target global set clock HWCLOCK_SYNC=utc " ;
if ( ( this - > check_config ( " region " , 1 ) = = false | | this - > check_config ( " zone " , 1 ) = = false ) ) {
this - > enter_zone ( cmd ) ;
}
if ( this - > check_config ( " dhcp " , 1 ) = = false ) {
this - > save_Dhcp ( cmd_default , cmd_dhcp , remove_ntp , cmd_set_ntp ) ;
}
if ( this - > check_config ( " hw " , 1 ) = = false ) {
this - > set_hardware_clock ( local , hw ) ;
}
info_warning_error ( 3 ) ;
map_config_data_global_old = map_config_data_global ;
flag_global = true ;
if ( flag_global and flag_local ) {
map_config_data_global_local_old = map_config_data_global_local ;
}
}
}
void MainWindow : : save_global_local_cfg ( ) {
if ( ( this - > check_config ( " region " , 2 ) & & this - > check_config ( " zone " , 2 ) & &
this - > check_config ( " dhcp " , 2 ) & & this - > check_config ( " hw " , 2 ) ) ) {
lblWarning - > set_text ( gettext ( " Nothing to save! " ) ) ;
}
else {
string cmd = " " ;
string cmd_default = " " ;
string cmd_dhcp = " " ;
string cmd_set_ntp = " " ;
string remove = " " ;
string local = " " ;
string hw = " " ;
string remove_ntp = " " ;
string cmd_zone = " " ;
if ( ( this - > check_config ( " region " , 2 ) = = false | | this - > check_config ( " zone " , 2 ) = = false ) ) {
if ( flag_local = = false ) {
cmd_zone = " ubconfig --target system set clock ZONE= " ;
this - > enter_zone ( cmd_zone ) ;
}
if ( flag_global = = false ) {
cmd_zone = " ubconfig --target global set clock ZONE= " ;
this - > enter_zone ( cmd_zone ) ;
}
}
if ( this - > check_config ( " dhcp " , 2 ) = = false ) {
if ( flag_local = = false ) {
cmd_default = " ubconfig --target system set network NTPSERVERS=default " ;
cmd_dhcp = " ubconfig --target system set network NTPSERVERS=dhcp " ;
cmd_set_ntp = " ubconfig --target system set network NTPSERVERS= \" " ;
remove_ntp = " ubconfig --target system remove network NTPSERVERS " ;
this - > save_Dhcp ( cmd_default , cmd_dhcp , remove_ntp , cmd_set_ntp ) ;
}
if ( flag_global = = false ) {
cmd_default = " ubconfig --target global set network NTPSERVERS=default " ;
cmd_dhcp = " ubconfig --target global set network NTPSERVERS=dhcp " ;
cmd_set_ntp = " ubconfig --target global set network NTPSERVERS= \" " ;
remove_ntp = " ubconfig --target global remove network NTPSERVERS " ;
this - > save_Dhcp ( cmd_default , cmd_dhcp , remove_ntp , cmd_set_ntp ) ;
}
}
if ( this - > check_config ( " hw " , 2 ) = = false ) {
if ( flag_local = = false ) {
local = " ubconfig --target system set clock HWCLOCK_SYNC=localtime " ;
hw = " ubconfig --target system set clock HWCLOCK_SYNC=utc " ;
this - > set_hardware_clock ( local , hw ) ;
}
if ( flag_global = = false ) {
local = " ubconfig --target global set clock HWCLOCK_SYNC=localtime " ;
hw = " ubconfig --target global set clock HWCLOCK_SYNC=utc " ;
this - > set_hardware_clock ( local , hw ) ;
}
}
map_config_data_global_local_old = map_config_data_global_local ;
map_config_data_global_old = map_config_data_global ;
map_config_data_local_old = map_config_data_local ;
info_warning_error ( 4 ) ;
flag_global_local = true ;
}
}
void MainWindow : : write_config ( string data , string key ) {
std : : map < string , string > : : iterator it , it2 , it3 ;
it3 = map_config_data_global_local . find ( key ) ;
it2 = map_config_data_global . find ( key ) ;
it = map_config_data_local . find ( key ) ;
if ( it ! = map_config_data_local . end ( ) | | it2 ! = map_config_data_global . end ( ) | | it3 ! = map_config_data_global_local . end ( ) ) {
if ( map_config_data_local [ key ] ! = data ) {
map_config_data_global [ key ] = data ;
map_config_data_local [ key ] = data ;
map_config_data_global_local [ key ] = data ;
flag_local = false ;
flag_global = false ;
flag_global_local = false ;
}
}
else if ( it = = map_config_data_local . end ( ) | | it2 = = map_config_data_global . end ( ) | | it3 = = map_config_data_global_local . end ( ) ) {
map_config_data_global [ key ] = data ;
map_config_data_local [ key ] = data ;
map_config_data_global_local [ key ] = data ;
flag_local = false ;
flag_global = false ;
flag_global_local = false ;
}
}
bool MainWindow : : check_config ( string key , int key_save ) {
std : : map < string , string > : : iterator iter_map_config_data ;
std : : map < string , string > : : iterator iter_map_config_data_old ;
std : : map < string , string > map_config_data ;
std : : map < string , string > map_config_data_old ;
if ( ( key_save = = 0 | | key_save = = 1 ) & & flag_global_local = = true ) {
map_config_data_global_local_old = map_config_data_global_local ;
map_config_data_global_old = map_config_data_global ;
map_config_data_local_old = map_config_data_local ;
return true ;
}
else if ( key_save = = 0 & & flag_local = = true ) {
return true ;
}
else if ( key_save = = 1 & & flag_global = = true ) {
return true ;
}
else if ( key_save = = 2 & & flag_global = = true & & flag_local = = true ) {
return true ;
}
else if ( key_save = = 2 & & flag_global_local = = true ) {
return true ;
}
if ( key_save = = 0 ) {
iter_map_config_data = map_config_data_local . find ( key ) ;
map_config_data = map_config_data_local ;
map_config_data_old = map_config_data_local_old ;
}
else if ( key_save = = 1 ) {
iter_map_config_data = map_config_data_global . find ( key ) ;
map_config_data = map_config_data_global ;
map_config_data_old = map_config_data_global_old ;
}
else if ( key_save = = 2 ) {
iter_map_config_data = map_config_data_global_local . find ( key ) ;
map_config_data = map_config_data_global_local ;
map_config_data_old = map_config_data_global_local_old ;
}
iter_map_config_data = map_config_data . find ( key ) ;
iter_map_config_data_old = map_config_data_old . find ( key ) ;
if ( iter_map_config_data = = map_config_data . end ( ) ) { ;
return false ;
}
else if ( iter_map_config_data_old = = map_config_data_old . end ( ) ) {
return false ;
}
else if ( iter_map_config_data - > second ! = iter_map_config_data_old - > second ) {
return false ;
}
else if ( iter_map_config_data - > second . length ( ) = = 0 | | iter_map_config_data_old - > second . length ( ) = = 0 ) {
return true ;
}
else if ( iter_map_config_data - > second = = iter_map_config_data_old - > second ) {
return true ;
}
else {
return false ;
}
return false ;
}
string MainWindow : : get_ubconfig_value ( string & cmd ) {
@ -405,21 +658,6 @@ string MainWindow::get_ubconfig_value(string &cmd){
}
void MainWindow : : save_global_local_cfg ( ) {
string cmd = " " ;
string cmd_default = " " ;
string cmd_dhcp = " " ;
string cmd_set_ntp = " " ;
string remove = " " ;
if ( flag_save_global = = false ) {
this - > save_local_cfg ( ) ;
}
if ( flag_save_local = = false ) {
this - > save_global_cfg ( ) ;
}
info_warning_error ( 4 ) ;
}
void MainWindow : : info_warning_error ( int mess ) {
if ( error_info > 0 | | warning_info > 0 ) {
info_status_app ( " boxInfoMessError " ) ;
@ -428,23 +666,23 @@ void MainWindow::info_warning_error(int mess) {
warning_info = 0 ;
string mess_error = " " ;
if ( mess = = 0 ) {
mess_error = string ( _ ( " Local configuration reading error " ) ) + cmd_error ;
mess_error = string ( gettext ( " Local configuration reading error " ) ) + cmd_error ;
lblWarning - > set_text ( mess_error ) ;
}
else if ( mess = = 1 ) {
mess_error = string ( _ ( " Global configuration read error " ) ) + cmd_error ;
mess_error = string ( gettext ( " Global configuration read error " ) ) + cmd_error ;
lblWarning - > set_text ( mess_error ) ;
}
else if ( mess = = 2 ) {
mess_error = string ( _ ( " Local configuration write error " ) ) + cmd_error ;
mess_error = string ( gettext ( " Local configuration write error " ) ) + cmd_error ;
lblWarning - > set_text ( mess_error ) ;
}
else if ( mess = = 3 ) {
mess_error = string ( _ ( " Global configuration write error " ) ) + cmd_error ;
mess_error = string ( gettext ( " Global configuration write error " ) ) + cmd_error ;
lblWarning - > set_text ( mess_error ) ;
}
else if ( mess = = 4 ) {
mess_error = string ( _ ( " Error saved local and global configuration " ) ) + cmd_error ;
mess_error = string ( gettext ( " Error saved local and global configuration " ) ) + cmd_error ;
lblWarning - > set_text ( mess_error ) ;
}
cmd_error = " " ;
@ -453,19 +691,19 @@ void MainWindow::info_warning_error(int mess) {
info_status_app ( " boxInfoMessOK " ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-datetime.checked " , Gtk : : ICON_SIZE_MENU ) ; //Gtk::IconSize::INHERIT);
if ( mess = = 0 ) {
lblWarning - > set_text ( _ ( " Local configuration downloaded successfully " ) ) ;
lblWarning - > set_text ( gettext ( " Local configuration downloaded successfully " ) ) ;
}
else if ( mess = = 1 ) {
lblWarning - > set_text ( _ ( " Global configuration downloaded successfully " ) ) ;
lblWarning - > set_text ( gettext ( " Global configuration downloaded successfully " ) ) ;
}
else if ( mess = = 2 ) {
lblWarning - > set_text ( _ ( " Local configuration successfully written " ) ) ;
lblWarning - > set_text ( gettext ( " Local configuration successfully written " ) ) ;
}
else if ( mess = = 3 ) {
lblWarning - > set_text ( _ ( " Global configuration successfully written " ) ) ;
lblWarning - > set_text ( gettext ( " Global configuration successfully written " ) ) ;
}
else if ( mess = = 4 ) {
lblWarning - > set_text ( _ ( " Successfully saved local and global configuration " ) ) ;
lblWarning - > set_text ( gettext ( " Successfully saved local and global configuration " ) ) ;
}
}
}
@ -500,7 +738,7 @@ void MainWindow::set_hardware_clock(string &local, string &etc) {
string str_hw = cbHw - > get_active_text ( ) ;
for ( int index = 0 ; index < 2 ; index + + ) {
if ( array_hw_local [ index ] = = str_hw ) {
if ( array_hw [ index ] = = " utc " ) {
if ( array_hw [ index ] = = " utc " ) {
wrapper_system ( etc , " & " ) ;
}
else {
@ -514,6 +752,7 @@ void MainWindow::get_hardware_clock(string &cmd) {
int error = warning_info ;
struct Result < string > obj_result = this - > wrapper_call ( cmd ) ;
if ( obj_result . error = = 0 ) {
this - > write_config ( obj_result . response , " hw " ) ;
if ( obj_result . response . find ( " localtime " ) ! = string : : npos ) {
if ( array_hw [ 0 ] = = " localtime " ) {
cbHw - > set_active ( 0 ) ;
@ -536,6 +775,7 @@ void MainWindow::get_hardware_clock(string &cmd) {
}
}
else {
this - > write_config ( " " , " hw " ) ;
cbHw - > set_active ( - 1 ) ;
}
if ( error ! = warning_info ) {
@ -553,9 +793,9 @@ void MainWindow::gui_mess_close() {
windowMessDchp - > hide ( ) ;
}
bool MainWindow : : focus_ntp ( string & cmd_set_ntp ) {
bool MainWindow : : focus_ntp _text( ) {
if ( txtNtpServer - > get_text ( ) = = " " | | txtNtpServer - > get_text ( ) = = " " ) {
lblMessage - > set_text ( _ ( " Enter DHCP! " ) ) ;
lblMessage - > set_text ( gettext ( " Enter DHCP! " ) ) ;
windowMessDchp - > show ( ) ;
}
else {
@ -576,18 +816,19 @@ bool MainWindow::focus_ntp(string &cmd_set_ntp) {
}
}
if ( ( flag_error = = false ) & & ( flag_error_check_ntp = = false ) ) {
cmd = cmd_set_ntp + str_ntp + " \" " ;
wrapper_system ( cmd , " & " ) ;
this - > write_config ( str_ntp , " dhcp " ) ;
return true ;
}
else {
if ( flag_error = = true ) {
lblMessage - > set_text ( _ ( " An invalid character is entered " ) ) ;
lblMessage - > set_text ( gettext ( " An invalid character is entered " ) ) ;
windowMessDchp - > show ( ) ;
}
else if ( flag_error_check_ntp = = true ) {
lblMessage - > set_text ( _ ( " Error in the ntp name " ) ) ;
lblMessage - > set_text ( gettext ( " Error in the ntp name " ) ) ;
windowMessDchp - > show ( ) ;
}
return false ;
}
}
return true ;
@ -706,19 +947,24 @@ void MainWindow::event_entry_cbDhcp() {
int activ_index = cbDhcp - > get_active_row_number ( ) ;
if ( str_dhcp . length ( ) = = 0 ) {
cbDhcp - > set_active ( 0 ) ;
this - > write_config ( " default " , " dhcp " ) ;
}
else if ( activ_index = = 0 ) {
txtNtpServer - > set_text ( default_get_dhcp ) ;
txtNtpServer - > set_sensitive ( false ) ;
this - > write_config ( " default " , " dhcp " ) ;
}
else if ( activ_index = = 1 ) {
// btnUpdateDateTime->set_sensitive(false);
txtNtpServer - > set_sensitive ( false ) ;
txtNtpServer - > set_text ( " " ) ;
this - > write_config ( " dhcp " , " dhcp " ) ;
}
else if ( activ_index = = 2 ) {
txtNtpServer - > set_text ( " " ) ;
if ( flag_ntp_edit = = false ) {
txtNtpServer - > set_sensitive ( true ) ;
txtNtpServer - > grab_focus ( ) ;
string cmd = " " ;
if ( flag_load = = false ) {
cmd = " ubconfig --default --source system get network NTPSERVERS " ;
@ -727,14 +973,17 @@ void MainWindow::event_entry_cbDhcp() {
cmd = " ubconfig --default --source global get network NTPSERVERS " ;
}
string response = this - > get_ubconfig_value ( cmd ) ;
if ( response ! = " dhcp " & & response ! = " default " ) {
if ( response ! = " dhcp " & & response ! = " default " ) {
txtNtpServer - > set_text ( response ) ;
}
txtNtpServer - > set_sensitive ( true ) ;
this - > write_config ( response , " dhcp " ) ;
}
else {
this - > write_config ( " " , " dhcp " ) ;
}
}
else if ( activ_index = = 3 ) {
this - > write_config ( " " , " dhcp " ) ;
txtNtpServer - > set_text ( " " ) ;
txtNtpServer - > set_sensitive ( false ) ;
// btnUpdateDateTime->set_sensitive(true);
@ -747,13 +996,23 @@ void MainWindow::save_Dhcp(string &cmd_default, string &cmd_dhcp, string &remove
if ( str_dhcp . length ( ) = = 0 ) {
}
else if ( activ_index = = 0 ) {
this - > write_config ( " default " , " dhcp " ) ;
wrapper_system ( cmd_default , " & " ) ;
}
else if ( activ_index = = 1 ) {
this - > write_config ( " dhcp " , " dhcp " ) ;
wrapper_system ( cmd_dhcp , " & " ) ;
}
else if ( activ_index = = 2 ) {
this - > focus_ntp ( cmd_set_ntp ) ;
if ( flag_ntp_edit = = false ) {
if ( this - > focus_ntp_text ( ) ) {
string str_ntp = txtNtpServer - > get_text ( ) ;
string cmd = cmd_set_ntp + str_ntp + " \" " ;
this - > write_config ( str_ntp , " dhcp " ) ;
wrapper_system ( cmd , " & " ) ;
}
}
}
else if ( activ_index = = 3 ) {
int start_error = error_info ;
@ -761,18 +1020,20 @@ void MainWindow::save_Dhcp(string &cmd_default, string &cmd_dhcp, string &remove
if ( start_error ! = error_info ) {
error_info = start_error ;
}
this - > write_config ( " " , " dhcp " ) ;
}
}
void MainWindow : : entry_dhcp_mess ( string cmd_get_dhcp , string cmd_default_get_dhcp ) {
string cmd = cmd_get_dhcp ;
struct Result < string > obj_result = this - > wrapper_call ( cmd ) ;
if ( obj_result . error = = 0 ) {
if ( obj_result . error = = 0 ) {
string str_dhcp = obj_result . response ;
// btnUpdateDateTime->set_sensitive(false);
str_dhcp = str_dhcp . substr ( str_dhcp . find ( " = " ) + 1 , str_dhcp . length ( ) ) ;
str_dhcp = str_dhcp . substr ( 0 , str_dhcp . find ( " \n " ) ) ;
str_dhcp = str_dhcp . substr ( str_dhcp . find ( " = " ) + 1 , str_dhcp . length ( ) ) ;
str_dhcp = str_dhcp . substr ( 0 , str_dhcp . find ( " \n " ) ) ;
if ( str_dhcp = = " dhcp " ) {
this - > write_config ( " dhcp " , " dhcp " ) ;
cbDhcp - > set_active ( 1 ) ;
txtNtpServer - > set_text ( " " ) ;
txtNtpServer - > set_sensitive ( false ) ;
@ -782,6 +1043,7 @@ void MainWindow::entry_dhcp_mess(string cmd_get_dhcp, string cmd_default_get_dhc
cbDhcp - > set_active ( 0 ) ;
cmd = cmd_default_get_dhcp ;
struct Result < string > obj_result = this - > wrapper_call ( cmd ) ;
this - > write_config ( " default " , " dhcp " ) ;
txtNtpServer - > set_sensitive ( false ) ;
if ( obj_result . error = = 0 ) {
txtNtpServer - > set_text ( obj_result . response ) ;
@ -795,15 +1057,18 @@ void MainWindow::entry_dhcp_mess(string cmd_get_dhcp, string cmd_default_get_dhc
else {
// btnUpdateDateTime->set_sensitive(false);
if ( str_dhcp = = " " ) {
lblMessage - > set_text ( _ ( " Enter DHCP! " ) ) ;
this - > write_config ( " " , " dhcp " ) ;
lblMessage - > set_text ( gettext ( " Enter DHCP! " ) ) ;
windowMessDchp - > show ( ) ;
}
else if ( str_dhcp = = " (null) " ) {
cbDhcp - > set_active ( 0 ) ;
txtNtpServer - > set_text ( " " ) ;
this - > write_config ( " " , " dhcp " ) ;
}
else {
cbDhcp - > set_active ( 2 ) ;
this - > write_config ( str_dhcp , " dhcp " ) ;
txtNtpServer - > set_text ( str_dhcp ) ;
if ( flag_ntp_edit = = false ) {
txtNtpServer - > set_sensitive ( true ) ;
@ -812,6 +1077,7 @@ void MainWindow::entry_dhcp_mess(string cmd_get_dhcp, string cmd_default_get_dhc
}
}
else {
this - > write_config ( " " , " dhcp " ) ;
cbDhcp - > set_active ( 3 ) ;
txtNtpServer - > set_text ( " " ) ;
txtNtpServer - > set_sensitive ( false ) ;
@ -919,20 +1185,26 @@ array<string, 2> MainWindow::split_region_zone(string &read_reg_zon_cfg) {
void MainWindow : : enter_zone ( string & cmd ) {
int activ_index_reg = cbRegion - > get_active_row_number ( ) ;
if ( activ_index_reg = = - 1 ) {
return ;
}
string reg_text = array_region [ activ_index_reg ] ;
int activ_index = cbZone - > get_active_row_number ( ) ;
if ( activ_index = = - 1 ) {
return ;
}
string zone_text = " " ;
if ( ! ( reg_text . empty ( ) ) ) {
int index = 0 ;
for ( const auto & zone : time_reg_map . at ( reg_text ) ) {
if ( index = = activ_index ) {
zone_text = zone ;
zone_text = zone ;
}
index + = 1 ;
}
if ( ! ( zone_text . empty ( ) ) ) {
str_zone = zone_text ;
str_region = reg_text ;
str_zone = zone_text ;
str_region = reg_text ;
cmd = cmd + str_region + " / " + str_zone ;
wrapper_system ( cmd , " & " ) ;
}
@ -957,13 +1229,15 @@ void MainWindow::parse_text_date() {
}
void MainWindow : : append_region_zone ( string region , string zone , Gtk : : ComboBoxText * tmpCbReg , Gtk : : ComboBoxText * tmpCbZone ) {
this - > write_config ( region , " region " ) ;
this - > write_config ( zone , " zone " ) ;
str_region = region ;
int index = 0 ;
Glib : : ustring reg_local = " " ;
int size_vec = array_region_local . size ( ) ;
if ( size_vec = = 0 ) {
for ( auto & [ key , value ] : time_reg_map ) {
array_region_local . push_back ( string ( _ ( key . c_str ( ) ) ) ) ;
array_region_local . push_back ( string ( gettext ( key . c_str ( ) ) ) ) ;
array_region . push_back ( key ) ;
index + = 1 ;
}
@ -989,7 +1263,7 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex
if ( size_vec = = 0 ) {
tmpCbReg - > append ( Glib : : ustring ( reg ) ) ;
}
if ( reg = = string ( _ ( region . c_str ( ) ) ) ) {
if ( reg = = string ( gettext ( region . c_str ( ) ) ) ) {
tmpCbReg - > set_active_text ( reg ) ;
}
}
@ -999,7 +1273,7 @@ void MainWindow::append_region_zone(string region, string zone, Gtk::ComboBoxTex
string path_reg_zone = " " ;
string zone_offest = " " ;
path_reg_zone = region + " / " + zone ;
zone_offest = this - > zone_file_read ( path_reg_zone ) + _ ( zone . c_str ( ) ) ;
zone_offest = this - > zone_file_read ( path_reg_zone ) + gettext ( zone . c_str ( ) ) ;
if ( region = = " " ) {
tmpCbZone - > append ( " " ) ;
tmpCbZone - > set_active ( 0 ) ;
@ -1055,11 +1329,13 @@ string MainWindow::call(string cmd) {
}
void MainWindow : : append_zone ( ) {
cbZone - > remove_all ( ) ;
int index = cbRegion - > get_active_row_number ( ) ;
if ( index ! = - 1 ) {
string str_region = array_region [ index ] ;
string zone_mixing = " " ;
this - > write_config ( str_region , " region " ) ;
string path_dir = " " ;
if ( str_region . length ( ) ! = 0 ) {
for ( const auto & _str_zone : time_reg_map_local . at ( str_region ) ) {
@ -1130,12 +1406,12 @@ void MainWindow::post_entry_data() {
string str_error_clock = this - > call ( cmd ) ;
size_t index = str_error_clock . find ( " date: " ) ;
if ( index ! = std : : string : : npos ) {
lblMessage - > set_text ( _ ( " Incorrect date format " ) ) ;
lblMessage - > set_text ( gettext ( " Incorrect date format " ) ) ;
windowMessDchp - > show ( ) ;
}
}
else {
lblMessage - > set_text ( _ ( " Incorrect date format " ) ) ;
lblMessage - > set_text ( gettext ( " Incorrect date format " ) ) ;
windowMessDchp - > show ( ) ;
}
}
@ -1200,7 +1476,7 @@ void MainWindow::read_file() {
string reg_reg_zone = entry_reg_reg_zone . path ( ) . filename ( ) . string ( ) ;
zone . push_back ( reg_reg_zone ) ;
path_reg_zone = key_reg + " / " + reg_reg_zone ;
key_zone_local = this - > zone_file_read ( path_reg_zone ) + _ ( reg_reg_zone . c_str ( ) ) ;
key_zone_local = this - > zone_file_read ( path_reg_zone ) + gettext ( reg_reg_zone . c_str ( ) ) ;
zone_local . push_back ( key_zone_local ) ;
}
in2 . close ( ) ;
@ -1209,7 +1485,7 @@ void MainWindow::read_file() {
else if ( key_zone . length ( ) ! = 0 | | key_zone ! = " " ) {
zone . push_back ( key_zone ) ;
path_reg_zone = key_reg + " / " + key_zone ;
key_zone_local = this - > zone_file_read ( path_reg_zone ) + _ ( key_zone . c_str ( ) ) ;
key_zone_local = this - > zone_file_read ( path_reg_zone ) + gettext ( key_zone . c_str ( ) ) ;
zone_local . push_back ( key_zone_local ) ;
}
}
@ -1340,16 +1616,17 @@ void help() {
help = " GTK settings datetime for UBLinux \n \n "
" Usage: ubl-settings-datetime [OPTIONS...] \n "
" Options: \n "
" -h, --help Show this help \n "
" -V, --version Show package version \n "
" --lock-datetime Lock date and time changes \n "
" --lock-timezone Lock time zone changes \n "
" --lock-ntp-mode Lock NTP mode selection \n "
" --lock-ntp-edit Lock editing NTP servers \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 " ;
" -h, --help Show this help \n "
" -V, --version Show package version \n "
" --lock-datetime Lock date and time changes \n "
" --lock-timezone Lock time zone changes \n "
" --lock-ntp-mode Lock NTP mode selection \n "
" --lock-ntp-edit Lock editing NTP servers \n "
" --lock-sync-hwclock Lock sync hwclock mode selection \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 < < gettext ( help . c_str ( ) ) ;
}