glib/gobject/auto/signal_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::{Object, ffi, prelude::*, translate::*};
6
7crate::wrapper! {
8 /// `GSignalGroup` manages a collection of signals on a `GObject`.
9 ///
10 /// `GSignalGroup` simplifies the process of connecting many signals to a `GObject`
11 /// as a group. As such there is no API to disconnect a signal from the group.
12 ///
13 /// In particular, this allows you to:
14 ///
15 /// - Change the target instance, which automatically causes disconnection
16 /// of the signals from the old instance and connecting to the new instance.
17 /// - Block and unblock signals as a group
18 /// - Ensuring that blocked state transfers across target instances.
19 ///
20 /// One place you might want to use such a structure is with `GtkTextView` and
21 /// `GtkTextBuffer`. Often times, you'll need to connect to many signals on
22 /// `GtkTextBuffer` from a `GtkTextView` subclass. This allows you to create a
23 /// signal group during instance construction, simply bind the
24 /// `GtkTextView:buffer` property to `GSignalGroup:target` and connect
25 /// all the signals you need. When the `GtkTextView:buffer` property changes
26 /// all of the signals will be transitioned correctly.
27 ///
28 /// ## Properties
29 ///
30 ///
31 /// #### `target`
32 /// The target instance used when connecting signals.
33 ///
34 /// Readable | Writeable
35 ///
36 ///
37 /// #### `target-type`
38 /// The #GType of the target property.
39 ///
40 /// Readable | Writeable | Construct Only
41 ///
42 /// ## Signals
43 ///
44 ///
45 /// #### `bind`
46 /// This signal is emitted when #GSignalGroup:target is set to a new value
47 /// other than [`None`]. It is similar to #GObject::notify on `target` except it
48 /// will not emit when #GSignalGroup:target is [`None`] and also allows for
49 /// receiving the #GObject without a data-race.
50 ///
51 ///
52 ///
53 ///
54 /// #### `unbind`
55 /// This signal is emitted when the target instance of @self_ is set to a
56 /// new #GObject.
57 ///
58 /// This signal will only be emitted if the previous target of @self_ is
59 /// non-[`None`].
60 ///
61 ///
62 ///
63 /// # Implements
64 ///
65 /// [`ObjectExt`][trait@crate::prelude::ObjectExt]
66 // rustdoc-stripper-ignore-next-stop
67 /// `GSignalGroup` manages a collection of signals on a `GObject`.
68 ///
69 /// `GSignalGroup` simplifies the process of connecting many signals to a `GObject`
70 /// as a group. As such there is no API to disconnect a signal from the group.
71 ///
72 /// In particular, this allows you to:
73 ///
74 /// - Change the target instance, which automatically causes disconnection
75 /// of the signals from the old instance and connecting to the new instance.
76 /// - Block and unblock signals as a group
77 /// - Ensuring that blocked state transfers across target instances.
78 ///
79 /// One place you might want to use such a structure is with `GtkTextView` and
80 /// `GtkTextBuffer`. Often times, you'll need to connect to many signals on
81 /// `GtkTextBuffer` from a `GtkTextView` subclass. This allows you to create a
82 /// signal group during instance construction, simply bind the
83 /// `GtkTextView:buffer` property to `GSignalGroup:target` and connect
84 /// all the signals you need. When the `GtkTextView:buffer` property changes
85 /// all of the signals will be transitioned correctly.
86 ///
87 /// ## Properties
88 ///
89 ///
90 /// #### `target`
91 /// The target instance used when connecting signals.
92 ///
93 /// Readable | Writeable
94 ///
95 ///
96 /// #### `target-type`
97 /// The #GType of the target property.
98 ///
99 /// Readable | Writeable | Construct Only
100 ///
101 /// ## Signals
102 ///
103 ///
104 /// #### `bind`
105 /// This signal is emitted when #GSignalGroup:target is set to a new value
106 /// other than [`None`]. It is similar to #GObject::notify on `target` except it
107 /// will not emit when #GSignalGroup:target is [`None`] and also allows for
108 /// receiving the #GObject without a data-race.
109 ///
110 ///
111 ///
112 ///
113 /// #### `unbind`
114 /// This signal is emitted when the target instance of @self_ is set to a
115 /// new #GObject.
116 ///
117 /// This signal will only be emitted if the previous target of @self_ is
118 /// non-[`None`].
119 ///
120 ///
121 ///
122 /// # Implements
123 ///
124 /// [`ObjectExt`][trait@crate::prelude::ObjectExt]
125 #[doc(alias = "GSignalGroup")]
126 pub struct SignalGroup(Object<crate::gobject_ffi::GSignalGroup>);
127
128 match fn {
129 type_ => || crate::gobject_ffi::g_signal_group_get_type(),
130 }
131}
132
133impl SignalGroup {
134 /// Creates a new #GSignalGroup for target instances of @target_type.
135 /// ## `target_type`
136 /// the #GType of the target instance.
137 ///
138 /// # Returns
139 ///
140 /// a new #GSignalGroup
141 // rustdoc-stripper-ignore-next-stop
142 /// Creates a new #GSignalGroup for target instances of @target_type.
143 /// ## `target_type`
144 /// the #GType of the target instance.
145 ///
146 /// # Returns
147 ///
148 /// a new #GSignalGroup
149 #[doc(alias = "g_signal_group_new")]
150 #[doc(alias = "new")]
151 pub fn with_type(target_type: crate::types::Type) -> SignalGroup {
152 unsafe {
153 from_glib_full(crate::gobject_ffi::g_signal_group_new(
154 target_type.into_glib(),
155 ))
156 }
157 }
158
159 /// Blocks all signal handlers managed by @self so they will not
160 /// be called during any signal emissions. Must be unblocked exactly
161 /// the same number of times it has been blocked to become active again.
162 ///
163 /// This blocked state will be kept across changes of the target instance.
164 // rustdoc-stripper-ignore-next-stop
165 /// Blocks all signal handlers managed by @self so they will not
166 /// be called during any signal emissions. Must be unblocked exactly
167 /// the same number of times it has been blocked to become active again.
168 ///
169 /// This blocked state will be kept across changes of the target instance.
170 #[doc(alias = "g_signal_group_block")]
171 pub fn block(&self) {
172 unsafe {
173 crate::gobject_ffi::g_signal_group_block(self.to_glib_none().0);
174 }
175 }
176
177 /// Gets the target instance used when connecting signals.
178 ///
179 /// # Returns
180 ///
181 /// The target instance
182 // rustdoc-stripper-ignore-next-stop
183 /// Gets the target instance used when connecting signals.
184 ///
185 /// # Returns
186 ///
187 /// The target instance
188 #[doc(alias = "g_signal_group_dup_target")]
189 #[doc(alias = "dup_target")]
190 pub fn target(&self) -> Option<Object> {
191 unsafe {
192 from_glib_full(crate::gobject_ffi::g_signal_group_dup_target(
193 self.to_glib_none().0,
194 ))
195 }
196 }
197
198 /// Sets the target instance used when connecting signals. Any signal
199 /// that has been registered with g_signal_group_connect_object() or
200 /// similar functions will be connected to this object.
201 ///
202 /// If the target instance was previously set, signals will be
203 /// disconnected from that object prior to connecting to @target.
204 /// ## `target`
205 /// The target instance used
206 /// when connecting signals.
207 // rustdoc-stripper-ignore-next-stop
208 /// Sets the target instance used when connecting signals. Any signal
209 /// that has been registered with g_signal_group_connect_object() or
210 /// similar functions will be connected to this object.
211 ///
212 /// If the target instance was previously set, signals will be
213 /// disconnected from that object prior to connecting to @target.
214 /// ## `target`
215 /// The target instance used
216 /// when connecting signals.
217 #[doc(alias = "g_signal_group_set_target")]
218 #[doc(alias = "target")]
219 pub fn set_target(&self, target: Option<&impl IsA<Object>>) {
220 unsafe {
221 crate::gobject_ffi::g_signal_group_set_target(
222 self.to_glib_none().0,
223 target.map(|p| p.as_ref()).to_glib_none().0,
224 );
225 }
226 }
227
228 /// Unblocks all signal handlers managed by @self so they will be
229 /// called again during any signal emissions unless it is blocked
230 /// again. Must be unblocked exactly the same number of times it
231 /// has been blocked to become active again.
232 // rustdoc-stripper-ignore-next-stop
233 /// Unblocks all signal handlers managed by @self so they will be
234 /// called again during any signal emissions unless it is blocked
235 /// again. Must be unblocked exactly the same number of times it
236 /// has been blocked to become active again.
237 #[doc(alias = "g_signal_group_unblock")]
238 pub fn unblock(&self) {
239 unsafe {
240 crate::gobject_ffi::g_signal_group_unblock(self.to_glib_none().0);
241 }
242 }
243
244 /// The #GType of the target property.
245 // rustdoc-stripper-ignore-next-stop
246 /// The #GType of the target property.
247 #[cfg(feature = "v2_72")]
248 #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
249 #[doc(alias = "target-type")]
250 pub fn target_type(&self) -> crate::types::Type {
251 ObjectExt::property(self, "target-type")
252 }
253}
254
255unsafe impl Send for SignalGroup {}
256unsafe impl Sync for SignalGroup {}