From 1101e96765923535af5d43c46c5cbb9e1c773790 Mon Sep 17 00:00:00 2001 From: Reinout Meliesie Date: Fri, 2 Jan 2026 13:59:28 +0100 Subject: [PATCH] Use regular view macro where more appropriate --- .../collation_menu/mod.rs | 10 +++--- .../collation_menu/sort_button.rs | 35 +++++++++---------- src/ui/collatable_container/mod.rs | 7 ++-- src/ui/mod.rs | 15 ++++---- 4 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/ui/collatable_container/collation_menu/mod.rs b/src/ui/collatable_container/collation_menu/mod.rs index 492b080..abdac94 100644 --- a/src/ui/collatable_container/collation_menu/mod.rs +++ b/src/ui/collatable_container/collation_menu/mod.rs @@ -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 :: :: 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 } } diff --git a/src/ui/collatable_container/collation_menu/sort_button.rs b/src/ui/collatable_container/collation_menu/sort_button.rs index 920a213..3665e79 100644 --- a/src/ui/collatable_container/collation_menu/sort_button.rs +++ b/src/ui/collatable_container/collation_menu/sort_button.rs @@ -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 { 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 :: ( 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 { } ) ; } - 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 } } } diff --git a/src/ui/collatable_container/mod.rs b/src/ui/collatable_container/mod.rs index cc1ceaf..24b9695 100644 --- a/src/ui/collatable_container/mod.rs +++ b/src/ui/collatable_container/mod.rs @@ -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 { |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 { } } , } - } ; + } Self { collated_grid, widget } } diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 1444ecc..3e853b2 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -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 {