gstreamer: Implement new ParamSpecBuilderExt trait from glib

This commit is contained in:
Sebastian Dröge 2022-08-10 12:03:51 +03:00
parent 8a50bbcaa3
commit 446f09fec6

View file

@ -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();
}
}