@@ -4,7 +4,7 @@ use url::Url;
44use wxdragon:: prelude:: * ;
55
66use crate :: {
7- config:: { Account , ContentWarningDisplay , SortOrder , TimestampFormat } ,
7+ config:: { Account , AutoloadMode , ContentWarningDisplay , SortOrder , TimestampFormat } ,
88 html:: { self , Link } ,
99 mastodon:: { Account as MastodonAccount , PollLimits , Status } ,
1010 network:: { NetworkCommand , ProfileUpdate } ,
@@ -656,12 +656,12 @@ pub fn prompt_for_options(
656656 enter_to_send : bool ,
657657 always_show_link_dialog : bool ,
658658 quick_action_keys : bool ,
659- autoload : bool ,
659+ autoload : AutoloadMode ,
660660 fetch_limit : u8 ,
661661 content_warning_display : ContentWarningDisplay ,
662662 sort_order : SortOrder ,
663663 timestamp_format : TimestampFormat ,
664- ) -> Option < ( bool , bool , bool , bool , u8 , ContentWarningDisplay , SortOrder , TimestampFormat ) > {
664+ ) -> Option < ( bool , bool , bool , AutoloadMode , u8 , ContentWarningDisplay , SortOrder , TimestampFormat ) > {
665665 let dialog = Dialog :: builder ( frame, "Options" ) . with_size ( 400 , 450 ) . build ( ) ;
666666 let panel = Panel :: builder ( & dialog) . build ( ) ;
667667 let main_sizer = BoxSizer :: builder ( Orientation :: Vertical ) . build ( ) ;
@@ -671,8 +671,20 @@ pub fn prompt_for_options(
671671 link_checkbox. set_value ( always_show_link_dialog) ;
672672 let quick_action_checkbox = CheckBox :: builder ( & panel) . with_label ( "Use &quick action keys in timelines" ) . build ( ) ;
673673 quick_action_checkbox. set_value ( quick_action_keys) ;
674- let autoload_checkbox = CheckBox :: builder ( & panel) . with_label ( "&Autoload posts when scrolling" ) . build ( ) ;
675- autoload_checkbox. set_value ( autoload) ;
674+ let autoload_label = StaticText :: builder ( & panel) . with_label ( "&Autoload posts:" ) . build ( ) ;
675+ let autoload_choices =
676+ vec ! [ "Never" . to_string( ) , "When reaching the end" . to_string( ) , "When navigating past the end" . to_string( ) ] ;
677+ let autoload_choice =
678+ ComboBox :: builder ( & panel) . with_choices ( autoload_choices) . with_style ( ComboBoxStyle :: ReadOnly ) . build ( ) ;
679+ let autoload_index = match autoload {
680+ AutoloadMode :: Never => 0 ,
681+ AutoloadMode :: AtEnd => 1 ,
682+ AutoloadMode :: AtBoundary => 2 ,
683+ } ;
684+ autoload_choice. set_selection ( autoload_index) ;
685+ let autoload_sizer = BoxSizer :: builder ( Orientation :: Horizontal ) . build ( ) ;
686+ autoload_sizer. add ( & autoload_label, 0 , SizerFlag :: AlignCenterVertical | SizerFlag :: Right , 8 ) ;
687+ autoload_sizer. add ( & autoload_choice, 1 , SizerFlag :: Expand , 0 ) ;
676688 let fetch_limit_label = StaticText :: builder ( & panel) . with_label ( "Posts to &fetch when loading more:" ) . build ( ) ;
677689 let fetch_limit_spin = SpinCtrl :: builder ( & panel) . with_range ( 1 , 40 ) . with_initial_value ( fetch_limit as i32 ) . build ( ) ;
678690 let fetch_limit_sizer = BoxSizer :: builder ( Orientation :: Horizontal ) . build ( ) ;
@@ -704,7 +716,7 @@ pub fn prompt_for_options(
704716 main_sizer. add ( & enter_checkbox, 0 , SizerFlag :: Expand | SizerFlag :: All , 8 ) ;
705717 main_sizer. add ( & link_checkbox, 0 , SizerFlag :: Expand | SizerFlag :: All , 8 ) ;
706718 main_sizer. add ( & quick_action_checkbox, 0 , SizerFlag :: Expand | SizerFlag :: All , 8 ) ;
707- main_sizer. add ( & autoload_checkbox , 0 , SizerFlag :: Expand | SizerFlag :: All , 8 ) ;
719+ main_sizer. add_sizer ( & autoload_sizer , 0 , SizerFlag :: Expand | SizerFlag :: All , 8 ) ;
708720 main_sizer. add_sizer ( & fetch_limit_sizer, 0 , SizerFlag :: Expand | SizerFlag :: All , 8 ) ;
709721 main_sizer. add_sizer ( & cw_sizer, 0 , SizerFlag :: Expand | SizerFlag :: All , 8 ) ;
710722 main_sizer. add ( & timestamp_checkbox, 0 , SizerFlag :: Expand | SizerFlag :: All , 8 ) ;
@@ -731,12 +743,18 @@ pub fn prompt_for_options(
731743 Some ( 2 ) => ContentWarningDisplay :: WarningOnly ,
732744 _ => content_warning_display,
733745 } ;
746+ let new_autoload = match autoload_choice. get_selection ( ) {
747+ Some ( 0 ) => AutoloadMode :: Never ,
748+ Some ( 1 ) => AutoloadMode :: AtEnd ,
749+ Some ( 2 ) => AutoloadMode :: AtBoundary ,
750+ _ => autoload,
751+ } ;
734752 let new_fetch_limit = ( fetch_limit_spin. value ( ) as u8 ) . clamp ( 1 , 40 ) ;
735753 Some ( (
736754 enter_checkbox. get_value ( ) ,
737755 link_checkbox. get_value ( ) ,
738756 quick_action_checkbox. get_value ( ) ,
739- autoload_checkbox . get_value ( ) ,
757+ new_autoload ,
740758 new_fetch_limit,
741759 new_cw_display,
742760 new_sort,
0 commit comments