glib/gobject/auto/
binding_group.rs1use crate::{
6 ffi,
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10 Object,
11};
12use std::boxed::Box as Box_;
13
14crate::wrapper! {
15 #[doc(alias = "GBindingGroup")]
16 pub struct BindingGroup(Object<crate::gobject_ffi::GBindingGroup>);
17
18 match fn {
19 type_ => || crate::gobject_ffi::g_binding_group_get_type(),
20 }
21}
22
23impl BindingGroup {
24 #[doc(alias = "g_binding_group_new")]
25 pub fn new() -> BindingGroup {
26 unsafe { from_glib_full(crate::gobject_ffi::g_binding_group_new()) }
27 }
28
29 #[doc(alias = "g_binding_group_dup_source")]
30 #[doc(alias = "dup_source")]
31 pub fn source(&self) -> Option<Object> {
32 unsafe {
33 from_glib_none(crate::gobject_ffi::g_binding_group_dup_source(
34 self.to_glib_none().0,
35 ))
36 }
37 }
38
39 #[doc(alias = "g_binding_group_set_source")]
40 #[doc(alias = "source")]
41 pub fn set_source(&self, source: Option<&impl IsA<Object>>) {
42 unsafe {
43 crate::gobject_ffi::g_binding_group_set_source(
44 self.to_glib_none().0,
45 source.map(|p| p.as_ref()).to_glib_none().0,
46 );
47 }
48 }
49
50 #[cfg(feature = "v2_72")]
51 #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
52 #[doc(alias = "source")]
53 pub fn connect_source_notify<F: Fn(&Self) + Send + Sync + 'static>(
54 &self,
55 f: F,
56 ) -> SignalHandlerId {
57 unsafe extern "C" fn notify_source_trampoline<
58 F: Fn(&BindingGroup) + Send + Sync + 'static,
59 >(
60 this: *mut crate::gobject_ffi::GBindingGroup,
61 _param_spec: ffi::gpointer,
62 f: ffi::gpointer,
63 ) {
64 let f: &F = &*(f as *const F);
65 f(&from_glib_borrow(this))
66 }
67 unsafe {
68 let f: Box_<F> = Box_::new(f);
69 connect_raw(
70 self.as_ptr() as *mut _,
71 c"notify::source".as_ptr() as *const _,
72 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
73 notify_source_trampoline::<F> as *const (),
74 )),
75 Box_::into_raw(f),
76 )
77 }
78 }
79}
80
81#[cfg(feature = "v2_72")]
82#[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
83impl Default for BindingGroup {
84 fn default() -> Self {
85 Self::new()
86 }
87}
88
89unsafe impl Send for BindingGroup {}
90unsafe impl Sync for BindingGroup {}