@@ -467,6 +467,28 @@ fn expand_getset_properties_impl(imp_type_ident: &syn::Ident, props: &[PropDesc]
467
467
quote ! ( #( #defs) * )
468
468
}
469
469
470
+ fn expand_connect_prop_notify ( p : & PropDesc ) -> TokenStream2 {
471
+ let name = & p. name ;
472
+ let fn_ident = format_ident ! ( "connect_{}_notify" , name_to_ident( name) ) ;
473
+ quote ! ( fn #fn_ident<F : Fn ( & Self ) + ' static >( & self , f: F ) -> glib:: SignalHandlerId )
474
+ }
475
+ fn expand_connect_prop_notify_def ( props : & [ PropDesc ] ) -> TokenStream2 {
476
+ let connection_fns = props. iter ( ) . map ( expand_connect_prop_notify) ;
477
+ quote ! ( #( #connection_fns; ) * )
478
+ }
479
+ fn expand_connect_prop_notify_impl ( props : & [ PropDesc ] ) -> TokenStream2 {
480
+ let connection_fns = props. iter ( ) . map ( |p| {
481
+ let name = & p. name ;
482
+ let fn_signature = expand_connect_prop_notify ( p) ;
483
+ quote ! ( #fn_signature {
484
+ self . connect_notify_local( Some ( #name) , move |this, _| {
485
+ f( this)
486
+ } )
487
+ } )
488
+ } ) ;
489
+ quote ! ( #( #connection_fns) * )
490
+ }
491
+
470
492
pub fn impl_derive_props ( input : PropsMacroInput ) -> TokenStream {
471
493
let struct_ident = & input. ident ;
472
494
let struct_ident_ext = format_ident ! ( "{}Ext" , & input. ident) ;
@@ -477,6 +499,8 @@ pub fn impl_derive_props(input: PropsMacroInput) -> TokenStream {
477
499
let fn_set_property = expand_set_property_fn ( & input. props ) ;
478
500
let getset_properties_def = expand_getset_properties_def ( & input. props ) ;
479
501
let getset_properties_impl = expand_getset_properties_impl ( struct_ident, & input. props ) ;
502
+ let connect_prop_notify_def = expand_connect_prop_notify_def ( & input. props ) ;
503
+ let connect_prop_notify_impl = expand_connect_prop_notify_impl ( & input. props ) ;
480
504
let expanded = quote ! {
481
505
use glib:: { PropRead , PropWrite } ;
482
506
@@ -493,9 +517,11 @@ pub fn impl_derive_props(input: PropsMacroInput) -> TokenStream {
493
517
494
518
pub trait #struct_ident_ext {
495
519
#getset_properties_def
520
+ #connect_prop_notify_def
496
521
}
497
522
impl #struct_ident_ext for #wrapper_type {
498
523
#getset_properties_impl
524
+ #connect_prop_notify_impl
499
525
}
500
526
501
527
} ;
0 commit comments