Use regular view macro where more appropriate

This commit is contained in:
Reinout Meliesie 2026-01-02 13:59:28 +01:00
commit 1101e96765
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
4 changed files with 33 additions and 34 deletions

View file

@ -4,10 +4,10 @@ use gtk4 :: Box ;
use gtk4 :: Align :: * ;
use gtk4 :: Orientation :: * ;
use gtk4 :: prelude :: * ;
use relm4_macros :: * ;
use std :: ops :: * ;
use crate :: ui :: component :: * ;
use crate :: ui :: utility :: * ;
use crate :: ui :: collatable_container :: * ;
use crate :: ui :: collatable_container :: collation_menu :: sort_button :: * ;
@ -19,16 +19,16 @@ impl MediaCollationMenu {
pub fn new < A : MediaAdapter > ( on_sort : impl Fn ( A :: Sorting ) + 'static ) -> Self {
let sort_button = MediaSortButton :: <A> :: new (on_sort) ;
let widget = view_expr ! {
gtk4 :: Box {
view ! {
widget = gtk4 :: Box {
set_spacing : 20 ,
set_css_classes : & [ "toolbar" , "collation-menu" ] ,
set_halign : Center ,
set_orientation : Horizontal ,
append : sort_button . get_widget () ,
}
} ;
} ,
}
Self { widget }
}

View file

@ -1,6 +1,7 @@
use gtk4 :: { Image , ListBox , Popover } ;
use gtk4 :: Align :: * ;
use libadwaita :: SplitButton ;
use relm4_macros :: * ;
use std :: cell :: * ;
use crate :: utility :: * ;
@ -30,16 +31,28 @@ impl < A : MediaAdapter > MediaSortButton <A> {
Box :: leak ( sort_icons . into_boxed_slice () ) as & 'static _
} ;
let list_box = view_expr ! {
ListBox {
view ! {
list_box = ListBox {
connect_row_activated : move | _ , row | on_media_sort_activated :: <A> (
row . index () ,
previous_sorting ,
& on_sort ,
sort_icons ,
) ,
}
} ;
} ,
widget = SplitButton {
set_popover : Some ( & view_expr ! {
Popover {
set_css_classes : & [ "menu" ] ,
set_child : Some ( & list_box ) ,
}
} ) ,
set_child : Some ( & view_expr ! {
Label { set_label : "Sort" }
} ) ,
} ,
}
for ( index , ( _ , description ) ) in property_descriptions . iter () . enumerate () {
list_box . append ( & view_expr ! {
gtk4 :: Box {
@ -57,20 +70,6 @@ impl < A : MediaAdapter > MediaSortButton <A> {
} ) ;
}
let widget = view_expr ! {
SplitButton {
set_popover : Some ( & view_expr ! {
Popover {
set_css_classes : & [ "menu" ] ,
set_child : Some ( & list_box ) ,
}
} ) ,
set_child : Some ( & view_expr ! {
Label { set_label : "Sort" }
} ) ,
}
} ;
Self { widget , previous_sorting }
}
}

View file

@ -4,6 +4,7 @@ mod collation_menu ;
use gtk4 :: { Box , ScrolledWindow } ;
use gtk4 :: Orientation :: * ;
use gtk4 :: prelude :: * ;
use relm4_macros :: * ;
use std :: cmp :: * ;
use std :: fmt :: * ;
@ -73,8 +74,8 @@ impl < A : MediaAdapter > CollatableMediaContainer <A> {
|sorting| collated_grid . set_sorting (sorting) ,
) ;
let widget = view_expr ! {
gtk4 :: Box {
view ! {
widget = gtk4 :: Box {
set_orientation : Vertical ,
append : collation_menu . get_widget () ,
append : & view_expr ! {
@ -84,7 +85,7 @@ impl < A : MediaAdapter > CollatableMediaContainer <A> {
}
} ,
}
} ;
}
Self { collated_grid, widget }
}

View file

@ -96,22 +96,21 @@ impl UI {
Dialog { present : Some ( & window . libadwaita_window ) }
} ;
} ) ;
let switched = view_expr ! {
ViewStack {
view ! {
switched = ViewStack {
add_titled_with_icon : ( films_component . get_widget () , None , "Films" , "camera-video-symbolic" ) ,
add_titled_with_icon : ( series_component . get_widget () , None , "Series" , "video-display-symbolic" ) ,
}
} ;
let header_bar = view_expr ! {
HeaderBar {
} ,
header_bar = HeaderBar {
set_title_widget : Some ( & view_expr ! {
ViewSwitcher {
set_policy : Wide ,
set_stack : Some ( & switched ) ,
}
} ) ,
}
} ;
} ,
}
window . libadwaita_window . set_content ( Some ( & view_expr ! {
ToolbarView {