fix fmt issues

This commit is contained in:
Naveen Prashanth 2026-05-07 19:04:10 +05:30
parent ef98acb716
commit c713fbb69b
8 changed files with 73 additions and 41 deletions

View file

@ -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::<graph::Node>() else {
@ -196,7 +199,10 @@ mod imp {
return;
};
let Ok(node) = node.clone().dynamic_cast::<graph::Node>() 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::<graph::Port>() 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::<graph::Node>() 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::<graph::Port>() 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::<graph::Port>() 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::<graph::Link>() else {

View file

@ -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,
}

View file

@ -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");

View file

@ -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));

View file

@ -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;

View file

@ -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!(),
}
}

View file

@ -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());

View file

@ -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::<PortMediaType>("media-type")
.build(),
glib::ParamSpecString::builder("name")
.build(),
glib::ParamSpecEnum::builder::<PortMediaType>("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");