@@ -10,15 +10,15 @@ use gtk::gio;
1010use gtk:: glib;
1111use gtk:: prelude:: * ;
1212use gtk:: subclass:: prelude:: * ;
13+ use gtk:: CompositeTemplate ;
14+ use gtk:: TemplateChild ;
1315use log:: { debug, error, info} ;
1416use once_cell:: sync:: Lazy ;
1517use std:: cell:: RefCell ;
1618use std:: marker:: PhantomData ;
1719use std:: pin:: Pin ;
1820use std:: rc:: Rc ;
1921use url:: Url ;
20- use gtk:: CompositeTemplate ;
21- use gtk:: TemplateChild ;
2222
2323use crate :: common;
2424use crate :: common:: { glibctx, HistoryItem , LossyTextRead , PageElement , RequestCtx } ;
@@ -42,7 +42,7 @@ pub mod imp {
4242 pub ( crate ) draw_ctx : RefCell < Option < DrawCtx > > ,
4343 pub ( crate ) history : RefCell < Vec < HistoryItem > > ,
4444 pub ( crate ) current_hi : RefCell < Option < usize > > ,
45- #[ template_child]
45+ #[ template_child]
4646 pub ( crate ) scroll_win : TemplateChild < gtk:: ScrolledWindow > ,
4747 #[ template_child]
4848 pub ( crate ) text_view : TemplateChild < gtk:: TextView > ,
@@ -142,11 +142,15 @@ impl Tab {
142142 pub fn new ( config : crate :: config:: Config ) -> Self {
143143 let this: Self = glib:: Object :: new ( & [ ] ) . unwrap ( ) ;
144144 let imp = this. imp ( ) ;
145- imp. text_view . add_controller ( imp. left_click_ctrl . borrow ( ) . as_ref ( ) . unwrap ( ) ) ;
146- imp. text_view . add_controller ( imp. right_click_ctrl . borrow ( ) . as_ref ( ) . unwrap ( ) ) ;
147- imp. text_view . add_controller ( imp. motion_ctrl . borrow ( ) . as_ref ( ) . unwrap ( ) ) ;
145+ imp. text_view
146+ . add_controller ( imp. left_click_ctrl . borrow ( ) . as_ref ( ) . unwrap ( ) ) ;
147+ imp. text_view
148+ . add_controller ( imp. right_click_ctrl . borrow ( ) . as_ref ( ) . unwrap ( ) ) ;
149+ imp. text_view
150+ . add_controller ( imp. motion_ctrl . borrow ( ) . as_ref ( ) . unwrap ( ) ) ;
148151
149- imp. draw_ctx . replace ( Some ( DrawCtx :: new ( imp. text_view . clone ( ) , config) ) ) ;
152+ imp. draw_ctx
153+ . replace ( Some ( DrawCtx :: new ( imp. text_view . clone ( ) , config) ) ) ;
150154
151155 this. bind_signals ( ) ;
152156 this
@@ -212,7 +216,6 @@ impl Tab {
212216 pub fn spawn_open_url ( & self , url : Url ) {
213217 let imp = self . imp ( ) ;
214218
215-
216219 let i = self . add_to_history ( HistoryItem {
217220 url : url. clone ( ) ,
218221 cache : Default :: default ( ) ,
@@ -253,7 +256,7 @@ impl Tab {
253256 imp. stack . set_visible_child ( & first_page. child ( ) ) ;
254257 for page in iter. skip ( 1 ) {
255258 imp. stack . remove ( & page. unwrap ( ) . child ( ) ) ;
256- } ;
259+ }
257260 }
258261 fn spawn_request ( & self , fut : impl Future < Output = ( ) > + ' static ) {
259262 let imp = self . imp ( ) ;
@@ -543,7 +546,6 @@ impl Tab {
543546 gtk:: show_uri ( None :: < & gtk:: Window > , & downloaded_file_url, 0 ) ;
544547 } ) ;
545548
546-
547549 let ext = file_name. split ( "." ) . last ( ) ;
548550 if let Some ( true ) = ext. map ( |ext| crate :: common:: STREAMABLE_EXTS . contains ( & ext) ) {
549551 page. imp ( ) . open_btn . set_opacity ( 1.0 ) ;
@@ -567,7 +569,9 @@ impl Tab {
567569 let t = glib:: real_time ( ) ;
568570 if t - last_update_time > THROTTLE_TIME {
569571 page. imp ( ) . progress_bar . pulse ( ) ;
570- page. imp ( ) . label_downloaded . set_text ( & format ! ( "{:.2}KB" , read as f64 / 1000.0 ) ) ;
572+ page. imp ( )
573+ . label_downloaded
574+ . set_text ( & format ! ( "{:.2}KB" , read as f64 / 1000.0 ) ) ;
571575 last_update_time = t;
572576 }
573577 }
@@ -577,7 +581,9 @@ impl Tab {
577581 Err ( e) => return Err ( e. into ( ) ) ,
578582 }
579583 }
580- page. imp ( ) . label_downloaded . set_text ( & format ! ( "{:.2}KB" , read as f64 / 1000.0 ) ) ;
584+ page. imp ( )
585+ . label_downloaded
586+ . set_text ( & format ! ( "{:.2}KB" , read as f64 / 1000.0 ) ) ;
581587 page. imp ( ) . progress_bar . set_fraction ( 1.0 ) ;
582588 page. imp ( ) . open_btn . set_opacity ( 1.0 ) ;
583589 page. imp ( ) . open_btn . set_label ( "Open" ) ;
@@ -617,7 +623,6 @@ impl Tab {
617623 . activate_action ( "win.open-url" , Some ( & url. to_string ( ) . to_variant ( ) ) )
618624 . unwrap ( ) ;
619625 } ) ;
620-
621626 }
622627
623628 fn display_url_confirmation ( ctx : & mut DrawCtx , url : & Url ) {
0 commit comments