From 446f09fec683c5e0a2a24111dcb97617276707d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 10 Aug 2022 12:03:51 +0300 Subject: [PATCH] gstreamer: Implement new ParamSpecBuilderExt trait from glib --- gstreamer/src/param_spec.rs | 82 ++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/gstreamer/src/param_spec.rs b/gstreamer/src/param_spec.rs index 53e46e90c..b01c99b0d 100644 --- a/gstreamer/src/param_spec.rs +++ b/gstreamer/src/param_spec.rs @@ -124,27 +124,6 @@ impl<'a> ParamSpecFractionBuilder<'a> { } } - // rustdoc-stripper-ignore-next - /// Default: `self.name` - pub fn nick(mut self, nick: &'a str) -> Self { - self.nick = Some(nick); - self - } - - // rustdoc-stripper-ignore-next - /// Default: `self.name` - pub fn blurb(mut self, blurb: &'a str) -> Self { - self.blurb = Some(blurb); - self - } - - // rustdoc-stripper-ignore-next - /// Default: `glib::ParamFlags::READWRITE` - pub fn flags(mut self, flags: glib::ParamFlags) -> Self { - self.flags = flags; - self - } - // rustdoc-stripper-ignore-next /// Default: `-i32::MAX/1` pub fn minimum(mut self, minimum: crate::Fraction) -> Self { @@ -183,6 +162,21 @@ impl<'a> ParamSpecFractionBuilder<'a> { } } +impl<'a> glib::prelude::ParamSpecBuilderExt<'a> for ParamSpecFractionBuilder<'a> { + fn set_nick(&mut self, nick: Option<&'a str>) { + self.nick = nick; + } + fn set_blurb(&mut self, blurb: Option<&'a str>) { + self.blurb = blurb; + } + fn set_flags(&mut self, flags: glib::ParamFlags) { + self.flags = flags; + } + fn current_flags(&self) -> glib::ParamFlags { + self.flags + } +} + glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[doc(alias = "GstParamSpecArray")] @@ -278,27 +272,6 @@ impl<'a> ParamSpecArrayBuilder<'a> { } } - // rustdoc-stripper-ignore-next - /// Default: `self.name` - pub fn nick(mut self, nick: &'a str) -> Self { - self.nick = Some(nick); - self - } - - // rustdoc-stripper-ignore-next - /// Default: `self.name` - pub fn blurb(mut self, blurb: &'a str) -> Self { - self.blurb = Some(blurb); - self - } - - // rustdoc-stripper-ignore-next - /// Default: `glib::ParamFlags::READWRITE` - pub fn flags(mut self, flags: glib::ParamFlags) -> Self { - self.flags = flags; - self - } - // rustdoc-stripper-ignore-next /// Default: `None` pub fn element_spec(mut self, element_spec: &'a glib::ParamSpec) -> Self { @@ -318,9 +291,25 @@ impl<'a> ParamSpecArrayBuilder<'a> { } } +impl<'a> glib::prelude::ParamSpecBuilderExt<'a> for ParamSpecArrayBuilder<'a> { + fn set_nick(&mut self, nick: Option<&'a str>) { + self.nick = nick; + } + fn set_blurb(&mut self, blurb: Option<&'a str>) { + self.blurb = blurb; + } + fn set_flags(&mut self, flags: glib::ParamFlags) { + self.flags = flags; + } + fn current_flags(&self) -> glib::ParamFlags { + self.flags + } +} + #[cfg(test)] mod tests { use super::*; + use glib::prelude::*; #[test] fn test_trait() { @@ -335,5 +324,14 @@ mod tests { (1, 1).into(), glib::ParamFlags::READWRITE, ); + + let _pspec = ParamSpecFraction::builder("foo") + .nick("Foo") + .blurb("Foo Bar") + .minimum((0, 1).into()) + .maximum((100, 1).into()) + .default_value((1, 1).into()) + .readwrite() + .build(); } }