@@ -23,11 +23,11 @@ use crate::common::{glibctx, HistoryItem, LossyTextRead, PageElement, RequestCtx
2323use crate :: draw_ctx:: DrawCtx ;
2424use crate :: gemini;
2525
26- #[ derive( Clone , glib:: Boxed , Default ) ]
26+ #[ derive( Clone , Debug , glib:: Boxed , Default ) ]
2727#[ boxed_type( name = "GeopardHistoryStatus" ) ]
2828pub struct HistoryStatus {
29- current : usize ,
30- available : usize ,
29+ pub ( crate ) current : usize ,
30+ pub ( crate ) available : usize ,
3131}
3232pub mod imp {
3333
@@ -230,16 +230,20 @@ impl Tab {
230230 }
231231 fn add_to_history ( & self , item : HistoryItem ) -> usize {
232232 let imp = self . imp ( ) ;
233- let mut history = imp. history . borrow_mut ( ) ;
234- let i = * imp. current_hi . borrow ( ) ;
235- if let Some ( i) = i {
236- let scroll_progress = imp. scroll_win . vadjustment ( ) . value ( ) ;
237- history[ i] . scroll_progress = scroll_progress;
238- history. truncate ( i + 1 ) ;
233+ let i = {
234+ let mut history = imp. history . borrow_mut ( ) ;
235+ let i = * imp. current_hi . borrow ( ) ;
236+ if let Some ( i) = i {
237+ let scroll_progress = imp. scroll_win . vadjustment ( ) . value ( ) ;
238+ history[ i] . scroll_progress = scroll_progress;
239+ history. truncate ( i + 1 ) ;
240+ } ;
241+ history. push ( item) ;
242+ let i = history. len ( ) - 1 ;
243+ imp. current_hi . replace ( Some ( i) ) ;
244+ i
239245 } ;
240- history. push ( item) ;
241- let i = history. len ( ) - 1 ;
242- imp. current_hi . replace ( Some ( i) ) ;
246+ self . notify ( "history-status" ) ;
243247 self . log_history_position ( ) ;
244248 i
245249 }
@@ -293,6 +297,9 @@ impl Tab {
293297 let imp = self . imp ( ) ;
294298 let mut draw_ctx = imp. draw_ctx . borrow ( ) . clone ( ) . unwrap ( ) ;
295299
300+ * self . imp ( ) . progress . borrow_mut ( ) = 0.0 ;
301+ self . notify ( "progress" ) ;
302+
296303 * self . imp ( ) . title . borrow_mut ( ) = url. to_string ( ) ;
297304 self . notify ( "title" ) ;
298305
@@ -326,6 +333,7 @@ impl Tab {
326333 } ;
327334 imp. current_hi . replace ( Some ( i) ) ;
328335 self . log_history_position ( ) ;
336+ self . notify ( "history-status" ) ;
329337
330338 let h = { imp. history . borrow_mut ( ) . get ( i) . cloned ( ) } ;
331339 h. map ( |x| self . spawn_request ( self . open_history ( x) ) )
@@ -342,6 +350,7 @@ impl Tab {
342350 } ;
343351 imp. current_hi . replace ( Some ( i) ) ;
344352 self . log_history_position ( ) ;
353+ self . notify ( "history-status" ) ;
345354
346355 let h = { imp. history . borrow_mut ( ) . get ( i) . cloned ( ) } ;
347356 h. map ( |x| self . spawn_request ( self . open_history ( x) ) )
0 commit comments