mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-09-18 12:46:58 +02:00
fix(networkmanager): remove icons for removed devices
This commit is contained in:
parent
d752e88abf
commit
af49acb40b
2 changed files with 20 additions and 3 deletions
|
@ -113,7 +113,6 @@ impl ClientInner {
|
||||||
watchers.insert(added_device_path.clone(), watcher);
|
watchers.insert(added_device_path.clone(), watcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Inform module of removed devices
|
|
||||||
let removed_device_paths = device_paths.difference(&new_device_paths);
|
let removed_device_paths = device_paths.difference(&new_device_paths);
|
||||||
for removed_device_path in removed_device_paths {
|
for removed_device_path in removed_device_paths {
|
||||||
let watcher = watchers
|
let watcher = watchers
|
||||||
|
@ -122,6 +121,13 @@ impl ClientInner {
|
||||||
watcher.state_watcher.abort();
|
watcher.state_watcher.abort();
|
||||||
watchers.remove(removed_device_path);
|
watchers.remove(removed_device_path);
|
||||||
|
|
||||||
|
// TODO: Replace the identifier sent to modules with the dbus device number (last segment of its path)
|
||||||
|
let dbus_connection = &self.dbus_connection().await?;
|
||||||
|
let device = DeviceDbusProxy::new(dbus_connection, removed_device_path).await?;
|
||||||
|
let interface = device.interface().await?.to_string();
|
||||||
|
self.controller_sender
|
||||||
|
.send(ClientToModuleEvent::DeviceRemoved { interface })?;
|
||||||
|
|
||||||
debug!("D-bus device watchers for {} stopped", removed_device_path);
|
debug!("D-bus device watchers for {} stopped", removed_device_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ use gtk::{Image, Orientation};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use tokio::sync::{broadcast, mpsc};
|
use tokio::sync::{broadcast, mpsc};
|
||||||
|
use tracing::debug;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||||
|
@ -99,7 +100,9 @@ async fn handle_update_events(
|
||||||
r#type,
|
r#type,
|
||||||
new_state,
|
new_state,
|
||||||
} => {
|
} => {
|
||||||
let icon: &_ = icons.entry(interface).or_insert_with(|| {
|
let icon: &_ = icons.entry(interface.clone()).or_insert_with(|| {
|
||||||
|
debug!("Adding icon for {}", interface);
|
||||||
|
|
||||||
let icon = Image::new();
|
let icon = Image::new();
|
||||||
icon.add_class("icon");
|
icon.add_class("icon");
|
||||||
container.add(&icon);
|
container.add(&icon);
|
||||||
|
@ -120,7 +123,15 @@ async fn handle_update_events(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClientToModuleEvent::DeviceRemoved { .. } => {}
|
ClientToModuleEvent::DeviceRemoved { interface } => {
|
||||||
|
let icon = icons
|
||||||
|
.get(interface.as_str())
|
||||||
|
.expect("The icon for {} was about to be removed but was not present");
|
||||||
|
container.remove(icon);
|
||||||
|
icons.remove(interface.as_str());
|
||||||
|
|
||||||
|
debug!("Removed icon for {}", interface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue