mirror of
https://gitlab.freedesktop.org/pipewire/helvum
synced 2026-03-15 11:36:11 +08:00
Move port coloring into view
The controller still determines the ports media type, but instead of coloring the port itself, the media type is passed to the constructor, which then colors the port.
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
use gtk::WidgetExt;
|
||||
|
||||
use crate::controller::MediaType;
|
||||
|
||||
/// Graphical representation of a pipewire port.
|
||||
pub struct Port {
|
||||
pub widget: gtk::Button,
|
||||
@@ -6,9 +10,24 @@ pub struct Port {
|
||||
}
|
||||
|
||||
impl Port {
|
||||
pub fn new(id: u32, name: &str, direction: pipewire::port::Direction) -> Self {
|
||||
pub fn new(
|
||||
id: u32,
|
||||
name: &str,
|
||||
direction: pipewire::port::Direction,
|
||||
media_type: Option<MediaType>,
|
||||
) -> Self {
|
||||
let widget = gtk::Button::with_label(name);
|
||||
|
||||
// Color the port according to its media type.
|
||||
match media_type {
|
||||
Some(MediaType::Video) => widget.add_css_class("video"),
|
||||
Some(MediaType::Audio) => widget.add_css_class("audio"),
|
||||
Some(MediaType::Midi) => widget.add_css_class("midi"),
|
||||
None => {}
|
||||
}
|
||||
|
||||
Self {
|
||||
widget: gtk::Button::with_label(name),
|
||||
widget,
|
||||
id,
|
||||
direction,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user