|
|
|
|
@ -114,39 +114,39 @@ void MainWindow::settings(){
|
|
|
|
|
|
|
|
|
|
int MainWindow::check_root(){
|
|
|
|
|
if (geteuid()!=0){
|
|
|
|
|
lblMessageSudo->set_text(gettext("The program must be run with \nsuperuser privileges!"));
|
|
|
|
|
lblMessageSudo->set_text(_("The program must be run with \nsuperuser privileges!"));
|
|
|
|
|
mess_sudo->show();
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
void MainWindow::lacalization(){
|
|
|
|
|
txtDate->set_tooltip_text(gettext("Date of\nFormat: DD.MM.YYYY"));
|
|
|
|
|
lblSynchronizebChkGLob->set_text(gettext("Synchronize via NTP"));
|
|
|
|
|
cbDhcp->append(gettext("By default"));
|
|
|
|
|
cbDhcp->append(gettext("DHCP"));
|
|
|
|
|
cbDhcp->append(gettext("Manually"));
|
|
|
|
|
lblDateTimeSetting->set_text(gettext("Local Configuration"));
|
|
|
|
|
lblHead->set_text(gettext("Settings 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"));
|
|
|
|
|
lblRegGlob->set_text(gettext("Region"));
|
|
|
|
|
lblZone1Glob->set_text(gettext("Zone"));
|
|
|
|
|
lblTimeZoneGlob->set_text(gettext("Time zone"));
|
|
|
|
|
lblSynchronizeBtn->set_text(gettext("Sync by"));
|
|
|
|
|
lblDateTimeSettingGlob->set_text(gettext("Global customization"));
|
|
|
|
|
this->set_title(gettext("ubl-settings-datetime"));
|
|
|
|
|
windowsNnpClose->set_title(gettext("Warning!"));
|
|
|
|
|
mess_sudo->set_title(gettext("Warning!"));
|
|
|
|
|
mess_dchp->set_title(gettext("Warning!"));
|
|
|
|
|
lblTimeBios->set_text(gettext("Synchronize hardware time"));
|
|
|
|
|
lblBanerStopNtp->set_text(gettext("Active service detected\nAutomatic time and date synchronization service detected"));
|
|
|
|
|
lblNtpStop->set_text(gettext("Stop the synchronization service"));
|
|
|
|
|
lblNtpClose->set_text(gettext("Close"));
|
|
|
|
|
//_lblSynchronizebChk->set_text(gettext("Synchronize via NTP"));
|
|
|
|
|
txtDate->set_tooltip_text(_("Date of\nFormat: DD.MM.YYYY"));
|
|
|
|
|
lblSynchronizebChkGLob->set_text(_("Synchronize via NTP"));
|
|
|
|
|
cbDhcp->append(_("By default"));
|
|
|
|
|
cbDhcp->append(_("DHCP"));
|
|
|
|
|
cbDhcp->append(_("Manually"));
|
|
|
|
|
lblDateTimeSetting->set_text(_("Local Configuration"));
|
|
|
|
|
lblHead->set_text(_("Settings 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"));
|
|
|
|
|
lblRegGlob->set_text(_("Region"));
|
|
|
|
|
lblZone1Glob->set_text(_("Zone"));
|
|
|
|
|
lblTimeZoneGlob->set_text(_("Time zone"));
|
|
|
|
|
lblSynchronizeBtn->set_text(_("Sync by"));
|
|
|
|
|
lblDateTimeSettingGlob->set_text(_("Global customization"));
|
|
|
|
|
this->set_title(_("ubl-settings-datetime"));
|
|
|
|
|
windowsNnpClose->set_title(_("Warning!"));
|
|
|
|
|
mess_sudo->set_title(_("Warning!"));
|
|
|
|
|
mess_dchp->set_title(_("Warning!"));
|
|
|
|
|
lblTimeBios->set_text(_("Synchronize hardware time"));
|
|
|
|
|
lblBanerStopNtp->set_text(_("Active service detected\nAutomatic time and date synchronization service detected"));
|
|
|
|
|
lblNtpStop->set_text(_("Stop the synchronization service"));
|
|
|
|
|
lblNtpClose->set_text(_("Close"));
|
|
|
|
|
//_lblSynchronizebChk->set_text(_("Synchronize via NTP"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::flag_block_gui(){
|
|
|
|
|
@ -320,7 +320,7 @@ void MainWindow::gui_mess_close(){
|
|
|
|
|
bool MainWindow::focus_ntp(GdkEventFocus* event){
|
|
|
|
|
if (event!=NULL){}
|
|
|
|
|
if (txtNtpServer->get_text()=="" || txtNtpServer->get_text()==" "){
|
|
|
|
|
lblMessage->set_text(gettext("Enter DHCP!"));
|
|
|
|
|
lblMessage->set_text(_("Enter DHCP!"));
|
|
|
|
|
mess_dchp->show();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
@ -335,7 +335,6 @@ bool MainWindow::focus_ntp(GdkEventFocus* event){
|
|
|
|
|
void MainWindow::event_entry_cbDhcp(){
|
|
|
|
|
Glib::ustring str_dhcp = cbDhcp->get_active_text();
|
|
|
|
|
int activ_index = cbDhcp->get_active_row_number();
|
|
|
|
|
cout << activ_index << endl;
|
|
|
|
|
if (str_dhcp.length()!=0){
|
|
|
|
|
if (activ_index==0){
|
|
|
|
|
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default";
|
|
|
|
|
@ -443,7 +442,7 @@ void MainWindow::enry_dhcp_mess(){
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
if (str_dhcp==""){
|
|
|
|
|
lblMessage->set_text(gettext("Enter DHCP!"));
|
|
|
|
|
lblMessage->set_text(_("Enter DHCP!"));
|
|
|
|
|
mess_dchp->show();
|
|
|
|
|
}
|
|
|
|
|
else if (str_dhcp=="(null)"){
|
|
|
|
|
@ -480,6 +479,7 @@ void MainWindow::get_config(){
|
|
|
|
|
str_filling_zon = str_filling_zon.substr(0,str_filling_zon.find("\n"));
|
|
|
|
|
string str_zone_check = "";
|
|
|
|
|
this->append_region_zone(str_filling_reg,str_filling_zon);
|
|
|
|
|
//this->append_region_zone("Africa","Abidjan");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this->append_region_zone("Africa","Abidjan");
|
|
|
|
|
@ -487,8 +487,9 @@ void MainWindow::get_config(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::enter_zone(){
|
|
|
|
|
string reg_text = cbRegion->get_active_text();
|
|
|
|
|
int activ_index = cbZone->get_active_row_number();
|
|
|
|
|
int activ_index_reg = cbRegion->get_active_row_number();
|
|
|
|
|
string reg_text=array_region[activ_index_reg];
|
|
|
|
|
int activ_index = cbZone->get_active_row_number();
|
|
|
|
|
string zone_text = "";
|
|
|
|
|
if(!(reg_text.empty())){
|
|
|
|
|
int index=0;
|
|
|
|
|
@ -527,7 +528,8 @@ void MainWindow::parse_text_date(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::enter_zone_glob(){
|
|
|
|
|
string reg_text = cbRegionGlob->get_active_text();
|
|
|
|
|
int activ_index_reg = cbRegionGlob->get_active_row_number();
|
|
|
|
|
string reg_text=array_region[activ_index_reg];
|
|
|
|
|
int activ_index = cbZoneGlob->get_active_row_number();
|
|
|
|
|
string zone_text="";
|
|
|
|
|
if(!(reg_text.empty())){
|
|
|
|
|
@ -569,29 +571,34 @@ void MainWindow::set_ntp_toggle_glob(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::append_region_zone(string region, string zone){
|
|
|
|
|
str_region=region;
|
|
|
|
|
str_region_glob=region;
|
|
|
|
|
int index = 0;
|
|
|
|
|
string reg_local = "";
|
|
|
|
|
for (auto &text : time_reg_map ) {
|
|
|
|
|
reg_local = text.first;
|
|
|
|
|
//reg_local = string(gettext(reg_local.c_str()));
|
|
|
|
|
cbRegion->append(reg_local);
|
|
|
|
|
cbRegionGlob->append(reg_local);
|
|
|
|
|
if (text.first == region){
|
|
|
|
|
cbRegionGlob->set_active(index);
|
|
|
|
|
cbRegion->set_active(index);
|
|
|
|
|
Glib::ustring reg_local = "";
|
|
|
|
|
for (const auto &text : array_region) {
|
|
|
|
|
reg_local = text;
|
|
|
|
|
reg_local = string(_(reg_local.c_str()));
|
|
|
|
|
cbRegion->append(Glib::ustring(reg_local));
|
|
|
|
|
cbRegionGlob->append(Glib::ustring(reg_local));
|
|
|
|
|
if (text == region){
|
|
|
|
|
cbRegionGlob->set_active_text(reg_local);
|
|
|
|
|
cbRegion->set_active_text(reg_local);
|
|
|
|
|
}
|
|
|
|
|
index+=1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
|
string zone_mixing = "";
|
|
|
|
|
string path_dir = "";
|
|
|
|
|
for (const auto &_str_zone : time_reg_map.at(region)){
|
|
|
|
|
path_dir=region+"/"+_str_zone;
|
|
|
|
|
zone_mixing = this->zone_file_read(path_dir) + string(gettext(_str_zone.c_str()));
|
|
|
|
|
string path_reg_zone = "";
|
|
|
|
|
string zone_offest = "";
|
|
|
|
|
path_reg_zone=region+"/"+zone;
|
|
|
|
|
zone_offest = this->zone_file_read(path_reg_zone) + _(zone.c_str());
|
|
|
|
|
for (string &_str_zone : time_reg_map_local.at(region)){
|
|
|
|
|
cbZone->append(zone_mixing);
|
|
|
|
|
cbZoneGlob->append(zone_mixing);
|
|
|
|
|
cout <<_str_zone << endl;
|
|
|
|
|
if (_str_zone!=""){
|
|
|
|
|
if (_str_zone == zone){
|
|
|
|
|
if (zone_offest == _str_zone){
|
|
|
|
|
cbZone->set_active(index);
|
|
|
|
|
cbZoneGlob->set_active(index);
|
|
|
|
|
}
|
|
|
|
|
@ -621,34 +628,33 @@ string MainWindow::call(string cmd){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::append_zone(){
|
|
|
|
|
//int length_zone = time_reg_map.at(str_region).size();
|
|
|
|
|
cbZone->remove_all();
|
|
|
|
|
Glib::ustring text = cbRegion->get_active_text();
|
|
|
|
|
int index = cbRegion->get_active_row_number();
|
|
|
|
|
string str_region = array_region[index];
|
|
|
|
|
string zone_mixing="";
|
|
|
|
|
string path_dir="";
|
|
|
|
|
if(!(text.empty())){
|
|
|
|
|
str_region = text;
|
|
|
|
|
for (const auto &_str_zone : time_reg_map.at(str_region)){
|
|
|
|
|
path_dir=str_region+"/"+_str_zone;
|
|
|
|
|
zone_mixing = this->zone_file_read(path_dir) + string(gettext(_str_zone.c_str()));
|
|
|
|
|
cbZone->append(zone_mixing);
|
|
|
|
|
if(str_region.length()!=0){
|
|
|
|
|
for (const auto &_str_zone : time_reg_map_local.at(str_region)){
|
|
|
|
|
cbZone->append(Glib::ustring(_str_zone));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cbZone->set_active(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::append_zone_glob(){
|
|
|
|
|
cbZoneGlob->remove_all();
|
|
|
|
|
Glib::ustring text = cbRegionGlob->get_active_text();
|
|
|
|
|
int index = cbRegionGlob->get_active_row_number();
|
|
|
|
|
string str_region_glob = array_region[index];
|
|
|
|
|
string zone_mixing="";
|
|
|
|
|
string path_dir="";
|
|
|
|
|
|
|
|
|
|
if(!(text.empty())){
|
|
|
|
|
str_region_glob = text;
|
|
|
|
|
for (const auto &_str_zone : time_reg_map.at(str_region_glob)){
|
|
|
|
|
path_dir=str_region+"/"+_str_zone;
|
|
|
|
|
zone_mixing = this->zone_file_read(path_dir) + string(gettext(_str_zone.c_str()));
|
|
|
|
|
cbZoneGlob->append(zone_mixing);
|
|
|
|
|
if(str_region_glob.length()!=0){
|
|
|
|
|
for (const auto &_str_zone : time_reg_map_local.at(str_region_glob)){
|
|
|
|
|
cbZoneGlob->append(Glib::ustring(_str_zone));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cbZoneGlob->set_active(0);
|
|
|
|
|
}
|
|
|
|
|
void MainWindow::wrapper_update_time_date(){
|
|
|
|
|
string cmd = "pidof systemd-timesyncd ntpd chronyd";
|
|
|
|
|
@ -726,7 +732,7 @@ void MainWindow::post_entry_data(){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
lblMessage->set_text(gettext("Incorrect date format"));
|
|
|
|
|
lblMessage->set_text(_("Incorrect date format"));
|
|
|
|
|
mess_dchp->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -765,6 +771,8 @@ void MainWindow::update_calendar(){
|
|
|
|
|
|
|
|
|
|
void MainWindow::read_file(){
|
|
|
|
|
std::string line;
|
|
|
|
|
string key_zone_local = "";
|
|
|
|
|
string path_reg_zone = "";
|
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
|
for (const auto & entry : fs::directory_iterator("/usr/share/zoneinfo/")){
|
|
|
|
|
std::ifstream in(entry.path()); // окрываем файл для чтения
|
|
|
|
|
@ -777,6 +785,7 @@ void MainWindow::read_file(){
|
|
|
|
|
if (key_reg!="Etc"){
|
|
|
|
|
if (key_reg!="right"){
|
|
|
|
|
vector<string> zone;
|
|
|
|
|
vector<string> zone_local;
|
|
|
|
|
//zone.push_back("");
|
|
|
|
|
for (const auto & entry_zone : fs::directory_iterator(path_dir)){
|
|
|
|
|
std::ifstream in1(entry_zone.path()); // окрываем файл для чтения
|
|
|
|
|
@ -784,13 +793,16 @@ void MainWindow::read_file(){
|
|
|
|
|
string key_zone = entry_zone.path().filename().string();
|
|
|
|
|
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());
|
|
|
|
|
zone_local.push_back(key_zone_local);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
in1.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
key_reg = string(key_reg);
|
|
|
|
|
time_reg_map.insert({key_reg, zone});
|
|
|
|
|
time_reg_map_local.insert({key_reg, zone_local});
|
|
|
|
|
}}}}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|