UI macro syntax now differentiates at-properties from arguments

This commit is contained in:
Reinout Meliesie 2025-02-04 15:02:58 +01:00
commit ce70725b60
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
8 changed files with 80 additions and 80 deletions

View file

@ -1,8 +1,8 @@
macro_rules ! label { (
$ ( @ hexpand : $ hexpand : expr , ) ?
$ ( @ vexpand : $ vexpand : expr , ) ?
$ ( @ halign : $ halign : expr , ) ?
$ ( @ valign : $ valign : expr , ) ?
$ ( @ hexpand : $ hexpand : expr ;) ?
$ ( @ vexpand : $ vexpand : expr ; ) ?
$ ( @ halign : $ halign : expr ; ) ?
$ ( @ valign : $ valign : expr ; ) ?
$ label : expr $ (,) ?
) => { {
let label = gtk4 :: Label :: builder () . build () ;
@ -15,15 +15,15 @@ macro_rules ! label { (
} } }
macro_rules ! g_box { (
$ ( @ orientation : $ orientation : expr , ) ?
$ ( @ halign : $ halign : expr , ) ?
$ ( @ valign : $ valign : expr , ) ?
$ ( @ spacing : $ spacing : expr , ) ?
$ ( @ margin_top : $ margin_top : expr , ) ?
$ ( @ margin_bottom : $ margin_bottom : expr , ) ?
$ ( @ widget_name : $ widget_name : expr , ) ?
$ ( @ css_classes : $ css_classes : expr , ) ?
$ ( $ child : expr ) , + $ (,) ?
$ ( @ orientation : $ orientation : expr ; ) ?
$ ( @ halign : $ halign : expr ; ) ?
$ ( @ valign : $ valign : expr ; ) ?
$ ( @ spacing : $ spacing : expr ; ) ?
$ ( @ margin_top : $ margin_top : expr ; ) ?
$ ( @ margin_bottom : $ margin_bottom : expr ; ) ?
$ ( @ widget_name : $ widget_name : expr ; ) ?
$ ( @ css_classes : $ css_classes : expr ; ) ?
$ ( $ child : expr ) , * $ (,) ?
) => { {
let container = gtk4 :: Box :: builder () . build () ;
$ ( container . set_orientation ( $ orientation ) ; ) ?
@ -39,7 +39,7 @@ macro_rules ! g_box { (
} } }
macro_rules ! view_stack { (
$ ( $ title : expr , $ icon : expr , $ widget : expr , ) *
$ ( ( $ title : expr , $ icon : expr , $ widget : expr $ (,) ? ) ) , * $ (,) ?
) => { {
let container = libadwaita :: ViewStack :: new () ;
$ ( container . add_titled_with_icon ( $ widget , None , $ title , $ icon ) ; ) *
@ -47,17 +47,17 @@ macro_rules ! view_stack { (
} } }
macro_rules ! list_box { (
$ ( @ connect_row_activated : $ connect_row_activated : expr , ) ?
$ ( $ child : expr ) , + $ (,) ?
$ ( @ 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 . append ( & $ child ) ; ) *
container
} } }
macro_rules ! split_button { (
$ ( @ popover : $ popover : expr , ) ?
$ ( @ popover : $ popover : expr ; ) ?
$ child : expr $ (,) ?
) => { {
let widget = libadwaita :: SplitButton :: new () ;
@ -67,7 +67,7 @@ macro_rules ! split_button { (
} } }
macro_rules ! popover { (
$ ( @ css_classes : $ css_classes : expr , ) ?
$ ( @ css_classes : $ css_classes : expr ; ) ?
$ child : expr $ (,) ?
) => { {
let widget = gtk4 :: Popover :: new () ;
@ -81,7 +81,7 @@ macro_rules ! icon { ( $ icon_name : expr ) => {
} }
macro_rules ! scrolled_window { (
$ ( @ propagate_natural_height : $ propagate_natural_height : expr , ) ?
$ ( @ propagate_natural_height : $ propagate_natural_height : expr ; ) ?
$ child : expr $ (,) ?
) => { {
let widget = gtk4 :: ScrolledWindow :: new () ;
@ -91,9 +91,9 @@ macro_rules ! scrolled_window { (
} } }
macro_rules ! flow_box { (
$ ( @ orientation : $ orientation : expr , ) ?
$ ( @ homogeneous : $ homogeneous : expr , ) ?
$ ( @ selection_mode : $ selection_mode : expr , ) ?
$ ( @ orientation : $ orientation : expr ; ) ?
$ ( @ homogeneous : $ homogeneous : expr ; ) ?
$ ( @ selection_mode : $ selection_mode : expr ; ) ?
) => { {
let widget = gtk4 :: FlowBox :: new () ;
$ ( widget . set_orientation ( $ orientation ) ; ) ?
@ -103,7 +103,7 @@ macro_rules ! flow_box { (
} } }
macro_rules ! view_switcher { (
$ ( @ policy : $ policy : expr , ) ?
$ ( @ policy : $ policy : expr ; ) ?
$ stack : expr $ (,) ?
) => { {
let widget = libadwaita :: ViewSwitcher :: new () ;
@ -118,15 +118,15 @@ macro_rules ! header_bar { ( $ title_widget : expr $ (,) ? ) => { {
widget
} } }
macro_rules ! bin { ( $ ( @ vexpand : $ vexpand : expr ) ? $ (,) ? ) => { {
macro_rules ! bin { ( $ ( @ vexpand : $ vexpand : expr ; ) ? ) => { {
let widget = libadwaita :: Bin :: new () ;
$ ( widget . set_vexpand ( $ vexpand ) ; ) ?
widget
} } }
macro_rules ! application_window { (
@ application : $ application : expr ,
@ title : $ title : expr ,
@ application : $ application : expr ;
@ title : $ title : expr ;
$ content : expr $ (,) ?
) => { {
use libadwaita :: prelude :: * ;
@ -139,15 +139,15 @@ macro_rules ! application_window { (
macro_rules ! vertically_filling { ( $ child : expr ) => {
g_box ! (
@ orientation : gtk4 :: Orientation :: Vertical ,
@ orientation : gtk4 :: Orientation :: Vertical ;
$ child ,
bin ! ( @ vexpand : true ) ,
bin ! ( @ vexpand : true ; ) ,
)
} }
macro_rules ! pango_attributes { (
$ ( @ scale : $ scale : expr , ) ?
$ ( @ weight : $ weight : expr , ) ?
$ ( @ scale : $ scale : expr ; ) ?
$ ( @ weight : $ weight : expr ; ) ?
) => { {
let attributes = gtk4 :: pango :: AttrList :: new () ;
# [ allow (unused_mut) ] let mut font_description = gtk4 :: pango :: FontDescription :: new () ;