1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-09-18 12:46:58 +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:
Reinout Meliesie 2025-09-02 23:23:44 +02:00
commit 3ffb668e6b
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
2 changed files with 6 additions and 14 deletions

View file

@ -5,7 +5,7 @@ use std::collections::HashSet;
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::{Mutex, broadcast}; use tokio::sync::{Mutex, broadcast};
use zbus::Connection; use zbus::Connection;
use zbus::zvariant::{ObjectPath, Str}; use zbus::zvariant::ObjectPath;
use crate::clients::ClientResult; use crate::clients::ClientResult;
use crate::clients::networkmanager::dbus::{DbusProxy, DeviceDbusProxy}; use crate::clients::networkmanager::dbus::{DbusProxy, DeviceDbusProxy};
@ -141,24 +141,16 @@ async fn watch_device(
let dbus_connection = Connection::system().await?; let dbus_connection = Connection::system().await?;
let device = DeviceDbusProxy::new(&dbus_connection, device_path.to_owned()).await?; let device = DeviceDbusProxy::new(&dbus_connection, device_path.to_owned()).await?;
let interface = device.interface().await?; spawn(watch_device_state(device, controller_sender));
spawn(watch_device_state(
device_path.to_owned(),
interface.to_owned(),
controller_sender.clone(),
));
Ok(()) Ok(())
} }
async fn watch_device_state( async fn watch_device_state(
device_path: ObjectPath<'_>, device: DeviceDbusProxy<'_>,
interface: Str<'_>,
controller_sender: broadcast::Sender<ClientToModuleEvent>, controller_sender: broadcast::Sender<ClientToModuleEvent>,
) -> Result<()> { ) -> Result<()> {
let dbus_connection = Connection::system().await?; let interface = device.interface().await?;
let device = DeviceDbusProxy::new(&dbus_connection, &device_path).await?;
let r#type = device.device_type().await?; let r#type = device.device_type().await?;
// Send an event communicating the initial state // Send an event communicating the initial state

View file

@ -84,7 +84,7 @@ impl Module<gtk::Box> for NetworkManagerModule {
} }
async fn handle_update_events( async fn handle_update_events(
mut receiver: broadcast::Receiver<ClientToModuleEvent>, mut widget_receiver: broadcast::Receiver<ClientToModuleEvent>,
container: gtk::Box, container: gtk::Box,
icon_size: i32, icon_size: i32,
image_provider: Provider, image_provider: Provider,
@ -92,7 +92,7 @@ async fn handle_update_events(
// TODO: Ensure the visible icons are always in the same order // TODO: Ensure the visible icons are always in the same order
let mut icons = HashMap::<String, Image>::new(); 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 { match event {
ClientToModuleEvent::DeviceChanged { ClientToModuleEvent::DeviceChanged {
interface, interface,