@@ -49,6 +49,8 @@ pub mod imp {
4949 pub ( crate ) progress_bar : TemplateChild < gtk:: ProgressBar > ,
5050 #[ template_child]
5151 pub ( crate ) tab_view : TemplateChild < adw:: TabView > ,
52+ #[ template_child]
53+ pub ( crate ) primary_menu_btn : TemplateChild < gtk:: MenuButton > ,
5254 pub ( crate ) config : RefCell < config:: Config > ,
5355 pub ( crate ) progress_animation : RefCell < Option < adw:: SpringAnimation > > ,
5456 pub ( crate ) binded_tab_properties : RefCell < Vec < glib:: Binding > > ,
@@ -60,7 +62,7 @@ pub mod imp {
6062 pub ( crate ) action_previous : RefCell < Option < gio:: SimpleAction > > ,
6163 pub ( crate ) action_next : RefCell < Option < gio:: SimpleAction > > ,
6264 pub ( crate ) style_provider : RefCell < gtk:: CssProvider > ,
63- #[ property( get = Self :: zoom , set = Self :: set_zoom, type = f32 , member = value) ]
65+ #[ property( get, set = Self :: set_zoom, type = f32 , member = value) ]
6466 pub ( crate ) zoom : RefCell < Zoom > ,
6567 }
6668
@@ -94,9 +96,6 @@ pub mod imp {
9496 animation. play ( ) ;
9597 self . progress_animation . replace ( Some ( animation) ) ;
9698 }
97- fn zoom ( & self ) -> f32 {
98- self . zoom . borrow ( ) . value
99- }
10099 fn set_zoom ( & self , v : f32 ) {
101100 let Zoom { value, provider } = & mut * self . zoom . borrow_mut ( ) ;
102101 * value = v. clamp ( 1.0 / ZOOM_MAX_FACTOR , ZOOM_MAX_FACTOR ) ;
@@ -176,6 +175,44 @@ impl Window {
176175 gtk:: STYLE_PROVIDER_PRIORITY_APPLICATION ,
177176 ) ;
178177
178+ let popover: gtk:: PopoverMenu = imp. primary_menu_btn . popover ( ) . unwrap ( ) . downcast ( ) . unwrap ( ) ;
179+ let zoom_box = gtk:: Box :: builder ( )
180+ . spacing ( 12 )
181+ . margin_start ( 18 )
182+ . margin_end ( 18 )
183+ . build ( ) ;
184+
185+ zoom_box. append (
186+ & gtk:: Button :: builder ( )
187+ . icon_name ( "zoom-out-symbolic" )
188+ . action_name ( "win.zoom-out" )
189+ . css_classes ( vec ! [ "flat" . into( ) , "circular" . into( ) ] )
190+ . build ( ) ,
191+ ) ;
192+
193+ let value_btn = gtk:: Button :: with_label ( "100%" ) ;
194+ value_btn. set_hexpand ( true ) ;
195+ this. bind_property ( "zoom" , & value_btn, "label" )
196+ . transform_to ( |_, v| {
197+ let zoom: f32 = v. get ( ) . unwrap ( ) ;
198+ Some ( format ! ( "{:3}%" , ( zoom * 100.0 ) as usize ) . to_value ( ) )
199+ } )
200+ . build ( ) ;
201+ value_btn. set_action_name ( Some ( "win.reset-zoom" ) ) ;
202+ value_btn. add_css_class ( "flat" ) ;
203+ value_btn. add_css_class ( "body" ) ;
204+ value_btn. add_css_class ( "numeric" ) ;
205+
206+ zoom_box. append ( & value_btn) ;
207+ zoom_box. append (
208+ & gtk:: Button :: builder ( )
209+ . icon_name ( "zoom-in-symbolic" )
210+ . css_classes ( vec ! [ "flat" . into( ) , "circular" . into( ) ] )
211+ . action_name ( "win.zoom-in" )
212+ . build ( ) ,
213+ ) ;
214+ popover. add_child ( & zoom_box, "zoom" ) ;
215+
179216 this. squeezer_changed ( ) ;
180217 this. setup_actions_signals ( ) ;
181218 this. open_in_new_tab ( bookmarks_url ( ) . as_str ( ) ) ;
@@ -236,9 +273,19 @@ impl Window {
236273 imp. scroll_ctrl
237274 . set_flags ( gtk:: EventControllerScrollFlags :: VERTICAL ) ;
238275 imp. scroll_ctrl . connect_scroll (
239- clone ! ( @weak self as this => @default -panic, move |_, _, y| {
240- this. imp( ) . bottom_bar_revealer. set_reveal_child( y < 0.0 && this. is_small_screen( ) ) ;
276+ clone ! ( @weak self as this => @default -panic, move |ctrl, _, y| {
277+ let up = y < 0.0 ;
278+ if let Some ( true ) = ctrl. current_event( ) . map( |e| e. modifier_state( ) ) . map( |m| m == gdk:: ModifierType :: CONTROL_MASK ) {
279+ if up {
280+ this. zoom_in( ) ;
281+ } else {
282+ this. zoom_out( ) ;
283+ }
284+ gtk:: Inhibit ( true )
285+ } else {
286+ this. imp( ) . bottom_bar_revealer. set_reveal_child( up && this. is_small_screen( ) ) ;
241287 gtk:: Inhibit ( false )
288+ }
242289 } ) ,
243290 ) ;
244291 self . connect_local (
0 commit comments