use crate::{Core,SessionItem};
use glib::{prelude::*,translate::*};
glib::wrapper! {
#[doc(alias = "WpSiFactory")]
pub struct SiFactory(Object<ffi::WpSiFactory, ffi::WpSiFactoryClass>);
match fn {
type_ => || ffi::wp_si_factory_get_type(),
}
}
impl SiFactory {
pub const NONE: Option<&'static SiFactory> = None;
#[doc(alias = "wp_si_factory_new_simple")]
pub fn new_simple(factory_name: &str, si_type: glib::types::Type) -> SiFactory {
unsafe {
from_glib_full(ffi::wp_si_factory_new_simple(factory_name.to_glib_none().0, si_type.into_glib()))
}
}
#[doc(alias = "wp_si_factory_find")]
pub fn find(core: &Core, factory_name: &str) -> Option<SiFactory> {
unsafe {
from_glib_full(ffi::wp_si_factory_find(core.to_glib_none().0, factory_name.to_glib_none().0))
}
}
#[doc(alias = "wp_si_factory_register")]
pub fn register(core: &Core, factory: impl IsA<SiFactory>) {
unsafe {
ffi::wp_si_factory_register(core.to_glib_none().0, factory.upcast().into_glib_ptr());
}
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::SiFactory>> Sealed for T {}
}
pub trait SiFactoryExt: IsA<SiFactory> + sealed::Sealed + 'static {
#[doc(alias = "wp_si_factory_construct")]
fn construct(&self, core: &Core) -> Option<SessionItem> {
unsafe {
from_glib_full(ffi::wp_si_factory_construct(self.as_ref().to_glib_none().0, core.to_glib_none().0))
}
}
#[doc(alias = "wp_si_factory_get_name")]
#[doc(alias = "get_name")]
fn name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::wp_si_factory_get_name(self.as_ref().to_glib_none().0))
}
}
}
impl<O: IsA<SiFactory>> SiFactoryExt for O {}