2018-10-31 16:10:30 +00:00
|
|
|
// This file was generated by gir (https://github.com/gtk-rs/gir)
|
|
|
|
// from gir-files (https://github.com/gtk-rs/gir-files)
|
|
|
|
// DO NOT EDIT
|
|
|
|
|
|
|
|
use Error;
|
|
|
|
use Extractable;
|
|
|
|
use ffi;
|
|
|
|
#[cfg(feature = "futures")]
|
|
|
|
use futures_core;
|
|
|
|
use gio;
|
|
|
|
use gio_ffi;
|
|
|
|
use glib;
|
2018-12-09 16:06:12 +00:00
|
|
|
use glib::GString;
|
2018-10-31 16:10:30 +00:00
|
|
|
use glib::Value;
|
2019-01-16 11:32:39 +00:00
|
|
|
use glib::object::Cast;
|
2018-10-31 16:10:30 +00:00
|
|
|
use glib::object::IsA;
|
|
|
|
use glib::signal::SignalHandlerId;
|
2018-12-08 09:05:20 +00:00
|
|
|
use glib::signal::connect_raw;
|
2018-10-31 16:10:30 +00:00
|
|
|
use glib::translate::*;
|
|
|
|
use glib_ffi;
|
|
|
|
use gobject_ffi;
|
|
|
|
use std::boxed::Box as Box_;
|
|
|
|
use std::mem::transmute;
|
|
|
|
use std::ptr;
|
|
|
|
|
|
|
|
glib_wrapper! {
|
2019-01-16 11:32:39 +00:00
|
|
|
pub struct Asset(Object<ffi::GESAsset, ffi::GESAssetClass, AssetClass>);
|
2018-10-31 16:10:30 +00:00
|
|
|
|
|
|
|
match fn {
|
|
|
|
get_type => || ffi::ges_asset_get_type(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Asset {
|
|
|
|
pub fn needs_reload(extractable_type: glib::types::Type, id: &str) -> bool {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
|
|
|
from_glib(ffi::ges_asset_needs_reload(extractable_type.to_glib(), id.to_glib_none().0))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn request<'a, P: Into<Option<&'a str>>>(extractable_type: glib::types::Type, id: P) -> Result<Option<Asset>, Error> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
let id = id.into();
|
|
|
|
unsafe {
|
|
|
|
let mut error = ptr::null_mut();
|
2019-01-16 11:32:39 +00:00
|
|
|
let ret = ffi::ges_asset_request(extractable_type.to_glib(), id.to_glib_none().0, &mut error);
|
2018-10-31 16:10:30 +00:00
|
|
|
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-16 11:32:39 +00:00
|
|
|
pub fn request_async<'a, P: IsA<gio::Cancellable> + 'a, Q: Into<Option<&'a P>>, R: FnOnce(Result<Asset, Error>) + Send + 'static>(extractable_type: glib::types::Type, id: &str, cancellable: Q, callback: R) {
|
2018-10-31 16:10:30 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
let cancellable = cancellable.into();
|
2019-01-16 11:32:39 +00:00
|
|
|
let user_data: Box<Box<R>> = Box::new(Box::new(callback));
|
|
|
|
unsafe extern "C" fn request_async_trampoline<R: FnOnce(Result<Asset, Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer)
|
2018-10-31 16:10:30 +00:00
|
|
|
{
|
|
|
|
let mut error = ptr::null_mut();
|
|
|
|
let ret = ffi::ges_asset_request_finish(res, &mut error);
|
|
|
|
let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) };
|
2019-01-16 11:32:39 +00:00
|
|
|
let callback: Box<Box<R>> = Box::from_raw(user_data as *mut _);
|
2018-10-31 16:10:30 +00:00
|
|
|
callback(result);
|
|
|
|
}
|
2019-01-16 11:32:39 +00:00
|
|
|
let callback = request_async_trampoline::<R>;
|
2018-10-31 16:10:30 +00:00
|
|
|
unsafe {
|
2019-01-16 11:32:39 +00:00
|
|
|
ffi::ges_asset_request_async(extractable_type.to_glib(), id.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _);
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "futures")]
|
|
|
|
pub fn request_async_future(extractable_type: glib::types::Type, id: &str) -> Box_<futures_core::Future<Item = Asset, Error = Error>> {
|
|
|
|
use gio::GioFuture;
|
|
|
|
use fragile::Fragile;
|
|
|
|
|
|
|
|
let id = String::from(id);
|
|
|
|
GioFuture::new(&(), move |_obj, send| {
|
|
|
|
let cancellable = gio::Cancellable::new();
|
|
|
|
let send = Fragile::new(send);
|
|
|
|
Self::request_async(
|
|
|
|
extractable_type,
|
|
|
|
&id,
|
|
|
|
Some(&cancellable),
|
|
|
|
move |res| {
|
|
|
|
let _ = send.into_inner().send(res);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
cancellable
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-16 11:32:39 +00:00
|
|
|
pub const NONE_ASSET: Option<&Asset> = None;
|
|
|
|
|
2018-12-08 09:05:20 +00:00
|
|
|
pub trait AssetExt: 'static {
|
2018-10-31 16:10:30 +00:00
|
|
|
fn extract(&self) -> Result<Option<Extractable>, Error>;
|
|
|
|
|
|
|
|
fn get_error(&self) -> Option<Error>;
|
|
|
|
|
|
|
|
fn get_extractable_type(&self) -> glib::types::Type;
|
|
|
|
|
2018-12-09 16:06:12 +00:00
|
|
|
fn get_id(&self) -> Option<GString>;
|
2018-10-31 16:10:30 +00:00
|
|
|
|
|
|
|
fn get_proxy(&self) -> Option<Asset>;
|
|
|
|
|
|
|
|
fn get_proxy_target(&self) -> Option<Asset>;
|
|
|
|
|
|
|
|
fn list_proxies(&self) -> Vec<Asset>;
|
|
|
|
|
|
|
|
fn set_proxy<'a, P: IsA<Asset> + 'a, Q: Into<Option<&'a P>>>(&self, proxy: Q) -> bool;
|
|
|
|
|
|
|
|
fn unproxy<P: IsA<Asset>>(&self, proxy: &P) -> bool;
|
|
|
|
|
2018-12-08 09:05:20 +00:00
|
|
|
fn set_property_proxy_target<P: IsA<Asset> + glib::value::SetValueOptional>(&self, proxy_target: Option<&P>);
|
2018-10-31 16:10:30 +00:00
|
|
|
|
|
|
|
fn connect_property_proxy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
|
|
|
|
|
|
|
|
fn connect_property_proxy_target_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
|
|
|
|
}
|
|
|
|
|
2018-12-08 09:05:20 +00:00
|
|
|
impl<O: IsA<Asset>> AssetExt for O {
|
2018-10-31 16:10:30 +00:00
|
|
|
fn extract(&self) -> Result<Option<Extractable>, Error> {
|
|
|
|
unsafe {
|
|
|
|
let mut error = ptr::null_mut();
|
2019-01-16 11:32:39 +00:00
|
|
|
let ret = ffi::ges_asset_extract(self.as_ref().to_glib_none().0, &mut error);
|
2018-10-31 16:10:30 +00:00
|
|
|
if error.is_null() { Ok(from_glib_none(ret)) } else { Err(from_glib_full(error)) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_error(&self) -> Option<Error> {
|
|
|
|
unsafe {
|
2019-01-16 11:32:39 +00:00
|
|
|
from_glib_none(ffi::ges_asset_get_error(self.as_ref().to_glib_none().0))
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_extractable_type(&self) -> glib::types::Type {
|
|
|
|
unsafe {
|
2019-01-16 11:32:39 +00:00
|
|
|
from_glib(ffi::ges_asset_get_extractable_type(self.as_ref().to_glib_none().0))
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 16:06:12 +00:00
|
|
|
fn get_id(&self) -> Option<GString> {
|
2018-10-31 16:10:30 +00:00
|
|
|
unsafe {
|
2019-01-16 11:32:39 +00:00
|
|
|
from_glib_none(ffi::ges_asset_get_id(self.as_ref().to_glib_none().0))
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_proxy(&self) -> Option<Asset> {
|
|
|
|
unsafe {
|
2019-01-16 11:32:39 +00:00
|
|
|
from_glib_none(ffi::ges_asset_get_proxy(self.as_ref().to_glib_none().0))
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_proxy_target(&self) -> Option<Asset> {
|
|
|
|
unsafe {
|
2019-01-16 11:32:39 +00:00
|
|
|
from_glib_none(ffi::ges_asset_get_proxy_target(self.as_ref().to_glib_none().0))
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn list_proxies(&self) -> Vec<Asset> {
|
|
|
|
unsafe {
|
2019-01-16 11:32:39 +00:00
|
|
|
FromGlibPtrContainer::from_glib_none(ffi::ges_asset_list_proxies(self.as_ref().to_glib_none().0))
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_proxy<'a, P: IsA<Asset> + 'a, Q: Into<Option<&'a P>>>(&self, proxy: Q) -> bool {
|
|
|
|
let proxy = proxy.into();
|
|
|
|
unsafe {
|
2019-01-16 11:32:39 +00:00
|
|
|
from_glib(ffi::ges_asset_set_proxy(self.as_ref().to_glib_none().0, proxy.map(|p| p.as_ref()).to_glib_none().0))
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn unproxy<P: IsA<Asset>>(&self, proxy: &P) -> bool {
|
|
|
|
unsafe {
|
2019-01-16 11:32:39 +00:00
|
|
|
from_glib(ffi::ges_asset_unproxy(self.as_ref().to_glib_none().0, proxy.as_ref().to_glib_none().0))
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 09:05:20 +00:00
|
|
|
fn set_property_proxy_target<P: IsA<Asset> + glib::value::SetValueOptional>(&self, proxy_target: Option<&P>) {
|
2018-10-31 16:10:30 +00:00
|
|
|
unsafe {
|
2018-12-08 09:05:20 +00:00
|
|
|
gobject_ffi::g_object_set_property(self.to_glib_none().0 as *mut gobject_ffi::GObject, b"proxy-target\0".as_ptr() as *const _, Value::from(proxy_target).to_glib_none().0);
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn connect_property_proxy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
|
|
|
|
unsafe {
|
|
|
|
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
|
2019-01-16 11:32:39 +00:00
|
|
|
connect_raw(self.as_ptr() as *mut _, b"notify::proxy\0".as_ptr() as *const _,
|
2018-10-31 16:10:30 +00:00
|
|
|
transmute(notify_proxy_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn connect_property_proxy_target_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
|
|
|
|
unsafe {
|
|
|
|
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
|
2019-01-16 11:32:39 +00:00
|
|
|
connect_raw(self.as_ptr() as *mut _, b"notify::proxy-target\0".as_ptr() as *const _,
|
2018-10-31 16:10:30 +00:00
|
|
|
transmute(notify_proxy_target_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn notify_proxy_trampoline<P>(this: *mut ffi::GESAsset, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
|
|
|
|
where P: IsA<Asset> {
|
|
|
|
let f: &&(Fn(&P) + 'static) = transmute(f);
|
2019-01-16 11:32:39 +00:00
|
|
|
f(&Asset::from_glib_borrow(this).unsafe_cast())
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn notify_proxy_target_trampoline<P>(this: *mut ffi::GESAsset, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
|
|
|
|
where P: IsA<Asset> {
|
|
|
|
let f: &&(Fn(&P) + 'static) = transmute(f);
|
2019-01-16 11:32:39 +00:00
|
|
|
f(&Asset::from_glib_borrow(this).unsafe_cast())
|
2018-10-31 16:10:30 +00:00
|
|
|
}
|