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
62/// Trait containing all [`struct@ChildProxy`] methods.
63///
64/// # Implementors
65///
66/// [`Bin`][struct@crate::Bin], [`ChildProxy`][struct@crate::ChildProxy], [`Pipeline`][struct@crate::Pipeline]
67pub trait ChildProxyExt: IsA<ChildProxy> + 'static {
68    /// Emits the [`child-added`][struct@crate::ChildProxy#child-added] signal.
69    /// ## `child`
70    /// the newly added child
71    /// ## `name`
72    /// the name of the new child
73    #[doc(alias = "gst_child_proxy_child_added")]
74    fn child_added(&self, child: &impl IsA<glib::Object>, name: &str) {
75        unsafe {
76            ffi::gst_child_proxy_child_added(
77                self.as_ref().to_glib_none().0,
78                child.as_ref().to_glib_none().0,
79                name.to_glib_none().0,
80            );
81        }
82    }
83
84    /// Emits the [`child-removed`][struct@crate::ChildProxy#child-removed] signal.
85    /// ## `child`
86    /// the removed child
87    /// ## `name`
88    /// the name of the old child
89    #[doc(alias = "gst_child_proxy_child_removed")]
90    fn child_removed(&self, child: &impl IsA<glib::Object>, name: &str) {
91        unsafe {
92            ffi::gst_child_proxy_child_removed(
93                self.as_ref().to_glib_none().0,
94                child.as_ref().to_glib_none().0,
95                name.to_glib_none().0,
96            );
97        }
98    }
99
100    //#[doc(alias = "gst_child_proxy_get")]
101    //fn get(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
102    //    unsafe { TODO: call ffi:gst_child_proxy_get() }
103    //}
104
105    /// Fetches a child by its number.
106    /// ## `index`
107    /// the child's position in the child list
108    ///
109    /// # Returns
110    ///
111    /// the child object or [`None`] if
112    ///  not found (index too high).
113    #[doc(alias = "gst_child_proxy_get_child_by_index")]
114    #[doc(alias = "get_child_by_index")]
115    fn child_by_index(&self, index: u32) -> Option<glib::Object> {
116        unsafe {
117            from_glib_full(ffi::gst_child_proxy_get_child_by_index(
118                self.as_ref().to_glib_none().0,
119                index,
120            ))
121        }
122    }
123
124    /// Looks up a child element by the given name.
125    ///
126    /// This virtual method has a default implementation that uses [`Object`][crate::Object]
127    /// together with [`GstObjectExt::name()`][crate::prelude::GstObjectExt::name()]. If the interface is to be used with
128    /// `GObjects`, this methods needs to be overridden.
129    /// ## `name`
130    /// the child's name
131    ///
132    /// # Returns
133    ///
134    /// the child object or [`None`] if
135    ///  not found.
136    #[doc(alias = "gst_child_proxy_get_child_by_name")]
137    #[doc(alias = "get_child_by_name")]
138    fn child_by_name(&self, name: &str) -> Option<glib::Object> {
139        unsafe {
140            from_glib_full(ffi::gst_child_proxy_get_child_by_name(
141                self.as_ref().to_glib_none().0,
142                name.to_glib_none().0,
143            ))
144        }
145    }
146
147    /// Looks up a child element by the given full-path name.
148    ///
149    /// Similar to [`child_by_name()`][Self::child_by_name()], this method
150    /// searches and returns a child given a name. The difference is that
151    /// this method allows a hierarchical path in the form of
152    /// child1::child2::child3. In the later example this method would
153    /// return a reference to child3, if found. The name should be made of
154    /// element names only and should not contain any property names.
155    /// ## `name`
156    /// the full-path child's name
157    ///
158    /// # Returns
159    ///
160    /// the child object or [`None`] if
161    ///  not found.
162    #[cfg(feature = "v1_22")]
163    #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
164    #[doc(alias = "gst_child_proxy_get_child_by_name_recurse")]
165    #[doc(alias = "get_child_by_name_recurse")]
166    fn child_by_name_recurse(&self, name: &str) -> Option<glib::Object> {
167        unsafe {
168            from_glib_full(ffi::gst_child_proxy_get_child_by_name_recurse(
169                self.as_ref().to_glib_none().0,
170                name.to_glib_none().0,
171            ))
172        }
173    }
174
175    /// Gets the number of child objects this parent contains.
176    ///
177    /// # Returns
178    ///
179    /// the number of child objects
180    #[doc(alias = "gst_child_proxy_get_children_count")]
181    #[doc(alias = "get_children_count")]
182    fn children_count(&self) -> u32 {
183        unsafe { ffi::gst_child_proxy_get_children_count(self.as_ref().to_glib_none().0) }
184    }
185
186    //#[doc(alias = "gst_child_proxy_get_valist")]
187    //#[doc(alias = "get_valist")]
188    //fn valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
189    //    unsafe { TODO: call ffi:gst_child_proxy_get_valist() }
190    //}
191
192    //#[doc(alias = "gst_child_proxy_set")]
193    //fn set(&self, first_property_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
194    //    unsafe { TODO: call ffi:gst_child_proxy_set() }
195    //}
196
197    //#[doc(alias = "gst_child_proxy_set_valist")]
198    //fn set_valist(&self, first_property_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
199    //    unsafe { TODO: call ffi:gst_child_proxy_set_valist() }
200    //}
201
202    /// Will be emitted after the `object` was added to the `child_proxy`.
203    /// ## `object`
204    /// the [`glib::Object`][crate::glib::Object] that was added
205    /// ## `name`
206    /// the name of the new child
207    #[doc(alias = "child-added")]
208    fn connect_child_added<F: Fn(&Self, &glib::Object, &str) + Send + Sync + 'static>(
209        &self,
210        f: F,
211    ) -> SignalHandlerId {
212        unsafe extern "C" fn child_added_trampoline<
213            P: IsA<ChildProxy>,
214            F: Fn(&P, &glib::Object, &str) + Send + Sync + 'static,
215        >(
216            this: *mut ffi::GstChildProxy,
217            object: *mut glib::gobject_ffi::GObject,
218            name: *mut std::ffi::c_char,
219            f: glib::ffi::gpointer,
220        ) {
221            let f: &F = &*(f as *const F);
222            f(
223                ChildProxy::from_glib_borrow(this).unsafe_cast_ref(),
224                &from_glib_borrow(object),
225                &glib::GString::from_glib_borrow(name),
226            )
227        }
228        unsafe {
229            let f: Box_<F> = Box_::new(f);
230            connect_raw(
231                self.as_ptr() as *mut _,
232                c"child-added".as_ptr() as *const _,
233                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
234                    child_added_trampoline::<Self, F> as *const (),
235                )),
236                Box_::into_raw(f),
237            )
238        }
239    }
240
241    /// Will be emitted after the `object` was removed from the `child_proxy`.
242    /// ## `object`
243    /// the [`glib::Object`][crate::glib::Object] that was removed
244    /// ## `name`
245    /// the name of the old child
246    #[doc(alias = "child-removed")]
247    fn connect_child_removed<F: Fn(&Self, &glib::Object, &str) + Send + Sync + 'static>(
248        &self,
249        f: F,
250    ) -> SignalHandlerId {
251        unsafe extern "C" fn child_removed_trampoline<
252            P: IsA<ChildProxy>,
253            F: Fn(&P, &glib::Object, &str) + Send + Sync + 'static,
254        >(
255            this: *mut ffi::GstChildProxy,
256            object: *mut glib::gobject_ffi::GObject,
257            name: *mut std::ffi::c_char,
258            f: glib::ffi::gpointer,
259        ) {
260            let f: &F = &*(f as *const F);
261            f(
262                ChildProxy::from_glib_borrow(this).unsafe_cast_ref(),
263                &from_glib_borrow(object),
264                &glib::GString::from_glib_borrow(name),
265            )
266        }
267        unsafe {
268            let f: Box_<F> = Box_::new(f);
269            connect_raw(
270                self.as_ptr() as *mut _,
271                c"child-removed".as_ptr() as *const _,
272                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
273                    child_removed_trampoline::<Self, F> as *const (),
274                )),
275                Box_::into_raw(f),
276            )
277        }
278    }
279}
280
281impl<O: IsA<ChildProxy>> ChildProxyExt for O {}