ges: Replace (set_)child_property with autogenerated implementation

This function is now autogenerated thanks to `glib::Value` being
declared as available in `Gir.toml` and does not seem to have any
deficiencies compared to the manual implementation [1].

[1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/789#note_937493
This commit is contained in:
Marijn Suijten 2021-05-31 09:31:55 +02:00 committed by Sebastian Dröge
parent 1c05f61bb8
commit f78cb39615
2 changed files with 0 additions and 73 deletions

View file

@ -56,8 +56,6 @@ macro_rules! skip_assert_initialized {
mod auto;
pub use crate::auto::*;
mod timeline_element;
// Re-export all the traits in a prelude module, so that applications
// can always "use ges::prelude::*" without getting conflicts
pub mod prelude {
@ -68,7 +66,5 @@ pub mod prelude {
#[doc(hidden)]
pub use gst_pbutils::prelude::*;
pub use crate::timeline_element::TimelineElementExtManual;
pub use crate::auto::traits::*;
}

View file

@ -1,69 +0,0 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use crate::TimelineElement;
use glib::prelude::*;
use glib::translate::*;
use std::ptr;
pub trait TimelineElementExtManual: 'static {
#[doc(alias = "get_child_property")]
#[doc(alias = "ges_timeline_element_get_child_property")]
fn child_property(&self, name: &str) -> Option<glib::Value>;
#[doc(alias = "ges_timeline_element_set_child_property")]
fn set_child_property(
&self,
name: &str,
value: &dyn glib::ToValue,
) -> Result<(), glib::BoolError>;
}
impl<O: IsA<TimelineElement>> TimelineElementExtManual for O {
fn child_property(&self, name: &str) -> Option<glib::Value> {
unsafe {
let found: bool = from_glib(ffi::ges_timeline_element_lookup_child(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
ptr::null_mut(),
ptr::null_mut(),
));
if !found {
return None;
}
let mut value = glib::Value::uninitialized();
ffi::ges_timeline_element_get_child_property(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
value.to_glib_none_mut().0,
);
Some(value)
}
}
fn set_child_property(
&self,
name: &str,
value: &dyn glib::ToValue,
) -> Result<(), glib::BoolError> {
unsafe {
let found: bool = from_glib(ffi::ges_timeline_element_lookup_child(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
ptr::null_mut(),
ptr::null_mut(),
));
if !found {
return Err(glib::bool_error!("Child property not found"));
}
let value = value.to_value();
ffi::ges_timeline_element_set_child_property(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
value.to_glib_none().0,
);
Ok(())
}
}
}