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