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
635
636
637
638
639
640
641
642
643
644
645
646
// 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::Asset;
use crate::Clip;
use crate::Extractable;
use crate::Timeline;
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
use crate::Track;
use crate::TrackType;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::mem::transmute;
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
use std::ptr;

glib::wrapper! {
    /// [`crate::Layer`]-s are responsible for collecting and ordering [`crate::Clip`]-s.
    ///
    /// A layer within a timeline will have an associated priority,
    /// corresponding to their index within the timeline. A layer with the
    /// index/priority 0 will have the highest priority and the layer with the
    /// largest index will have the lowest priority (the order of priorities,
    /// in this sense, is the _reverse_ of the numerical ordering of the
    /// indices). [`crate::prelude::TimelineExt::move_layer()`] should be used if you wish to
    /// change how layers are prioritised in a timeline.
    ///
    /// Layers with higher priorities will have their content priorities
    /// over content from lower priority layers, similar to how layers are
    /// used in image editing. For example, if two separate layers both
    /// display video content, then the layer with the higher priority will
    /// have its images shown first. The other layer will only have its image
    /// shown if the higher priority layer has no content at the given
    /// playtime, or is transparent in some way. Audio content in separate
    /// layers will simply play in addition.
    ///
    /// # Implements
    ///
    /// [`trait@crate::prelude::LayerExt`], [`trait@glib::object::ObjectExt`], [`trait@crate::prelude::ExtractableExt`]
    pub struct Layer(Object<ffi::GESLayer, ffi::GESLayerClass>) @implements Extractable;

    match fn {
        type_ => || ffi::ges_layer_get_type(),
    }
}

impl Layer {
    /// Creates a new layer.
    ///
    /// # Returns
    ///
    /// A new layer.
    #[doc(alias = "ges_layer_new")]
    pub fn new() -> Layer {
        assert_initialized_main_thread!();
        unsafe { from_glib_none(ffi::ges_layer_new()) }
    }
}

impl Default for Layer {
    fn default() -> Self {
        Self::new()
    }
}

pub const NONE_LAYER: Option<&Layer> = None;

/// Trait containing all `Layer` methods.
///
/// # Implementors
///
/// [`struct@crate::Layer`]
pub trait LayerExt: 'static {
    /// See [`Self::add_asset_full()`], which also gives an error.
    /// ## `asset`
    /// The asset to extract the new clip from
    /// ## `start`
    /// The [`crate::TimelineElement:start`] value to set on the new clip
    /// If `start == #GST_CLOCK_TIME_NONE`, it will be added to the end
    /// of `self`, i.e. it will be set to `self`'s duration
    /// ## `inpoint`
    /// The [`crate::TimelineElement:in-point`] value to set on the new
    /// clip
    /// ## `duration`
    /// The [`crate::TimelineElement:duration`] value to set on the new
    /// clip
    /// ## `track_types`
    /// The [`crate::Clip:supported-formats`] to set on the the new
    /// clip, or [`crate::TrackType::Unknown`] to use the default
    ///
    /// # Returns
    ///
    /// The newly created clip.
    #[doc(alias = "ges_layer_add_asset")]
    fn add_asset<P: IsA<Asset>>(
        &self,
        asset: &P,
        start: gst::ClockTime,
        inpoint: gst::ClockTime,
        duration: gst::ClockTime,
        track_types: TrackType,
    ) -> Result<Clip, glib::BoolError>;

    /// Extracts a new clip from an asset and adds it to the layer with
    /// the given properties.
    /// ## `asset`
    /// The asset to extract the new clip from
    /// ## `start`
    /// The [`crate::TimelineElement:start`] value to set on the new clip
    /// If `start == #GST_CLOCK_TIME_NONE`, it will be added to the end
    /// of `self`, i.e. it will be set to `self`'s duration
    /// ## `inpoint`
    /// The [`crate::TimelineElement:in-point`] value to set on the new
    /// clip
    /// ## `duration`
    /// The [`crate::TimelineElement:duration`] value to set on the new
    /// clip
    /// ## `track_types`
    /// The [`crate::Clip:supported-formats`] to set on the the new
    /// clip, or [`crate::TrackType::Unknown`] to use the default
    ///
    /// # Returns
    ///
    /// The newly created clip.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_layer_add_asset_full")]
    fn add_asset_full<P: IsA<Asset>>(
        &self,
        asset: &P,
        start: gst::ClockTime,
        inpoint: gst::ClockTime,
        duration: gst::ClockTime,
        track_types: TrackType,
    ) -> Result<Clip, glib::Error>;

    /// See [`Self::add_clip_full()`], which also gives an error.
    /// ## `clip`
    /// The clip to add
    ///
    /// # Returns
    ///
    /// [`true`] if `clip` was properly added to `self`, or [`false`]
    /// if `self` refused to add `clip`.
    #[doc(alias = "ges_layer_add_clip")]
    fn add_clip<P: IsA<Clip>>(&self, clip: &P) -> Result<(), glib::error::BoolError>;

    /// Adds the given clip to the layer. If the method succeeds, the layer
    /// will take ownership of the clip.
    ///
    /// This method will fail and return [`false`] if `clip` already resides in
    /// some layer. It can also fail if the additional clip breaks some
    /// compositional rules (see [`crate::TimelineElement`]).
    /// ## `clip`
    /// The clip to add
    ///
    /// # Returns
    ///
    /// [`true`] if `clip` was properly added to `self`, or [`false`]
    /// if `self` refused to add `clip`.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_layer_add_clip_full")]
    fn add_clip_full<P: IsA<Clip>>(&self, clip: &P) -> Result<(), glib::Error>;

    /// Gets whether the layer is active for the given track. See
    /// [`Self::set_active_for_tracks()`].
    /// ## `track`
    /// The [`crate::Track`] to check if `self` is currently active for
    ///
    /// # Returns
    ///
    /// [`true`] if `self` is active for `track`, or [`false`] otherwise.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_layer_get_active_for_track")]
    #[doc(alias = "get_active_for_track")]
    fn is_active_for_track<P: IsA<Track>>(&self, track: &P) -> bool;

    /// Gets the [`crate::Layer:auto-transition`] of the layer.
    ///
    /// # Returns
    ///
    /// [`true`] if transitions are automatically added to `self`.
    #[doc(alias = "ges_layer_get_auto_transition")]
    #[doc(alias = "get_auto_transition")]
    fn is_auto_transition(&self) -> bool;

    /// Get the [`crate::Clip`]-s contained in this layer.
    ///
    /// # Returns
    ///
    /// A list of clips in
    /// `self`.
    #[doc(alias = "ges_layer_get_clips")]
    #[doc(alias = "get_clips")]
    fn clips(&self) -> Vec<Clip>;

    /// Gets the clips within the layer that appear between `start` and `end`.
    /// ## `start`
    /// Start of the interval
    /// ## `end`
    /// End of the interval
    ///
    /// # Returns
    ///
    /// A list of [`crate::Clip`]-s
    /// that intersect the interval `[start, end)` in `self`.
    #[doc(alias = "ges_layer_get_clips_in_interval")]
    #[doc(alias = "get_clips_in_interval")]
    fn clips_in_interval(&self, start: gst::ClockTime, end: gst::ClockTime) -> Vec<Clip>;

    /// Retrieves the duration of the layer, which is the difference
    /// between the start of the layer (always time 0) and the end (which will
    /// be the end time of the final clip).
    ///
    /// # Returns
    ///
    /// The duration of `self`.
    #[doc(alias = "ges_layer_get_duration")]
    #[doc(alias = "get_duration")]
    fn duration(&self) -> gst::ClockTime;

    /// Get the priority of the layer. When inside a timeline, this is its
    /// index in the timeline. See [`crate::prelude::TimelineExt::move_layer()`].
    ///
    /// # Returns
    ///
    /// The priority of `self` within its timeline.
    #[doc(alias = "ges_layer_get_priority")]
    #[doc(alias = "get_priority")]
    fn priority(&self) -> u32;

    /// Gets the timeline that the layer is a part of.
    ///
    /// # Returns
    ///
    /// The timeline that `self`
    /// is currently part of, or [`None`] if it is not associated with any
    /// timeline.
    #[doc(alias = "ges_layer_get_timeline")]
    #[doc(alias = "get_timeline")]
    fn timeline(&self) -> Option<Timeline>;

    /// Convenience method to check if the layer is empty (doesn't contain
    /// any [`crate::Clip`]), or not.
    ///
    /// # Returns
    ///
    /// [`true`] if `self` is empty, [`false`] if it contains at least
    /// one clip.
    #[doc(alias = "ges_layer_is_empty")]
    fn is_empty(&self) -> bool;

    /// Removes the given clip from the layer.
    /// ## `clip`
    /// The clip to remove
    ///
    /// # Returns
    ///
    /// [`true`] if `clip` was removed from `self`, or [`false`] if the
    /// operation failed.
    #[doc(alias = "ges_layer_remove_clip")]
    fn remove_clip<P: IsA<Clip>>(&self, clip: &P) -> Result<(), glib::error::BoolError>;

    /// Activate or deactivate track elements in `tracks` (or in all tracks if `tracks`
    /// is [`None`]).
    ///
    /// When a layer is deactivated for a track, all the [`crate::TrackElement`]-s in
    /// the track that belong to a [`crate::Clip`] in the layer will no longer be
    /// active in the track, regardless of their individual
    /// [`crate::TrackElement:active`] value.
    ///
    /// Note that by default a layer will be active for all of its
    /// timeline's tracks.
    /// ## `active`
    /// Whether elements in `tracks` should be active or not
    /// ## `tracks`
    /// The list of
    /// tracks `self` should be (de-)active in, or [`None`] to include all the tracks
    /// in the `self`'s timeline
    ///
    /// # Returns
    ///
    /// [`true`] if the operation worked [`false`] otherwise.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_layer_set_active_for_tracks")]
    fn set_active_for_tracks(&self, active: bool, tracks: &[Track]) -> bool;

    /// Sets [`crate::Layer:auto-transition`] for the layer. Use
    /// [`crate::prelude::TimelineExt::set_auto_transition()`] if you want all layers within a
    /// [`crate::Timeline`] to have [`crate::Layer:auto-transition`] set to [`true`]. Use this
    /// method if you want different values for different layers (and make sure
    /// to keep [`crate::Timeline:auto-transition`] as [`false`] for the corresponding
    /// timeline).
    /// ## `auto_transition`
    /// Whether transitions should be automatically added to
    /// the layer
    #[doc(alias = "ges_layer_set_auto_transition")]
    fn set_auto_transition(&self, auto_transition: bool);

    /// Sets the layer to the given priority. See [`crate::Layer:priority`].
    ///
    /// # Deprecated since 1.16
    ///
    /// use [`crate::prelude::TimelineExt::move_layer`] instead. This deprecation means
    /// that you will not need to handle layer priorities at all yourself, GES
    /// will make sure there is never 'gaps' between layer priorities.
    /// ## `priority`
    /// The priority to set
    #[cfg_attr(feature = "v1_16", deprecated = "Since 1.16")]
    #[doc(alias = "ges_layer_set_priority")]
    fn set_priority(&self, priority: u32);

    #[doc(alias = "ges_layer_set_timeline")]
    fn set_timeline<P: IsA<Timeline>>(&self, timeline: &P);

    //#[cfg(any(feature = "v1_18", feature = "dox"))]
    //#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    //#[doc(alias = "active-changed")]
    //fn connect_active_changed<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId;

    /// Will be emitted after the clip is added to the layer.
    /// ## `clip`
    /// The clip that was added
    #[doc(alias = "clip-added")]
    fn connect_clip_added<F: Fn(&Self, &Clip) + 'static>(&self, f: F) -> SignalHandlerId;

    /// Will be emitted after the clip is removed from the layer.
    /// ## `clip`
    /// The clip that was removed
    #[doc(alias = "clip-removed")]
    fn connect_clip_removed<F: Fn(&Self, &Clip) + 'static>(&self, f: F) -> SignalHandlerId;

    #[doc(alias = "auto-transition")]
    fn connect_auto_transition_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    #[cfg_attr(feature = "v1_16", deprecated = "Since 1.16")]
    #[doc(alias = "priority")]
    fn connect_priority_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<Layer>> LayerExt for O {
    fn add_asset<P: IsA<Asset>>(
        &self,
        asset: &P,
        start: gst::ClockTime,
        inpoint: gst::ClockTime,
        duration: gst::ClockTime,
        track_types: TrackType,
    ) -> Result<Clip, glib::BoolError> {
        unsafe {
            Option::<_>::from_glib_none(ffi::ges_layer_add_asset(
                self.as_ref().to_glib_none().0,
                asset.as_ref().to_glib_none().0,
                start.into_glib(),
                inpoint.into_glib(),
                duration.into_glib(),
                track_types.into_glib(),
            ))
            .ok_or_else(|| glib::bool_error!("Failed to add asset"))
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    fn add_asset_full<P: IsA<Asset>>(
        &self,
        asset: &P,
        start: gst::ClockTime,
        inpoint: gst::ClockTime,
        duration: gst::ClockTime,
        track_types: TrackType,
    ) -> Result<Clip, glib::Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let ret = ffi::ges_layer_add_asset_full(
                self.as_ref().to_glib_none().0,
                asset.as_ref().to_glib_none().0,
                start.into_glib(),
                inpoint.into_glib(),
                duration.into_glib(),
                track_types.into_glib(),
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib_none(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    fn add_clip<P: IsA<Clip>>(&self, clip: &P) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::ges_layer_add_clip(
                    self.as_ref().to_glib_none().0,
                    clip.as_ref().to_glib_none().0
                ),
                "Failed to add clip"
            )
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    fn add_clip_full<P: IsA<Clip>>(&self, clip: &P) -> Result<(), glib::Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let _ = ffi::ges_layer_add_clip_full(
                self.as_ref().to_glib_none().0,
                clip.as_ref().to_glib_none().0,
                &mut error,
            );
            if error.is_null() {
                Ok(())
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    fn is_active_for_track<P: IsA<Track>>(&self, track: &P) -> bool {
        unsafe {
            from_glib(ffi::ges_layer_get_active_for_track(
                self.as_ref().to_glib_none().0,
                track.as_ref().to_glib_none().0,
            ))
        }
    }

    fn is_auto_transition(&self) -> bool {
        unsafe {
            from_glib(ffi::ges_layer_get_auto_transition(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn clips(&self) -> Vec<Clip> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::ges_layer_get_clips(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn clips_in_interval(&self, start: gst::ClockTime, end: gst::ClockTime) -> Vec<Clip> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::ges_layer_get_clips_in_interval(
                self.as_ref().to_glib_none().0,
                start.into_glib(),
                end.into_glib(),
            ))
        }
    }

    fn duration(&self) -> gst::ClockTime {
        unsafe { from_glib(ffi::ges_layer_get_duration(self.as_ref().to_glib_none().0)) }
    }

    fn priority(&self) -> u32 {
        unsafe { ffi::ges_layer_get_priority(self.as_ref().to_glib_none().0) }
    }

    fn timeline(&self) -> Option<Timeline> {
        unsafe { from_glib_none(ffi::ges_layer_get_timeline(self.as_ref().to_glib_none().0)) }
    }

    fn is_empty(&self) -> bool {
        unsafe { from_glib(ffi::ges_layer_is_empty(self.as_ref().to_glib_none().0)) }
    }

    fn remove_clip<P: IsA<Clip>>(&self, clip: &P) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::ges_layer_remove_clip(
                    self.as_ref().to_glib_none().0,
                    clip.as_ref().to_glib_none().0
                ),
                "Failed to remove clip"
            )
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    fn set_active_for_tracks(&self, active: bool, tracks: &[Track]) -> bool {
        unsafe {
            from_glib(ffi::ges_layer_set_active_for_tracks(
                self.as_ref().to_glib_none().0,
                active.into_glib(),
                tracks.to_glib_none().0,
            ))
        }
    }

    fn set_auto_transition(&self, auto_transition: bool) {
        unsafe {
            ffi::ges_layer_set_auto_transition(
                self.as_ref().to_glib_none().0,
                auto_transition.into_glib(),
            );
        }
    }

    fn set_priority(&self, priority: u32) {
        unsafe {
            ffi::ges_layer_set_priority(self.as_ref().to_glib_none().0, priority);
        }
    }

    fn set_timeline<P: IsA<Timeline>>(&self, timeline: &P) {
        unsafe {
            ffi::ges_layer_set_timeline(
                self.as_ref().to_glib_none().0,
                timeline.as_ref().to_glib_none().0,
            );
        }
    }

    //#[cfg(any(feature = "v1_18", feature = "dox"))]
    //#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    //#[doc(alias = "active-changed")]
    //fn connect_active_changed<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
    //    Empty ctype tracks: *.PtrArray TypeId { ns_id: 1, id: 17 }
    //}

    #[doc(alias = "clip-added")]
    fn connect_clip_added<F: Fn(&Self, &Clip) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn clip_added_trampoline<P, F: Fn(&P, &Clip) + 'static>(
            this: *mut ffi::GESLayer,
            clip: *mut ffi::GESClip,
            f: glib::ffi::gpointer,
        ) where
            P: IsA<Layer>,
        {
            let f: &F = &*(f as *const F);
            f(
                &Layer::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(clip),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"clip-added\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    clip_added_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "clip-removed")]
    fn connect_clip_removed<F: Fn(&Self, &Clip) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn clip_removed_trampoline<P, F: Fn(&P, &Clip) + 'static>(
            this: *mut ffi::GESLayer,
            clip: *mut ffi::GESClip,
            f: glib::ffi::gpointer,
        ) where
            P: IsA<Layer>,
        {
            let f: &F = &*(f as *const F);
            f(
                &Layer::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(clip),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"clip-removed\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    clip_removed_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "auto-transition")]
    fn connect_auto_transition_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_auto_transition_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut ffi::GESLayer,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) where
            P: IsA<Layer>,
        {
            let f: &F = &*(f as *const F);
            f(&Layer::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::auto-transition\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_auto_transition_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "priority")]
    fn connect_priority_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_priority_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut ffi::GESLayer,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) where
            P: IsA<Layer>,
        {
            let f: &F = &*(f as *const F);
            f(&Layer::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::priority\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_priority_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}