use gtk4 :: Widget ; use gtk4 :: Orientation :: * ; use gtk4 :: prelude :: * ; use libadwaita :: Bin ; // Convenience function to conditionally append child to a widget pub trait OptChildExt { fn append_opt ( & self , child : & Option < impl IsA > ) ; } impl OptChildExt for gtk4 :: Box { fn append_opt ( & self , child : & Option < impl IsA > ) { if let Some (child) = child { self . append (child) ; } } } // The `view` macro from Relm4 as an expression instead of a variable declaration macro_rules ! view_expr { ( $ ( $ contents : tt ) * ) => { { relm4_macros :: view ! { outer = $ ( $ contents ) * } outer } } } pub fn vertical_filler ( child : & impl IsA ) -> gtk4 :: Box { view_expr ! { gtk4 :: Box { set_orientation : Vertical , append : child , append : & view_expr ! { Bin { set_vexpand : true } } , } } } macro_rules ! pango_attributes { ( $ ( scale : $ scale : expr ) ? $ ( , weight : $ weight : expr $ (,) ? ) ? ) => { { let attributes = gtk4 :: pango :: AttrList :: new () ; # [ allow (unused_mut) ] let mut font_description = gtk4 :: pango :: FontDescription :: new () ; $ ( attributes . insert ( gtk4 :: pango :: AttrFloat :: new_scale ( $ scale ) ) ; ) ? $ ( font_description . set_weight ( $ weight ) ; ) ? attributes . insert ( gtk4 :: pango :: AttrFontDesc :: new ( & font_description ) ) ; attributes } } } # [ allow (unused_imports) ] pub (crate) use { pango_attributes , view_expr , } ;