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