@@ -22,23 +22,16 @@ use cosmic::{
2222 } ,
2323 surface,
2424 theme:: { self , CosmicTheme } ,
25- widget:: { Column , divider, text} ,
25+ widget:: { Column , divider, text, toggler } ,
2626} ;
2727
2828use cosmic_settings_a11y_manager_subscription:: {
2929 self as cosmic_a11y_manager, AccessibilityEvent , AccessibilityRequest , ColorFilter ,
3030} ;
3131use cosmic_settings_accessibility_subscription:: { self as accessibility} ;
32- use cosmic_time:: { Instant , Timeline , anim, chain, id} ;
3332use std:: sync:: LazyLock ;
3433use tokio:: sync:: mpsc:: UnboundedSender ;
3534
36- static READER_TOGGLE : LazyLock < id:: Toggler > = LazyLock :: new ( id:: Toggler :: unique) ;
37- static FILTER_TOGGLE : LazyLock < id:: Toggler > = LazyLock :: new ( id:: Toggler :: unique) ;
38- static HC_TOGGLE : LazyLock < id:: Toggler > = LazyLock :: new ( id:: Toggler :: unique) ;
39- static MAGNIFIER_TOGGLE : LazyLock < id:: Toggler > = LazyLock :: new ( id:: Toggler :: unique) ;
40- static INVERT_COLORS_TOGGLE : LazyLock < id:: Toggler > = LazyLock :: new ( id:: Toggler :: unique) ;
41-
4235pub fn run ( ) -> cosmic:: iced:: Result {
4336 cosmic:: applet:: run :: < CosmicA11yApplet > ( ( ) )
4437}
@@ -54,7 +47,6 @@ struct CosmicA11yApplet {
5447 dbus_sender : Option < UnboundedSender < accessibility:: Request > > ,
5548 wayland_sender : Option < calloop:: channel:: Sender < AccessibilityRequest > > ,
5649 wayland_protocol_version : Option < u32 > ,
57- timeline : Timeline ,
5850 token_tx : Option < channel:: Sender < TokenRequest > > ,
5951 screen_filter_active : bool ,
6052}
@@ -63,12 +55,11 @@ struct CosmicA11yApplet {
6355enum Message {
6456 TogglePopup ,
6557 CloseRequested ( window:: Id ) ,
66- HighContrastEnabled ( chain:: Toggler , bool ) ,
67- ScreenReaderEnabled ( chain:: Toggler , bool ) ,
68- MagnifierEnabled ( chain:: Toggler , bool ) ,
69- InvertedColorsEnabled ( chain:: Toggler , bool ) ,
70- FilterColorsEnabled ( chain:: Toggler , bool ) ,
71- Frame ( Instant ) ,
58+ HighContrastEnabled ( bool ) ,
59+ ScreenReaderEnabled ( bool ) ,
60+ MagnifierEnabled ( bool ) ,
61+ InvertedColorsEnabled ( bool ) ,
62+ FilterColorsEnabled ( bool ) ,
7263 Token ( TokenUpdate ) ,
7364 OpenSettings ,
7465 DBusUpdate ( accessibility:: Response ) ,
@@ -104,28 +95,24 @@ impl cosmic::Application for CosmicA11yApplet {
10495
10596 fn update ( & mut self , message : Self :: Message ) -> app:: Task < Self :: Message > {
10697 match message {
107- Message :: Frame ( now) => self . timeline . now ( now) ,
108- Message :: ScreenReaderEnabled ( chain, enabled) => {
98+ Message :: ScreenReaderEnabled ( enabled) => {
10999 if let Some ( tx) = & self . dbus_sender {
110- self . timeline . set_chain ( chain) . start ( ) ;
111100 self . reader_enabled = enabled;
112101 let _ = tx. send ( accessibility:: Request :: ScreenReader ( enabled) ) ;
113102 } else {
114103 self . reader_enabled = false ;
115104 }
116105 }
117- Message :: MagnifierEnabled ( chain , enabled) => {
106+ Message :: MagnifierEnabled ( enabled) => {
118107 if let Some ( tx) = & self . wayland_sender {
119- self . timeline . set_chain ( chain) . start ( ) ;
120108 self . magnifier_enabled = enabled;
121109 let _ = tx. send ( AccessibilityRequest :: Magnifier ( enabled) ) ;
122110 } else {
123111 self . magnifier_enabled = false ;
124112 }
125113 }
126- Message :: InvertedColorsEnabled ( chain , enabled) => {
114+ Message :: InvertedColorsEnabled ( enabled) => {
127115 if let Some ( tx) = & self . wayland_sender {
128- self . timeline . set_chain ( chain) . start ( ) ;
129116 self . inverted_colors_enabled = enabled;
130117 let _ = tx. send ( AccessibilityRequest :: ScreenFilter {
131118 inverted : enabled,
@@ -135,9 +122,8 @@ impl cosmic::Application for CosmicA11yApplet {
135122 self . inverted_colors_enabled = false ;
136123 }
137124 }
138- Message :: FilterColorsEnabled ( chain , enabled) => {
125+ Message :: FilterColorsEnabled ( enabled) => {
139126 if let Some ( sender) = self . wayland_sender . as_ref ( ) {
140- self . timeline . set_chain ( chain) . start ( ) ;
141127 self . screen_filter_active = enabled;
142128 let _ = sender. send ( AccessibilityRequest :: ScreenFilter {
143129 inverted : self . inverted_colors_enabled ,
@@ -149,8 +135,6 @@ impl cosmic::Application for CosmicA11yApplet {
149135 if let Some ( p) = self . popup . take ( ) {
150136 return destroy_popup ( p) ;
151137 } else {
152- self . timeline = Timeline :: new ( ) ;
153-
154138 let new_id = window:: Id :: unique ( ) ;
155139 self . popup . replace ( new_id) ;
156140
@@ -170,13 +154,13 @@ impl cosmic::Application for CosmicA11yApplet {
170154 self . popup = None ;
171155 }
172156 }
173- Message :: HighContrastEnabled ( chain , enabled) => {
157+ Message :: HighContrastEnabled ( enabled) => {
174158 if self . core . system_theme ( ) . cosmic ( ) . is_high_contrast == enabled
175159 || self . high_contrast . is_some_and ( |hc| hc == enabled)
176160 {
177161 return Task :: none ( ) ;
178162 }
179- self . timeline . set_chain ( chain ) . start ( ) ;
163+
180164 self . high_contrast = Some ( enabled) ;
181165
182166 _ = std:: thread:: spawn ( move || {
@@ -319,62 +303,44 @@ impl cosmic::Application for CosmicA11yApplet {
319303 } = theme:: active ( ) . cosmic ( ) . spacing ;
320304
321305 let reader_toggle = padded_control (
322- anim ! (
323- READER_TOGGLE ,
324- & self . timeline,
325- fl!( "screen-reader" ) ,
326- self . reader_enabled,
327- Message :: ScreenReaderEnabled ,
328- )
329- . text_size ( 14 )
330- . width ( Length :: Fill ) ,
306+ toggler ( self . reader_enabled )
307+ . on_toggle ( Message :: ScreenReaderEnabled )
308+ . text_size ( 14 )
309+ . width ( Length :: Fill )
310+ . label ( fl ! ( "screen-reader" ) ) ,
331311 ) ;
332312 let magnifier_toggle = padded_control (
333- anim ! (
334- MAGNIFIER_TOGGLE ,
335- & self . timeline,
336- fl!( "magnifier" ) ,
337- self . magnifier_enabled,
338- Message :: MagnifierEnabled ,
339- )
340- . text_size ( 14 )
341- . width ( Length :: Fill ) ,
313+ toggler ( self . magnifier_enabled )
314+ . on_toggle ( Message :: MagnifierEnabled )
315+ . text_size ( 14 )
316+ . width ( Length :: Fill )
317+ . label ( fl ! ( "magnifier" ) ) ,
342318 ) ;
343319 let invert_colors_toggle = padded_control (
344- anim ! (
345- INVERT_COLORS_TOGGLE ,
346- & self . timeline,
347- fl!( "invert-colors" ) ,
348- self . inverted_colors_enabled,
349- Message :: InvertedColorsEnabled ,
350- )
351- . text_size ( 14 )
352- . width ( Length :: Fill ) ,
320+ toggler ( self . inverted_colors_enabled )
321+ . on_toggle ( Message :: InvertedColorsEnabled )
322+ . text_size ( 14 )
323+ . width ( Length :: Fill )
324+ . label ( fl ! ( "invert-colors" ) ) ,
353325 ) ;
354326
355327 let hc_colors_toggle = padded_control (
356- anim ! (
357- HC_TOGGLE ,
358- & self . timeline,
359- fl!( "high-contrast" ) ,
328+ toggler (
360329 self . high_contrast
361330 . unwrap_or ( self . core . system_theme ( ) . cosmic ( ) . is_high_contrast ) ,
362- Message :: HighContrastEnabled ,
363331 )
332+ . on_toggle ( Message :: HighContrastEnabled )
333+ . label ( fl ! ( "high-contrast" ) )
364334 . text_size ( 14 )
365335 . width ( Length :: Fill ) ,
366336 ) ;
367337
368338 let filter_colors_toggle = padded_control (
369- anim ! (
370- FILTER_TOGGLE ,
371- & self . timeline,
372- fl!( "filter-colors" ) ,
373- self . screen_filter_active,
374- Message :: FilterColorsEnabled ,
375- )
376- . text_size ( 14 )
377- . width ( Length :: Fill ) ,
339+ toggler ( self . screen_filter_active )
340+ . on_toggle ( Message :: FilterColorsEnabled )
341+ . label ( fl ! ( "filter-colors" ) )
342+ . width ( Length :: Fill )
343+ . text_size ( 14 ) ,
378344 ) ;
379345
380346 let content_list = Column :: with_capacity ( 5 )
@@ -406,9 +372,6 @@ impl cosmic::Application for CosmicA11yApplet {
406372 Subscription :: batch ( [
407373 accessibility:: subscription ( ) . map ( Message :: DBusUpdate ) ,
408374 backend:: wayland:: a11y_subscription ( ) . map ( Message :: WaylandUpdate ) ,
409- self . timeline
410- . as_subscription ( )
411- . map ( |( _, now) | Message :: Frame ( now) ) ,
412375 activation_token_subscription ( 0 ) . map ( Message :: Token ) ,
413376 ] )
414377 }
@@ -417,7 +380,7 @@ impl cosmic::Application for CosmicA11yApplet {
417380 Some ( Message :: CloseRequested ( id) )
418381 }
419382
420- fn style ( & self ) -> Option < cosmic:: iced_runtime :: Appearance > {
383+ fn style ( & self ) -> Option < cosmic:: iced :: theme :: Style > {
421384 Some ( cosmic:: applet:: style ( ) )
422385 }
423386}
0 commit comments