@@ -8,6 +8,7 @@ use gtk::{
88 glib:: { self } ,
99} ;
1010use std:: cell:: RefCell ;
11+ use std:: time:: Duration ;
1112
1213use glib:: clone;
1314
@@ -81,7 +82,7 @@ mod imp {
8182 break ;
8283 }
8384 }
84- this_clone. imp ( ) . warning_icon . set_visible ( has_warning) ;
85+ this_clone. set_has_warning ( has_warning) ;
8586
8687 // Listen when a new task will fail
8788 for i in position..position + added {
@@ -91,7 +92,7 @@ mod imp {
9192 let this_clone = this_clone. clone ( ) ;
9293 item. connect_status_notify ( move |item| {
9394 if item. is_failed ( ) {
94- this_clone. imp ( ) . warning_icon . set_visible ( true ) ;
95+ this_clone. set_has_warning ( true ) ;
9596 }
9697 } ) ;
9798 }
@@ -117,4 +118,14 @@ impl TasksButton {
117118 . property ( "root-store" , root_store)
118119 . build ( )
119120 }
121+ pub fn set_has_warning ( & self , has_warning : bool ) {
122+ self . imp ( ) . warning_icon . set_visible ( has_warning) ;
123+ // trigger the animation
124+ self . imp ( ) . warning_icon . remove_css_class ( "task-warning" ) ;
125+ let this = self . clone ( ) ;
126+ glib:: timeout_add_local_full ( Duration :: from_millis ( 100 ) , glib:: Priority :: LOW , move || {
127+ this. imp ( ) . warning_icon . remove_css_class ( "task-warning" ) ;
128+ glib:: ControlFlow :: Break
129+ } ) ;
130+ }
120131}
0 commit comments