use slab instead of reinventing the wheel (#112)

This commit is contained in:
Ferdinand Schober
2024-04-26 00:10:04 +02:00
committed by GitHub
parent 279e582698
commit 3e96b42067
14 changed files with 83 additions and 115 deletions

View File

@@ -10,9 +10,9 @@ glib::wrapper! {
}
impl ClientObject {
pub fn new(client: Client, active: bool) -> Self {
pub fn new(handle: ClientHandle, client: Client, active: bool) -> Self {
Object::builder()
.property("handle", client.handle)
.property("handle", handle)
.property("hostname", client.hostname)
.property("port", client.port as u32)
.property("position", client.pos.to_string())

View File

@@ -87,8 +87,8 @@ impl Window {
row
}
pub fn new_client(&self, client: Client, active: bool) {
let client = ClientObject::new(client, active);
pub fn new_client(&self, handle: ClientHandle, client: Client, active: bool) {
let client = ClientObject::new(handle, client, active);
self.clients().append(&client);
self.set_placeholder_visible(false);
}
@@ -115,9 +115,9 @@ impl Window {
}
}
pub fn update_client(&self, client: Client) {
let Some(idx) = self.client_idx(client.handle) else {
log::warn!("could not find client with handle {}", client.handle);
pub fn update_client(&self, handle: ClientHandle, client: Client) {
let Some(idx) = self.client_idx(handle) else {
log::warn!("could not find client with handle {}", handle);
return;
};
let client_object = self.clients().item(idx as u32).unwrap();