@@ -490,13 +490,11 @@ impl cosmic::Application for Audio {
490
490
match msg {
491
491
// This is where we match messages from the subscription to app state
492
492
pulse:: Message :: SetSinks ( sinks) => self . outputs = sinks,
493
- pulse:: Message :: SetSources ( sources) => {
494
- self . inputs = sources
495
- . into_iter ( )
496
- . filter ( |source| {
497
- !source. name . as_ref ( ) . is_some_and ( |n| n. contains ( "monitor" ) )
498
- } )
499
- . collect ( )
493
+ pulse:: Message :: SetSources ( mut sources) => {
494
+ sources. retain ( |source| {
495
+ !source. name . as_ref ( ) . is_some_and ( |n| n. contains ( "monitor" ) )
496
+ } ) ;
497
+ self . inputs = sources;
500
498
}
501
499
pulse:: Message :: SetDefaultSink ( sink) => {
502
500
self . update_output ( Some ( sink) ) ;
@@ -824,13 +822,7 @@ impl cosmic::Application for Audio {
824
822
Some ( output) => pretty_name( output. description. clone( ) ) ,
825
823
None => String :: from( "No device selected" ) ,
826
824
} ,
827
- self . outputs
828
- . iter( )
829
- . map( |output| (
830
- output. name. clone( ) . unwrap_or_default( ) ,
831
- pretty_name( output. description. clone( ) )
832
- ) )
833
- . collect( ) ,
825
+ self . outputs. as_slice( ) ,
834
826
Message :: OutputToggle ,
835
827
Message :: OutputChanged ,
836
828
) ,
@@ -841,13 +833,7 @@ impl cosmic::Application for Audio {
841
833
Some ( input) => pretty_name( input. description. clone( ) ) ,
842
834
None => fl!( "no-device" ) ,
843
835
} ,
844
- self . inputs
845
- . iter( )
846
- . map( |input| (
847
- input. name. clone( ) . unwrap_or_default( ) ,
848
- pretty_name( input. description. clone( ) )
849
- ) )
850
- . collect( ) ,
836
+ self . inputs. as_slice( ) ,
851
837
Message :: InputToggle ,
852
838
Message :: InputChanged ,
853
839
)
@@ -975,17 +961,23 @@ fn revealer(
975
961
open : bool ,
976
962
title : String ,
977
963
selected : String ,
978
- options : Vec < ( String , String ) > ,
964
+ device_info : & [ DeviceInfo ] ,
979
965
toggle : Message ,
980
966
mut change : impl FnMut ( String ) -> Message + ' static ,
981
967
) -> widget:: Column < ' static , Message , crate :: Theme , Renderer > {
982
968
if open {
983
- options. iter ( ) . fold (
969
+ let options = device_info. iter ( ) . map ( |device| {
970
+ (
971
+ device. name . clone ( ) . unwrap_or_default ( ) ,
972
+ pretty_name ( device. description . clone ( ) ) ,
973
+ )
974
+ } ) ;
975
+ options. fold (
984
976
column ! [ revealer_head( open, title, selected, toggle) ] . width ( Length :: Fill ) ,
985
977
|col, ( id, name) | {
986
978
col. push (
987
- menu_button ( text:: body ( name. clone ( ) ) )
988
- . on_press ( change ( id. clone ( ) ) )
979
+ menu_button ( text:: body ( name) )
980
+ . on_press ( change ( id) )
989
981
. width ( Length :: Fill )
990
982
. padding ( [ 8 , 48 ] ) ,
991
983
)
0 commit comments