@@ -42,6 +42,50 @@ impl SignalGroup {
42
42
self . connect_closure ( signal_name, after, RustClosure :: new_local ( callback) ) ;
43
43
}
44
44
45
+ #[ inline]
46
+ pub fn connect_notify < F > ( & self , name : Option < & str > , callback : F )
47
+ where
48
+ F : Fn ( & crate :: Object , & crate :: ParamSpec ) + Send + Sync + ' static ,
49
+ {
50
+ let signal_name = if let Some ( name) = name {
51
+ format ! ( "notify::{name}" )
52
+ } else {
53
+ "notify" . into ( )
54
+ } ;
55
+
56
+ let closure = crate :: RustClosure :: new ( move |values| {
57
+ let obj = values[ 0 ] . get ( ) . unwrap ( ) ;
58
+ let pspec = values[ 1 ] . get ( ) . unwrap ( ) ;
59
+ callback ( obj, pspec) ;
60
+
61
+ None
62
+ } ) ;
63
+
64
+ self . connect_closure ( & signal_name, false , closure) ;
65
+ }
66
+
67
+ #[ inline]
68
+ pub fn connect_notify_local < F > ( & self , name : Option < & str > , callback : F )
69
+ where
70
+ F : Fn ( & crate :: Object , & crate :: ParamSpec ) + ' static ,
71
+ {
72
+ let signal_name = if let Some ( name) = name {
73
+ format ! ( "notify::{name}" )
74
+ } else {
75
+ "notify" . into ( )
76
+ } ;
77
+
78
+ let closure = crate :: RustClosure :: new_local ( move |values| {
79
+ let obj = values[ 0 ] . get ( ) . unwrap ( ) ;
80
+ let pspec = values[ 1 ] . get ( ) . unwrap ( ) ;
81
+ callback ( obj, pspec) ;
82
+
83
+ None
84
+ } ) ;
85
+
86
+ self . connect_closure ( & signal_name, false , closure) ;
87
+ }
88
+
45
89
unsafe fn connect_bind_unsafe < F : Fn ( & Self , & Object ) > ( & self , f : F ) -> SignalHandlerId {
46
90
unsafe extern "C" fn bind_trampoline < F : Fn ( & SignalGroup , & Object ) > (
47
91
this : * mut crate :: gobject_ffi:: GSignalGroup ,
0 commit comments