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