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")]
34 pub struct BindingGroup(Object<crate::gobject_ffi::GBindingGroup>);
35
36 match fn {
37 type_ => || crate::gobject_ffi::g_binding_group_get_type(),
38 }
39}
40
41impl BindingGroup {
42 #[doc(alias = "g_binding_group_new")]
48 pub fn new() -> BindingGroup {
49 unsafe { from_glib_full(crate::gobject_ffi::g_binding_group_new()) }
50 }
51
52 #[doc(alias = "g_binding_group_dup_source")]
58 #[doc(alias = "dup_source")]
59 pub fn source(&self) -> Option<Object> {
60 unsafe {
61 from_glib_none(crate::gobject_ffi::g_binding_group_dup_source(
62 self.to_glib_none().0,
63 ))
64 }
65 }
66
67 #[doc(alias = "g_binding_group_set_source")]
76 #[doc(alias = "source")]
77 pub fn set_source(&self, source: Option<&impl IsA<Object>>) {
78 unsafe {
79 crate::gobject_ffi::g_binding_group_set_source(
80 self.to_glib_none().0,
81 source.map(|p| p.as_ref()).to_glib_none().0,
82 );
83 }
84 }
85
86 #[cfg(feature = "v2_72")]
87 #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
88 #[doc(alias = "source")]
89 pub fn connect_source_notify<F: Fn(&Self) + Send + Sync + 'static>(
90 &self,
91 f: F,
92 ) -> SignalHandlerId {
93 unsafe extern "C" fn notify_source_trampoline<
94 F: Fn(&BindingGroup) + Send + Sync + 'static,
95 >(
96 this: *mut crate::gobject_ffi::GBindingGroup,
97 _param_spec: ffi::gpointer,
98 f: ffi::gpointer,
99 ) {
100 unsafe {
101 let f: &F = &*(f as *const F);
102 f(&from_glib_borrow(this))
103 }
104 }
105 unsafe {
106 let f: Box_<F> = Box_::new(f);
107 connect_raw(
108 self.as_ptr() as *mut _,
109 c"notify::source".as_ptr() as *const _,
110 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
111 notify_source_trampoline::<F> as *const (),
112 )),
113 Box_::into_raw(f),
114 )
115 }
116 }
117}
118
119#[cfg(feature = "v2_72")]
120#[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
121impl Default for BindingGroup {
122 fn default() -> Self {
123 Self::new()
124 }
125}
126
127unsafe impl Send for BindingGroup {}
128unsafe impl Sync for BindingGroup {}