fix(dock): msg conversion using provided function

This commit is contained in:
Ashley Wulber 2025-03-17 17:02:32 -04:00 committed by Ashley Wulber
parent 96954a217a
commit ccbf883ff0
4 changed files with 9 additions and 22 deletions

View file

@ -17,7 +17,6 @@ use slotmap::SlotMap;
pub mod magnifier; pub mod magnifier;
mod wayland; mod wayland;
use tokio::task::spawn_blocking;
pub use wayland::{AccessibilityEvent, AccessibilityRequest}; pub use wayland::{AccessibilityEvent, AccessibilityRequest};
#[derive(Debug, Default)] #[derive(Debug, Default)]

View file

@ -94,7 +94,7 @@ pub trait PanelPage {
pub(crate) fn behavior_and_position< pub(crate) fn behavior_and_position<
P: page::Page<crate::pages::Message> + PanelPage, P: page::Page<crate::pages::Message> + PanelPage,
T: Fn(Message) -> crate::pages::Message + Copy + 'static, T: Fn(Message) -> crate::pages::Message + Copy + Send + Sync + 'static,
>( >(
p: &P, p: &P,
msg_map: T, msg_map: T,
@ -128,11 +128,7 @@ pub(crate) fn behavior_and_position<
Message::PanelAnchor, Message::PanelAnchor,
cosmic::iced::window::Id::RESERVED, cosmic::iced::window::Id::RESERVED,
Message::Surface, Message::Surface,
|a| { move |a| crate::app::Message::PageMessage(msg_map(a)),
crate::app::Message::PageMessage(crate::pages::Message::Panel(
super::Message(a),
))
},
), ),
)) ))
.add(settings::item( .add(settings::item(
@ -147,11 +143,7 @@ pub(crate) fn behavior_and_position<
Message::Output, Message::Output,
cosmic::iced::window::Id::RESERVED, cosmic::iced::window::Id::RESERVED,
Message::Surface, Message::Surface,
|a| { move |a| crate::app::Message::PageMessage(msg_map(a)),
crate::app::Message::PageMessage(crate::pages::Message::Panel(
super::Message(a),
))
},
), ),
)) ))
.apply(Element::from) .apply(Element::from)
@ -161,7 +153,7 @@ pub(crate) fn behavior_and_position<
pub(crate) fn style< pub(crate) fn style<
P: page::Page<crate::pages::Message> + PanelPage, P: page::Page<crate::pages::Message> + PanelPage,
T: Fn(Message) -> crate::pages::Message + Copy + 'static, T: Fn(Message) -> crate::pages::Message + Copy + Send + Sync + 'static,
>( >(
p: &P, p: &P,
msg_map: T, msg_map: T,
@ -206,11 +198,7 @@ pub(crate) fn style<
Message::Appearance, Message::Appearance,
cosmic::iced::window::Id::RESERVED, cosmic::iced::window::Id::RESERVED,
Message::Surface, Message::Surface,
|a| { move |a| crate::app::Message::PageMessage(msg_map(a)),
crate::app::Message::PageMessage(crate::pages::Message::Panel(
super::Message(a),
))
},
), ),
)) ))
.add(settings::flex_item( .add(settings::flex_item(
@ -592,7 +580,7 @@ impl PageInner {
return Task::none(); return Task::none();
} }
Message::ResetPanel | Message::FullReset => {} Message::ResetPanel | Message::FullReset => {}
Message::Surface(a) => { Message::Surface(_) => {
unimplemented!() unimplemented!()
} }
} }

View file

@ -5,7 +5,7 @@ use cosmic::{
iced::Length, iced::Length,
surface, surface,
widget::{self, settings, toggler}, widget::{self, settings, toggler},
Apply, Element, Task, Apply, Element,
}; };
use cosmic_config::{ConfigGet, ConfigSet}; use cosmic_config::{ConfigGet, ConfigSet};

View file

@ -615,7 +615,7 @@ fn input() -> Section<crate::pages::Message> {
widget::slider(0..=150, page.source_volume, Message::SourceVolumeChanged) widget::slider(0..=150, page.source_volume, Message::SourceVolumeChanged)
.breakpoints(&[100]), .breakpoints(&[100]),
); );
let mut devices = widget::dropdown::popup_dropdown( let devices = widget::dropdown::popup_dropdown(
&page.sources, &page.sources,
Some(page.active_source.unwrap_or(0)), Some(page.active_source.unwrap_or(0)),
Message::SourceChanged, Message::SourceChanged,
@ -633,7 +633,7 @@ fn input() -> Section<crate::pages::Message> {
.add(settings::item(&*section.descriptions[device], devices)); .add(settings::item(&*section.descriptions[device], devices));
if !page.source_profiles.is_empty() { if !page.source_profiles.is_empty() {
let mut dropdown = widget::dropdown::popup_dropdown( let dropdown = widget::dropdown::popup_dropdown(
&page.source_profiles, &page.source_profiles,
page.active_source_profile, page.active_source_profile,
Message::SourceProfileChanged, Message::SourceProfileChanged,