forked from mirrors/gstreamer-rs
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.
This commit is contained in:
parent
43f5a10f9c
commit
d780b92f21
2 changed files with 46 additions and 5 deletions
|
@ -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(());
|
||||
|
||||
impl ParamSpec {
|
||||
pub trait GstParamSpecExt {
|
||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||
pub fn array(
|
||||
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 GstParamSpecExt for glib::ParamSpec {
|
||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue