gstreamer_editing_services/
timeline_element.rs

1use glib::translate::*;
2
3use crate::prelude::*;
4use crate::{ffi, TimelineElement};
5
6pub trait TimelineElementExtManual: IsA<TimelineElement> + 'static {
7    /// See [`TimelineElementExt::set_child_property_full()`][crate::prelude::TimelineElementExt::set_child_property_full()], which also gives an
8    /// error.
9    ///
10    /// Note that `ges_timeline_element_set_child_properties()` may be more
11    /// convenient for C programming.
12    /// ## `property_name`
13    /// The name of the child property to set
14    /// ## `value`
15    /// The value to set the property to
16    ///
17    /// # Returns
18    ///
19    /// [`true`] if the property was found and set.
20    #[doc(alias = "ges_timeline_element_set_child_property")]
21    fn set_child_property(
22        &self,
23        property_name: &str,
24        value: impl Into<glib::Value>,
25    ) -> Result<(), glib::error::BoolError> {
26        self.set_child_property_by_pspec(
27            self.as_ref()
28                .lookup_child(property_name)
29                .ok_or_else(|| glib::bool_error!("No such child property: {property_name}"))?
30                .1,
31            value,
32        );
33
34        Ok(())
35    }
36
37    /// Sets the property of a child of the element. Specifically, the property
38    /// corresponding to the `pspec` used in
39    /// [`TimelineElementExt::add_child_property()`][crate::prelude::TimelineElementExt::add_child_property()] is set to `value`.
40    /// ## `pspec`
41    /// The specification of a registered child property to set
42    /// ## `value`
43    /// The value to set the property to
44    #[doc(alias = "ges_timeline_element_set_child_property_by_pspec")]
45    fn set_child_property_by_pspec(
46        &self,
47        pspec: impl AsRef<glib::ParamSpec>,
48        value: impl Into<glib::Value>,
49    ) {
50        unsafe {
51            ffi::ges_timeline_element_set_child_property_by_pspec(
52                self.as_ref().to_glib_none().0,
53                pspec.as_ref().to_glib_none().0,
54                value.into().to_glib_none().0,
55            );
56        }
57    }
58}
59
60impl<O: IsA<TimelineElement>> TimelineElementExtManual for O {}