From c713fbb69b6d0763045f0659b2245fa7aefa2d4d Mon Sep 17 00:00:00 2001 From: Naveen Prashanth Date: Thu, 7 May 2026 19:04:10 +0530 Subject: [PATCH] fix fmt issues --- src/graph_manager.rs | 59 ++++++++++++++++++++++++++------ src/main.rs | 5 +-- src/pipewire_connection/mod.rs | 7 ++-- src/pipewire_connection/state.rs | 4 +-- src/ui/graph/graph_view.rs | 2 +- src/ui/graph/link.rs | 4 ++- src/ui/graph/node.rs | 22 ++++++------ src/ui/graph/port.rs | 11 +++--- 8 files changed, 73 insertions(+), 41 deletions(-) diff --git a/src/graph_manager.rs b/src/graph_manager.rs index ad08573..8cb867b 100644 --- a/src/graph_manager.rs +++ b/src/graph_manager.rs @@ -139,7 +139,10 @@ mod imp { let items = self.items.borrow(); let Some(node) = items.get(&id.0) else { - log::warn!("Node (id: {}) for changed name not found in graph manager", id.0); + log::warn!( + "Node (id: {}) for changed name not found in graph manager", + id.0 + ); return; }; let Some(node) = node.dynamic_cast_ref::() else { @@ -196,7 +199,10 @@ mod imp { return; }; let Ok(node) = node.clone().dynamic_cast::() else { - log::warn!("Graph Manager item under node id {} is not a node", node_id.0); + log::warn!( + "Graph Manager item under node id {} is not a node", + node_id.0 + ); return; }; @@ -231,7 +237,10 @@ mod imp { let items = self.items.borrow(); let Some(port) = items.get(&id.0) else { - log::warn!("Port (id: {}) for changed media type not found in graph manager", id.0); + log::warn!( + "Port (id: {}) for changed media type not found in graph manager", + id.0 + ); return; }; let Some(port) = port.dynamic_cast_ref::() else { @@ -245,16 +254,27 @@ mod imp { /// Remove the port with the id `id` from the node with the id `node_id` /// from the view. fn remove_port(&self, id: PortId, node_id: NodeId) { - log::info!("Removing port from graph: id {}, node_id: {}", id.0, node_id.0); + log::info!( + "Removing port from graph: id {}, node_id: {}", + id.0, + node_id.0 + ); let mut items = self.items.borrow_mut(); let Some(node) = items.get(&node_id.0) else { - log::warn!("Node (id: {}) for port (id: {}) not found in graph manager", node_id.0, id.0); + log::warn!( + "Node (id: {}) for port (id: {}) not found in graph manager", + node_id.0, + id.0 + ); return; }; let Ok(node) = node.clone().dynamic_cast::() else { - log::warn!("Graph Manager item under node id {} is not a node", node_id.0); + log::warn!( + "Graph Manager item under node id {} is not a node", + node_id.0 + ); return; }; let Some(port) = items.remove(&id.0) else { @@ -293,19 +313,33 @@ mod imp { } let Some(output_port) = items.get(&output_port_id.0) else { - log::warn!("Output port (id: {}) for link (id: {}) not found in graph manager", output_port_id.0, id.0); + log::warn!( + "Output port (id: {}) for link (id: {}) not found in graph manager", + output_port_id.0, + id.0 + ); return; }; let Ok(output_port) = output_port.clone().dynamic_cast::() else { - log::warn!("Graph Manager item under port id {} is not a port", output_port_id.0); + log::warn!( + "Graph Manager item under port id {} is not a port", + output_port_id.0 + ); return; }; let Some(input_port) = items.get(&input_port_id.0) else { - log::warn!("Output port (id: {}) for link (id: {}) not found in graph manager", input_port_id.0, id.0); + log::warn!( + "Output port (id: {}) for link (id: {}) not found in graph manager", + input_port_id.0, + id.0 + ); return; }; let Ok(input_port) = input_port.clone().dynamic_cast::() else { - log::warn!("Graph Manager item under port id {} is not a port", input_port_id.0); + log::warn!( + "Graph Manager item under port id {} is not a port", + input_port_id.0 + ); return; }; @@ -350,7 +384,10 @@ mod imp { let items = self.items.borrow(); let Some(link) = items.get(&id.0) else { - log::warn!("Link (id: {}) for changed media type not found in graph manager", id.0); + log::warn!( + "Link (id: {}) for changed media type not found in graph manager", + id.0 + ); return; }; let Some(link) = link.dynamic_cast_ref::() else { diff --git a/src/main.rs b/src/main.rs index 3d02d08..6f58fa1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,10 +53,7 @@ impl std::fmt::Display for LinkId { #[derive(Debug, Clone)] pub enum GtkMessage { /// Toggle a link between the two specified ports. - ToggleLink { - port_from: PortId, - port_to: PortId, - }, + ToggleLink { port_from: PortId, port_to: PortId }, /// Quit the event loop and let the thread finish. Terminate, } diff --git a/src/pipewire_connection/mod.rs b/src/pipewire_connection/mod.rs index 255a70a..5ccf780 100644 --- a/src/pipewire_connection/mod.rs +++ b/src/pipewire_connection/mod.rs @@ -180,9 +180,10 @@ pub(super) fn thread_main( gtk_sender4 .send_blocking(match item { Item::Node => PipewireMessage::NodeRemoved { id: NodeId(id) }, - Item::Port { node_id } => { - PipewireMessage::PortRemoved { id: PortId(id), node_id } - } + Item::Port { node_id } => PipewireMessage::PortRemoved { + id: PortId(id), + node_id, + }, Item::Link { .. } => PipewireMessage::LinkRemoved { id: LinkId(id) }, }) .expect("Failed to send message"); diff --git a/src/pipewire_connection/state.rs b/src/pipewire_connection/state.rs index 80f7531..86c857d 100644 --- a/src/pipewire_connection/state.rs +++ b/src/pipewire_connection/state.rs @@ -52,9 +52,7 @@ impl State { /// Add a new item under the specified id. pub fn insert(&mut self, id: u32, item: Item) { if let Item::Link { - port_from, - port_to, - .. + port_from, port_to, .. } = item { self.links.insert((port_from, port_to), LinkId(id)); diff --git a/src/ui/graph/graph_view.rs b/src/ui/graph/graph_view.rs index 44d0e88..88f1815 100644 --- a/src/ui/graph/graph_view.rs +++ b/src/ui/graph/graph_view.rs @@ -39,9 +39,9 @@ mod imp { use std::cell::{Cell, RefCell}; use std::collections::{HashMap, HashSet}; + use crate::ui::graph::PortDirection; use adw::gtk::gdk; use libspa::param::format::MediaType; - use crate::ui::graph::PortDirection; use log::warn; use std::sync::LazyLock; diff --git a/src/ui/graph/link.rs b/src/ui/graph/link.rs index 9b542cd..6435171 100644 --- a/src/ui/graph/link.rs +++ b/src/ui/graph/link.rs @@ -89,7 +89,9 @@ mod imp { "output-port" => self.output_port.set(value.get().unwrap()), "input-port" => self.input_port.set(value.get().unwrap()), "active" => self.active.set(value.get().unwrap()), - "media-type" => self.media_type.set(value.get().expect("Value should be a PortMediaType")), + "media-type" => self + .media_type + .set(value.get().expect("Value should be a PortMediaType")), _ => unimplemented!(), } } diff --git a/src/ui/graph/node.rs b/src/ui/graph/node.rs index e27b342..5fd1b8a 100644 --- a/src/ui/graph/node.rs +++ b/src/ui/graph/node.rs @@ -14,11 +14,11 @@ // // SPDX-License-Identifier: GPL-3.0-only -use adw::{glib, gtk, prelude::*, subclass::prelude::*}; use crate::ui::graph::PortDirection; +use adw::{glib, gtk, prelude::*, subclass::prelude::*}; -use crate::NodeId; use super::Port; +use crate::NodeId; mod imp { use super::*; @@ -118,16 +118,14 @@ mod imp { let mut ports_out = Vec::new(); let mut ports_in = Vec::new(); - ports - .iter() - .for_each(|port| match port.port_direction() { - PortDirection::Output => { - ports_out.push(port); - } - PortDirection::Input => { - ports_in.push(port); - } - }); + ports.iter().for_each(|port| match port.port_direction() { + PortDirection::Output => { + ports_out.push(port); + } + PortDirection::Input => { + ports_in.push(port); + } + }); ports_out.sort_unstable_by_key(|port| port.name()); ports_in.sort_unstable_by_key(|port| port.name()); diff --git a/src/ui/graph/port.rs b/src/ui/graph/port.rs index 64afe0a..754757e 100644 --- a/src/ui/graph/port.rs +++ b/src/ui/graph/port.rs @@ -14,6 +14,7 @@ // // SPDX-License-Identifier: GPL-3.0-only +use crate::PortId; use adw::{ gdk, glib::{self, subclass::Signal}, @@ -22,7 +23,6 @@ use adw::{ subclass::prelude::*, }; pub use imp::{PortDirection, PortMediaType}; -use crate::PortId; use libspa::{param::format::MediaType, utils::Direction}; use super::PortHandle; @@ -176,10 +176,8 @@ mod imp { glib::ParamSpecUInt::builder("pipewire-id") .construct_only() .build(), - glib::ParamSpecEnum::builder::("media-type") - .build(), - glib::ParamSpecString::builder("name") - .build(), + glib::ParamSpecEnum::builder::("media-type").build(), + glib::ParamSpecString::builder("name").build(), ] }); PROPERTIES.as_ref() @@ -193,7 +191,8 @@ mod imp { self.update_ui_for_direction(); } "pipewire-id" => { - self.pipewire_id.set(value.get().expect("Value should be a u32")); + self.pipewire_id + .set(value.get().expect("Value should be a u32")); } "media-type" => { let val = value.get().expect("Value should be a PortMediaType");