glib/gobject/auto/binding_group.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6 Object, ffi,
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13crate::wrapper! {
14 /// `GBindingGroup` can be used to bind multiple properties
15 /// from an object collectively.
16 ///
17 /// Use the various methods to bind properties from a single source
18 /// object to multiple destination objects. Properties can be bound
19 /// bidirectionally and are connected when the source object is set
20 /// with [`set_source()`][Self::set_source()].
21 ///
22 /// ## Properties
23 ///
24 ///
25 /// #### `source`
26 /// The source object used for binding properties.
27 ///
28 /// Readable | Writeable
29 ///
30 /// # Implements
31 ///
32 /// [`ObjectExt`][trait@crate::prelude::ObjectExt]
33 // rustdoc-stripper-ignore-next-stop
34 /// `GBindingGroup` can be used to bind multiple properties
35 /// from an object collectively.
36 ///
37 /// Use the various methods to bind properties from a single source
38 /// object to multiple destination objects. Properties can be bound
39 /// bidirectionally and are connected when the source object is set
40 /// with [`set_source()`][Self::set_source()].
41 ///
42 /// ## Properties
43 ///
44 ///
45 /// #### `source`
46 /// The source object used for binding properties.
47 ///
48 /// Readable | Writeable
49 ///
50 /// # Implements
51 ///
52 /// [`ObjectExt`][trait@crate::prelude::ObjectExt]
53 #[doc(alias = "GBindingGroup")]
54 pub struct BindingGroup(Object<crate::gobject_ffi::GBindingGroup>);
55
56 match fn {
57 type_ => || crate::gobject_ffi::g_binding_group_get_type(),
58 }
59}
60
61impl BindingGroup {
62 /// Creates a new #GBindingGroup.
63 ///
64 /// # Returns
65 ///
66 /// a new #GBindingGroup
67 // rustdoc-stripper-ignore-next-stop
68 /// Creates a new #GBindingGroup.
69 ///
70 /// # Returns
71 ///
72 /// a new #GBindingGroup
73 #[doc(alias = "g_binding_group_new")]
74 pub fn new() -> BindingGroup {
75 unsafe { from_glib_full(crate::gobject_ffi::g_binding_group_new()) }
76 }
77
78 /// Gets the source object used for binding properties.
79 ///
80 /// # Returns
81 ///
82 /// a #GObject or [`None`].
83 // rustdoc-stripper-ignore-next-stop
84 /// Gets the source object used for binding properties.
85 ///
86 /// # Returns
87 ///
88 /// a #GObject or [`None`].
89 #[doc(alias = "g_binding_group_dup_source")]
90 #[doc(alias = "dup_source")]
91 pub fn source(&self) -> Option<Object> {
92 unsafe {
93 from_glib_none(crate::gobject_ffi::g_binding_group_dup_source(
94 self.to_glib_none().0,
95 ))
96 }
97 }
98
99 /// Sets @source as the source object used for creating property
100 /// bindings. If there is already a source object all bindings from it
101 /// will be removed.
102 ///
103 /// Note that all properties that have been bound must exist on @source.
104 /// ## `source`
105 /// the source #GObject,
106 /// or [`None`] to clear it
107 // rustdoc-stripper-ignore-next-stop
108 /// Sets @source as the source object used for creating property
109 /// bindings. If there is already a source object all bindings from it
110 /// will be removed.
111 ///
112 /// Note that all properties that have been bound must exist on @source.
113 /// ## `source`
114 /// the source #GObject,
115 /// or [`None`] to clear it
116 #[doc(alias = "g_binding_group_set_source")]
117 #[doc(alias = "source")]
118 pub fn set_source(&self, source: Option<&impl IsA<Object>>) {
119 unsafe {
120 crate::gobject_ffi::g_binding_group_set_source(
121 self.to_glib_none().0,
122 source.map(|p| p.as_ref()).to_glib_none().0,
123 );
124 }
125 }
126
127 #[cfg(feature = "v2_72")]
128 #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
129 #[doc(alias = "source")]
130 pub fn connect_source_notify<F: Fn(&Self) + Send + Sync + 'static>(
131 &self,
132 f: F,
133 ) -> SignalHandlerId {
134 unsafe extern "C" fn notify_source_trampoline<
135 F: Fn(&BindingGroup) + Send + Sync + 'static,
136 >(
137 this: *mut crate::gobject_ffi::GBindingGroup,
138 _param_spec: ffi::gpointer,
139 f: ffi::gpointer,
140 ) {
141 unsafe {
142 let f: &F = &*(f as *const F);
143 f(&from_glib_borrow(this))
144 }
145 }
146 unsafe {
147 let f: Box_<F> = Box_::new(f);
148 connect_raw(
149 self.as_ptr() as *mut _,
150 c"notify::source".as_ptr(),
151 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
152 notify_source_trampoline::<F> as *const (),
153 )),
154 Box_::into_raw(f),
155 )
156 }
157 }
158}
159
160#[cfg(feature = "v2_72")]
161#[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
162impl Default for BindingGroup {
163 fn default() -> Self {
164 Self::new()
165 }
166}
167
168unsafe impl Send for BindingGroup {}
169unsafe impl Sync for BindingGroup {}