@@ -67,6 +67,9 @@ mod imp {
6767
6868 #[ template_child]
6969 pub collections : TemplateChild < Sidebar > ,
70+
71+ #[ template_child]
72+ toaster : TemplateChild < adw:: ToastOverlay > ,
7073 }
7174
7275 #[ gtk:: template_callbacks]
@@ -89,6 +92,11 @@ mod imp {
8992 Some ( page)
9093 }
9194
95+ fn toast_error ( & self , error : CarteroError ) {
96+ let toast = adw:: Toast :: new ( & error. to_string ( ) ) ;
97+ self . toaster . add_toast ( toast) ;
98+ }
99+
92100 pub fn add_new_endpoint ( & self , ep : Option < Endpoint > ) {
93101 // Take the tour in order to get a reference to the application settings.
94102 let obj = self . obj ( ) ;
@@ -167,10 +175,7 @@ mod imp {
167175 let _ = settings. set ( "last-directory-open-collection" , parent_dir) ;
168176
169177 match open_collection ( & path) {
170- Ok ( col) => {
171- println ! ( "You are opening {}" , col. title( ) ) ;
172- self . finish_open_collection ( & path)
173- }
178+ Ok ( _) => self . finish_open_collection ( & path) ,
174179 Err ( e) => Err ( e) ,
175180 }
176181 }
@@ -259,8 +264,7 @@ mod imp {
259264 . activate ( glib:: clone!( @weak self as window => move |_, _, _| {
260265 glib:: spawn_future_local( glib:: clone!( @weak window => async move {
261266 if let Err ( e) = window. trigger_new_collection( ) . await {
262- let error_msg = format!( "{}" , e) ;
263- println!( "{:?}" , error_msg) ;
267+ window. toast_error( e) ;
264268 }
265269 } ) ) ;
266270 } ) )
@@ -270,8 +274,7 @@ mod imp {
270274 . activate ( glib:: clone!( @weak self as window => move |_, _, _| {
271275 glib:: spawn_future_local( glib:: clone!( @weak window => async move {
272276 if let Err ( e) = window. trigger_open_collection( ) . await {
273- let error_msg = format!( "{}" , e) ;
274- println!( "{:?}" , error_msg) ;
277+ window. toast_error( e) ;
275278 }
276279 } ) ) ;
277280 } ) )
0 commit comments