1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::ptr;
4
5use glib::{prelude::*, translate::*};
6
7use crate::ChildProxy;
8
9mod sealed {
10 pub trait Sealed {}
11 impl<T: super::IsA<super::ChildProxy>> Sealed for T {}
12}
13
14pub trait ChildProxyExtManual: sealed::Sealed + IsA<ChildProxy> + 'static {
15 #[doc(alias = "gst_child_proxy_lookup")]
16 fn lookup(&self, name: &str) -> Result<(glib::Object, glib::ParamSpec), glib::BoolError> {
17 unsafe {
18 let mut target = ptr::null_mut();
19 let mut pspec = ptr::null_mut();
20 let ret = from_glib(ffi::gst_child_proxy_lookup(
21 self.as_ref().to_glib_none().0,
22 name.to_glib_none().0,
23 &mut target,
24 &mut pspec,
25 ));
26 if ret {
27 Ok((from_glib_full(target), from_glib_none(pspec)))
28 } else {
29 Err(glib::bool_error!("Failed to find child property"))
30 }
31 }
32 }
33
34 #[doc(alias = "get_child_property")]
35 #[doc(alias = "gst_child_proxy_get")]
36 #[track_caller]
37 fn child_property<V: for<'b> glib::value::FromValue<'b> + 'static>(&self, name: &str) -> V {
38 let (child, pspec) = self.lookup(name).unwrap();
39 child.property(pspec.name())
40 }
41
42 #[doc(alias = "get_child_property")]
43 #[doc(alias = "gst_child_proxy_get")]
44 #[track_caller]
45 fn child_property_value(&self, name: &str) -> glib::Value {
46 let (child, pspec) = self.lookup(name).unwrap();
47 child.property_value(pspec.name())
48 }
49
50 #[doc(alias = "gst_child_proxy_set")]
51 #[track_caller]
52 fn set_child_property(&self, name: &str, value: impl Into<glib::Value>) {
53 let (child, pspec) = self.lookup(name).unwrap();
54 child.set_property(pspec.name(), value)
55 }
56
57 #[doc(alias = "gst_child_proxy_set_property")]
58 #[track_caller]
59 fn set_child_property_from_value(&self, name: &str, value: &glib::Value) {
60 let (child, pspec) = self.lookup(name).unwrap();
61 child.set_property_from_value(pspec.name(), value)
62 }
63}
64
65impl<O: IsA<ChildProxy>> ChildProxyExtManual for O {}
66