fix hostname / port binding

This commit is contained in:
Ferdinand Schober
2025-03-14 18:27:09 +01:00
parent 7e9ad6f1a2
commit 6f8d7e3c1d
4 changed files with 6 additions and 12 deletions

View File

@@ -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)]

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}