mirror of
https://gitlab.freedesktop.org/pipewire/helvum
synced 2026-03-15 11:36:11 +08:00
Fix some pedantic clippy warnings
This commit is contained in:
@@ -108,8 +108,8 @@ impl Application {
|
||||
@weak app => @default-return Continue(true),
|
||||
move |msg| {
|
||||
match msg {
|
||||
PipewireMessage::NodeAdded{ id, name } => app.add_node(id,name),
|
||||
PipewireMessage::PortAdded{ id, node_id, name, direction, media_type} => app.add_port(id,name,node_id,direction,media_type),
|
||||
PipewireMessage::NodeAdded{ id, name } => app.add_node(id, name.as_str()),
|
||||
PipewireMessage::PortAdded{ id, node_id, name, direction, media_type} => app.add_port(id, name.as_str(), node_id, direction, media_type),
|
||||
PipewireMessage::LinkAdded{ id, node_from, port_from, node_to, port_to} => app.add_link(id, node_from, port_from, node_to, port_to),
|
||||
PipewireMessage::NodeRemoved { id } => app.remove_node(id),
|
||||
PipewireMessage::PortRemoved { id, node_id } => app.remove_port(id, node_id),
|
||||
@@ -124,19 +124,19 @@ impl Application {
|
||||
}
|
||||
|
||||
/// Add a new node to the view.
|
||||
pub fn add_node(&self, id: u32, name: String) {
|
||||
pub fn add_node(&self, id: u32, name: &str) {
|
||||
info!("Adding node to graph: id {}", id);
|
||||
|
||||
imp::Application::from_instance(self)
|
||||
.graphview
|
||||
.add_node(id, view::Node::new(name.as_str()));
|
||||
.add_node(id, view::Node::new(name));
|
||||
}
|
||||
|
||||
/// Add a new port to the view.
|
||||
pub fn add_port(
|
||||
&self,
|
||||
id: u32,
|
||||
name: String,
|
||||
name: &str,
|
||||
node_id: u32,
|
||||
direction: Direction,
|
||||
media_type: Option<MediaType>,
|
||||
@@ -145,7 +145,7 @@ impl Application {
|
||||
|
||||
let imp = imp::Application::from_instance(self);
|
||||
|
||||
let port = view::Port::new(id, name.as_str(), direction, media_type);
|
||||
let port = view::Port::new(id, name, direction, media_type);
|
||||
|
||||
// Create or delete a link if the widget emits the "port-toggled" signal.
|
||||
if let Err(e) = port.connect_local(
|
||||
|
||||
@@ -100,9 +100,7 @@ fn handle_node(
|
||||
);
|
||||
|
||||
// FIXME: Instead of checking these props, the "EnumFormat" parameter should be checked instead.
|
||||
let media_type = props
|
||||
.get("media.class")
|
||||
.map(|class| {
|
||||
let media_type = props.get("media.class").and_then(|class| {
|
||||
if class.contains("Audio") {
|
||||
Some(MediaType::Audio)
|
||||
} else if class.contains("Video") {
|
||||
@@ -112,8 +110,7 @@ fn handle_node(
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.flatten();
|
||||
});
|
||||
|
||||
state.borrow_mut().insert(
|
||||
node.id,
|
||||
|
||||
@@ -34,7 +34,7 @@ pub(super) struct State {
|
||||
impl State {
|
||||
/// Create a new, empty state.
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Add a new item under the specified id.
|
||||
|
||||
@@ -119,13 +119,13 @@ mod imp {
|
||||
let mut y = 0.0;
|
||||
while y < alloc.height.into() {
|
||||
cr.move_to(0.0, y);
|
||||
cr.line_to(alloc.width as f64, y);
|
||||
cr.line_to(alloc.width.into(), y);
|
||||
y += 20.0; // TODO: Change to em;
|
||||
}
|
||||
let mut x = 0.0;
|
||||
while x < alloc.width as f64 {
|
||||
while x < alloc.width.into() {
|
||||
cr.move_to(x, 0.0);
|
||||
cr.line_to(x, alloc.height as f64);
|
||||
cr.line_to(x, alloc.height.into());
|
||||
x += 20.0; // TODO: Change to em;
|
||||
}
|
||||
if let Err(e) = cr.stroke() {
|
||||
@@ -159,7 +159,7 @@ mod imp {
|
||||
/// Get coordinates for the drawn link to start at and to end at.
|
||||
///
|
||||
/// # Returns
|
||||
/// Some((from_x, from_y, to_x, to_y)) if all objects the links refers to exist as widgets.
|
||||
/// `Some((from_x, from_y, to_x, to_y))` if all objects the links refers to exist as widgets.
|
||||
fn get_link_coordinates(&self, link: &crate::PipewireLink) -> Option<(f64, f64, f64, f64)> {
|
||||
let nodes = self.nodes.borrow();
|
||||
|
||||
@@ -194,7 +194,7 @@ mod imp {
|
||||
tx += tnx;
|
||||
ty += tny + (th / 2);
|
||||
|
||||
Some((fx as f64, fy as f64, tx as f64, ty as f64))
|
||||
Some((fx.into(), fy.into(), tx.into(), ty.into()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ mod imp {
|
||||
pub(super) grid: gtk::Grid,
|
||||
pub(super) label: gtk::Label,
|
||||
pub(super) ports: RefCell<HashMap<u32, Rc<crate::view::port::Port>>>,
|
||||
pub(super) num_ports_in: Cell<u32>,
|
||||
pub(super) num_ports_out: Cell<u32>,
|
||||
pub(super) num_ports_in: Cell<i32>,
|
||||
pub(super) num_ports_out: Cell<i32>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
@@ -81,13 +81,13 @@ impl Node {
|
||||
Direction::Input => {
|
||||
private
|
||||
.grid
|
||||
.attach(&port, 0, private.num_ports_in.get() as i32 + 1, 1, 1);
|
||||
.attach(&port, 0, private.num_ports_in.get() + 1, 1, 1);
|
||||
private.num_ports_in.set(private.num_ports_in.get() + 1);
|
||||
}
|
||||
Direction::Output => {
|
||||
private
|
||||
.grid
|
||||
.attach(&port, 1, private.num_ports_out.get() as i32 + 1, 1, 1);
|
||||
.attach(&port, 1, private.num_ports_out.get() + 1, 1, 1);
|
||||
private.num_ports_out.set(private.num_ports_out.get() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user