gstreamer/auto/child_proxy.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// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{
8 object::ObjectType as _,
9 prelude::*,
10 signal::{connect_raw, SignalHandlerId},
11 translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16 /// This interface abstracts handling of property sets for elements with
17 /// children. Imagine elements such as mixers or polyphonic generators. They all
18 /// have multiple [`Pad`][crate::Pad] or some kind of voice objects. Another use case are
19 /// container elements like [`Bin`][crate::Bin].
20 /// The element implementing the interface acts as a parent for those child
21 /// objects.
22 ///
23 /// By implementing this interface the child properties can be accessed from the
24 /// parent element by using `gst_child_proxy_get()` and `gst_child_proxy_set()`.
25 ///
26 /// Property names are written as `child-name::property-name`. The whole naming
27 /// scheme is recursive. Thus `child1::child2::property` is valid too, if
28 /// `child1` and `child2` implement the [`ChildProxy`][crate::ChildProxy] interface.
29 ///
30 /// ## Signals
31 ///
32 ///
33 /// #### `child-added`
34 /// Will be emitted after the `object` was added to the `child_proxy`.
35 ///
36 ///
37 ///
38 ///
39 /// #### `child-removed`
40 /// Will be emitted after the `object` was removed from the `child_proxy`.
41 ///
42 ///
43 ///
44 /// # Implements
45 ///
46 /// [`ChildProxyExt`][trait@crate::prelude::ChildProxyExt], [`ChildProxyExtManual`][trait@crate::prelude::ChildProxyExtManual]
47 #[doc(alias = "GstChildProxy")]
48 pub struct ChildProxy(Interface<ffi::GstChildProxy, ffi::GstChildProxyInterface>);
49
50 match fn {
51 type_ => || ffi::gst_child_proxy_get_type(),
52 }
53}
54
55impl ChildProxy {
56 pub const NONE: Option<&'static ChildProxy> = None;
57}
58
59unsafe impl Send for ChildProxy {}
60unsafe impl Sync for ChildProxy {}
61
62mod sealed {
63 pub trait Sealed {}
64 impl<T: super::IsA<super::ChildProxy>> Sealed for T {}
65}
66
67/// Trait containing all [`struct@ChildProxy`] methods.
68///
69/// # Implementors
70///
71/// [`Bin`][struct@crate::Bin], [`ChildProxy`][struct@crate::ChildProxy], [`Pipeline`][struct@crate::Pipeline]
72pub trait ChildProxyExt: IsA<ChildProxy> + sealed::Sealed + 'static {
73 /// Emits the [`child-added`][struct@crate::ChildProxy#child-added] signal.
74 /// ## `child`
75 /// the newly added child
76 /// ## `name`
77 /// the name of the new child
78 #[doc(alias = "gst_child_proxy_child_added")]
79 fn child_added(&self, child: &impl IsA<glib::Object>, name: &str) {
80 unsafe {
81 ffi::gst_child_proxy_child_added(
82 self.as_ref().to_glib_none().0,
83 child.as_ref().to_glib_none().0,
84 name.to_glib_none().0,
85 );
86 }
87 }
88
89 /// Emits the [`child-removed`][struct@crate::ChildProxy#child-removed] signal.
90 /// ## `child`
91 /// the removed child
92 /// ## `name`
93 /// the name of the old child
94 #[doc(alias = "gst_child_proxy_child_removed")]
95 fn child_removed(&self, child: &impl IsA<glib::Object>, name: &str) {
96 unsafe {
97 ffi::gst_child_proxy_child_removed(
98 self.as_ref().to_glib_none().0,
99 child.as_ref().to_glib_none().0,
100 name.to_glib_none().0,
101 );
102 }
103 }
104
105 //#[doc(alias = "gst_child_proxy_get")]
106 //fn get(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
107 // unsafe { TODO: call ffi:gst_child_proxy_get() }
108 //}
109
110 /// Fetches a child by its number.
111 /// ## `index`
112 /// the child's position in the child list
113 ///
114 /// # Returns
115 ///
116 /// the child object or [`None`] if
117 /// not found (index too high).
118 #[doc(alias = "gst_child_proxy_get_child_by_index")]
119 #[doc(alias = "get_child_by_index")]
120 fn child_by_index(&self, index: u32) -> Option<glib::Object> {
121 unsafe {
122 from_glib_full(ffi::gst_child_proxy_get_child_by_index(
123 self.as_ref().to_glib_none().0,
124 index,
125 ))
126 }
127 }
128
129 /// Looks up a child element by the given name.
130 ///
131 /// This virtual method has a default implementation that uses [`Object`][crate::Object]
132 /// together with [`GstObjectExt::name()`][crate::prelude::GstObjectExt::name()]. If the interface is to be used with
133 /// `GObjects`, this methods needs to be overridden.
134 /// ## `name`
135 /// the child's name
136 ///
137 /// # Returns
138 ///
139 /// the child object or [`None`] if
140 /// not found.
141 #[doc(alias = "gst_child_proxy_get_child_by_name")]
142 #[doc(alias = "get_child_by_name")]
143 fn child_by_name(&self, name: &str) -> Option<glib::Object> {
144 unsafe {
145 from_glib_full(ffi::gst_child_proxy_get_child_by_name(
146 self.as_ref().to_glib_none().0,
147 name.to_glib_none().0,
148 ))
149 }
150 }
151
152 /// Looks up a child element by the given full-path name.
153 ///
154 /// Similar to [`child_by_name()`][Self::child_by_name()], this method
155 /// searches and returns a child given a name. The difference is that
156 /// this method allows a hierarchical path in the form of
157 /// child1::child2::child3. In the later example this method would
158 /// return a reference to child3, if found. The name should be made of
159 /// element names only and should not contain any property names.
160 /// ## `name`
161 /// the full-path child's name
162 ///
163 /// # Returns
164 ///
165 /// the child object or [`None`] if
166 /// not found.
167 #[cfg(feature = "v1_22")]
168 #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
169 #[doc(alias = "gst_child_proxy_get_child_by_name_recurse")]
170 #[doc(alias = "get_child_by_name_recurse")]
171 fn child_by_name_recurse(&self, name: &str) -> Option<glib::Object> {
172 unsafe {
173 from_glib_full(ffi::gst_child_proxy_get_child_by_name_recurse(
174 self.as_ref().to_glib_none().0,
175 name.to_glib_none().0,
176 ))
177 }
178 }
179
180 /// Gets the number of child objects this parent contains.
181 ///
182 /// # Returns
183 ///
184 /// the number of child objects
185 #[doc(alias = "gst_child_proxy_get_children_count")]
186 #[doc(alias = "get_children_count")]
187 fn children_count(&self) -> u32 {
188 unsafe { ffi::gst_child_proxy_get_children_count(self.as_ref().to_glib_none().0) }
189 }
190
191 //#[doc(alias = "gst_child_proxy_get_valist")]
192 //#[doc(alias = "get_valist")]
193 //fn valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
194 // unsafe { TODO: call ffi:gst_child_proxy_get_valist() }
195 //}
196
197 //#[doc(alias = "gst_child_proxy_set")]
198 //fn set(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
199 // unsafe { TODO: call ffi:gst_child_proxy_set() }
200 //}
201
202 //#[doc(alias = "gst_child_proxy_set_valist")]
203 //fn set_valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
204 // unsafe { TODO: call ffi:gst_child_proxy_set_valist() }
205 //}
206
207 /// Will be emitted after the `object` was added to the `child_proxy`.
208 /// ## `object`
209 /// the [`glib::Object`][crate::glib::Object] that was added
210 /// ## `name`
211 /// the name of the new child
212 #[doc(alias = "child-added")]
213 fn connect_child_added<F: Fn(&Self, &glib::Object, &str) + Send + Sync + 'static>(
214 &self,
215 f: F,
216 ) -> SignalHandlerId {
217 unsafe extern "C" fn child_added_trampoline<
218 P: IsA<ChildProxy>,
219 F: Fn(&P, &glib::Object, &str) + Send + Sync + 'static,
220 >(
221 this: *mut ffi::GstChildProxy,
222 object: *mut glib::gobject_ffi::GObject,
223 name: *mut std::ffi::c_char,
224 f: glib::ffi::gpointer,
225 ) {
226 let f: &F = &*(f as *const F);
227 f(
228 ChildProxy::from_glib_borrow(this).unsafe_cast_ref(),
229 &from_glib_borrow(object),
230 &glib::GString::from_glib_borrow(name),
231 )
232 }
233 unsafe {
234 let f: Box_<F> = Box_::new(f);
235 connect_raw(
236 self.as_ptr() as *mut _,
237 b"child-added\0".as_ptr() as *const _,
238 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
239 child_added_trampoline::<Self, F> as *const (),
240 )),
241 Box_::into_raw(f),
242 )
243 }
244 }
245
246 /// Will be emitted after the `object` was removed from the `child_proxy`.
247 /// ## `object`
248 /// the [`glib::Object`][crate::glib::Object] that was removed
249 /// ## `name`
250 /// the name of the old child
251 #[doc(alias = "child-removed")]
252 fn connect_child_removed<F: Fn(&Self, &glib::Object, &str) + Send + Sync + 'static>(
253 &self,
254 f: F,
255 ) -> SignalHandlerId {
256 unsafe extern "C" fn child_removed_trampoline<
257 P: IsA<ChildProxy>,
258 F: Fn(&P, &glib::Object, &str) + Send + Sync + 'static,
259 >(
260 this: *mut ffi::GstChildProxy,
261 object: *mut glib::gobject_ffi::GObject,
262 name: *mut std::ffi::c_char,
263 f: glib::ffi::gpointer,
264 ) {
265 let f: &F = &*(f as *const F);
266 f(
267 ChildProxy::from_glib_borrow(this).unsafe_cast_ref(),
268 &from_glib_borrow(object),
269 &glib::GString::from_glib_borrow(name),
270 )
271 }
272 unsafe {
273 let f: Box_<F> = Box_::new(f);
274 connect_raw(
275 self.as_ptr() as *mut _,
276 b"child-removed\0".as_ptr() as *const _,
277 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
278 child_removed_trampoline::<Self, F> as *const (),
279 )),
280 Box_::into_raw(f),
281 )
282 }
283 }
284}
285
286impl<O: IsA<ChildProxy>> ChildProxyExt for O {}