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,9 +108,9 @@ impl Application {
|
|||||||
@weak app => @default-return Continue(true),
|
@weak app => @default-return Continue(true),
|
||||||
move |msg| {
|
move |msg| {
|
||||||
match msg {
|
match msg {
|
||||||
PipewireMessage::NodeAdded{ id, name } => app.add_node(id,name),
|
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,node_id,direction,media_type),
|
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::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::NodeRemoved { id } => app.remove_node(id),
|
||||||
PipewireMessage::PortRemoved { id, node_id } => app.remove_port(id, node_id),
|
PipewireMessage::PortRemoved { id, node_id } => app.remove_port(id, node_id),
|
||||||
PipewireMessage::LinkRemoved { id } => app.remove_link(id)
|
PipewireMessage::LinkRemoved { id } => app.remove_link(id)
|
||||||
@@ -124,19 +124,19 @@ impl Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Add a new node to the view.
|
/// 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);
|
info!("Adding node to graph: id {}", id);
|
||||||
|
|
||||||
imp::Application::from_instance(self)
|
imp::Application::from_instance(self)
|
||||||
.graphview
|
.graphview
|
||||||
.add_node(id, view::Node::new(name.as_str()));
|
.add_node(id, view::Node::new(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a new port to the view.
|
/// Add a new port to the view.
|
||||||
pub fn add_port(
|
pub fn add_port(
|
||||||
&self,
|
&self,
|
||||||
id: u32,
|
id: u32,
|
||||||
name: String,
|
name: &str,
|
||||||
node_id: u32,
|
node_id: u32,
|
||||||
direction: Direction,
|
direction: Direction,
|
||||||
media_type: Option<MediaType>,
|
media_type: Option<MediaType>,
|
||||||
@@ -145,7 +145,7 @@ impl Application {
|
|||||||
|
|
||||||
let imp = imp::Application::from_instance(self);
|
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.
|
// Create or delete a link if the widget emits the "port-toggled" signal.
|
||||||
if let Err(e) = port.connect_local(
|
if let Err(e) = port.connect_local(
|
||||||
|
|||||||
@@ -100,20 +100,17 @@ fn handle_node(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// FIXME: Instead of checking these props, the "EnumFormat" parameter should be checked instead.
|
// FIXME: Instead of checking these props, the "EnumFormat" parameter should be checked instead.
|
||||||
let media_type = props
|
let media_type = props.get("media.class").and_then(|class| {
|
||||||
.get("media.class")
|
if class.contains("Audio") {
|
||||||
.map(|class| {
|
Some(MediaType::Audio)
|
||||||
if class.contains("Audio") {
|
} else if class.contains("Video") {
|
||||||
Some(MediaType::Audio)
|
Some(MediaType::Video)
|
||||||
} else if class.contains("Video") {
|
} else if class.contains("Midi") {
|
||||||
Some(MediaType::Video)
|
Some(MediaType::Midi)
|
||||||
} else if class.contains("Midi") {
|
} else {
|
||||||
Some(MediaType::Midi)
|
None
|
||||||
} else {
|
}
|
||||||
None
|
});
|
||||||
}
|
|
||||||
})
|
|
||||||
.flatten();
|
|
||||||
|
|
||||||
state.borrow_mut().insert(
|
state.borrow_mut().insert(
|
||||||
node.id,
|
node.id,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ pub(super) struct State {
|
|||||||
impl State {
|
impl State {
|
||||||
/// Create a new, empty state.
|
/// Create a new, empty state.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Default::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a new item under the specified id.
|
/// Add a new item under the specified id.
|
||||||
|
|||||||
@@ -119,13 +119,13 @@ mod imp {
|
|||||||
let mut y = 0.0;
|
let mut y = 0.0;
|
||||||
while y < alloc.height.into() {
|
while y < alloc.height.into() {
|
||||||
cr.move_to(0.0, y);
|
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;
|
y += 20.0; // TODO: Change to em;
|
||||||
}
|
}
|
||||||
let mut x = 0.0;
|
let mut x = 0.0;
|
||||||
while x < alloc.width as f64 {
|
while x < alloc.width.into() {
|
||||||
cr.move_to(x, 0.0);
|
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;
|
x += 20.0; // TODO: Change to em;
|
||||||
}
|
}
|
||||||
if let Err(e) = cr.stroke() {
|
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.
|
/// Get coordinates for the drawn link to start at and to end at.
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # 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)> {
|
fn get_link_coordinates(&self, link: &crate::PipewireLink) -> Option<(f64, f64, f64, f64)> {
|
||||||
let nodes = self.nodes.borrow();
|
let nodes = self.nodes.borrow();
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ mod imp {
|
|||||||
tx += tnx;
|
tx += tnx;
|
||||||
ty += tny + (th / 2);
|
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) grid: gtk::Grid,
|
||||||
pub(super) label: gtk::Label,
|
pub(super) label: gtk::Label,
|
||||||
pub(super) ports: RefCell<HashMap<u32, Rc<crate::view::port::Port>>>,
|
pub(super) ports: RefCell<HashMap<u32, Rc<crate::view::port::Port>>>,
|
||||||
pub(super) num_ports_in: Cell<u32>,
|
pub(super) num_ports_in: Cell<i32>,
|
||||||
pub(super) num_ports_out: Cell<u32>,
|
pub(super) num_ports_out: Cell<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[glib::object_subclass]
|
#[glib::object_subclass]
|
||||||
@@ -81,13 +81,13 @@ impl Node {
|
|||||||
Direction::Input => {
|
Direction::Input => {
|
||||||
private
|
private
|
||||||
.grid
|
.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);
|
private.num_ports_in.set(private.num_ports_in.get() + 1);
|
||||||
}
|
}
|
||||||
Direction::Output => {
|
Direction::Output => {
|
||||||
private
|
private
|
||||||
.grid
|
.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);
|
private.num_ports_out.set(private.num_ports_out.get() + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user