@@ -22,10 +22,19 @@ use std::rc::Rc;
2222use url:: Url ;
2323
2424use crate :: common;
25- use crate :: common:: { glibctx, HistoryItem , LossyTextRead } ;
25+ use crate :: common:: glibctx;
2626use crate :: gemini;
2727use crate :: gemini:: PageElement ;
28+ use crate :: lossy_text_read:: * ;
2829use crate :: text_extensions:: Gemini as GeminiTextExt ;
30+ use crate :: widgets;
31+
32+ #[ derive( Debug , Clone , PartialEq ) ]
33+ pub struct HistoryItem {
34+ pub url : url:: Url ,
35+ pub cache : Rc < RefCell < Option < Vec < u8 > > > > ,
36+ pub scroll_progress : f64 ,
37+ }
2938
3039#[ derive( Clone , Debug , glib:: Boxed , Default ) ]
3140#[ boxed_type( name = "GeopardHistoryStatus" ) ]
@@ -413,7 +422,7 @@ impl Tab {
413422 . iter ( )
414423 . find_map ( GeminiTextExt :: linkhandler)
415424 . cloned ( )
416- . ok_or ( anyhow:: Error :: msg ( "Clicked text doesn't have a link tag" ) )
425+ . ok_or_else ( || anyhow:: Error :: msg ( "Clicked text doesn't have a link tag" ) )
417426 }
418427 async fn open_file_url ( & self , url : Url ) -> Result < ( ) > {
419428 let path = url
@@ -459,7 +468,7 @@ impl Tab {
459468 }
460469 async fn open_gemini_url ( & self , url : Url ) -> anyhow:: Result < Option < Vec < u8 > > > {
461470 let imp = self . imp ( ) ;
462- let res: gemini:: Response = imp. gemini_client . borrow ( ) . fetch ( url. as_str ( ) ) . await ?;
471+ let res: gemini:: Response = { imp. gemini_client . borrow ( ) . fetch ( url. as_str ( ) ) } . await ?;
463472
464473 use gemini:: Status :: * ;
465474 let meta = res. meta ( ) . to_owned ( ) ;
@@ -536,7 +545,7 @@ impl Tab {
536545 . context ( "Can't get last url segment" ) ?;
537546 let d_path = Self :: download_path ( file_name) ?;
538547
539- let page = crate :: download_page :: DownloadPage :: new ( ) ;
548+ let page = widgets :: DownloadPage :: new ( ) ;
540549 page. imp ( ) . label . set_label ( file_name) ;
541550 imp. stack . add_child ( & page) ;
542551 imp. stack . set_visible_child ( & page) ;
@@ -547,7 +556,7 @@ impl Tab {
547556 gtk:: show_uri ( None :: < & gtk:: Window > , & downloaded_file_url, 0 ) ;
548557 } ) ;
549558
550- let ext = file_name. split ( "." ) . last ( ) ;
559+ let ext = file_name. split ( '.' ) . last ( ) ;
551560 if let Some ( true ) = ext. map ( |ext| crate :: common:: STREAMABLE_EXTS . contains ( & ext) ) {
552561 page. imp ( ) . open_btn . set_opacity ( 1.0 ) ;
553562 }
@@ -611,7 +620,7 @@ impl Tab {
611620 fn display_input ( & self , url : Url , msg : & str ) {
612621 let imp = self . imp ( ) ;
613622
614- let text_input = crate :: input_page :: InputPage :: new ( ) ;
623+ let text_input = widgets :: InputPage :: new ( ) ;
615624 imp. stack . add_child ( & text_input) ;
616625 imp. stack . set_visible_child ( & text_input) ;
617626 text_input. imp ( ) . label . set_label ( msg) ;
@@ -699,7 +708,7 @@ impl Tab {
699708 if !title_updated {
700709 title_updated = true ;
701710 imp. title
702- . replace ( line. trim_end ( ) . trim_start_matches ( "#" ) . to_string ( ) ) ;
711+ . replace ( line. trim_end ( ) . trim_start_matches ( '#' ) . to_string ( ) ) ;
703712 self . notify ( "title" ) ;
704713 }
705714 }
0 commit comments