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