11use gtk4 as gtk;
2- use gtk4:: gio;
32use gtk4:: prelude:: * ;
43use gtk4:: subclass:: prelude:: * ;
4+ use gtk4:: { gio, glib} ;
55
66use super :: {
77 BrowseModel , BrowseTab , BrowseTabInput , ClipboardInput , EditInput , PagingInput , SaveInput , SelectionInput ,
@@ -24,6 +24,10 @@ pub(super) struct BrowseActions {
2424 pub ( super ) delete_rows : gio:: SimpleAction ,
2525 pub ( super ) copy_rows : gio:: SimpleAction ,
2626 pub ( super ) clear_selection : gio:: SimpleAction ,
27+ /// The More menu's Count Rows, on where the pager offers it.
28+ pub ( super ) count_rows : gio:: SimpleAction ,
29+ /// The More menu's page sizes, its state the size the tab reads.
30+ pub ( super ) page_size : gio:: SimpleAction ,
2731}
2832
2933impl BrowseActions {
@@ -43,7 +47,7 @@ impl BrowseActions {
4347/// The tab's `browse` group, the tab's own keys for it and the keys its
4448/// buttons announce. The grid's keys go on each column view the tab
4549/// builds, through `install_grid_shortcuts`.
46- pub ( super ) fn install_browse_actions ( tab : & BrowseTab ) -> BrowseActions {
50+ pub ( super ) fn install_browse_actions ( tab : & BrowseTab , page_size : u64 ) -> BrowseActions {
4751 let group = gio:: SimpleActionGroup :: new ( ) ;
4852 let add = |name : & str , input : fn ( ) -> BrowseTabInput | {
4953 let action = gio:: SimpleAction :: new ( name, None ) ;
@@ -57,6 +61,16 @@ pub(super) fn install_browse_actions(tab: &BrowseTab) -> BrowseActions {
5761 action
5862 } ;
5963 add ( "filter" , || PagingInput :: ToggleFilterStrip . into ( ) ) ;
64+ add ( "export" , || ClipboardInput :: Export ( None ) . into ( ) ) ;
65+ let page_size =
66+ gio:: SimpleAction :: new_stateful ( "page-size" , Some ( glib:: VariantTy :: UINT64 ) , & page_size. to_variant ( ) ) ;
67+ let weak = tab. downgrade ( ) ;
68+ page_size. connect_change_state ( move |_, size| {
69+ if let ( Some ( tab) , Some ( size) ) = ( weak. upgrade ( ) , size. and_then ( u64:: from_variant) ) {
70+ tab. send ( PagingInput :: PageSizeChanged ( size) ) ;
71+ }
72+ } ) ;
73+ group. add_action ( & page_size) ;
6074 add ( "refresh" , || PagingInput :: RequestRefresh . into ( ) ) ;
6175 add ( "paste-rows" , || ClipboardInput :: PasteNotSupported . into ( ) ) ;
6276 let previous = add ( "previous-page" , || PagingInput :: PrevPage . into ( ) ) ;
@@ -80,6 +94,8 @@ pub(super) fn install_browse_actions(tab: &BrowseTab) -> BrowseActions {
8094 delete_rows,
8195 copy_rows : add ( "copy-rows" , || ClipboardInput :: CopySelectedRowsAsTsv . into ( ) ) ,
8296 clear_selection : add ( "clear-selection" , || SelectionInput :: ClearSelection . into ( ) ) ,
97+ count_rows : add ( "count-rows" , || PagingInput :: CountRows . into ( ) ) ,
98+ page_size,
8399 } ;
84100 for action in [
85101 & actions. save ,
@@ -89,6 +105,7 @@ pub(super) fn install_browse_actions(tab: &BrowseTab) -> BrowseActions {
89105 & actions. delete_rows ,
90106 & actions. copy_rows ,
91107 & actions. clear_selection ,
108+ & actions. count_rows ,
92109 ] {
93110 action. set_enabled ( false ) ;
94111 }
0 commit comments