11use adw:: prelude:: * ;
22use adw:: subclass:: application_window:: AdwApplicationWindowImpl ;
33use anyhow:: Context ;
4+ use config:: APP_ID ;
45use futures:: prelude:: * ;
56use glib:: { clone, Properties } ;
67use gtk:: gdk;
@@ -20,12 +21,12 @@ use crate::config;
2021use crate :: self_action;
2122use crate :: widgets:: tab:: { HistoryStatus , Tab } ;
2223
23- const ZOOM_CHANGE_FACTOR : f32 = 1.15 ;
24- const ZOOM_MAX_FACTOR : f32 = 5.0 ;
24+ const ZOOM_CHANGE_FACTOR : f64 = 1.15 ;
25+ const ZOOM_MAX_FACTOR : f64 = 5.0 ;
2526
2627#[ derive( Debug , Clone , Default ) ]
2728pub ( crate ) struct Zoom {
28- value : f32 ,
29+ value : f64 ,
2930 provider : gtk:: CssProvider ,
3031}
3132
@@ -62,8 +63,9 @@ pub mod imp {
6263 pub ( crate ) action_previous : RefCell < Option < gio:: SimpleAction > > ,
6364 pub ( crate ) action_next : RefCell < Option < gio:: SimpleAction > > ,
6465 pub ( crate ) style_provider : RefCell < gtk:: CssProvider > ,
65- #[ property( get, set = Self :: set_zoom, type = f32 , member = value) ]
66+ #[ property( get, set = Self :: set_zoom, type = f64 , member = value) ]
6667 pub ( crate ) zoom : RefCell < Zoom > ,
68+ pub ( crate ) settings : RefCell < Option < gio:: Settings > > , // TODO: May use ConstructCell
6769 }
6870
6971 impl Window {
@@ -96,7 +98,7 @@ pub mod imp {
9698 animation. play ( ) ;
9799 self . progress_animation . replace ( Some ( animation) ) ;
98100 }
99- fn set_zoom ( & self , v : f32 ) {
101+ fn set_zoom ( & self , v : f64 ) {
100102 let Zoom { value, provider } = & mut * self . zoom . borrow_mut ( ) ;
101103 * value = v. clamp ( 1.0 / ZOOM_MAX_FACTOR , ZOOM_MAX_FACTOR ) ;
102104 provider. load_from_data (
@@ -194,7 +196,7 @@ impl Window {
194196 value_btn. set_hexpand ( true ) ;
195197 this. bind_property ( "zoom" , & value_btn, "label" )
196198 . transform_to ( |_, v| {
197- let zoom: f32 = v. get ( ) . unwrap ( ) ;
199+ let zoom: f64 = v. get ( ) . unwrap ( ) ;
198200 Some ( format ! ( "{:3}%" , ( zoom * 100.0 ) as usize ) . to_value ( ) )
199201 } )
200202 . build ( ) ;
@@ -213,6 +215,10 @@ impl Window {
213215 ) ;
214216 popover. add_child ( & zoom_box, "zoom" ) ;
215217
218+ let settings = gio:: Settings :: new ( APP_ID ) ;
219+ settings. bind ( "zoom" , & this, "zoom" ) . build ( ) ;
220+ imp. settings . replace ( Some ( settings) ) ;
221+
216222 this. squeezer_changed ( ) ;
217223 this. setup_actions_signals ( ) ;
218224 this. open_in_new_tab ( bookmarks_url ( ) . as_str ( ) ) ;
0 commit comments