mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-09-18 04:36:57 +02:00
refactor(networkmanager): pass device proxy directly to device state watcher
Also clarify what receiver we're dealing with in handle_update_events.
This commit is contained in:
parent
4c516a1c2a
commit
3ffb668e6b
2 changed files with 6 additions and 14 deletions
|
@ -5,7 +5,7 @@ use std::collections::HashSet;
|
|||
use std::sync::Arc;
|
||||
use tokio::sync::{Mutex, broadcast};
|
||||
use zbus::Connection;
|
||||
use zbus::zvariant::{ObjectPath, Str};
|
||||
use zbus::zvariant::ObjectPath;
|
||||
|
||||
use crate::clients::ClientResult;
|
||||
use crate::clients::networkmanager::dbus::{DbusProxy, DeviceDbusProxy};
|
||||
|
@ -141,24 +141,16 @@ async fn watch_device(
|
|||
let dbus_connection = Connection::system().await?;
|
||||
let device = DeviceDbusProxy::new(&dbus_connection, device_path.to_owned()).await?;
|
||||
|
||||
let interface = device.interface().await?;
|
||||
|
||||
spawn(watch_device_state(
|
||||
device_path.to_owned(),
|
||||
interface.to_owned(),
|
||||
controller_sender.clone(),
|
||||
));
|
||||
spawn(watch_device_state(device, controller_sender));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn watch_device_state(
|
||||
device_path: ObjectPath<'_>,
|
||||
interface: Str<'_>,
|
||||
device: DeviceDbusProxy<'_>,
|
||||
controller_sender: broadcast::Sender<ClientToModuleEvent>,
|
||||
) -> Result<()> {
|
||||
let dbus_connection = Connection::system().await?;
|
||||
let device = DeviceDbusProxy::new(&dbus_connection, &device_path).await?;
|
||||
let interface = device.interface().await?;
|
||||
let r#type = device.device_type().await?;
|
||||
|
||||
// Send an event communicating the initial state
|
||||
|
|
|
@ -84,7 +84,7 @@ impl Module<gtk::Box> for NetworkManagerModule {
|
|||
}
|
||||
|
||||
async fn handle_update_events(
|
||||
mut receiver: broadcast::Receiver<ClientToModuleEvent>,
|
||||
mut widget_receiver: broadcast::Receiver<ClientToModuleEvent>,
|
||||
container: gtk::Box,
|
||||
icon_size: i32,
|
||||
image_provider: Provider,
|
||||
|
@ -92,7 +92,7 @@ async fn handle_update_events(
|
|||
// TODO: Ensure the visible icons are always in the same order
|
||||
let mut icons = HashMap::<String, Image>::new();
|
||||
|
||||
while let Result::Ok(event) = receiver.recv().await {
|
||||
while let Result::Ok(event) = widget_receiver.recv().await {
|
||||
match event {
|
||||
ClientToModuleEvent::DeviceChanged {
|
||||
interface,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue