Reimplement collation menu as component

This commit is contained in:
Reinout Meliesie 2025-01-31 15:34:09 +01:00
commit 04755fabb7
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
4 changed files with 133 additions and 45 deletions

View file

@ -3,24 +3,34 @@ macro_rules ! label { (
$ ( @ vexpand : $ vexpand : expr , ) ?
$ ( @ halign : $ halign : expr , ) ?
$ ( @ valign : $ valign : expr , ) ?
$ ( $ label : 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_label ( $ label ) ;
label
} } }
macro_rules ! g_box { (
$ ( @ orientation : $ orientation : expr , ) ?
$ ( $ child : expr ) , * $ (,) ?
$ ( @ halign : $ halign : expr , ) ?
$ ( @ valign : $ valign : expr , ) ?
$ ( @ spacing : $ spacing : expr , ) ?
$ ( @ widget_name : $ widget_name : expr , ) ?
$ ( @ css_classes : $ css_classes : expr , ) ?
$ ( $ child : expr ) , + $ (,) ?
) => { {
let container = gtk4 :: Box :: builder () . build () ;
$ ( container . set_orientation ( $ orientation ) ; ) ?
$ ( container . append ( $ child ) ; ) *
$ ( container . set_halign ( $ halign ) ; ) ?
$ ( container . set_valign ( $ valign ) ; ) ?
$ ( container . set_spacing ( $ spacing ) ; ) ?
$ ( container . set_widget_name ( & $ widget_name ) ; ) ?
$ ( container . set_css_classes ( & $ css_classes ) ; ) ?
$ ( container . append ( & $ child ) ; ) *
container
} } }
@ -32,17 +42,41 @@ macro_rules ! view_stack { (
container
} } }
macro_rules ! list_box { ( $ ( $ child : expr , ) * ) => { {
macro_rules ! list_box { ( $ ( $ child : expr ) , * $ (,) ? ) => { {
let container = gtk4 :: ListBox :: new () ;
$ ( container . append ( $ child ) ; ) *
$ ( container . append ( & $ child ) ; ) *
container
} } }
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
} } }
macro_rules ! icon { ( $ icon_name : expr ) => {
gtk4 :: Image :: from_icon_name ( $ icon_name )
} }
macro_rules ! vertically_filling { ( $ child : expr ) => {
g_box ! (
@ orientation : gtk4 :: Orientation :: Vertical ,
$ child ,
& libadwaita :: Bin :: builder ()
libadwaita :: Bin :: builder ()
. css_name ("filler")
. vexpand (true)
. build () ,
@ -56,5 +90,8 @@ pub (crate) use {
g_box ,
view_stack ,
list_box ,
split_button ,
popover ,
icon ,
vertically_filling ,
} ;