Introduce image UI macro, require explicit borrowing in UI macros
This commit is contained in:
parent
0dffdbc660
commit
38adb5f4b9
7 changed files with 88 additions and 75 deletions
|
|
@ -156,11 +156,11 @@ async fn create_collection_item (
|
|||
poster_file_path : Option < & Path > ,
|
||||
details_widget : & Box ,
|
||||
) -> Box {
|
||||
let container = Box :: builder ()
|
||||
. orientation (Vertical)
|
||||
. margin_top (20)
|
||||
. margin_bottom (20)
|
||||
. build () ;
|
||||
let container = g_box ! (
|
||||
@ orientation : Vertical ;
|
||||
@ margin_top : 20 ;
|
||||
@ margin_bottom : 20 ;
|
||||
) ;
|
||||
|
||||
if let Some (poster_file_path) = poster_file_path {
|
||||
let poster_file_path = PathBuf :: from (poster_file_path) ; // God forbid `Path` would work with `clone ! ()`
|
||||
|
|
@ -169,12 +169,12 @@ async fn create_collection_item (
|
|||
) . await . unwrap () ;
|
||||
|
||||
container . append (
|
||||
& Image :: builder ()
|
||||
. paintable ( & poster_texture )
|
||||
. width_request (300)
|
||||
. height_request (300)
|
||||
. margin_bottom (10)
|
||||
. build ()
|
||||
& image ! (
|
||||
@ paintable : & poster_texture ;
|
||||
@ width_request : 300 ;
|
||||
@ height_request : 300 ;
|
||||
@ margin_bottom : 10 ;
|
||||
)
|
||||
) ;
|
||||
}
|
||||
|
||||
|
|
@ -209,8 +209,8 @@ fn create_film_details ( film : & FilmOverview ) -> Box {
|
|||
@ orientation : Horizontal ;
|
||||
@ halign : Center ;
|
||||
@ spacing : 20 ;
|
||||
label ! ( film . release_date . as_str () ) ,
|
||||
label ! ( format ! ( "{}m" , film . runtime_minutes ) . as_str () ) ,
|
||||
& label ! ( film . release_date . as_str () ) ,
|
||||
& label ! ( format ! ( "{}m" , film . runtime_minutes ) . as_str () ) ,
|
||||
)
|
||||
}
|
||||
fn create_series_details ( series : & SeriesOverview ) -> Box {
|
||||
|
|
@ -218,6 +218,6 @@ fn create_series_details ( series : & SeriesOverview ) -> Box {
|
|||
@ orientation : Horizontal ;
|
||||
@ halign : Center ;
|
||||
@ spacing : 20 ;
|
||||
label ! ( series . first_release_date . as_str () ) ,
|
||||
& label ! ( series . first_release_date . as_str () ) ,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ impl FilmCollationMenu {
|
|||
@ halign : Center ;
|
||||
@ spacing : 20 ;
|
||||
@ widget_name : "film-collation-menu" ;
|
||||
@ css_classes : [ "toolbar" ] ;
|
||||
* film_sort_button . get_widget () ,
|
||||
@ css_classes : & [ "toolbar" ] ;
|
||||
film_sort_button . get_widget () ,
|
||||
) ;
|
||||
|
||||
Self { widget }
|
||||
|
|
@ -41,8 +41,8 @@ impl SeriesCollationMenu {
|
|||
@ halign : Center ;
|
||||
@ spacing : 20 ;
|
||||
@ widget_name : "series-collation-menu" ;
|
||||
@ css_classes : [ "toolbar" ] ;
|
||||
* series_sort_button . get_widget () ,
|
||||
@ css_classes : & [ "toolbar" ] ;
|
||||
series_sort_button . get_widget () ,
|
||||
) ;
|
||||
|
||||
Self { widget }
|
||||
|
|
|
|||
|
|
@ -25,36 +25,36 @@ impl FilmSortButton {
|
|||
let previous_sorting = leak ( RefCell :: new ( FilmsSorting :: default () ) ) ;
|
||||
|
||||
let sort_icons = leak ( [
|
||||
icon ! ("view-sort-ascending-symbolic") ,
|
||||
icon ! ("view-sort-ascending-symbolic") ,
|
||||
icon ! ("view-sort-ascending-symbolic") ,
|
||||
image ! ( @ icon_name : "view-sort-ascending-symbolic" ; ) ,
|
||||
image ! ( @ icon_name : "view-sort-ascending-symbolic" ; ) ,
|
||||
image ! ( @ icon_name : "view-sort-ascending-symbolic" ; ) ,
|
||||
] ) ;
|
||||
|
||||
let widget = split_button ! (
|
||||
@ popover : popover ! (
|
||||
@ css_classes : [ "menu" ] ;
|
||||
list_box ! (
|
||||
@ popover : & popover ! (
|
||||
@ css_classes : & [ "menu" ] ;
|
||||
& list_box ! (
|
||||
@ connect_row_activated : move | _ , row | {
|
||||
on_film_sort_activated ( row , previous_sorting , & on_sort , sort_icons ) ;
|
||||
} ;
|
||||
g_box ! (
|
||||
& g_box ! (
|
||||
@ orientation : Horizontal ; @ spacing : 20 ;
|
||||
label ! ( @ hexpand : true ; @ halign : Start ; "Name" ) ,
|
||||
sort_icons [0] ,
|
||||
& label ! ( @ hexpand : true ; @ halign : Start ; "Name" ) ,
|
||||
& sort_icons [0] ,
|
||||
) ,
|
||||
g_box ! (
|
||||
& g_box ! (
|
||||
@ orientation : Horizontal ; @ spacing : 20 ;
|
||||
label ! ( @ hexpand : true ; @ halign : Start ; "Release date" ) ,
|
||||
sort_icons [1] ,
|
||||
& label ! ( @ hexpand : true ; @ halign : Start ; "Release date" ) ,
|
||||
& sort_icons [1] ,
|
||||
) ,
|
||||
g_box ! (
|
||||
& g_box ! (
|
||||
@ orientation : Horizontal ; @ spacing : 20 ;
|
||||
label ! ( @ hexpand : true ; @ halign : Start ; "Runtime" ) ,
|
||||
sort_icons [2] ,
|
||||
& label ! ( @ hexpand : true ; @ halign : Start ; "Runtime" ) ,
|
||||
& sort_icons [2] ,
|
||||
) ,
|
||||
) ,
|
||||
) ;
|
||||
label ! ("Sort") ,
|
||||
& label ! ("Sort") ,
|
||||
) ;
|
||||
|
||||
Self { widget , previous_sorting }
|
||||
|
|
@ -65,30 +65,29 @@ impl SeriesSortButton {
|
|||
let previous_sorting = leak ( RefCell :: new ( SeriesSorting :: default () ) ) ;
|
||||
|
||||
let sort_icons = leak ( [
|
||||
icon ! ("view-sort-ascending-symbolic") ,
|
||||
icon ! ("view-sort-ascending-symbolic") ,
|
||||
image ! ( @ icon_name : "view-sort-ascending-symbolic" ; ) ,
|
||||
image ! ( @ icon_name : "view-sort-ascending-symbolic" ; ) ,
|
||||
] ) ;
|
||||
|
||||
let widget = split_button ! (
|
||||
@ popover : popover ! (
|
||||
@ css_classes : [ "menu" ] ;
|
||||
list_box ! (
|
||||
@ connect_row_activated : move | _ , row | {
|
||||
@ popover : & popover ! (
|
||||
@ css_classes : & [ "menu" ] ;
|
||||
& list_box ! (
|
||||
@ connect_row_activated : move | _ , row |
|
||||
on_series_sort_activated ( row , previous_sorting , & on_sort , sort_icons ) ;
|
||||
} ;
|
||||
g_box ! (
|
||||
& g_box ! (
|
||||
@ orientation : Horizontal ; @ spacing : 20 ;
|
||||
label ! ( @ hexpand : true ; @ halign : Start ; "Name" ) ,
|
||||
sort_icons [0] ,
|
||||
& label ! ( @ hexpand : true ; @ halign : Start ; "Name" ) ,
|
||||
& sort_icons [0] ,
|
||||
) ,
|
||||
g_box ! (
|
||||
& g_box ! (
|
||||
@ orientation : Horizontal ; @ spacing : 20 ;
|
||||
label ! ( @ hexpand : true ; @ halign : Start ; "First release date" ) ,
|
||||
sort_icons [1] ,
|
||||
& label ! ( @ hexpand : true ; @ halign : Start ; "First release date" ) ,
|
||||
& sort_icons [1] ,
|
||||
) ,
|
||||
) ,
|
||||
) ;
|
||||
label ! ("Sort") ,
|
||||
& label ! ("Sort") ,
|
||||
) ;
|
||||
|
||||
Self { widget , previous_sorting }
|
||||
|
|
|
|||
|
|
@ -70,10 +70,10 @@ impl CollatableFilmsContainer {
|
|||
|
||||
let widget = g_box ! (
|
||||
@ orientation : Vertical ;
|
||||
* film_collation_menu . get_widget () ,
|
||||
scrolled_window ! (
|
||||
film_collation_menu . get_widget () ,
|
||||
& scrolled_window ! (
|
||||
@ propagate_natural_height : true ;
|
||||
vertically_filling ! ( * collated_grid . get_widget () ) ,
|
||||
& vertically_filling ! ( collated_grid . get_widget () ) ,
|
||||
) ,
|
||||
) ;
|
||||
|
||||
|
|
@ -92,10 +92,10 @@ impl CollatableSeriesContainer {
|
|||
|
||||
let widget = g_box ! (
|
||||
@ orientation : Vertical ;
|
||||
* series_collation_menu . get_widget () ,
|
||||
scrolled_window ! (
|
||||
series_collation_menu . get_widget () ,
|
||||
& scrolled_window ! (
|
||||
@ propagate_natural_height : true ;
|
||||
vertically_filling ! ( * collated_grid . get_widget () ) ,
|
||||
& vertically_filling ! ( collated_grid . get_widget () ) ,
|
||||
) ,
|
||||
) ;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue