1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT
use crate::{ffi, Extractable, MetaContainer};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, pin::Pin};
glib::wrapper! {
/// A [`Asset`][crate::Asset] in the GStreamer Editing Services represents a resources
/// that can be used. In particular, any class that implements the
/// [`Extractable`][crate::Extractable] interface may have some associated assets with a
/// corresponding [`extractable-type`][struct@crate::Asset#extractable-type], from which its objects can be
/// extracted using [`AssetExt::extract()`][crate::prelude::AssetExt::extract()]. Some examples would be
/// [`Clip`][crate::Clip], [`Formatter`][crate::Formatter] and [`TrackElement`][crate::TrackElement].
///
/// All assets that are created within GES are stored in a cache; one per
/// each [`id`][struct@crate::Asset#id] and [`extractable-type`][struct@crate::Asset#extractable-type] pair. These assets can
/// be fetched, and initialized if they do not yet exist in the cache,
/// using [`request()`][Self::request()].
///
/// **⚠️ The following code is in c ⚠️**
///
/// ``` c
/// GESAsset *effect_asset;
/// GESEffect *effect;
///
/// // You create an asset for an effect
/// effect_asset = ges_asset_request (GES_TYPE_EFFECT, "agingtv", NULL);
///
/// // And now you can extract an instance of GESEffect from that asset
/// effect = GES_EFFECT (ges_asset_extract (effect_asset));
///
/// ```
///
/// The advantage of using assets, rather than simply creating the object
/// directly, is that the currently loaded resources can be listed with
/// `ges_list_assets()` and displayed to an end user. For example, to show
/// which media files have been loaded, and a standard list of effects. In
/// fact, the GES library already creates assets for [`TransitionClip`][crate::TransitionClip] and
/// [`Formatter`][crate::Formatter], which you can use to list all the available transition
/// types and supported formats.
///
/// The other advantage is that [`Asset`][crate::Asset] implements [`MetaContainer`][crate::MetaContainer], so
/// metadata can be set on the asset, with some subclasses automatically
/// creating this metadata on initiation.
///
/// For example, to display information about the supported formats, you
/// could do the following:
///
/// ```text
/// GList *formatter_assets, *tmp;
///
/// // List all the transitions
/// formatter_assets = ges_list_assets (GES_TYPE_FORMATTER);
///
/// // Print some infos about the formatter GESAsset
/// for (tmp = formatter_assets; tmp; tmp = tmp->next) {
/// gst_print ("Name of the formatter: %s, file extension it produces: %s",
/// ges_meta_container_get_string (
/// GES_META_CONTAINER (tmp->data), GES_META_FORMATTER_NAME),
/// ges_meta_container_get_string (
/// GES_META_CONTAINER (tmp->data), GES_META_FORMATTER_EXTENSION));
/// }
///
/// g_list_free (transition_assets);
///
/// ```
///
/// ## ID
///
/// Each asset is uniquely defined in the cache by its
/// [`extractable-type`][struct@crate::Asset#extractable-type] and [`id`][struct@crate::Asset#id]. Depending on the
/// [`extractable-type`][struct@crate::Asset#extractable-type], the [`id`][struct@crate::Asset#id] can be used to parametrise
/// the creation of the object upon extraction. By default, a class that
/// implements [`Extractable`][crate::Extractable] will only have a single associated asset,
/// with an [`id`][struct@crate::Asset#id] set to the type name of its objects. However, this
/// is overwritten by some implementations, which allow a class to have
/// multiple associated assets. For example, for [`TransitionClip`][crate::TransitionClip] the
/// [`id`][struct@crate::Asset#id] will be a nickname of the [`vtype`][struct@crate::TransitionClip#vtype]. You
/// should check the documentation for each extractable type to see if they
/// differ from the default.
///
/// Moreover, each [`extractable-type`][struct@crate::Asset#extractable-type] may also associate itself
/// with a specific asset subclass. In such cases, when their asset is
/// requested, an asset of this subclass will be returned instead.
///
/// ## Managing
///
/// You can use a [`Project`][crate::Project] to easily manage the assets of a
/// [`Timeline`][crate::Timeline].
///
/// ## Proxies
///
/// Some assets can (temporarily) act as the [`proxy`][struct@crate::Asset#proxy] of another
/// asset. When the original asset is requested from the cache, the proxy
/// will be returned in its place. This can be useful if, say, you want
/// to substitute a [`UriClipAsset`][crate::UriClipAsset] corresponding to a high resolution
/// media file with the asset of a lower resolution stand in.
///
/// An asset may even have several proxies, the first of which will act as
/// its default and be returned on requests, but the others will be ordered
/// to take its place once it is removed. You can add a proxy to an asset,
/// or set its default, using [`AssetExt::set_proxy()`][crate::prelude::AssetExt::set_proxy()], and you can remove
/// them with [`AssetExt::unproxy()`][crate::prelude::AssetExt::unproxy()].
///
/// ## Properties
///
///
/// #### `extractable-type`
/// The [`Extractable`][crate::Extractable] object type that can be extracted from the asset.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `id`
/// The ID of the asset. This should be unique amongst all assets with
/// the same [`extractable-type`][struct@crate::Asset#extractable-type]. Depending on the associated
/// [`Extractable`][crate::Extractable] implementation, this id may convey some information
/// about the [`glib::Object`][crate::glib::Object] that should be extracted. Note that, as such, the
/// ID will have an expected format, and you can not choose this value
/// arbitrarily. By default, this will be set to the type name of the
/// [`extractable-type`][struct@crate::Asset#extractable-type], but you should check the documentation
/// of the extractable type to see whether they differ from the
/// default behaviour.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `proxy`
/// The default proxy for this asset, or [`None`] if it has no proxy. A
/// proxy will act as a substitute for the original asset when the
/// original is requested (see [`Asset::request()`][crate::Asset::request()]).
///
/// Setting this property will not usually remove the existing proxy, but
/// will replace it as the default (see [`AssetExt::set_proxy()`][crate::prelude::AssetExt::set_proxy()]).
///
/// Readable | Writeable
///
///
/// #### `proxy-target`
/// The asset that this asset is a proxy for, or [`None`] if it is not a
/// proxy for another asset.
///
/// Note that even if this asset is acting as a proxy for another asset,
/// but this asset is not the default [`proxy`][struct@crate::Asset#proxy], then `proxy`-target
/// will *still* point to this other asset. So you should check the
/// [`proxy`][struct@crate::Asset#proxy] property of `target`-proxy before assuming it is the
/// current default proxy for the target.
///
/// Note that the [`notify`][struct@crate::glib::Object#notify] for this property is emitted after
/// the [`proxy`][struct@crate::Asset#proxy] [`notify`][struct@crate::glib::Object#notify] for the corresponding (if any)
/// asset it is now the proxy of/no longer the proxy of.
///
/// Readable
///
/// # Implements
///
/// [`AssetExt`][trait@crate::prelude::AssetExt], [`trait@glib::ObjectExt`], [`MetaContainerExt`][trait@crate::prelude::MetaContainerExt]
#[doc(alias = "GESAsset")]
pub struct Asset(Object<ffi::GESAsset, ffi::GESAssetClass>) @implements MetaContainer;
match fn {
type_ => || ffi::ges_asset_get_type(),
}
}
impl Asset {
pub const NONE: Option<&'static Asset> = None;
/// Indicate that an existing [`Asset`][crate::Asset] in the cache should be reloaded
/// upon the next request. This can be used when some condition has
/// changed, which may require that an existing asset should be updated.
/// For example, if an external resource has changed or now become
/// available.
///
/// Note, the asset is not immediately changed, but will only actually
/// reload on the next call to [`request()`][Self::request()] or
/// [`request_async()`][Self::request_async()].
/// ## `extractable_type`
/// The [`extractable-type`][struct@crate::Asset#extractable-type] of the asset that
/// needs reloading
/// ## `id`
/// The [`id`][struct@crate::Asset#id] of the asset asset that needs
/// reloading
///
/// # Returns
///
/// [`true`] if the specified asset exists in the cache and could be
/// marked for reloading.
#[doc(alias = "ges_asset_needs_reload")]
pub fn needs_reload(extractable_type: glib::types::Type, id: Option<&str>) -> bool {
assert_initialized_main_thread!();
unsafe {
from_glib(ffi::ges_asset_needs_reload(
extractable_type.into_glib(),
id.to_glib_none().0,
))
}
}
/// Returns an asset with the given properties. If such an asset already
/// exists in the cache (it has been previously created in GES), then a
/// reference to the existing asset is returned. Otherwise, a newly created
/// asset is returned, and also added to the cache.
///
/// If the requested asset has been loaded with an error, then `error` is
/// set, if given, and [`None`] will be returned instead.
///
/// Note that the given `id` may not be exactly the [`id`][struct@crate::Asset#id] that is
/// set on the returned asset. For instance, it may be adjusted into a
/// standard format. Or, if a [`Extractable`][crate::Extractable] type does not have its
/// extraction parametrised, as is the case by default, then the given `id`
/// may be ignored entirely and the [`id`][struct@crate::Asset#id] set to some standard, in
/// which case a [`None`] `id` can be given.
///
/// Similarly, the given `extractable_type` may not be exactly the
/// [`extractable-type`][struct@crate::Asset#extractable-type] that is set on the returned asset. Instead,
/// the actual extractable type may correspond to a subclass of the given
/// `extractable_type`, depending on the given `id`.
///
/// Moreover, depending on the given `extractable_type`, the returned asset
/// may belong to a subclass of [`Asset`][crate::Asset].
///
/// Finally, if the requested asset has a [`proxy`][struct@crate::Asset#proxy], then the proxy
/// that is found at the end of the chain of proxies is returned (a proxy's
/// proxy will take its place, and so on, unless it has no proxy).
///
/// Some asset subclasses only support asynchronous construction of its
/// assets, such as [`UriClip`][crate::UriClip]. For such assets this method will fail, and
/// you should use [`request_async()`][Self::request_async()] instead. In the case of
/// [`UriClip`][crate::UriClip], you can use [`UriClipAsset::request_sync()`][crate::UriClipAsset::request_sync()] if you only
/// want to wait for the request to finish.
/// ## `extractable_type`
/// The [`extractable-type`][struct@crate::Asset#extractable-type] of the asset
/// ## `id`
/// The [`id`][struct@crate::Asset#id] of the asset
///
/// # Returns
///
/// A reference to the requested
/// asset, or [`None`] if an error occurred.
#[doc(alias = "ges_asset_request")]
pub fn request(
extractable_type: glib::types::Type,
id: Option<&str>,
) -> Result<Option<Asset>, glib::Error> {
assert_initialized_main_thread!();
unsafe {
let mut error = std::ptr::null_mut();
let ret = ffi::ges_asset_request(
extractable_type.into_glib(),
id.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
/// Requests an asset with the given properties asynchronously (see
/// [`request()`][Self::request()]). When the asset has been initialized or fetched
/// from the cache, the given callback function will be called. The
/// asset can then be retrieved in the callback using the
/// `ges_asset_request_finish()` method on the given `GAsyncResult`.
///
/// Note that the source object passed to the callback will be the
/// [`Asset`][crate::Asset] corresponding to the request, but it may not have loaded
/// correctly and therefore can not be used as is. Instead,
/// `ges_asset_request_finish()` should be used to fetch a usable asset, or
/// indicate that an error occurred in the asset's creation.
///
/// Note that the callback will be called in the `GMainLoop` running under
/// the same `GMainContext` that `ges_init()` was called in. So, if you wish
/// the callback to be invoked outside the default `GMainContext`, you can
/// call `g_main_context_push_thread_default()` in a new thread before
/// calling `ges_init()`.
///
/// Example of an asynchronous asset request:
/// **⚠️ The following code is in c ⚠️**
///
/// ``` c
/// // The request callback
/// static void
/// asset_loaded_cb (GESAsset * source, GAsyncResult * res, gpointer user_data)
/// {
/// GESAsset *asset;
/// GError *error = NULL;
///
/// asset = ges_asset_request_finish (res, &error);
/// if (asset) {
/// gst_print ("The file: %s is usable as a GESUriClip",
/// ges_asset_get_id (asset));
/// } else {
/// gst_print ("The file: %s is *not* usable as a GESUriClip because: %s",
/// ges_asset_get_id (source), error->message);
/// }
///
/// gst_object_unref (asset);
/// }
///
/// // The request:
/// ges_asset_request_async (GES_TYPE_URI_CLIP, some_uri, NULL,
/// (GAsyncReadyCallback) asset_loaded_cb, user_data);
/// ```
/// ## `extractable_type`
/// The [`extractable-type`][struct@crate::Asset#extractable-type] of the asset
/// ## `id`
/// The [`id`][struct@crate::Asset#id] of the asset
/// ## `cancellable`
/// An object to allow cancellation of the
/// asset request, or [`None`] to ignore
/// ## `callback`
/// A function to call when the initialization is finished
#[doc(alias = "ges_asset_request_async")]
pub fn request_async<P: FnOnce(Result<Asset, glib::Error>) + 'static>(
extractable_type: glib::types::Type,
id: Option<&str>,
cancellable: Option<&impl IsA<gio::Cancellable>>,
callback: P,
) {
assert_initialized_main_thread!();
let main_context = glib::MainContext::ref_thread_default();
let is_main_context_owner = main_context.is_owner();
let has_acquired_main_context = (!is_main_context_owner)
.then(|| main_context.acquire().ok())
.flatten();
assert!(
is_main_context_owner || has_acquired_main_context.is_some(),
"Async operations only allowed if the thread is owning the MainContext"
);
let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::new(glib::thread_guard::ThreadGuard::new(callback));
unsafe extern "C" fn request_async_trampoline<
P: FnOnce(Result<Asset, glib::Error>) + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib::ffi::gpointer,
) {
let mut error = std::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))
};
let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
Box_::from_raw(user_data as *mut _);
let callback: P = callback.into_inner();
callback(result);
}
let callback = request_async_trampoline::<P>;
unsafe {
ffi::ges_asset_request_async(
extractable_type.into_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 _,
);
}
}
pub fn request_future(
extractable_type: glib::types::Type,
id: Option<&str>,
) -> Pin<Box_<dyn std::future::Future<Output = Result<Asset, glib::Error>> + 'static>> {
skip_assert_initialized!();
let id = id.map(ToOwned::to_owned);
Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| {
Self::request_async(
extractable_type,
id.as_ref().map(::std::borrow::Borrow::borrow),
Some(cancellable),
move |res| {
send.resolve(res);
},
);
}))
}
}
unsafe impl Send for Asset {}
unsafe impl Sync for Asset {}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Asset>> Sealed for T {}
}
/// Trait containing all [`struct@Asset`] methods.
///
/// # Implementors
///
/// [`Asset`][struct@crate::Asset], [`ClipAsset`][struct@crate::ClipAsset], [`Project`][struct@crate::Project], [`TrackElementAsset`][struct@crate::TrackElementAsset]
pub trait AssetExt: IsA<Asset> + sealed::Sealed + 'static {
/// Extracts a new [`extractable-type`][struct@crate::Asset#extractable-type] object from the asset. The
/// [`id`][struct@crate::Asset#id] of the asset may determine the properties and state of the
/// newly created object.
///
/// # Returns
///
/// A newly created object, or [`None`] if an
/// error occurred.
#[doc(alias = "ges_asset_extract")]
fn extract(&self) -> Result<Extractable, glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let ret = ffi::ges_asset_extract(self.as_ref().to_glib_none().0, &mut error);
if error.is_null() {
Ok(from_glib_none(ret))
} else {
Err(from_glib_full(error))
}
}
}
/// Retrieve the error that was set on the asset when it was loaded.
///
/// # Returns
///
/// The error set on `asset`, or
/// [`None`] if no error occurred when `asset` was loaded.
#[doc(alias = "ges_asset_get_error")]
#[doc(alias = "get_error")]
fn error(&self) -> Option<glib::Error> {
unsafe { from_glib_none(ffi::ges_asset_get_error(self.as_ref().to_glib_none().0)) }
}
/// Gets the [`extractable-type`][struct@crate::Asset#extractable-type] of the asset.
///
/// # Returns
///
/// The extractable type of `self`.
#[doc(alias = "ges_asset_get_extractable_type")]
#[doc(alias = "get_extractable_type")]
#[doc(alias = "extractable-type")]
fn extractable_type(&self) -> glib::types::Type {
unsafe {
from_glib(ffi::ges_asset_get_extractable_type(
self.as_ref().to_glib_none().0,
))
}
}
/// Gets the [`id`][struct@crate::Asset#id] of the asset.
///
/// # Returns
///
/// The ID of `self`.
#[doc(alias = "ges_asset_get_id")]
#[doc(alias = "get_id")]
fn id(&self) -> glib::GString {
unsafe { from_glib_none(ffi::ges_asset_get_id(self.as_ref().to_glib_none().0)) }
}
/// Gets the default [`proxy`][struct@crate::Asset#proxy] of the asset.
///
/// # Returns
///
/// The default proxy of `self`.
#[doc(alias = "ges_asset_get_proxy")]
#[doc(alias = "get_proxy")]
#[must_use]
fn proxy(&self) -> Option<Asset> {
unsafe { from_glib_none(ffi::ges_asset_get_proxy(self.as_ref().to_glib_none().0)) }
}
/// Gets the [`proxy-target`][struct@crate::Asset#proxy-target] of the asset.
///
/// Note that the proxy target may have loaded with an error, so you should
/// call [`error()`][Self::error()] on the returned target.
///
/// # Returns
///
/// The asset that `self` is a proxy
/// of.
#[doc(alias = "ges_asset_get_proxy_target")]
#[doc(alias = "get_proxy_target")]
#[doc(alias = "proxy-target")]
#[must_use]
fn proxy_target(&self) -> Option<Asset> {
unsafe {
from_glib_none(ffi::ges_asset_get_proxy_target(
self.as_ref().to_glib_none().0,
))
}
}
/// Get all the proxies that the asset has. The first item of the list will
/// be the default [`proxy`][struct@crate::Asset#proxy]. The second will be the proxy that is
/// 'next in line' to be default, and so on.
///
/// # Returns
///
/// The list of proxies
/// that `self` has.
#[doc(alias = "ges_asset_list_proxies")]
fn list_proxies(&self) -> Vec<Asset> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::ges_asset_list_proxies(
self.as_ref().to_glib_none().0,
))
}
}
/// Sets the [`proxy`][struct@crate::Asset#proxy] for the asset.
///
/// If `proxy` is among the existing proxies of the asset (see
/// [`list_proxies()`][Self::list_proxies()]) it will be moved to become the default
/// proxy. Otherwise, if `proxy` is not [`None`], it will be added to the list
/// of proxies, as the new default. The previous default proxy will become
/// 'next in line' for if the new one is removed, and so on. As such, this
/// will **not** actually remove the previous default proxy (use
/// [`unproxy()`][Self::unproxy()] for that).
///
/// Note that an asset can only act as a proxy for one other asset.
///
/// As a special case, if `proxy` is [`None`], then this method will actually
/// remove **all** proxies from the asset.
/// ## `proxy`
/// A new default proxy for `self`
///
/// # Returns
///
/// [`true`] if `proxy` was successfully set as the default for
/// `self`.
#[doc(alias = "ges_asset_set_proxy")]
#[doc(alias = "proxy")]
fn set_proxy(&self, proxy: Option<&impl IsA<Asset>>) -> Result<(), glib::error::BoolError> {
unsafe {
glib::result_from_gboolean!(
ffi::ges_asset_set_proxy(
self.as_ref().to_glib_none().0,
proxy.map(|p| p.as_ref()).to_glib_none().0
),
"Failed to set proxy"
)
}
}
/// Removes the proxy from the available list of proxies for the asset. If
/// the given proxy is the default proxy of the list, then the next proxy
/// in the available list (see [`list_proxies()`][Self::list_proxies()]) will become the
/// default. If there are no other proxies, then the asset will no longer
/// have a default [`proxy`][struct@crate::Asset#proxy].
/// ## `proxy`
/// An existing proxy of `self`
///
/// # Returns
///
/// [`true`] if `proxy` was successfully removed from `self`'s proxy
/// list.
#[doc(alias = "ges_asset_unproxy")]
fn unproxy(&self, proxy: &impl IsA<Asset>) -> Result<(), glib::error::BoolError> {
unsafe {
glib::result_from_gboolean!(
ffi::ges_asset_unproxy(
self.as_ref().to_glib_none().0,
proxy.as_ref().to_glib_none().0
),
"Failed to unproxy asset"
)
}
}
#[doc(alias = "proxy")]
fn connect_proxy_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_proxy_trampoline<
P: IsA<Asset>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GESAsset,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Asset::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::proxy\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_proxy_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "proxy-target")]
fn connect_proxy_target_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_proxy_target_trampoline<
P: IsA<Asset>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GESAsset,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(Asset::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::proxy-target\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_proxy_target_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<Asset>> AssetExt for O {}