mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-25 22:20:53 +03:00
fix hostname / port binding
This commit is contained in:
@@ -13,7 +13,7 @@ use super::ClientData;
|
||||
#[properties(wrapper_type = super::ClientObject)]
|
||||
pub struct ClientObject {
|
||||
#[property(name = "handle", get, set, type = ClientHandle, member = handle)]
|
||||
#[property(name = "hostname", get, set, type = String, member = hostname)]
|
||||
#[property(name = "hostname", get, set, type = Option<String>, member = hostname)]
|
||||
#[property(name = "port", get, set, type = u32, member = port, maximum = u16::MAX as u32)]
|
||||
#[property(name = "active", get, set, type = bool, member = active)]
|
||||
#[property(name = "position", get, set, type = String, member = position)]
|
||||
|
||||
@@ -56,13 +56,7 @@ impl ClientRow {
|
||||
// bind hostname to title
|
||||
let title_binding = client_object
|
||||
.bind_property("hostname", self, "title")
|
||||
.transform_to(|_, v: Option<String>| {
|
||||
if let Some(hostname) = v {
|
||||
Some(hostname)
|
||||
} else {
|
||||
Some("<span font_style=\"italic\" font_weight=\"light\" foreground=\"darkgrey\">no hostname!</span>".to_string())
|
||||
}
|
||||
})
|
||||
.transform_to(|_, v: Option<String>| v.or(Some("<span font_style=\"italic\" font_weight=\"light\" foreground=\"darkgrey\">no hostname!</span>".to_string())))
|
||||
.sync_create()
|
||||
.build();
|
||||
|
||||
@@ -141,7 +135,7 @@ impl ClientRow {
|
||||
self.imp().set_active(active);
|
||||
}
|
||||
|
||||
pub fn set_hostname(&self, hostname: &str) {
|
||||
pub fn set_hostname(&self, hostname: Option<String>) {
|
||||
self.imp().set_hostname(hostname);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ impl ClientRow {
|
||||
.emit_by_name("request-position-change", &[&position.selected()])
|
||||
}
|
||||
|
||||
pub(super) fn set_hostname(&self, hostname: &str) {
|
||||
pub(super) fn set_hostname(&self, hostname: Option<String>) {
|
||||
let position = self.hostname.position();
|
||||
let handler = self.hostname_change_handler.borrow();
|
||||
let handler = handler.as_ref().expect("signal handler");
|
||||
@@ -171,7 +171,7 @@ impl ClientRow {
|
||||
.borrow_mut()
|
||||
.as_mut()
|
||||
.expect("client object")
|
||||
.set_hostname(hostname);
|
||||
.set_property("hostname", hostname);
|
||||
self.hostname.unblock_signal(handler);
|
||||
self.hostname.set_position(position);
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ impl Window {
|
||||
log::warn!("could not find row for handle {}", handle);
|
||||
return;
|
||||
};
|
||||
row.set_hostname(&client.hostname.unwrap_or("".into()));
|
||||
row.set_hostname(client.hostname);
|
||||
row.set_port(client.port);
|
||||
row.set_position(client.pos);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user