Include static lifetime in MediaAdapter trait, formatting
This commit is contained in:
parent
be92920cc5
commit
2c40217497
5 changed files with 162 additions and 142 deletions
|
@ -16,7 +16,7 @@ use crate :: ui :: component :: * ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub struct CollatedMediaGrid < A : MediaAdapter + 'static > {
|
pub struct CollatedMediaGrid < A : MediaAdapter > {
|
||||||
media_widget_pairs : RefCell < Vec < ( A :: Overview , Button ) > > ,
|
media_widget_pairs : RefCell < Vec < ( A :: Overview , Button ) > > ,
|
||||||
grid_widget : FlowBox ,
|
grid_widget : FlowBox ,
|
||||||
on_media_selected : & 'static dyn Fn ( A :: Overview ) ,
|
on_media_selected : & 'static dyn Fn ( A :: Overview ) ,
|
||||||
|
@ -29,7 +29,7 @@ impl < A : MediaAdapter > CollatedMediaGrid <A> {
|
||||||
@ homogeneous : true ;
|
@ homogeneous : true ;
|
||||||
@ selection_mode : SelectionMode :: None ;
|
@ selection_mode : SelectionMode :: None ;
|
||||||
) ;
|
) ;
|
||||||
let media_widget_pairs = RefCell :: new ( vec ! () ) ;
|
let media_widget_pairs = RefCell :: new ( Vec :: new () ) ;
|
||||||
let on_media_selected = leak (on_media_selected) ;
|
let on_media_selected = leak (on_media_selected) ;
|
||||||
|
|
||||||
Self { media_widget_pairs , grid_widget , on_media_selected }
|
Self { media_widget_pairs , grid_widget , on_media_selected }
|
||||||
|
@ -127,8 +127,8 @@ impl < A : MediaAdapter > CollatedMediaGrid <A> {
|
||||||
self . media_widget_pairs . borrow () . as_slice () ,
|
self . media_widget_pairs . borrow () . as_slice () ,
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
sorted . sort_by ( | ( media_1 , _ ) , ( media_2 , _ ) |
|
sorted . sort_by (
|
||||||
A :: compare_by ( media_1 , media_2 , sorting ) ,
|
| ( media_1 , _ ) , ( media_2 , _ ) | A :: compare_by ( media_1 , media_2 , sorting ) ,
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
// See it, say it, ...
|
// See it, say it, ...
|
||||||
|
|
|
@ -16,7 +16,7 @@ use crate :: ui :: collatable_container :: collation_menu :: sort_button :: * ;
|
||||||
pub struct MediaCollationMenu { widget : Box }
|
pub struct MediaCollationMenu { widget : Box }
|
||||||
|
|
||||||
impl MediaCollationMenu {
|
impl MediaCollationMenu {
|
||||||
pub fn new < A : MediaAdapter + 'static > ( 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 = g_box ! (
|
let widget = g_box ! (
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate :: ui :: collatable_container :: SortingDirection :: * ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub struct MediaSortButton < A : MediaAdapter + 'static > {
|
pub struct MediaSortButton < A : MediaAdapter > {
|
||||||
widget : SplitButton ,
|
widget : SplitButton ,
|
||||||
previous_sorting : & 'static RefCell < A :: Sorting > ,
|
previous_sorting : & 'static RefCell < A :: Sorting > ,
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,13 @@ 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 = list_box ! ( @ connect_row_activated : move | _ , row |
|
let list_box = list_box ! (
|
||||||
on_media_sort_activated :: <A> ( row . index () , previous_sorting , & on_sort , sort_icons ) ;
|
@ connect_row_activated : move | _ , row | on_media_sort_activated :: <A> (
|
||||||
|
row . index () ,
|
||||||
|
previous_sorting ,
|
||||||
|
& on_sort ,
|
||||||
|
sort_icons ,
|
||||||
|
) ;
|
||||||
) ;
|
) ;
|
||||||
for ( index , ( _ , description ) ) in property_descriptions . iter () . enumerate () {
|
for ( index , ( _ , description ) ) in property_descriptions . iter () . enumerate () {
|
||||||
list_box . append ( & g_box ! (
|
list_box . append ( & g_box ! (
|
||||||
|
@ -52,7 +57,7 @@ impl < A : MediaAdapter > Component for MediaSortButton <A> {
|
||||||
fn get_widget ( & self ) -> & SplitButton { & self . widget }
|
fn get_widget ( & self ) -> & SplitButton { & self . widget }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_media_sort_activated < A : MediaAdapter + 'static > (
|
fn on_media_sort_activated < A : MediaAdapter > (
|
||||||
row : i32 ,
|
row : i32 ,
|
||||||
previous_sorting_mut : & RefCell < A :: Sorting > ,
|
previous_sorting_mut : & RefCell < A :: Sorting > ,
|
||||||
on_sort : & impl Fn ( A :: Sorting ) ,
|
on_sort : & impl Fn ( A :: Sorting ) ,
|
||||||
|
|
|
@ -61,7 +61,7 @@ impl MediaSorting <SeriesProperty> for SeriesSorting {
|
||||||
impl MediaProperty for FilmProperty {}
|
impl MediaProperty for FilmProperty {}
|
||||||
impl MediaProperty for SeriesProperty {}
|
impl MediaProperty for SeriesProperty {}
|
||||||
|
|
||||||
pub struct CollatableMediaContainer < A : MediaAdapter + 'static > {
|
pub struct CollatableMediaContainer < A : MediaAdapter > {
|
||||||
collated_grid : & 'static CollatedMediaGrid <A> ,
|
collated_grid : & 'static CollatedMediaGrid <A> ,
|
||||||
widget : Box ,
|
widget : Box ,
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,8 @@ pub struct CollatableMediaContainer < A : MediaAdapter + 'static > {
|
||||||
impl < A : MediaAdapter > CollatableMediaContainer <A> {
|
impl < A : MediaAdapter > CollatableMediaContainer <A> {
|
||||||
pub fn new ( on_media_selected : impl Fn ( A :: Overview ) + 'static ) -> Self {
|
pub fn new ( on_media_selected : impl Fn ( A :: Overview ) + 'static ) -> Self {
|
||||||
let collated_grid = leak ( CollatedMediaGrid :: new (on_media_selected) ) ;
|
let collated_grid = leak ( CollatedMediaGrid :: new (on_media_selected) ) ;
|
||||||
let collation_menu = MediaCollationMenu :: new :: <A> ( |sorting|
|
let collation_menu = MediaCollationMenu :: new :: <A> (
|
||||||
collated_grid . set_sorting (sorting) ,
|
|sorting| collated_grid . set_sorting (sorting) ,
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
let widget = g_box ! (
|
let widget = g_box ! (
|
||||||
|
@ -90,7 +90,7 @@ impl < A : MediaAdapter > CollatableMediaContainer <A> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait MediaAdapter {
|
pub trait MediaAdapter : 'static {
|
||||||
type Overview : MediaOverview ;
|
type Overview : MediaOverview ;
|
||||||
type Sorting : MediaSorting < Self :: Property > ;
|
type Sorting : MediaSorting < Self :: Property > ;
|
||||||
type Property : MediaProperty ;
|
type Property : MediaProperty ;
|
||||||
|
@ -120,9 +120,12 @@ impl MediaAdapter for FilmsAdapter {
|
||||||
sorting : FilmsSorting ,
|
sorting : FilmsSorting ,
|
||||||
) -> Ordering {
|
) -> Ordering {
|
||||||
let ordering = match sorting . property {
|
let ordering = match sorting . property {
|
||||||
FilmProperty :: Name => film_1 . name . cmp ( & film_2 . name ) ,
|
FilmProperty :: Name =>
|
||||||
FilmProperty :: ReleaseDate => film_1 . release_date . cmp ( & film_2 . release_date ) ,
|
film_1 . name . cmp ( & film_2 . name ) ,
|
||||||
FilmProperty :: Runtime => film_1 . runtime_minutes . cmp ( & film_2 . runtime_minutes ) ,
|
FilmProperty :: ReleaseDate =>
|
||||||
|
film_1 . release_date . cmp ( & film_2 . release_date ) ,
|
||||||
|
FilmProperty :: Runtime =>
|
||||||
|
film_1 . runtime_minutes . cmp ( & film_2 . runtime_minutes ) ,
|
||||||
} ;
|
} ;
|
||||||
match sorting . direction {
|
match sorting . direction {
|
||||||
SortingDirection :: Ascending => ordering ,
|
SortingDirection :: Ascending => ordering ,
|
||||||
|
@ -149,8 +152,10 @@ impl MediaAdapter for SeriesAdapter {
|
||||||
sorting : SeriesSorting ,
|
sorting : SeriesSorting ,
|
||||||
) -> Ordering {
|
) -> Ordering {
|
||||||
let ordering = match sorting . property {
|
let ordering = match sorting . property {
|
||||||
SeriesProperty :: Name => series_1 . name . cmp ( & series_2 . name ) ,
|
SeriesProperty :: Name =>
|
||||||
SeriesProperty :: FirstReleaseDate => series_1 . first_release_date . cmp ( & series_2 . first_release_date ) ,
|
series_1 . name . cmp ( & series_2 . name ) ,
|
||||||
|
SeriesProperty :: FirstReleaseDate =>
|
||||||
|
series_1 . first_release_date . cmp ( & series_2 . first_release_date ) ,
|
||||||
} ;
|
} ;
|
||||||
match sorting . direction {
|
match sorting . direction {
|
||||||
SortingDirection :: Ascending => ordering ,
|
SortingDirection :: Ascending => ordering ,
|
||||||
|
|
|
@ -1,25 +1,38 @@
|
||||||
macro_rules ! label { (
|
// Widget macros
|
||||||
$ ( @ hexpand : $ hexpand : expr ; ) ?
|
|
||||||
$ ( @ vexpand : $ vexpand : expr ; ) ?
|
macro_rules ! bin { ( $ ( @ vexpand : $ vexpand : expr ; ) ? ) => { {
|
||||||
$ ( @ halign : $ halign : expr ; ) ?
|
let widget = libadwaita :: Bin :: new () ;
|
||||||
$ ( @ valign : $ valign : expr ; ) ?
|
$ ( widget . set_vexpand ( $ vexpand ) ; ) ?
|
||||||
$ ( @ justify : $ justify : expr ; ) ?
|
widget
|
||||||
$ ( @ wrap : $ wrap : expr ; ) ?
|
} } }
|
||||||
$ ( @ max_width_chars : $ max_width_chars : expr ; ) ?
|
|
||||||
$ ( @ attributes : $ attributes : expr ; ) ?
|
macro_rules ! button { (
|
||||||
$ ( $ label : expr ) ? $ (,) ?
|
$ ( @ css_classes : $ css_classes : expr ; ) ?
|
||||||
|
$ ( @ connect_clicked : $ connect_clicked : expr ; ) ?
|
||||||
|
$ ( $ child : expr ) ? $ (,) ?
|
||||||
) => { {
|
) => { {
|
||||||
let label = gtk4 :: Label :: builder () . build () ;
|
let button = gtk4 :: Button :: new () ;
|
||||||
$ ( label . set_hexpand ( $ hexpand ) ; ) ?
|
$ ( button . set_css_classes ( $ css_classes ) ; ) ?
|
||||||
$ ( label . set_vexpand ( $ vexpand ) ; ) ?
|
$ ( button . connect_clicked ( $ connect_clicked ) ; ) ?
|
||||||
$ ( label . set_halign ( $ halign ) ; ) ?
|
$ ( button . set_child ( Some ( $ child ) ) ; ) ?
|
||||||
$ ( label . set_valign ( $ valign ) ; ) ?
|
button
|
||||||
$ ( label . set_label ( $ label ) ; ) ?
|
} } }
|
||||||
$ ( label . set_justify ( $ justify ) ; ) ?
|
|
||||||
$ ( label . set_max_width_chars ( $ max_width_chars ) ; ) ?
|
macro_rules ! dialog { () => { {
|
||||||
$ ( label . set_attributes ( Some ( $ attributes ) ) ; ) ?
|
let widget = libadwaita :: Dialog :: new () ;
|
||||||
$ ( label . set_wrap ( $ wrap ) ; ) ?
|
widget
|
||||||
label
|
} } }
|
||||||
|
|
||||||
|
macro_rules ! flow_box { (
|
||||||
|
$ ( @ orientation : $ orientation : expr ; ) ?
|
||||||
|
$ ( @ homogeneous : $ homogeneous : expr ; ) ?
|
||||||
|
$ ( @ selection_mode : $ selection_mode : expr ; ) ?
|
||||||
|
) => { {
|
||||||
|
let widget = gtk4 :: FlowBox :: new () ;
|
||||||
|
$ ( widget . set_orientation ( $ orientation ) ; ) ?
|
||||||
|
$ ( widget . set_homogeneous ( $ homogeneous ) ; ) ?
|
||||||
|
$ ( widget . set_selection_mode ( $ selection_mode ) ; ) ?
|
||||||
|
widget
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
macro_rules ! g_box {
|
macro_rules ! g_box {
|
||||||
|
@ -72,53 +85,9 @@ macro_rules ! g_box {
|
||||||
} } ;
|
} } ;
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules ! view_stack { (
|
macro_rules ! header_bar { ( $ title_widget : expr $ (,) ? ) => { {
|
||||||
$ ( ( $ title : expr , $ icon : expr , $ widget : expr $ (,) ? ) ) , * $ (,) ?
|
let widget = libadwaita :: HeaderBar :: new () ;
|
||||||
) => { {
|
widget . set_title_widget ( Some ( $ title_widget ) ) ;
|
||||||
let container = libadwaita :: ViewStack :: new () ;
|
|
||||||
$ ( container . add_titled_with_icon ( $ widget , None , $ title , $ icon ) ; ) *
|
|
||||||
container
|
|
||||||
} } }
|
|
||||||
|
|
||||||
macro_rules ! list_box { (
|
|
||||||
$ ( @ connect_row_activated : $ connect_row_activated : expr ; ) ?
|
|
||||||
$ ( $ child : expr ) , * $ (,) ?
|
|
||||||
) => { {
|
|
||||||
let container = gtk4 :: ListBox :: new () ;
|
|
||||||
$ ( container . connect_row_activated ( $ connect_row_activated ) ; ) ?
|
|
||||||
$ ( container . append ( $ child ) ; ) *
|
|
||||||
container
|
|
||||||
} } }
|
|
||||||
|
|
||||||
macro_rules ! button { (
|
|
||||||
$ ( @ css_classes : $ css_classes : expr ; ) ?
|
|
||||||
$ ( @ connect_clicked : $ connect_clicked : expr ; ) ?
|
|
||||||
$ ( $ child : expr ) ? $ (,) ?
|
|
||||||
) => { {
|
|
||||||
let button = gtk4 :: Button :: new () ;
|
|
||||||
$ ( button . set_css_classes ( $ css_classes ) ; ) ?
|
|
||||||
$ ( button . connect_clicked ( $ connect_clicked ) ; ) ?
|
|
||||||
$ ( button . set_child ( Some ( $ child ) ) ; ) ?
|
|
||||||
button
|
|
||||||
} } }
|
|
||||||
|
|
||||||
macro_rules ! split_button { (
|
|
||||||
$ ( @ popover : $ popover : expr ; ) ?
|
|
||||||
$ child : expr $ (,) ?
|
|
||||||
) => { {
|
|
||||||
let widget = libadwaita :: SplitButton :: new () ;
|
|
||||||
$ ( widget . set_popover ( Some ( $ popover ) ) ; ) ?
|
|
||||||
widget . set_child ( Some ( $ child ) ) ;
|
|
||||||
widget
|
|
||||||
} } }
|
|
||||||
|
|
||||||
macro_rules ! popover { (
|
|
||||||
$ ( @ css_classes : $ css_classes : expr ; ) ?
|
|
||||||
$ child : expr $ (,) ?
|
|
||||||
) => { {
|
|
||||||
let widget = gtk4 :: Popover :: new () ;
|
|
||||||
$ ( widget . set_css_classes ( $ css_classes ) ; ) ?
|
|
||||||
widget . set_child ( Some ( $ child ) ) ;
|
|
||||||
widget
|
widget
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
|
@ -140,6 +109,50 @@ macro_rules ! image { (
|
||||||
image
|
image
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
|
macro_rules ! label { (
|
||||||
|
$ ( @ hexpand : $ hexpand : expr ; ) ?
|
||||||
|
$ ( @ vexpand : $ vexpand : expr ; ) ?
|
||||||
|
$ ( @ halign : $ halign : expr ; ) ?
|
||||||
|
$ ( @ valign : $ valign : expr ; ) ?
|
||||||
|
$ ( @ justify : $ justify : expr ; ) ?
|
||||||
|
$ ( @ wrap : $ wrap : expr ; ) ?
|
||||||
|
$ ( @ max_width_chars : $ max_width_chars : expr ; ) ?
|
||||||
|
$ ( @ attributes : $ attributes : expr ; ) ?
|
||||||
|
$ ( $ label : expr ) ? $ (,) ?
|
||||||
|
) => { {
|
||||||
|
let label = gtk4 :: Label :: builder () . build () ;
|
||||||
|
$ ( label . set_hexpand ( $ hexpand ) ; ) ?
|
||||||
|
$ ( label . set_vexpand ( $ vexpand ) ; ) ?
|
||||||
|
$ ( label . set_halign ( $ halign ) ; ) ?
|
||||||
|
$ ( label . set_valign ( $ valign ) ; ) ?
|
||||||
|
$ ( label . set_label ( $ label ) ; ) ?
|
||||||
|
$ ( label . set_justify ( $ justify ) ; ) ?
|
||||||
|
$ ( label . set_max_width_chars ( $ max_width_chars ) ; ) ?
|
||||||
|
$ ( label . set_attributes ( Some ( $ attributes ) ) ; ) ?
|
||||||
|
$ ( label . set_wrap ( $ wrap ) ; ) ?
|
||||||
|
label
|
||||||
|
} } }
|
||||||
|
|
||||||
|
macro_rules ! list_box { (
|
||||||
|
$ ( @ connect_row_activated : $ connect_row_activated : expr ; ) ?
|
||||||
|
$ ( $ child : expr ) , * $ (,) ?
|
||||||
|
) => { {
|
||||||
|
let container = gtk4 :: ListBox :: new () ;
|
||||||
|
$ ( container . connect_row_activated ( $ connect_row_activated ) ; ) ?
|
||||||
|
$ ( container . append ( $ child ) ; ) *
|
||||||
|
container
|
||||||
|
} } }
|
||||||
|
|
||||||
|
macro_rules ! popover { (
|
||||||
|
$ ( @ css_classes : $ css_classes : expr ; ) ?
|
||||||
|
$ child : expr $ (,) ?
|
||||||
|
) => { {
|
||||||
|
let widget = gtk4 :: Popover :: new () ;
|
||||||
|
$ ( widget . set_css_classes ( $ css_classes ) ; ) ?
|
||||||
|
widget . set_child ( Some ( $ child ) ) ;
|
||||||
|
widget
|
||||||
|
} } }
|
||||||
|
|
||||||
macro_rules ! scrolled_window { (
|
macro_rules ! scrolled_window { (
|
||||||
$ ( @ propagate_natural_height : $ propagate_natural_height : expr ; ) ?
|
$ ( @ propagate_natural_height : $ propagate_natural_height : expr ; ) ?
|
||||||
$ child : expr $ (,) ?
|
$ child : expr $ (,) ?
|
||||||
|
@ -150,18 +163,34 @@ macro_rules ! scrolled_window { (
|
||||||
widget
|
widget
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
macro_rules ! flow_box { (
|
macro_rules ! split_button { (
|
||||||
$ ( @ orientation : $ orientation : expr ; ) ?
|
$ ( @ popover : $ popover : expr ; ) ?
|
||||||
$ ( @ homogeneous : $ homogeneous : expr ; ) ?
|
$ child : expr $ (,) ?
|
||||||
$ ( @ selection_mode : $ selection_mode : expr ; ) ?
|
|
||||||
) => { {
|
) => { {
|
||||||
let widget = gtk4 :: FlowBox :: new () ;
|
let widget = libadwaita :: SplitButton :: new () ;
|
||||||
$ ( widget . set_orientation ( $ orientation ) ; ) ?
|
$ ( widget . set_popover ( Some ( $ popover ) ) ; ) ?
|
||||||
$ ( widget . set_homogeneous ( $ homogeneous ) ; ) ?
|
widget . set_child ( Some ( $ child ) ) ;
|
||||||
$ ( widget . set_selection_mode ( $ selection_mode ) ; ) ?
|
|
||||||
widget
|
widget
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
|
macro_rules ! toolbar_view { (
|
||||||
|
$ ( @ top_bar : $ top_bar : expr ; ) ?
|
||||||
|
$ ( $ content : expr ) ? $ (,) ?
|
||||||
|
) => { {
|
||||||
|
let widget = libadwaita :: ToolbarView :: new () ;
|
||||||
|
$ ( widget . add_top_bar ( $ top_bar ) ; ) ?
|
||||||
|
$ ( widget . set_content ( Some ( $ content ) ) ; ) ?
|
||||||
|
widget
|
||||||
|
} } }
|
||||||
|
|
||||||
|
macro_rules ! view_stack { (
|
||||||
|
$ ( ( $ title : expr , $ icon : expr , $ widget : expr $ (,) ? ) ) , * $ (,) ?
|
||||||
|
) => { {
|
||||||
|
let container = libadwaita :: ViewStack :: new () ;
|
||||||
|
$ ( container . add_titled_with_icon ( $ widget , None , $ title , $ icon ) ; ) *
|
||||||
|
container
|
||||||
|
} } }
|
||||||
|
|
||||||
macro_rules ! view_switcher { (
|
macro_rules ! view_switcher { (
|
||||||
$ ( @ policy : $ policy : expr ; ) ?
|
$ ( @ policy : $ policy : expr ; ) ?
|
||||||
$ stack : expr $ (,) ?
|
$ stack : expr $ (,) ?
|
||||||
|
@ -172,17 +201,21 @@ macro_rules ! view_switcher { (
|
||||||
widget
|
widget
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
macro_rules ! header_bar { ( $ title_widget : expr $ (,) ? ) => { {
|
|
||||||
let widget = libadwaita :: HeaderBar :: new () ;
|
|
||||||
widget . set_title_widget ( Some ( $ title_widget ) ) ;
|
|
||||||
widget
|
|
||||||
} } }
|
|
||||||
|
|
||||||
macro_rules ! bin { ( $ ( @ vexpand : $ vexpand : expr ; ) ? ) => { {
|
|
||||||
let widget = libadwaita :: Bin :: new () ;
|
// Convenience widget macros
|
||||||
$ ( widget . set_vexpand ( $ vexpand ) ; ) ?
|
|
||||||
widget
|
macro_rules ! vertically_filling { ( $ child : expr ) => {
|
||||||
} } }
|
g_box ! (
|
||||||
|
@ orientation : gtk4 :: Orientation :: Vertical ;
|
||||||
|
$ child ,
|
||||||
|
& bin ! ( @ vexpand : true ; ) ,
|
||||||
|
)
|
||||||
|
} }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Other UI macros
|
||||||
|
|
||||||
macro_rules ! application_window { (
|
macro_rules ! application_window { (
|
||||||
@ application : $ application : expr ;
|
@ application : $ application : expr ;
|
||||||
|
@ -197,29 +230,6 @@ macro_rules ! application_window { (
|
||||||
window
|
window
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
macro_rules ! toolbar_view { (
|
|
||||||
$ ( @ top_bar : $ top_bar : expr ; ) ?
|
|
||||||
$ ( $ content : expr ) ? $ (,) ?
|
|
||||||
) => { {
|
|
||||||
let widget = libadwaita :: ToolbarView :: new () ;
|
|
||||||
$ ( widget . add_top_bar ( $ top_bar ) ; ) ?
|
|
||||||
$ ( widget . set_content ( Some ( $ content ) ) ; ) ?
|
|
||||||
widget
|
|
||||||
} } }
|
|
||||||
|
|
||||||
macro_rules ! dialog { () => { {
|
|
||||||
let widget = libadwaita :: Dialog :: new () ;
|
|
||||||
widget
|
|
||||||
} } }
|
|
||||||
|
|
||||||
macro_rules ! vertically_filling { ( $ child : expr ) => {
|
|
||||||
g_box ! (
|
|
||||||
@ orientation : gtk4 :: Orientation :: Vertical ;
|
|
||||||
$ child ,
|
|
||||||
& bin ! ( @ vexpand : true ; ) ,
|
|
||||||
)
|
|
||||||
} }
|
|
||||||
|
|
||||||
macro_rules ! pango_attributes { (
|
macro_rules ! pango_attributes { (
|
||||||
$ ( @ scale : $ scale : expr ; ) ?
|
$ ( @ scale : $ scale : expr ; ) ?
|
||||||
$ ( @ weight : $ weight : expr ; ) ?
|
$ ( @ weight : $ weight : expr ; ) ?
|
||||||
|
@ -237,22 +247,22 @@ macro_rules ! pango_attributes { (
|
||||||
|
|
||||||
|
|
||||||
pub (crate) use {
|
pub (crate) use {
|
||||||
label ,
|
|
||||||
g_box ,
|
|
||||||
view_stack ,
|
|
||||||
list_box ,
|
|
||||||
button ,
|
|
||||||
split_button ,
|
|
||||||
popover ,
|
|
||||||
image ,
|
|
||||||
scrolled_window ,
|
|
||||||
flow_box ,
|
|
||||||
view_switcher ,
|
|
||||||
header_bar ,
|
|
||||||
bin ,
|
|
||||||
application_window ,
|
application_window ,
|
||||||
toolbar_view ,
|
bin ,
|
||||||
|
button ,
|
||||||
dialog ,
|
dialog ,
|
||||||
vertically_filling ,
|
flow_box ,
|
||||||
|
g_box ,
|
||||||
|
header_bar ,
|
||||||
|
image ,
|
||||||
|
label ,
|
||||||
|
list_box ,
|
||||||
pango_attributes ,
|
pango_attributes ,
|
||||||
|
popover ,
|
||||||
|
scrolled_window ,
|
||||||
|
split_button ,
|
||||||
|
toolbar_view ,
|
||||||
|
vertically_filling ,
|
||||||
|
view_stack ,
|
||||||
|
view_switcher ,
|
||||||
} ;
|
} ;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue