Commit d780b92f authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Use an extension trait instead of a custom type for the GStreamer param specs

This way they can simply be created via glib::ParamSpec::fraction() for
example.
parent 43f5a10f
Pipeline #11794 failed with stages
in 15 seconds
......@@ -334,6 +334,7 @@ pub mod prelude {
pub use gobject::GObjectExtManualGst;
pub use object::GstObjectExtManual;
pub use pad::PadExtManual;
pub use param_spec::GstParamSpecExt;
pub use tag_setter::TagSetterExtManual;
pub use value::GstValueExt;
......
......@@ -10,11 +10,30 @@ use ffi;
use glib;
use glib::translate::*;
pub struct ParamSpec(());
pub trait GstParamSpecExt {
#[cfg(any(feature = "v1_14", feature = "dox"))]
fn array(
name: &str,
nick: &str,
blurb: &str,
element_spec: &glib::ParamSpec,
flags: glib::ParamFlags,
) -> Self;
fn fraction(
name: &str,
nick: &str,
blurb: &str,
min: ::Fraction,
max: ::Fraction,
default: ::Fraction,
flags: glib::ParamFlags,
) -> Self;
}
impl ParamSpec {
impl GstParamSpecExt for glib::ParamSpec {
#[cfg(any(feature = "v1_14", feature = "dox"))]
pub fn array(
fn array(
name: &str,
nick: &str,
blurb: &str,
......@@ -32,7 +51,7 @@ impl ParamSpec {
}
}
pub fn fraction(
fn fraction(
name: &str,
nick: &str,
blurb: &str,
......@@ -57,3 +76,24 @@ impl ParamSpec {
}
}
}
#[cfg(test)]
mod tests {
use glib;
use prelude::*;
#[test]
fn test_trait() {
::init().unwrap();
let _pspec = glib::ParamSpec::fraction(
"foo",
"Foo",
"Foo Bar",
(0, 1).into(),
(100, 1).into(),
(1, 1).into(),
glib::ParamFlags::READWRITE,
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment