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