Include static lifetime in MediaAdapter trait, formatting

This commit is contained in:
Reinout Meliesie 2025-02-12 14:32:16 +01:00
commit 2c40217497
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
5 changed files with 162 additions and 142 deletions

View file

@ -1,25 +1,38 @@
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 ) ? $ (,) ?
// Widget macros
macro_rules ! bin { ( $ ( @ vexpand : $ vexpand : expr ; ) ? ) => { {
let widget = libadwaita :: Bin :: new () ;
$ ( widget . set_vexpand ( $ vexpand ) ; ) ?
widget
} } }
macro_rules ! button { (
$ ( @ css_classes : $ css_classes : expr ; ) ?
$ ( @ connect_clicked : $ connect_clicked : expr ; ) ?
$ ( $ child : 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
let button = gtk4 :: Button :: new () ;
$ ( button . set_css_classes ( $ css_classes ) ; ) ?
$ ( button . connect_clicked ( $ connect_clicked ) ; ) ?
$ ( button . set_child ( Some ( $ child ) ) ; ) ?
button
} } }
macro_rules ! dialog { () => { {
let widget = libadwaita :: Dialog :: new () ;
widget
} } }
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 {
@ -72,53 +85,9 @@ macro_rules ! g_box {
} } ;
}
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 ! 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 ) ) ;
macro_rules ! header_bar { ( $ title_widget : expr $ (,) ? ) => { {
let widget = libadwaita :: HeaderBar :: new () ;
widget . set_title_widget ( Some ( $ title_widget ) ) ;
widget
} } }
@ -140,6 +109,50 @@ macro_rules ! 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 { (
$ ( @ propagate_natural_height : $ propagate_natural_height : expr ; ) ?
$ child : expr $ (,) ?
@ -150,18 +163,34 @@ macro_rules ! scrolled_window { (
widget
} } }
macro_rules ! flow_box { (
$ ( @ orientation : $ orientation : expr ; ) ?
$ ( @ homogeneous : $ homogeneous : expr ; ) ?
$ ( @ selection_mode : $ selection_mode : expr ; ) ?
macro_rules ! split_button { (
$ ( @ popover : $ popover : expr ; ) ?
$ child : expr $ (,) ?
) => { {
let widget = gtk4 :: FlowBox :: new () ;
$ ( widget . set_orientation ( $ orientation ) ; ) ?
$ ( widget . set_homogeneous ( $ homogeneous ) ; ) ?
$ ( widget . set_selection_mode ( $ selection_mode ) ; ) ?
let widget = libadwaita :: SplitButton :: new () ;
$ ( widget . set_popover ( Some ( $ popover ) ) ; ) ?
widget . set_child ( Some ( $ child ) ) ;
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 { (
$ ( @ policy : $ policy : expr ; ) ?
$ stack : expr $ (,) ?
@ -172,17 +201,21 @@ macro_rules ! view_switcher { (
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 () ;
$ ( widget . set_vexpand ( $ vexpand ) ; ) ?
widget
} } }
// Convenience widget macros
macro_rules ! vertically_filling { ( $ child : expr ) => {
g_box ! (
@ orientation : gtk4 :: Orientation :: Vertical ;
$ child ,
& bin ! ( @ vexpand : true ; ) ,
)
} }
// Other UI macros
macro_rules ! application_window { (
@ application : $ application : expr ;
@ -197,29 +230,6 @@ macro_rules ! application_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 { (
$ ( @ scale : $ scale : expr ; ) ?
$ ( @ weight : $ weight : expr ; ) ?
@ -237,22 +247,22 @@ macro_rules ! pango_attributes { (
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 ,
toolbar_view ,
bin ,
button ,
dialog ,
vertically_filling ,
flow_box ,
g_box ,
header_bar ,
image ,
label ,
list_box ,
pango_attributes ,
popover ,
scrolled_window ,
split_button ,
toolbar_view ,
vertically_filling ,
view_stack ,
view_switcher ,
} ;