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
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
// 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 ges_sys;
use glib;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib_sys;
#[cfg(any(feature = "v1_18", feature = "dox"))]
use gst;
use std::boxed::Box as Box_;
use std::mem::transmute;
#[cfg(any(feature = "v1_18", feature = "dox"))]
use std::ptr;
use Asset;
use BaseEffect;
use Container;
use Extractable;
#[cfg(any(feature = "v1_18", feature = "dox"))]
use FrameNumber;
use Layer;
use TimelineElement;
use Track;
use TrackElement;
use TrackType;

glib_wrapper! {
    /// `Clip`-s are the core objects of a `Layer`. Each clip may exist in
    /// a single layer but may control several `TrackElement`-s that span
    /// several `Track`-s. A clip will ensure that all its children share the
    /// same `TimelineElement:start` and `TimelineElement:duration` in
    /// their tracks, which will match the `TimelineElement:start` and
    /// `TimelineElement:duration` of the clip itself. Therefore, changing
    /// the timing of the clip will change the timing of the children, and a
    /// change in the timing of a child will change the timing of the clip and
    /// subsequently all its siblings. As such, a clip can be treated as a
    /// singular object in its layer.
    ///
    /// For most uses of a `Timeline`, it is often sufficient to only
    /// interact with `Clip`-s directly, which will take care of creating and
    /// organising the elements of the timeline's tracks.
    ///
    /// ## Core Children
    ///
    /// In more detail, clips will usually have some *core* `TrackElement`
    /// children, which are created by the clip when it is added to a layer in
    /// a timeline. The type and form of these core children will depend on the
    /// clip's subclass. You can use `TrackElementExt::is_core` to determine
    /// whether a track element is considered such a core track element. Note,
    /// if a core track element is part of a clip, it will always be treated as
    /// a core *child* of the clip. You can connect to the
    /// `Container::child-added` signal to be notified of their creation.
    ///
    /// When a child is added to a clip, the timeline will select its tracks
    /// using `Timeline::select-tracks-for-object`. Note that it may be the
    /// case that the child will still have no set `TrackElement:track`
    /// after this process. For example, if the timeline does not have a track
    /// of the corresponding `Track:track-type`. A clip can safely contain
    /// such children, which may have their track set later, although they will
    /// play no functioning role in the timeline in the meantime.
    ///
    /// If a clip may create track elements with various
    /// `TrackElement:track-type`(s), such as a `UriClip`, but you only
    /// want it to create a subset of these types, you should set the
    /// `Clip:supported-formats` of the clip to the subset of types. This
    /// should be done *before* adding the clip to a layer.
    ///
    /// If a clip will produce several core elements of the same
    /// `TrackElement:track-type`, you should connect to the timeline's
    /// `Timeline::select-tracks-for-object` signal to coordinate which
    /// tracks each element should land in. Note, no two core children within a
    /// clip can share the same `Track`, so you should not select the same
    /// track for two separate core children. Provided you stick to this rule,
    /// it is still safe to select several tracks for the same core child, the
    /// core child will be copied into the additional tracks. You can manually
    /// add the child to more tracks later using `ClipExt::add_child_to_track`.
    /// If you do not wish to use a core child, you can always select no track.
    ///
    /// The `TimelineElement:in-point` of the clip will control the
    /// `TimelineElement:in-point` of its core children to be the same
    /// value if their `TrackElement:has-internal-source` is set to `true`.
    ///
    /// The `TimelineElement:max-duration` of the clip is the minimum
    /// `TimelineElement:max-duration` of its core children. If you set its
    /// value to anything other than its current value, this will also set the
    /// `TimelineElement:max-duration` of all its core children to the same
    /// value if their `TrackElement:has-internal-source` is set to `true`.
    /// As a special case, whilst a clip does not yet have any core children,
    /// its `TimelineElement:max-duration` may be set to indicate what its
    /// value will be once they are created.
    ///
    /// ## Effects
    ///
    /// Some subclasses (`SourceClip` and `BaseEffectClip`) may also allow
    /// their objects to have additional non-core `BaseEffect`-s elements as
    /// children. These are additional effects that are applied to the output
    /// data of the core elements. They can be added to the clip using
    /// `ClipExt::add_top_effect`, which will take care of adding the effect to
    /// the timeline's tracks. The new effect will be placed between the clip's
    /// core track elements and its other effects. As such, the newly added
    /// effect will be applied to any source data **before** the other existing
    /// effects. You can change the ordering of effects using
    /// `ClipExt::set_top_effect_index`.
    ///
    /// Tracks are selected for top effects in the same way as core children.
    /// If you add a top effect to a clip before it is part of a timeline, and
    /// later add the clip to a timeline, the track selection for the top
    /// effects will occur just after the track selection for the core
    /// children. If you add a top effect to a clip that is already part of a
    /// timeline, the track selection will occur immediately. Since a top
    /// effect must be applied on top of a core child, if you use
    /// `Timeline::select-tracks-for-object`, you should ensure that the
    /// added effects are destined for a `Track` that already contains a core
    /// child.
    ///
    /// In addition, if the core child in the track is not
    /// `TrackElement:active`, then neither can any of its effects be
    /// `TrackElement:active`. Therefore, if a core child is made in-active,
    /// all of the additional effects in the same track will also become
    /// in-active. Similarly, if an effect is set to be active, then the core
    /// child will also become active, but other effects will be left alone.
    /// Finally, if an active effect is added to the track of an in-active core
    /// child, it will become in-active as well. Note, in contrast, setting a
    /// core child to be active, or an effect to be in-active will *not* change
    /// the other children in the same track.
    ///
    /// ### Time Effects
    ///
    /// Some effects also change the timing of their data (see `BaseEffect`
    /// for what counts as a time effect). Note that a `BaseEffectClip` will
    /// refuse time effects, but a `Source` will allow them.
    ///
    /// When added to a clip, time effects may adjust the timing of other
    /// children in the same track. Similarly, when changing the order of
    /// effects, making them (in)-active, setting their time property values
    /// or removing time effects. These can cause the `Clip:duration-limit`
    /// to change in value. However, if such an operation would ever cause the
    /// `TimelineElement:duration` to shrink such that a clip's `Source` is
    /// totally overlapped in the timeline, the operation would be prevented.
    /// Note that the same can happen when adding non-time effects with a
    /// finite `TimelineElement:max-duration`.
    ///
    /// Therefore, when working with time effects, you should -- more so than
    /// usual -- not assume that setting the properties of the clip's children
    /// will succeed. In particular, you should use
    /// `TimelineElementExt::set_child_property_full` when setting the time
    /// properties.
    ///
    /// If you wish to preserve the *internal* duration of a source in a clip
    /// during these time effect operations, you can do something like the
    /// following.
    ///
    /// ```c
    /// void
    /// do_time_effect_change (GESClip * clip)
    /// {
    ///   GList *tmp, *children;
    ///   GESTrackElement *source;
    ///   GstClockTime source_outpoint;
    ///   GstClockTime new_end;
    ///   GError *error = NULL;
    ///
    ///   // choose some active source in a track to preserve the internal
    ///   // duration of
    ///   source = ges_clip_get_track_element (clip, NULL, GES_TYPE_SOURCE);
    ///
    ///   // note its current internal end time
    ///   source_outpoint = ges_clip_get_internal_time_from_timeline_time (
    ///         clip, source, GES_TIMELINE_ELEMENT_END (clip), NULL);
    ///
    ///   // handle invalid out-point
    ///
    ///   // stop the children's control sources from clamping when their
    ///   // out-point changes with a change in the time effects
    ///   children = ges_container_get_children (GES_CONTAINER (clip), FALSE);
    ///
    ///   for (tmp = children; tmp; tmp = tmp->next)
    ///     ges_track_element_set_auto_clamp_control_source (tmp->data, FALSE);
    ///
    ///   // add time effect, or set their children properties, or move them around
    ///   ...
    ///   // user can make sure that if a time effect changes one source, we should
    ///   // also change the time effect for another source. E.g. if
    ///   // "GstVideorate::rate" is set to 2.0, we also set "GstPitch::rate" to
    ///   // 2.0
    ///
    ///   // Note the duration of the clip may have already changed if the
    ///   // duration-limit of the clip dropped below its current value
    ///
    ///   new_end = ges_clip_get_timeline_time_from_internal_time (
    ///         clip, source, source_outpoint, &error);
    ///   // handle error
    ///
    ///   if (!ges_timeline_elemnet_edit_full (GES_TIMELINE_ELEMENT (clip),
    ///         -1, GES_EDIT_MODE_TRIM, GES_EDGE_END, new_end, &error))
    ///     // handle error
    ///
    ///   for (tmp = children; tmp; tmp = tmp->next)
    ///     ges_track_element_set_auto_clamp_control_source (tmp->data, TRUE);
    ///
    ///   g_list_free_full (children, gst_object_unref);
    ///   gst_object_unref (source);
    /// }
    /// ```
    ///
    /// # Implements
    ///
    /// [`ClipExt`](trait.ClipExt.html), [`GESContainerExt`](trait.GESContainerExt.html), [`TimelineElementExt`](trait.TimelineElementExt.html), [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html), [`ExtractableExt`](trait.ExtractableExt.html), [`TimelineElementExtManual`](prelude/trait.TimelineElementExtManual.html)
    pub struct Clip(Object<ges_sys::GESClip, ges_sys::GESClipClass, ClipClass>) @extends Container, TimelineElement, @implements Extractable;

    match fn {
        get_type => || ges_sys::ges_clip_get_type(),
    }
}

pub const NONE_CLIP: Option<&Clip> = None;

/// Trait containing all `Clip` methods.
///
/// # Implementors
///
/// [`Clip`](struct.Clip.html), [`OperationClip`](struct.OperationClip.html)
pub trait ClipExt: 'static {
    /// Extracts a `TrackElement` from an asset and adds it to the clip.
    /// This can be used to add effects that derive from the asset to the
    /// clip, but this method is not intended to be used to create the core
    /// elements of the clip.
    /// ## `asset`
    /// An asset with `GES_TYPE_TRACK_ELEMENT` as its
    /// `Asset:extractable-type`
    ///
    /// # Returns
    ///
    /// The newly created element, or
    /// `None` if an error occurred.
    fn add_asset<P: IsA<Asset>>(&self, asset: &P) -> Result<TrackElement, glib::BoolError>;

    /// Adds the track element child of the clip to a specific track.
    ///
    /// If the given child is already in another track, this will create a copy
    /// of the child, add it to the clip, and add this copy to the track.
    ///
    /// You should only call this whilst a clip is part of a `Timeline`, and
    /// for tracks that are in the same timeline.
    ///
    /// This method is an alternative to using the
    /// `Timeline::select-tracks-for-object` signal, but can be used to
    /// complement it when, say, you wish to copy a clip's children from one
    /// track into a new one.
    ///
    /// When the child is a core child, it must be added to a track that does
    /// not already contain another core child of the same clip. If it is not a
    /// core child (an additional effect), then it must be added to a track
    /// that already contains one of the core children of the same clip.
    ///
    /// This method can also fail if the adding the track element to the track
    /// would break a configuration rule of the corresponding `Timeline`,
    /// such as causing three sources to overlap at a single time, or causing
    /// a source to completely overlap another in the same track.
    ///
    /// Feature: `v1_18`
    ///
    /// ## `child`
    /// A child of `self`
    /// ## `track`
    /// The track to add `child` to
    ///
    /// # Returns
    ///
    /// The element that was added to `track`, either
    /// `child` or a copy of child, or `None` if the element could not be added.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn add_child_to_track<P: IsA<TrackElement>, Q: IsA<Track>>(
        &self,
        child: &P,
        track: &Q,
    ) -> Result<TrackElement, glib::Error>;

    /// Add a top effect to a clip at the given index.
    ///
    /// Unlike using `GESContainerExt::add`, this allows you to set the index
    /// in advance. It will also check that no error occurred during the track
    /// selection for the effect.
    ///
    /// Note, only subclasses of `ClipClass` that have
    /// `GES_CLIP_CLASS_CAN_ADD_EFFECTS` set to `true` (such as `SourceClip`
    /// and `BaseEffectClip`) can have additional top effects added.
    ///
    /// Note, if the effect is a time effect, this may be refused if the clip
    /// would not be able to adapt itself once the effect is added.
    ///
    /// Feature: `v1_18`
    ///
    /// ## `effect`
    /// A top effect to add
    /// ## `index`
    /// The index to add `effect` at, or -1 to add at the highest
    ///
    /// # Returns
    ///
    /// `true` if `effect` was successfully added to `self` at `index`.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn add_top_effect<P: IsA<BaseEffect>>(&self, effect: &P, index: i32)
        -> Result<(), glib::Error>;

    /// Finds an element controlled by the clip. If `track` is given,
    /// then only the track elements in `track` are searched for. If `type_` is
    /// given, then this function searches for a track element of the given
    /// `type_`.
    ///
    /// Note, if multiple track elements in the clip match the given criteria,
    /// this will return the element amongst them with the highest
    /// `TimelineElement:priority` (numerically, the smallest). See
    /// `ClipExt::find_track_elements` if you wish to find all such elements.
    /// ## `track`
    /// The track to search in, or `None` to search in
    /// all tracks
    /// ## `type_`
    /// The type of track element to search for, or `G_TYPE_NONE` to
    /// match any type
    ///
    /// # Returns
    ///
    /// The element controlled by
    /// `self`, in `track`, and of the given `type_`, or `None` if no such element
    /// could be found.
    fn find_track_element<P: IsA<Track>>(
        &self,
        track: Option<&P>,
        type_: glib::types::Type,
    ) -> Option<TrackElement>;

    /// Finds the `TrackElement`-s controlled by the clip that match the
    /// given criteria. If `track` is given as `None` and `track_type` is given as
    /// `TrackType::Unknown`, then the search will match all elements in any
    /// track, including those with no track, and of any
    /// `TrackElement:track-type`. Otherwise, if `track` is not `None`, but
    /// `track_type` is `TrackType::Unknown`, then only the track elements in
    /// `track` are searched for. Otherwise, if `track_type` is not
    /// `TrackType::Unknown`, but `track` is `None`, then only the track
    /// elements whose `TrackElement:track-type` matches `track_type` are
    /// searched for. Otherwise, when both are given, the track elements that
    /// match **either** criteria are searched for. Therefore, if you wish to
    /// only find elements in a specific track, you should give the track as
    /// `track`, but you should not give the track's `Track:track-type` as
    /// `track_type` because this would also select elements from other tracks
    /// of the same type.
    ///
    /// You may also give `type_` to _further_ restrict the search to track
    /// elements of the given `type_`.
    /// ## `track`
    /// The track to search in, or `None` to search in
    /// all tracks
    /// ## `track_type`
    /// The track-type of the track element to search for, or
    /// `TrackType::Unknown` to match any track type
    /// ## `type_`
    /// The type of track element to search for, or `G_TYPE_NONE` to
    /// match any type
    ///
    /// # Returns
    ///
    /// A list of all
    /// the `TrackElement`-s controlled by `self`, in `track` or of the given
    /// `track_type`, and of the given `type_`.
    fn find_track_elements<P: IsA<Track>>(
        &self,
        track: Option<&P>,
        track_type: TrackType,
        type_: glib::types::Type,
    ) -> Vec<TrackElement>;

    /// Gets the `Clip:duration-limit` of the clip.
    ///
    /// Feature: `v1_18`
    ///
    ///
    /// # Returns
    ///
    /// The duration-limit of `self`.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn get_duration_limit(&self) -> gst::ClockTime;

    /// Convert the timeline time to an internal source time of the child.
    /// This will take any time effects placed on the clip into account (see
    /// `BaseEffect` for what time effects are supported, and how to
    /// declare them in GES).
    ///
    /// When `timeline_time` is above the `TimelineElement:start` of `self`,
    /// this will return the internal time at which the content that appears at
    /// `timeline_time` in the output of the timeline is created in `child`. For
    /// example, if `timeline_time` corresponds to the current seek position,
    /// this would let you know which part of a media file is being read.
    ///
    /// This will be done assuming the clip has an indefinite end, so the
    /// internal time may be beyond the current out-point of the child, or even
    /// its `TimelineElement:max-duration`.
    ///
    /// If, instead, `timeline_time` is below the current
    /// `TimelineElement:start` of `self`, this will return what you would
    /// need to set the `TimelineElement:in-point` of `child` to if you set
    /// the `TimelineElement:start` of `self` to `timeline_time` and wanted
    /// to keep the content of `child` currently found at the current
    /// `TimelineElement:start` of `self` at the same timeline position. If
    /// this would be negative, the conversion fails. This is useful for
    /// determining what `TimelineElement:in-point` would result from a
    /// `EditMode::Trim` to `timeline_time`.
    ///
    /// Note that whilst a clip has no time effects, this second return is
    /// equivalent to finding the internal time at which the content that
    /// appears at `timeline_time` in the timeline can be found in `child` if it
    /// had indefinite extent in both directions. However, with non-linear time
    /// effects this second return will be more distinct.
    ///
    /// In either case, the returned time would be appropriate to use for the
    /// `TimelineElement:in-point` or `TimelineElement:max-duration` of the
    /// child.
    ///
    /// See `ClipExt::get_timeline_time_from_internal_time`, which performs the
    /// reverse.
    ///
    /// Feature: `v1_18`
    ///
    /// ## `child`
    /// An `TrackElement:active` child of `self` with a
    /// `TrackElement:track`
    /// ## `timeline_time`
    /// A time in the timeline time coordinates
    ///
    /// # Returns
    ///
    /// The time in the internal coordinates of `child` corresponding
    /// to `timeline_time`, or `GST_CLOCK_TIME_NONE` if the conversion could not
    /// be performed.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn get_internal_time_from_timeline_time<P: IsA<TrackElement>>(
        &self,
        child: &P,
        timeline_time: gst::ClockTime,
    ) -> Result<gst::ClockTime, glib::Error>;

    /// Gets the `Clip:layer` of the clip.
    ///
    /// # Returns
    ///
    /// The layer `self` is in, or `None` if
    /// `self` is not in any layer.
    fn get_layer(&self) -> Option<Layer>;

    /// Gets the `Clip:supported-formats` of the clip.
    ///
    /// # Returns
    ///
    /// The `TrackType`-s supported by `self`.
    fn get_supported_formats(&self) -> TrackType;

    /// Convert the internal source time from the child to a timeline time.
    /// This will take any time effects placed on the clip into account (see
    /// `BaseEffect` for what time effects are supported, and how to
    /// declare them in GES).
    ///
    /// When `internal_time` is above the `TimelineElement:in-point` of
    /// `child`, this will return the timeline time at which the internal
    /// content found at `internal_time` appears in the output of the timeline's
    /// track. For example, this would let you know where in the timeline a
    /// particular scene in a media file would appear.
    ///
    /// This will be done assuming the clip has an indefinite end, so the
    /// timeline time may be beyond the end of the clip, or even breaking its
    /// `Clip:duration-limit`.
    ///
    /// If, instead, `internal_time` is below the current
    /// `TimelineElement:in-point` of `child`, this will return what you would
    /// need to set the `TimelineElement:start` of `self` to if you set the
    /// `TimelineElement:in-point` of `child` to `internal_time` and wanted to
    /// keep the content of `child` currently found at the current
    /// `TimelineElement:start` of `self` at the same timeline position. If
    /// this would be negative, the conversion fails. This is useful for
    /// determining what position to use in a `EditMode::Trim` if you wish
    /// to trim to a specific point in the internal content, such as a
    /// particular scene in a media file.
    ///
    /// Note that whilst a clip has no time effects, this second return is
    /// equivalent to finding the timeline time at which the content of `child`
    /// at `internal_time` would be found in the timeline if it had indefinite
    /// extent in both directions. However, with non-linear time effects this
    /// second return will be more distinct.
    ///
    /// In either case, the returned time would be appropriate to use in
    /// `TimelineElementExt::edit` for `EditMode::Trim`, and similar, if
    /// you wish to use a particular internal point as a reference. For
    /// example, you could choose to end a clip at a certain internal
    /// 'out-point', similar to the `TimelineElement:in-point`, by
    /// translating the desired end time into the timeline coordinates, and
    /// using this position to trim the end of a clip.
    ///
    /// See `ClipExt::get_internal_time_from_timeline_time`, which performs the
    /// reverse, or `ClipExt::get_timeline_time_from_source_frame` which does
    /// the same conversion, but using frame numbers.
    ///
    /// Feature: `v1_18`
    ///
    /// ## `child`
    /// An `TrackElement:active` child of `self` with a
    /// `TrackElement:track`
    /// ## `internal_time`
    /// A time in the internal time coordinates of `child`
    ///
    /// # Returns
    ///
    /// The time in the timeline coordinates corresponding to
    /// `internal_time`, or `GST_CLOCK_TIME_NONE` if the conversion could not be
    /// performed.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn get_timeline_time_from_internal_time<P: IsA<TrackElement>>(
        &self,
        child: &P,
        internal_time: gst::ClockTime,
    ) -> Result<gst::ClockTime, glib::Error>;

    /// Convert the source frame number to a timeline time. This acts the same
    /// as `ClipExt::get_timeline_time_from_internal_time` using the core
    /// children of the clip and using the frame number to specify the internal
    /// position, rather than a timestamp.
    ///
    /// The returned timeline time can be used to seek or edit to a specific
    /// frame.
    ///
    /// Note that you can get the frame timestamp of a particular clip asset
    /// with `ClipAsset::get_frame_time`.
    ///
    /// Feature: `v1_18`
    ///
    /// ## `frame_number`
    /// The frame number to get the corresponding timestamp of
    /// in the timeline coordinates
    ///
    /// # Returns
    ///
    /// The timestamp corresponding to `frame_number` in the core
    /// children of `self`, in the timeline coordinates, or `GST_CLOCK_TIME_NONE`
    /// if the conversion could not be performed.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn get_timeline_time_from_source_frame(
        &self,
        frame_number: FrameNumber,
    ) -> Result<gst::ClockTime, glib::Error>;

    /// Gets the internal index of an effect in the clip. The index of effects
    /// in a clip will run from 0 to n-1, where n is the total number of
    /// effects. If two effects share the same `TrackElement:track`, the
    /// effect with the numerically lower index will be applied to the source
    /// data **after** the other effect, i.e. output data will always flow from
    /// a higher index effect to a lower index effect.
    /// ## `effect`
    /// The effect we want to get the index of
    ///
    /// # Returns
    ///
    /// The index of `effect` in `self`, or -1 if something went wrong.
    fn get_top_effect_index<P: IsA<BaseEffect>>(&self, effect: &P) -> i32;

    fn get_top_effect_position<P: IsA<BaseEffect>>(&self, effect: &P) -> i32;

    /// Gets the `BaseEffect`-s that have been added to the clip. The
    /// returned list is ordered by their internal index in the clip. See
    /// `ClipExt::get_top_effect_index`.
    ///
    /// # Returns
    ///
    /// A list of all
    /// `BaseEffect`-s that have been added to `self`.
    fn get_top_effects(&self) -> Vec<TrackElement>;

    /// See `ClipExt::move_to_layer_full`, which also gives an error.
    /// ## `layer`
    /// The new layer
    ///
    /// # Returns
    ///
    /// `true` if `self` was successfully moved to `layer`.
    fn move_to_layer<P: IsA<Layer>>(&self, layer: &P) -> Result<(), glib::error::BoolError>;

    /// Moves a clip to a new layer. If the clip already exists in a layer, it
    /// is first removed from its current layer before being added to the new
    /// layer.
    ///
    /// Feature: `v1_18`
    ///
    /// ## `layer`
    /// The new layer
    ///
    /// # Returns
    ///
    /// `true` if `self` was successfully moved to `layer`.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn move_to_layer_full<P: IsA<Layer>>(&self, layer: &P) -> Result<(), glib::Error>;

    /// Remove a top effect from the clip.
    ///
    /// Note, if the effect is a time effect, this may be refused if the clip
    /// would not be able to adapt itself once the effect is removed.
    ///
    /// Feature: `v1_18`
    ///
    /// ## `effect`
    /// The top effect to remove
    ///
    /// # Returns
    ///
    /// `true` if `effect` was successfully added to `self` at `index`.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn remove_top_effect<P: IsA<BaseEffect>>(&self, effect: &P) -> Result<(), glib::Error>;

    /// Sets the `Clip:supported-formats` of the clip. This should normally
    /// only be called by subclasses, which should be responsible for updating
    /// its value, rather than the user.
    /// ## `supportedformats`
    /// The `TrackType`-s supported by `self`
    fn set_supported_formats(&self, supportedformats: TrackType);

    /// See `ClipExt::set_top_effect_index_full`, which also gives an error.
    /// ## `effect`
    /// An effect within `self` to move
    /// ## `newindex`
    /// The index for `effect` in `self`
    ///
    /// # Returns
    ///
    /// `true` if `effect` was successfully moved to `newindex`.
    fn set_top_effect_index<P: IsA<BaseEffect>>(
        &self,
        effect: &P,
        newindex: u32,
    ) -> Result<(), glib::error::BoolError>;

    /// Set the index of an effect within the clip. See
    /// `ClipExt::get_top_effect_index`. The new index must be an existing
    /// index of the clip. The effect is moved to the new index, and the other
    /// effects may be shifted in index accordingly to otherwise maintain the
    /// ordering.
    ///
    /// Feature: `v1_18`
    ///
    /// ## `effect`
    /// An effect within `self` to move
    /// ## `newindex`
    /// The index for `effect` in `self`
    ///
    /// # Returns
    ///
    /// `true` if `effect` was successfully moved to `newindex`.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn set_top_effect_index_full<P: IsA<BaseEffect>>(
        &self,
        effect: &P,
        newindex: u32,
    ) -> Result<(), glib::Error>;

    fn set_top_effect_priority<P: IsA<BaseEffect>>(
        &self,
        effect: &P,
        newpriority: u32,
    ) -> Result<(), glib::error::BoolError>;

    /// See `ClipExt::split_full`, which also gives an error.
    /// ## `position`
    /// The timeline position at which to perform the split
    ///
    /// # Returns
    ///
    /// The newly created clip resulting
    /// from the splitting `self`, or `None` if `self` can't be split.
    fn split(&self, position: u64) -> Result<Clip, glib::BoolError>;

    /// Splits a clip at the given timeline position into two clips. The clip
    /// must already have a `Clip:layer`.
    ///
    /// The original clip's `TimelineElement:duration` is reduced such that
    /// its end point matches the split position. Then a new clip is created in
    /// the same layer, whose `TimelineElement:start` matches the split
    /// position and `TimelineElement:duration` will be set such that its end
    /// point matches the old end point of the original clip. Thus, the two
    /// clips together will occupy the same positions in the timeline as the
    /// original clip did.
    ///
    /// The children of the new clip will be new copies of the original clip's
    /// children, so it will share the same sources and use the same
    /// operations.
    ///
    /// The new clip will also have its `TimelineElement:in-point` set so
    /// that any internal data will appear in the timeline at the same time.
    /// Thus, when the timeline is played, the playback of data should
    /// appear the same. This may be complicated by any additional
    /// `Effect`-s that have been placed on the original clip that depend on
    /// the playback time or change the data consumption rate of sources. This
    /// method will attempt to translate these effects such that the playback
    /// appears the same. In such complex situations, you may get a better
    /// result if you place the clip in a separate sub `Project`, which only
    /// contains this clip (and its effects), and in the original layer
    /// create two neighbouring `UriClip`-s that reference this sub-project,
    /// but at a different `TimelineElement:in-point`.
    ///
    /// Feature: `v1_18`
    ///
    /// ## `position`
    /// The timeline position at which to perform the split, between
    /// the start and end of the clip
    ///
    /// # Returns
    ///
    /// The newly created clip resulting
    /// from the splitting `self`, or `None` if `self` can't be split.
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn split_full(&self, position: u64) -> Result<Option<Clip>, glib::Error>;

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn connect_property_duration_limit_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId;

    fn connect_property_layer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_supported_formats_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId;
}

impl<O: IsA<Clip>> ClipExt for O {
    fn add_asset<P: IsA<Asset>>(&self, asset: &P) -> Result<TrackElement, glib::BoolError> {
        unsafe {
            Option::<_>::from_glib_none(ges_sys::ges_clip_add_asset(
                self.as_ref().to_glib_none().0,
                asset.as_ref().to_glib_none().0,
            ))
            .ok_or_else(|| glib_bool_error!("Failed to add asset"))
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn add_child_to_track<P: IsA<TrackElement>, Q: IsA<Track>>(
        &self,
        child: &P,
        track: &Q,
    ) -> Result<TrackElement, glib::Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let ret = ges_sys::ges_clip_add_child_to_track(
                self.as_ref().to_glib_none().0,
                child.as_ref().to_glib_none().0,
                track.as_ref().to_glib_none().0,
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib_none(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn add_top_effect<P: IsA<BaseEffect>>(
        &self,
        effect: &P,
        index: i32,
    ) -> Result<(), glib::Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let _ = ges_sys::ges_clip_add_top_effect(
                self.as_ref().to_glib_none().0,
                effect.as_ref().to_glib_none().0,
                index,
                &mut error,
            );
            if error.is_null() {
                Ok(())
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    fn find_track_element<P: IsA<Track>>(
        &self,
        track: Option<&P>,
        type_: glib::types::Type,
    ) -> Option<TrackElement> {
        unsafe {
            from_glib_full(ges_sys::ges_clip_find_track_element(
                self.as_ref().to_glib_none().0,
                track.map(|p| p.as_ref()).to_glib_none().0,
                type_.to_glib(),
            ))
        }
    }

    fn find_track_elements<P: IsA<Track>>(
        &self,
        track: Option<&P>,
        track_type: TrackType,
        type_: glib::types::Type,
    ) -> Vec<TrackElement> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ges_sys::ges_clip_find_track_elements(
                self.as_ref().to_glib_none().0,
                track.map(|p| p.as_ref()).to_glib_none().0,
                track_type.to_glib(),
                type_.to_glib(),
            ))
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn get_duration_limit(&self) -> gst::ClockTime {
        unsafe {
            from_glib(ges_sys::ges_clip_get_duration_limit(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn get_internal_time_from_timeline_time<P: IsA<TrackElement>>(
        &self,
        child: &P,
        timeline_time: gst::ClockTime,
    ) -> Result<gst::ClockTime, glib::Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let ret = ges_sys::ges_clip_get_internal_time_from_timeline_time(
                self.as_ref().to_glib_none().0,
                child.as_ref().to_glib_none().0,
                timeline_time.to_glib(),
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    fn get_layer(&self) -> Option<Layer> {
        unsafe { from_glib_full(ges_sys::ges_clip_get_layer(self.as_ref().to_glib_none().0)) }
    }

    fn get_supported_formats(&self) -> TrackType {
        unsafe {
            from_glib(ges_sys::ges_clip_get_supported_formats(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn get_timeline_time_from_internal_time<P: IsA<TrackElement>>(
        &self,
        child: &P,
        internal_time: gst::ClockTime,
    ) -> Result<gst::ClockTime, glib::Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let ret = ges_sys::ges_clip_get_timeline_time_from_internal_time(
                self.as_ref().to_glib_none().0,
                child.as_ref().to_glib_none().0,
                internal_time.to_glib(),
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn get_timeline_time_from_source_frame(
        &self,
        frame_number: FrameNumber,
    ) -> Result<gst::ClockTime, glib::Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let ret = ges_sys::ges_clip_get_timeline_time_from_source_frame(
                self.as_ref().to_glib_none().0,
                frame_number,
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    fn get_top_effect_index<P: IsA<BaseEffect>>(&self, effect: &P) -> i32 {
        unsafe {
            ges_sys::ges_clip_get_top_effect_index(
                self.as_ref().to_glib_none().0,
                effect.as_ref().to_glib_none().0,
            )
        }
    }

    fn get_top_effect_position<P: IsA<BaseEffect>>(&self, effect: &P) -> i32 {
        unsafe {
            ges_sys::ges_clip_get_top_effect_position(
                self.as_ref().to_glib_none().0,
                effect.as_ref().to_glib_none().0,
            )
        }
    }

    fn get_top_effects(&self) -> Vec<TrackElement> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ges_sys::ges_clip_get_top_effects(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn move_to_layer<P: IsA<Layer>>(&self, layer: &P) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib_result_from_gboolean!(
                ges_sys::ges_clip_move_to_layer(
                    self.as_ref().to_glib_none().0,
                    layer.as_ref().to_glib_none().0
                ),
                "Failed to move clip to specified layer"
            )
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn move_to_layer_full<P: IsA<Layer>>(&self, layer: &P) -> Result<(), glib::Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let _ = ges_sys::ges_clip_move_to_layer_full(
                self.as_ref().to_glib_none().0,
                layer.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"))]
    fn remove_top_effect<P: IsA<BaseEffect>>(&self, effect: &P) -> Result<(), glib::Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let _ = ges_sys::ges_clip_remove_top_effect(
                self.as_ref().to_glib_none().0,
                effect.as_ref().to_glib_none().0,
                &mut error,
            );
            if error.is_null() {
                Ok(())
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    fn set_supported_formats(&self, supportedformats: TrackType) {
        unsafe {
            ges_sys::ges_clip_set_supported_formats(
                self.as_ref().to_glib_none().0,
                supportedformats.to_glib(),
            );
        }
    }

    fn set_top_effect_index<P: IsA<BaseEffect>>(
        &self,
        effect: &P,
        newindex: u32,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib_result_from_gboolean!(
                ges_sys::ges_clip_set_top_effect_index(
                    self.as_ref().to_glib_none().0,
                    effect.as_ref().to_glib_none().0,
                    newindex
                ),
                "Failed to move effect"
            )
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn set_top_effect_index_full<P: IsA<BaseEffect>>(
        &self,
        effect: &P,
        newindex: u32,
    ) -> Result<(), glib::Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let _ = ges_sys::ges_clip_set_top_effect_index_full(
                self.as_ref().to_glib_none().0,
                effect.as_ref().to_glib_none().0,
                newindex,
                &mut error,
            );
            if error.is_null() {
                Ok(())
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    fn set_top_effect_priority<P: IsA<BaseEffect>>(
        &self,
        effect: &P,
        newpriority: u32,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib_result_from_gboolean!(
                ges_sys::ges_clip_set_top_effect_priority(
                    self.as_ref().to_glib_none().0,
                    effect.as_ref().to_glib_none().0,
                    newpriority
                ),
                "Failed to the set top effect priority"
            )
        }
    }

    fn split(&self, position: u64) -> Result<Clip, glib::BoolError> {
        unsafe {
            Option::<_>::from_glib_none(ges_sys::ges_clip_split(
                self.as_ref().to_glib_none().0,
                position,
            ))
            .ok_or_else(|| glib_bool_error!("Failed to split clip"))
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn split_full(&self, position: u64) -> Result<Option<Clip>, glib::Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let ret =
                ges_sys::ges_clip_split_full(self.as_ref().to_glib_none().0, position, &mut error);
            if error.is_null() {
                Ok(from_glib_none(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    #[cfg(any(feature = "v1_18", feature = "dox"))]
    fn connect_property_duration_limit_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_duration_limit_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut ges_sys::GESClip,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<Clip>,
        {
            let f: &F = &*(f as *const F);
            f(&Clip::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::duration-limit\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_duration_limit_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_layer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_layer_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut ges_sys::GESClip,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<Clip>,
        {
            let f: &F = &*(f as *const F);
            f(&Clip::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::layer\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_layer_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_supported_formats_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_supported_formats_trampoline<P, F: Fn(&P) + 'static>(
            this: *mut ges_sys::GESClip,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<Clip>,
        {
            let f: &F = &*(f as *const F);
            f(&Clip::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::supported-formats\0".as_ptr() as *const _,
                Some(transmute::<_, unsafe extern "C" fn()>(
                    notify_supported_formats_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}