Исправлен дизайн и баг в логике при выборе по умолчанию

pull/30/head
Igor Belitskiy 3 years ago
parent 06bee15e03
commit 0600ec95de

@ -315,7 +315,9 @@ void MainWindow::event_entry_cbDhcp(){
system(cmd.c_str()); system(cmd.c_str());
txtNtpServer->set_sensitive(false); txtNtpServer->set_sensitive(false);
cbDhcp->set_active(activ_index); 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){ else if (activ_index==1){
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp"; string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp";
@ -326,8 +328,9 @@ void MainWindow::event_entry_cbDhcp(){
} }
else if (activ_index==2){ else if (activ_index==2){
txtNtpServer->set_sensitive(true); txtNtpServer->set_sensitive(true);
txtNtpServer->set_text("");
string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS"); 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(str_dhcp.find("=")+1,str_dhcp.length());
str_dhcp = str_dhcp.substr(0,str_dhcp.find("\n")); str_dhcp = str_dhcp.substr(0,str_dhcp.find("\n"));
if (str_dhcp!="dhcp" && str_dhcp!="(null)"){ if (str_dhcp!="dhcp" && str_dhcp!="(null)"){
@ -344,6 +347,15 @@ void MainWindow::event_entry_cbDhcp(){
} }
} }
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(){ void MainWindow::get_calendar(){
string str_month = ""; string str_month = "";
string str_day = ""; string str_day = "";
@ -397,7 +409,7 @@ void MainWindow::enry_dhcp_mess(){
} }
else if (str_dhcp=="default"){ else if (str_dhcp=="default"){
cbDhcp->set_active(0); cbDhcp->set_active(0);
txtNtpServer->set_text(""); txtNtpServer->set_text(str_dhcp);
txtNtpServer->set_sensitive(false); txtNtpServer->set_sensitive(false);
} }
else{ else{

@ -81,6 +81,7 @@ class MainWindow : public Gtk::ApplicationWindow {
void stop_ntp(); void stop_ntp();
void wind_close_ntp(); void wind_close_ntp();
void wrapper_update_time_date(); void wrapper_update_time_date();
string str_remove(std::string& source, const std::string to_remove);
vector<std::string> split(const std::string &s, char delim); vector<std::string> split(const std::string &s, char delim);
private: private:
Glib::RefPtr<Gtk::Builder> builder; Glib::RefPtr<Gtk::Builder> builder;

@ -598,10 +598,10 @@ Format: DD.MM.YYYY</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="margin-left">5</property> <property name="margin-left">5</property>
<property name="margin-right">5</property> <property name="margin-right">5</property>
<property name="margin-start">5</property> <property name="margin-start">8</property>
<property name="margin-end">5</property> <property name="margin-end">5</property>
<property name="margin-top">6</property> <property name="margin-top">6</property>
<property name="margin-bottom">8</property> <property name="margin-bottom">13</property>
<property name="label" translatable="yes" context="Region" comments="Region">Region</property> <property name="label" translatable="yes" context="Region" comments="Region">Region</property>
<property name="xalign">0</property> <property name="xalign">0</property>
</object> </object>
@ -620,7 +620,7 @@ Format: DD.MM.YYYY</property>
<property name="margin-start">5</property> <property name="margin-start">5</property>
<property name="margin-end">5</property> <property name="margin-end">5</property>
<property name="margin-top">6</property> <property name="margin-top">6</property>
<property name="margin-bottom">8</property> <property name="margin-bottom">13</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -637,7 +637,7 @@ Format: DD.MM.YYYY</property>
<property name="margin-start">10</property> <property name="margin-start">10</property>
<property name="margin-end">5</property> <property name="margin-end">5</property>
<property name="margin-top">6</property> <property name="margin-top">6</property>
<property name="margin-bottom">8</property> <property name="margin-bottom">13</property>
<property name="label" translatable="yes" context="Zone" comments="Zone">Area</property> <property name="label" translatable="yes" context="Zone" comments="Zone">Area</property>
<property name="xalign">0</property> <property name="xalign">0</property>
</object> </object>
@ -656,7 +656,7 @@ Format: DD.MM.YYYY</property>
<property name="margin-start">5</property> <property name="margin-start">5</property>
<property name="margin-end">5</property> <property name="margin-end">5</property>
<property name="margin-top">6</property> <property name="margin-top">6</property>
<property name="margin-bottom">8</property> <property name="margin-bottom">13</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -858,12 +858,12 @@ Format: DD.MM.YYYY</property>
<object class="GtkLabel" id="lblRegGlob"> <object class="GtkLabel" id="lblRegGlob">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="margin-left">5</property> <property name="margin-left">8</property>
<property name="margin-right">5</property> <property name="margin-right">5</property>
<property name="margin-start">5</property> <property name="margin-start">8</property>
<property name="margin-end">5</property> <property name="margin-end">5</property>
<property name="margin-top">6</property> <property name="margin-top">6</property>
<property name="margin-bottom">8</property> <property name="margin-bottom">13</property>
<property name="label" translatable="yes" context="Region" comments="Region">Region</property> <property name="label" translatable="yes" context="Region" comments="Region">Region</property>
<property name="xalign">0</property> <property name="xalign">0</property>
</object> </object>
@ -881,8 +881,8 @@ Format: DD.MM.YYYY</property>
<property name="margin-right">5</property> <property name="margin-right">5</property>
<property name="margin-start">5</property> <property name="margin-start">5</property>
<property name="margin-end">5</property> <property name="margin-end">5</property>
<property name="margin-top">5</property> <property name="margin-top">6</property>
<property name="margin-bottom">8</property> <property name="margin-bottom">13</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -899,7 +899,7 @@ Format: DD.MM.YYYY</property>
<property name="margin-start">10</property> <property name="margin-start">10</property>
<property name="margin-end">5</property> <property name="margin-end">5</property>
<property name="margin-top">5</property> <property name="margin-top">5</property>
<property name="margin-bottom">8</property> <property name="margin-bottom">13</property>
<property name="label" translatable="yes" context="Zone" comments="Zone">Area</property> <property name="label" translatable="yes" context="Zone" comments="Zone">Area</property>
<property name="xalign">0</property> <property name="xalign">0</property>
</object> </object>
@ -917,7 +917,8 @@ Format: DD.MM.YYYY</property>
<property name="margin-right">5</property> <property name="margin-right">5</property>
<property name="margin-start">5</property> <property name="margin-start">5</property>
<property name="margin-end">5</property> <property name="margin-end">5</property>
<property name="margin-bottom">8</property> <property name="margin-top">6</property>
<property name="margin-bottom">13</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

Loading…
Cancel
Save