From f78cb39615059eafc0e10713b00f8ca91629008d Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Mon, 31 May 2021 09:31:55 +0200 Subject: [PATCH] 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 --- gstreamer-editing-services/src/lib.rs | 4 -- .../src/timeline_element.rs | 69 ------------------- 2 files changed, 73 deletions(-) delete mode 100644 gstreamer-editing-services/src/timeline_element.rs diff --git a/gstreamer-editing-services/src/lib.rs b/gstreamer-editing-services/src/lib.rs index 800d8f5d0..1162c1e48 100644 --- a/gstreamer-editing-services/src/lib.rs +++ b/gstreamer-editing-services/src/lib.rs @@ -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::*; } diff --git a/gstreamer-editing-services/src/timeline_element.rs b/gstreamer-editing-services/src/timeline_element.rs deleted file mode 100644 index a1293fafd..000000000 --- a/gstreamer-editing-services/src/timeline_element.rs +++ /dev/null @@ -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; - #[doc(alias = "ges_timeline_element_set_child_property")] - fn set_child_property( - &self, - name: &str, - value: &dyn glib::ToValue, - ) -> Result<(), glib::BoolError>; -} - -impl> TimelineElementExtManual for O { - fn child_property(&self, name: &str) -> Option { - 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(()) - } - } -}