Formatting in collation_menu

This commit is contained in:
Reinout Meliesie 2024-12-23 23:41:08 +01:00
parent e29c555412
commit 70e8121a2a
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6

View file

@ -16,8 +16,7 @@ pub struct FilmCollationMenu { widget : Box }
pub struct SeriesCollationMenu { widget : Box } pub struct SeriesCollationMenu { widget : Box }
impl FilmCollationMenu { impl FilmCollationMenu {
pub fn new <F> ( on_sort : F ) -> Self pub fn new < F : Fn (FilmsSortedBy) + 'static > ( on_sort : F ) -> Self {
where F : Fn (FilmsSortedBy) + 'static {
let widget = Box :: builder () let widget = Box :: builder ()
. orientation (Horizontal) . orientation (Horizontal)
. halign (Center) . halign (Center)
@ -62,8 +61,7 @@ fn create_sort_button ( sort_menu : & Popover ) -> SplitButton {
. build () . build ()
} }
fn create_films_sort_menu <F> ( on_sort : F ) -> Popover fn create_films_sort_menu < F : Fn (FilmsSortedBy) + 'static > ( on_sort : F ) -> Popover {
where F : Fn (FilmsSortedBy) + 'static {
let container = ListBox :: new () ; let container = ListBox :: new () ;
container . append ( & create_sort_menu_entry ( "Name" , false , true ) ) ; container . append ( & create_sort_menu_entry ( "Name" , false , true ) ) ;
@ -84,8 +82,7 @@ where F : Fn (FilmsSortedBy) + 'static {
. css_classes ( ["menu"] ) . css_classes ( ["menu"] )
. build () . build ()
} }
fn create_series_sort_menu <F> ( on_sort : F ) -> Popover fn create_series_sort_menu < F : Fn (SeriesSortedBy) + 'static > ( on_sort : F ) -> Popover {
where F : Fn (SeriesSortedBy) + 'static {
let container = ListBox :: new () ; let container = ListBox :: new () ;
container . append ( & create_sort_menu_entry ( "Name" , false , true ) ) ; container . append ( & create_sort_menu_entry ( "Name" , false , true ) ) ;
@ -105,9 +102,7 @@ where F : Fn (SeriesSortedBy) + 'static {
. build () . build ()
} }
fn create_sort_menu_entry ( fn create_sort_menu_entry ( label : & str , reverse : bool , selected : bool ) -> ListBoxRow {
label : & str , reverse : bool , selected : bool ,
) -> ListBoxRow {
let icon = match reverse { let icon = match reverse {
false => Image :: from_icon_name ("view-sort-ascending-symbolic") , false => Image :: from_icon_name ("view-sort-ascending-symbolic") ,
true => Image :: from_icon_name ("view-sort-descending-symbolic") , true => Image :: from_icon_name ("view-sort-descending-symbolic") ,