Use regular view macro where more appropriate
This commit is contained in:
parent
0a61e55c3e
commit
1101e96765
4 changed files with 33 additions and 34 deletions
|
|
@ -4,10 +4,10 @@ use gtk4 :: Box ;
|
||||||
use gtk4 :: Align :: * ;
|
use gtk4 :: Align :: * ;
|
||||||
use gtk4 :: Orientation :: * ;
|
use gtk4 :: Orientation :: * ;
|
||||||
use gtk4 :: prelude :: * ;
|
use gtk4 :: prelude :: * ;
|
||||||
|
use relm4_macros :: * ;
|
||||||
use std :: ops :: * ;
|
use std :: ops :: * ;
|
||||||
|
|
||||||
use crate :: ui :: component :: * ;
|
use crate :: ui :: component :: * ;
|
||||||
use crate :: ui :: utility :: * ;
|
|
||||||
use crate :: ui :: collatable_container :: * ;
|
use crate :: ui :: collatable_container :: * ;
|
||||||
use crate :: ui :: collatable_container :: collation_menu :: sort_button :: * ;
|
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 {
|
pub fn new < A : MediaAdapter > ( on_sort : impl Fn ( A :: Sorting ) + 'static ) -> Self {
|
||||||
let sort_button = MediaSortButton :: <A> :: new (on_sort) ;
|
let sort_button = MediaSortButton :: <A> :: new (on_sort) ;
|
||||||
|
|
||||||
let widget = view_expr ! {
|
view ! {
|
||||||
gtk4 :: Box {
|
widget = gtk4 :: Box {
|
||||||
set_spacing : 20 ,
|
set_spacing : 20 ,
|
||||||
set_css_classes : & [ "toolbar" , "collation-menu" ] ,
|
set_css_classes : & [ "toolbar" , "collation-menu" ] ,
|
||||||
set_halign : Center ,
|
set_halign : Center ,
|
||||||
set_orientation : Horizontal ,
|
set_orientation : Horizontal ,
|
||||||
|
|
||||||
append : sort_button . get_widget () ,
|
append : sort_button . get_widget () ,
|
||||||
}
|
} ,
|
||||||
} ;
|
}
|
||||||
|
|
||||||
Self { widget }
|
Self { widget }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use gtk4 :: { Image , ListBox , Popover } ;
|
use gtk4 :: { Image , ListBox , Popover } ;
|
||||||
use gtk4 :: Align :: * ;
|
use gtk4 :: Align :: * ;
|
||||||
use libadwaita :: SplitButton ;
|
use libadwaita :: SplitButton ;
|
||||||
|
use relm4_macros :: * ;
|
||||||
use std :: cell :: * ;
|
use std :: cell :: * ;
|
||||||
|
|
||||||
use crate :: utility :: * ;
|
use crate :: utility :: * ;
|
||||||
|
|
@ -30,16 +31,28 @@ impl < A : MediaAdapter > MediaSortButton <A> {
|
||||||
Box :: leak ( sort_icons . into_boxed_slice () ) as & 'static _
|
Box :: leak ( sort_icons . into_boxed_slice () ) as & 'static _
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
let list_box = view_expr ! {
|
view ! {
|
||||||
ListBox {
|
list_box = ListBox {
|
||||||
connect_row_activated : move | _ , row | on_media_sort_activated :: <A> (
|
connect_row_activated : move | _ , row | on_media_sort_activated :: <A> (
|
||||||
row . index () ,
|
row . index () ,
|
||||||
previous_sorting ,
|
previous_sorting ,
|
||||||
& on_sort ,
|
& on_sort ,
|
||||||
sort_icons ,
|
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 () {
|
for ( index , ( _ , description ) ) in property_descriptions . iter () . enumerate () {
|
||||||
list_box . append ( & view_expr ! {
|
list_box . append ( & view_expr ! {
|
||||||
gtk4 :: Box {
|
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 }
|
Self { widget , previous_sorting }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ mod collation_menu ;
|
||||||
use gtk4 :: { Box , ScrolledWindow } ;
|
use gtk4 :: { Box , ScrolledWindow } ;
|
||||||
use gtk4 :: Orientation :: * ;
|
use gtk4 :: Orientation :: * ;
|
||||||
use gtk4 :: prelude :: * ;
|
use gtk4 :: prelude :: * ;
|
||||||
|
use relm4_macros :: * ;
|
||||||
use std :: cmp :: * ;
|
use std :: cmp :: * ;
|
||||||
use std :: fmt :: * ;
|
use std :: fmt :: * ;
|
||||||
|
|
||||||
|
|
@ -73,8 +74,8 @@ impl < A : MediaAdapter > CollatableMediaContainer <A> {
|
||||||
|sorting| collated_grid . set_sorting (sorting) ,
|
|sorting| collated_grid . set_sorting (sorting) ,
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
let widget = view_expr ! {
|
view ! {
|
||||||
gtk4 :: Box {
|
widget = gtk4 :: Box {
|
||||||
set_orientation : Vertical ,
|
set_orientation : Vertical ,
|
||||||
append : collation_menu . get_widget () ,
|
append : collation_menu . get_widget () ,
|
||||||
append : & view_expr ! {
|
append : & view_expr ! {
|
||||||
|
|
@ -84,7 +85,7 @@ impl < A : MediaAdapter > CollatableMediaContainer <A> {
|
||||||
}
|
}
|
||||||
} ,
|
} ,
|
||||||
}
|
}
|
||||||
} ;
|
}
|
||||||
|
|
||||||
Self { collated_grid, widget }
|
Self { collated_grid, widget }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,22 +96,21 @@ impl UI {
|
||||||
Dialog { present : Some ( & window . libadwaita_window ) }
|
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 : ( films_component . get_widget () , None , "Films" , "camera-video-symbolic" ) ,
|
||||||
add_titled_with_icon : ( series_component . get_widget () , None , "Series" , "video-display-symbolic" ) ,
|
add_titled_with_icon : ( series_component . get_widget () , None , "Series" , "video-display-symbolic" ) ,
|
||||||
}
|
} ,
|
||||||
} ;
|
header_bar = HeaderBar {
|
||||||
let header_bar = view_expr ! {
|
|
||||||
HeaderBar {
|
|
||||||
set_title_widget : Some ( & view_expr ! {
|
set_title_widget : Some ( & view_expr ! {
|
||||||
ViewSwitcher {
|
ViewSwitcher {
|
||||||
set_policy : Wide ,
|
set_policy : Wide ,
|
||||||
set_stack : Some ( & switched ) ,
|
set_stack : Some ( & switched ) ,
|
||||||
}
|
}
|
||||||
} ) ,
|
} ) ,
|
||||||
}
|
} ,
|
||||||
} ;
|
}
|
||||||
|
|
||||||
window . libadwaita_window . set_content ( Some ( & view_expr ! {
|
window . libadwaita_window . set_content ( Some ( & view_expr ! {
|
||||||
ToolbarView {
|
ToolbarView {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue