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
// 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

#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
use crate::Formatter;
use crate::{ffi, Asset, MetaContainer, Timeline};
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    /// The [`Project`][crate::Project] is used to control a set of [`Asset`][crate::Asset] and is a
    /// [`Asset`][crate::Asset] with `GES_TYPE_TIMELINE` as `extractable_type` itself. That
    /// means that you can extract [`Timeline`][crate::Timeline] from a project as followed:
    ///
    /// **⚠️ The following code is in c ⚠️**
    ///
    /// ```c
    /// GESProject *project;
    /// GESTimeline *timeline;
    ///
    /// project = ges_project_new ("file:///path/to/a/valid/project/uri");
    ///
    /// // Here you can connect to the various signal to get more infos about
    /// // what is happening and recover from errors if possible
    /// ...
    ///
    /// timeline = ges_asset_extract (GES_ASSET (project));
    /// ```
    ///
    /// The [`Project`][crate::Project] class offers a higher level API to handle [`Asset`][crate::Asset]-s.
    /// It lets you request new asset, and it informs you about new assets through
    /// a set of signals. Also it handles problem such as missing files/missing
    /// [`gst::Element`][crate::gst::Element] and lets you try to recover from those.
    ///
    /// ## Subprojects
    ///
    /// In order to add a subproject, the only thing to do is to add the subproject
    /// to the main project:
    ///
    /// **⚠️ The following code is in  c ⚠️**
    ///
    /// ``` c
    /// ges_project_add_asset (project, GES_ASSET (subproject));
    /// ```
    /// then the subproject will be serialized in the project files. To use
    /// the subproject in a timeline, you should use a [`UriClip`][crate::UriClip] with the
    /// same subproject URI.
    ///
    /// When loading a project with subproject, subprojects URIs will be temporary
    /// writable local files. If you want to edit the subproject timeline,
    /// you should retrieve the subproject from the parent project asset list and
    /// extract the timeline with [`AssetExt::extract()`][crate::prelude::AssetExt::extract()] and save it at
    /// the same temporary location.
    ///
    /// ## Properties
    ///
    ///
    /// #### `uri`
    ///  Readable | Writeable | Construct Only
    /// <details><summary><h4>Asset</h4></summary>
    ///
    ///
    /// #### `extractable-type`
    ///  The [`Extractable`][crate::Extractable] object type that can be extracted from the asset.
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `id`
    ///  The ID of the asset. This should be unique amongst all assets with
    /// the same [`extractable-type`][struct@crate::Asset#extractable-type]. Depending on the associated
    /// [`Extractable`][crate::Extractable] implementation, this id may convey some information
    /// about the [`glib::Object`][crate::glib::Object] that should be extracted. Note that, as such, the
    /// ID will have an expected format, and you can not choose this value
    /// arbitrarily. By default, this will be set to the type name of the
    /// [`extractable-type`][struct@crate::Asset#extractable-type], but you should check the documentation
    /// of the extractable type to see whether they differ from the
    /// default behaviour.
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `proxy`
    ///  The default proxy for this asset, or [`None`] if it has no proxy. A
    /// proxy will act as a substitute for the original asset when the
    /// original is requested (see [`Asset::request()`][crate::Asset::request()]).
    ///
    /// Setting this property will not usually remove the existing proxy, but
    /// will replace it as the default (see [`AssetExt::set_proxy()`][crate::prelude::AssetExt::set_proxy()]).
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `proxy-target`
    ///  The asset that this asset is a proxy for, or [`None`] if it is not a
    /// proxy for another asset.
    ///
    /// Note that even if this asset is acting as a proxy for another asset,
    /// but this asset is not the default [`proxy`][struct@crate::Asset#proxy], then `proxy`-target
    /// will *still* point to this other asset. So you should check the
    /// [`proxy`][struct@crate::Asset#proxy] property of `target`-proxy before assuming it is the
    /// current default proxy for the target.
    ///
    /// Note that the [`notify`][struct@crate::glib::Object#notify] for this property is emitted after
    /// the [`proxy`][struct@crate::Asset#proxy] [`notify`][struct@crate::glib::Object#notify] for the corresponding (if any)
    /// asset it is now the proxy of/no longer the proxy of.
    ///
    /// Readable
    /// </details>
    ///
    /// ## Signals
    ///
    ///
    /// #### `asset-added`
    ///
    ///
    ///
    /// #### `asset-loading`
    ///
    ///
    ///
    /// #### `asset-removed`
    ///
    ///
    ///
    /// #### `error-loading`
    ///
    ///
    ///
    /// #### `error-loading-asset`
    ///  Informs you that a [`Asset`][crate::Asset] could not be created. In case of
    /// missing GStreamer plugins, the error will be set to `GST_CORE_ERROR`
    /// [`gst::CoreError::MissingPlugin`][crate::gst::CoreError::MissingPlugin]
    ///
    ///
    ///
    ///
    /// #### `loaded`
    ///
    ///
    ///
    /// #### `loading`
    ///
    ///
    ///
    /// #### `missing-uri`
    ///  **⚠️ The following code is in c ⚠️**
    ///
    /// ```c
    /// static gchar
    /// source_moved_cb (GESProject *project, GError *error, GESAsset *asset_with_error)
    /// {
    ///   return g_strdup ("file:///the/new/uri.ogg");
    /// }
    ///
    /// static int
    /// main (int argc, gchar ** argv)
    /// {
    ///   GESTimeline *timeline;
    ///   GESProject *project = ges_project_new ("file:///some/uri.xges");
    ///
    ///   g_signal_connect (project, "missing-uri", source_moved_cb, NULL);
    ///   timeline = ges_asset_extract (GES_ASSET (project));
    /// }
    /// ```
    ///
    ///
    /// <details><summary><h4>MetaContainer</h4></summary>
    ///
    ///
    /// #### `notify-meta`
    ///  This is emitted for a meta container whenever the metadata under one
    /// of its fields changes, is set for the first time, or is removed. In
    /// the latter case, `value` will be [`None`].
    ///
    /// Detailed
    /// </details>
    ///
    /// # Implements
    ///
    /// [`ProjectExt`][trait@crate::prelude::ProjectExt], [`AssetExt`][trait@crate::prelude::AssetExt], [`trait@glib::ObjectExt`], [`MetaContainerExt`][trait@crate::prelude::MetaContainerExt]
    #[doc(alias = "GESProject")]
    pub struct Project(Object<ffi::GESProject, ffi::GESProjectClass>) @extends Asset, @implements MetaContainer;

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

impl Project {
    pub const NONE: Option<&'static Project> = None;

    /// Creates a new [`Project`][crate::Project] and sets its uri to `uri` if provided. Note that
    /// if `uri` is not valid or [`None`], the uri of the project will then be set
    /// the first time you save the project. If you then save the project to
    /// other locations, it will never be updated again and the first valid URI is
    /// the URI it will keep refering to.
    /// ## `uri`
    /// The uri to be set after creating the project.
    ///
    /// # Returns
    ///
    /// A newly created [`Project`][crate::Project]
    ///
    /// MT safe.
    #[doc(alias = "ges_project_new")]
    pub fn new(uri: Option<&str>) -> Project {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::ges_project_new(uri.to_glib_none().0)) }
    }
}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::Project>> Sealed for T {}
}

/// Trait containing all [`struct@Project`] methods.
///
/// # Implementors
///
/// [`Project`][struct@crate::Project]
pub trait ProjectExt: IsA<Project> + sealed::Sealed + 'static {
    /// Adds a [`Asset`][crate::Asset] to `self`, the project will keep a reference on
    /// `asset`.
    /// ## `asset`
    /// A [`Asset`][crate::Asset] to add to `self`
    ///
    /// # Returns
    ///
    /// [`true`] if the asset could be added [`false`] it was already
    /// in the project.
    ///
    /// MT safe.
    #[doc(alias = "ges_project_add_asset")]
    fn add_asset(&self, asset: &impl IsA<Asset>) -> bool {
        unsafe {
            from_glib(ffi::ges_project_add_asset(
                self.as_ref().to_glib_none().0,
                asset.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Adds `profile` to the project. It lets you save in what format
    /// the project will be rendered and keep a reference to those formats.
    /// Also, those formats will be saved to the project file when possible.
    /// ## `profile`
    /// A [`gst_pbutils::EncodingProfile`][crate::gst_pbutils::EncodingProfile] to add to the project. If a profile with
    /// the same name already exists, it will be replaced.
    ///
    /// # Returns
    ///
    /// [`true`] if `profile` could be added, [`false`] otherwise
    ///
    /// MT safe.
    #[doc(alias = "ges_project_add_encoding_profile")]
    fn add_encoding_profile(
        &self,
        profile: &impl IsA<gst_pbutils::EncodingProfile>,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::ges_project_add_encoding_profile(
                    self.as_ref().to_glib_none().0,
                    profile.as_ref().to_glib_none().0
                ),
                "Failed to add profile"
            )
        }
    }

    /// Adds a formatter to be used to load `self`
    /// ## `formatter`
    /// A formatter used by `self`
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_project_add_formatter")]
    fn add_formatter(&self, formatter: &impl IsA<Formatter>) {
        unsafe {
            ffi::ges_project_add_formatter(
                self.as_ref().to_glib_none().0,
                formatter.as_ref().to_glib_none().0,
            );
        }
    }

    /// Create and add a [`Asset`][crate::Asset] to `self`. You should connect to the
    /// "asset-added" signal to get the asset when it finally gets added to
    /// `self`
    /// ## `id`
    /// The id of the asset to create and add to `self`
    /// ## `extractable_type`
    /// The `GType` of the asset to create
    ///
    /// # Returns
    ///
    /// [`true`] if the asset was added and started loading, [`false`] it was
    /// already in the project.
    ///
    /// MT safe.
    #[doc(alias = "ges_project_create_asset")]
    fn create_asset(&self, id: Option<&str>, extractable_type: glib::types::Type) -> bool {
        unsafe {
            from_glib(ffi::ges_project_create_asset(
                self.as_ref().to_glib_none().0,
                id.to_glib_none().0,
                extractable_type.into_glib(),
            ))
        }
    }

    /// Create and add a [`Asset`][crate::Asset] to `self`. You should connect to the
    /// "asset-added" signal to get the asset when it finally gets added to
    /// `self`
    /// ## `id`
    /// The id of the asset to create and add to `self`
    /// ## `extractable_type`
    /// The `GType` of the asset to create
    ///
    /// # Returns
    ///
    /// The newly created [`Asset`][crate::Asset] or [`None`].
    ///
    /// MT safe.
    #[doc(alias = "ges_project_create_asset_sync")]
    fn create_asset_sync(
        &self,
        id: Option<&str>,
        extractable_type: glib::types::Type,
    ) -> Result<Option<Asset>, glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let ret = ffi::ges_project_create_asset_sync(
                self.as_ref().to_glib_none().0,
                id.to_glib_none().0,
                extractable_type.into_glib(),
                &mut error,
            );
            if error.is_null() {
                Ok(from_glib_full(ret))
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    /// ## `id`
    /// The id of the asset to retrieve
    /// ## `extractable_type`
    /// The extractable_type of the asset
    /// to retrieve from `object`
    ///
    /// # Returns
    ///
    /// The [`Asset`][crate::Asset] with
    /// `id` or [`None`] if no asset with `id` as an ID
    ///
    /// MT safe.
    #[doc(alias = "ges_project_get_asset")]
    #[doc(alias = "get_asset")]
    fn asset(&self, id: &str, extractable_type: glib::types::Type) -> Option<Asset> {
        unsafe {
            from_glib_full(ffi::ges_project_get_asset(
                self.as_ref().to_glib_none().0,
                id.to_glib_none().0,
                extractable_type.into_glib(),
            ))
        }
    }

    /// Get the assets that are being loaded
    ///
    /// # Returns
    ///
    /// A set of loading asset
    /// that will be added to `self`. Note that those Asset are *not* loaded yet,
    /// and thus can not be used.
    ///
    /// MT safe.
    #[doc(alias = "ges_project_get_loading_assets")]
    #[doc(alias = "get_loading_assets")]
    fn loading_assets(&self) -> Vec<Asset> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::ges_project_get_loading_assets(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Retrieve the uri that is currently set on `self`
    ///
    /// # Returns
    ///
    /// a newly allocated string representing uri.
    ///
    /// MT safe.
    #[doc(alias = "ges_project_get_uri")]
    #[doc(alias = "get_uri")]
    fn uri(&self) -> Option<glib::GString> {
        unsafe { from_glib_full(ffi::ges_project_get_uri(self.as_ref().to_glib_none().0)) }
    }

    /// List all `asset` contained in `self` filtering per extractable_type
    /// as defined by `filter`. It copies the asset and thus will not be updated
    /// in time.
    /// ## `filter`
    /// Type of assets to list, `GES_TYPE_EXTRACTABLE` will list
    /// all assets
    ///
    /// # Returns
    ///
    /// The list of
    /// [`Asset`][crate::Asset] the object contains
    ///
    /// MT safe.
    #[doc(alias = "ges_project_list_assets")]
    fn list_assets(&self, filter: glib::types::Type) -> Vec<Asset> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(ffi::ges_project_list_assets(
                self.as_ref().to_glib_none().0,
                filter.into_glib(),
            ))
        }
    }

    /// Lists the encoding profile that have been set to `self`. The first one
    /// is the latest added.
    ///
    /// # Returns
    ///
    /// The
    /// list of [`gst_pbutils::EncodingProfile`][crate::gst_pbutils::EncodingProfile] used in `self`
    #[doc(alias = "ges_project_list_encoding_profiles")]
    fn list_encoding_profiles(&self) -> Vec<gst_pbutils::EncodingProfile> {
        unsafe {
            FromGlibPtrContainer::from_glib_none(ffi::ges_project_list_encoding_profiles(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Loads `self` into `timeline`
    /// ## `timeline`
    /// A blank timeline to load `self` into
    ///
    /// # Returns
    ///
    /// [`true`] if the project could be loaded [`false`] otherwise.
    ///
    /// MT safe.
    #[doc(alias = "ges_project_load")]
    fn load(&self, timeline: &impl IsA<Timeline>) -> Result<(), glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let is_ok = ffi::ges_project_load(
                self.as_ref().to_glib_none().0,
                timeline.as_ref().to_glib_none().0,
                &mut error,
            );
            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            if error.is_null() {
                Ok(())
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    /// Remove `asset` from `self`.
    /// ## `asset`
    /// A [`Asset`][crate::Asset] to remove from `self`
    ///
    /// # Returns
    ///
    /// [`true`] if the asset could be removed [`false`] otherwise
    ///
    /// MT safe.
    #[doc(alias = "ges_project_remove_asset")]
    fn remove_asset(&self, asset: &impl IsA<Asset>) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::ges_project_remove_asset(
                    self.as_ref().to_glib_none().0,
                    asset.as_ref().to_glib_none().0
                ),
                "Failed to remove asset"
            )
        }
    }

    /// Save the timeline of `self` to `uri`. You should make sure that `timeline`
    /// is one of the timelines that have been extracted from `self`
    /// (using ges_asset_extract (`self`);)
    /// ## `timeline`
    /// The [`Timeline`][crate::Timeline] to save, it must have been extracted from `self`
    /// ## `uri`
    /// The uri where to save `self` and `timeline`
    /// ## `formatter_asset`
    /// The formatter asset to
    /// use or [`None`]. If [`None`], will try to save in the same format as the one
    /// from which the timeline as been loaded or default to the best formatter
    /// as defined in `ges_find_formatter_for_uri`
    /// ## `overwrite`
    /// [`true`] to overwrite file if it exists
    ///
    /// # Returns
    ///
    /// [`true`] if the project could be save, [`false`] otherwise
    ///
    /// MT safe.
    #[doc(alias = "ges_project_save")]
    fn save(
        &self,
        timeline: &impl IsA<Timeline>,
        uri: &str,
        formatter_asset: Option<impl IsA<Asset>>,
        overwrite: bool,
    ) -> Result<(), glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let is_ok = ffi::ges_project_save(
                self.as_ref().to_glib_none().0,
                timeline.as_ref().to_glib_none().0,
                uri.to_glib_none().0,
                formatter_asset.map(|p| p.upcast()).into_glib_ptr(),
                overwrite.into_glib(),
                &mut error,
            );
            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            if error.is_null() {
                Ok(())
            } else {
                Err(from_glib_full(error))
            }
        }
    }

    /// ## `asset`
    /// The [`Asset`][crate::Asset] that has been added to `project`
    #[doc(alias = "asset-added")]
    fn connect_asset_added<F: Fn(&Self, &Asset) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn asset_added_trampoline<
            P: IsA<Project>,
            F: Fn(&P, &Asset) + 'static,
        >(
            this: *mut ffi::GESProject,
            asset: *mut ffi::GESAsset,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                Project::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(asset),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"asset-added\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    asset_added_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    /// ## `asset`
    /// The [`Asset`][crate::Asset] that started loading
    #[doc(alias = "asset-loading")]
    fn connect_asset_loading<F: Fn(&Self, &Asset) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn asset_loading_trampoline<
            P: IsA<Project>,
            F: Fn(&P, &Asset) + 'static,
        >(
            this: *mut ffi::GESProject,
            asset: *mut ffi::GESAsset,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                Project::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(asset),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"asset-loading\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    asset_loading_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    /// ## `asset`
    /// The [`Asset`][crate::Asset] that has been removed from `project`
    #[doc(alias = "asset-removed")]
    fn connect_asset_removed<F: Fn(&Self, &Asset) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn asset_removed_trampoline<
            P: IsA<Project>,
            F: Fn(&P, &Asset) + 'static,
        >(
            this: *mut ffi::GESProject,
            asset: *mut ffi::GESAsset,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                Project::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(asset),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"asset-removed\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    asset_removed_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    /// ## `timeline`
    /// The timeline that failed loading
    /// ## `error`
    /// The [`glib::Error`][crate::glib::Error] defining the error that occured
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "error-loading")]
    fn connect_error_loading<F: Fn(&Self, &Timeline, &glib::Error) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn error_loading_trampoline<
            P: IsA<Project>,
            F: Fn(&P, &Timeline, &glib::Error) + 'static,
        >(
            this: *mut ffi::GESProject,
            timeline: *mut ffi::GESTimeline,
            error: *mut glib::ffi::GError,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                Project::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(timeline),
                &from_glib_borrow(error),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"error-loading\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    error_loading_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    /// Informs you that a [`Asset`][crate::Asset] could not be created. In case of
    /// missing GStreamer plugins, the error will be set to `GST_CORE_ERROR`
    /// [`gst::CoreError::MissingPlugin`][crate::gst::CoreError::MissingPlugin]
    /// ## `error`
    /// The [`glib::Error`][crate::glib::Error] defining the error that occured, might be [`None`]
    /// ## `id`
    /// The `id` of the asset that failed loading
    /// ## `extractable_type`
    /// The `extractable_type` of the asset that
    /// failed loading
    #[doc(alias = "error-loading-asset")]
    fn connect_error_loading_asset<
        F: Fn(&Self, &glib::Error, &str, glib::types::Type) + 'static,
    >(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn error_loading_asset_trampoline<
            P: IsA<Project>,
            F: Fn(&P, &glib::Error, &str, glib::types::Type) + 'static,
        >(
            this: *mut ffi::GESProject,
            error: *mut glib::ffi::GError,
            id: *mut libc::c_char,
            extractable_type: glib::ffi::GType,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                Project::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(error),
                &glib::GString::from_glib_borrow(id),
                from_glib(extractable_type),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"error-loading-asset\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    error_loading_asset_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    /// ## `timeline`
    /// The [`Timeline`][crate::Timeline] that completed loading
    #[doc(alias = "loaded")]
    fn connect_loaded<F: Fn(&Self, &Timeline) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn loaded_trampoline<P: IsA<Project>, F: Fn(&P, &Timeline) + 'static>(
            this: *mut ffi::GESProject,
            timeline: *mut ffi::GESTimeline,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                Project::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(timeline),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"loaded\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    loaded_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    /// ## `timeline`
    /// The [`Timeline`][crate::Timeline] that started loading
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "loading")]
    fn connect_loading<F: Fn(&Self, &Timeline) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn loading_trampoline<P: IsA<Project>, F: Fn(&P, &Timeline) + 'static>(
            this: *mut ffi::GESProject,
            timeline: *mut ffi::GESTimeline,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                Project::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(timeline),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"loading\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    loading_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    /// **⚠️ The following code is in c ⚠️**
    ///
    /// ```c
    /// static gchar
    /// source_moved_cb (GESProject *project, GError *error, GESAsset *asset_with_error)
    /// {
    ///   return g_strdup ("file:///the/new/uri.ogg");
    /// }
    ///
    /// static int
    /// main (int argc, gchar ** argv)
    /// {
    ///   GESTimeline *timeline;
    ///   GESProject *project = ges_project_new ("file:///some/uri.xges");
    ///
    ///   g_signal_connect (project, "missing-uri", source_moved_cb, NULL);
    ///   timeline = ges_asset_extract (GES_ASSET (project));
    /// }
    /// ```
    /// ## `error`
    /// The error that happened
    /// ## `wrong_asset`
    /// The asset with the wrong ID, you should us it and its content
    /// only to find out what the new location is.
    ///
    /// # Returns
    ///
    /// The new URI of `wrong_asset`
    #[doc(alias = "missing-uri")]
    fn connect_missing_uri<
        F: Fn(&Self, &glib::Error, &Asset) -> Option<glib::GString> + 'static,
    >(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn missing_uri_trampoline<
            P: IsA<Project>,
            F: Fn(&P, &glib::Error, &Asset) -> Option<glib::GString> + 'static,
        >(
            this: *mut ffi::GESProject,
            error: *mut glib::ffi::GError,
            wrong_asset: *mut ffi::GESAsset,
            f: glib::ffi::gpointer,
        ) -> *mut libc::c_char {
            let f: &F = &*(f as *const F);
            f(
                Project::from_glib_borrow(this).unsafe_cast_ref(),
                &from_glib_borrow(error),
                &from_glib_borrow(wrong_asset),
            )
            .to_glib_full()
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"missing-uri\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    missing_uri_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<Project>> ProjectExt for O {}