mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
update tooltips text, update host validation method
This commit is contained in:
parent
0f9bafdbd5
commit
16c8c2c0d4
1 changed files with 7 additions and 6 deletions
|
|
@ -138,7 +138,7 @@ pub fn new(on_add: impl Fn() + 'static) -> Box {
|
||||||
.css_classes(["success"])
|
.css_classes(["success"])
|
||||||
.hexpand(true)
|
.hexpand(true)
|
||||||
.icon_name("list-add-symbolic")
|
.icon_name("list-add-symbolic")
|
||||||
.tooltip_text("Add host exception")
|
.tooltip_text("Add hostname or IP exception")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
add.connect_clicked(move |_| on_add());
|
add.connect_clicked(move |_| on_add());
|
||||||
|
|
@ -163,15 +163,16 @@ fn validate(host: &Entry) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_host(value: &str) -> Result<(), String> {
|
fn validate_host(value: &str) -> Result<(), String> {
|
||||||
match gtk::gio::InetAddress::from_string(value) {
|
match gtk::gio::NetworkAddress::parse(value, 0) {
|
||||||
Some(address) => {
|
Ok(address) => {
|
||||||
if address.to_string() != value {
|
use gtk::prelude::NetworkAddressExt;
|
||||||
Err("Host could not be parsed properly".to_string())
|
if address.hostname() != value {
|
||||||
|
Err("Hostname or IP could not be parsed properly".to_string())
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => Err("Valid host is required".to_string()),
|
Err(e) => Err(format!("Valid hostname or IP is required: `{e}`")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue