diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index 38eac1a..0dbd896 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -315,7 +315,9 @@ void MainWindow::event_entry_cbDhcp(){ system(cmd.c_str()); txtNtpServer->set_sensitive(false); cbDhcp->set_active(activ_index); - txtNtpServer->set_text(""); + string response = this->call("/usr/bin/ubconfig --source=default get NTPSERVERS_DEFAULT"); + this->str_remove(response, "\n"); + txtNtpServer->set_text(response); } else if (activ_index==1){ string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp"; @@ -326,8 +328,9 @@ void MainWindow::event_entry_cbDhcp(){ } else if (activ_index==2){ txtNtpServer->set_sensitive(true); + txtNtpServer->set_text(""); string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS"); - if ((str_dhcp!="") && (str_dhcp!="(null)") && (str_dhcp!="default")){ + if ((str_dhcp!="") && (str_dhcp!="(null)") && (str_dhcp.find("default")==std::string::npos)){ 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" && str_dhcp!="(null)"){ @@ -343,6 +346,15 @@ void MainWindow::event_entry_cbDhcp(){ cbDhcp->set_active(0); } } + +string MainWindow::str_remove(std::string& source, const std::string to_remove){ + auto begin = source.find(to_remove); + if (begin!=std::string::npos){ + int len_to_remove = to_remove.length(); + source.erase(begin, begin+len_to_remove); + } + return source; +} void MainWindow::get_calendar(){ string str_month = ""; @@ -397,7 +409,7 @@ void MainWindow::enry_dhcp_mess(){ } else if (str_dhcp=="default"){ cbDhcp->set_active(0); - txtNtpServer->set_text(""); + txtNtpServer->set_text(str_dhcp); txtNtpServer->set_sensitive(false); } else{ diff --git a/source/ubl-settings-datetime.h b/source/ubl-settings-datetime.h index e8b202c..952baf1 100644 --- a/source/ubl-settings-datetime.h +++ b/source/ubl-settings-datetime.h @@ -81,6 +81,7 @@ class MainWindow : public Gtk::ApplicationWindow { void stop_ntp(); void wind_close_ntp(); void wrapper_update_time_date(); + string str_remove(std::string& source, const std::string to_remove); vector split(const std::string &s, char delim); private: Glib::RefPtr builder; diff --git a/ubl-settings-datetime.glade b/ubl-settings-datetime.glade index 1313ccf..760a76d 100644 --- a/ubl-settings-datetime.glade +++ b/ubl-settings-datetime.glade @@ -598,10 +598,10 @@ Format: DD.MM.YYYY False 5 5 - 5 + 8 5 6 - 8 + 13 Region 0 @@ -620,7 +620,7 @@ Format: DD.MM.YYYY 5 5 6 - 8 + 13 False @@ -637,7 +637,7 @@ Format: DD.MM.YYYY 10 5 6 - 8 + 13 Area 0 @@ -656,7 +656,7 @@ Format: DD.MM.YYYY 5 5 6 - 8 + 13 False @@ -858,12 +858,12 @@ Format: DD.MM.YYYY True False - 5 + 8 5 - 5 + 8 5 6 - 8 + 13 Region 0 @@ -881,8 +881,8 @@ Format: DD.MM.YYYY 5 5 5 - 5 - 8 + 6 + 13 False @@ -899,7 +899,7 @@ Format: DD.MM.YYYY 10 5 5 - 8 + 13 Area 0 @@ -917,7 +917,8 @@ Format: DD.MM.YYYY 5 5 5 - 8 + 6 + 13 False