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
// 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 glib::object::IsA;
use glib::translate::*;

glib::wrapper! {
    /// A [`glib::Object`][crate::glib::Object] that implements the [`Extractable`][crate::Extractable] interface can be
    /// extracted from a [`Asset`][crate::Asset] using [`AssetExt::extract()`][crate::prelude::AssetExt::extract()].
    ///
    /// Each extractable type will have its own way of interpreting the
    /// `property::Asset::id` of an asset (or, if it is associated with a specific
    /// subclass of [`Asset`][crate::Asset], the asset subclass may handle the
    /// interpretation of the `property::Asset::id`). By default, the requested asset
    /// `property::Asset::id` will be ignored by a [`Extractable`][crate::Extractable] and will be set to
    /// the type name of the extractable instead. Also by default, when the
    /// requested asset is extracted, the returned object will simply be a
    /// newly created default object of that extractable type. You should check
    /// the documentation for each extractable type to see if they differ from
    /// the default.
    ///
    /// After the object is extracted, it will have a reference to the asset it
    /// came from, which you can retrieve using [`ExtractableExt::asset()`][crate::prelude::ExtractableExt::asset()].
    ///
    /// # Implements
    ///
    /// [`ExtractableExt`][trait@crate::prelude::ExtractableExt], [`trait@glib::ObjectExt`]
    #[doc(alias = "GESExtractable")]
    pub struct Extractable(Interface<ffi::GESExtractable, ffi::GESExtractableInterface>);

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

pub const NONE_EXTRACTABLE: Option<&Extractable> = None;

/// Trait containing all [`struct@Extractable`] methods.
///
/// # Implementors
///
/// [`BaseEffect`][struct@crate::BaseEffect], [`BaseTransitionClip`][struct@crate::BaseTransitionClip], [`Clip`][struct@crate::Clip], [`Container`][struct@crate::Container], [`Effect`][struct@crate::Effect], [`Extractable`][struct@crate::Extractable], [`Group`][struct@crate::Group], [`Layer`][struct@crate::Layer], [`OperationClip`][struct@crate::OperationClip], [`TimelineElement`][struct@crate::TimelineElement], [`Timeline`][struct@crate::Timeline], [`TrackElement`][struct@crate::TrackElement], [`TransitionClip`][struct@crate::TransitionClip], [`UriClip`][struct@crate::UriClip]
pub trait ExtractableExt: 'static {
    /// Get the asset that has been set on the extractable object.
    ///
    /// # Returns
    ///
    /// The asset set on `self`, or [`None`]
    /// if no asset has been set.
    #[doc(alias = "ges_extractable_get_asset")]
    #[doc(alias = "get_asset")]
    fn asset(&self) -> Option<Asset>;

    /// Gets the `property::Asset::id` of some associated asset. It may be the case
    /// that the object has no set asset, or even that such an asset does not
    /// yet exist in the GES cache. Instead, this will return the asset
    /// `property::Asset::id` that is _compatible_ with the current state of the object,
    /// as determined by the [`Extractable`][crate::Extractable] implementer. If it was indeed
    /// extracted from an asset, this should return the same as its
    /// corresponding asset `property::Asset::id`.
    ///
    /// # Returns
    ///
    /// The `property::Asset::id` of some associated [`Asset`][crate::Asset]
    /// that is compatible with `self`'s current state.
    #[doc(alias = "ges_extractable_get_id")]
    #[doc(alias = "get_id")]
    fn id(&self) -> Option<glib::GString>;

    /// Sets the asset for this extractable object.
    ///
    /// When an object is extracted from an asset using [`AssetExt::extract()`][crate::prelude::AssetExt::extract()] its
    /// asset will be automatically set. Note that many classes that implement
    /// [`Extractable`][crate::Extractable] will automatically create their objects using assets
    /// when you call their `new` methods. However, you can use this method to
    /// associate an object with a compatible asset if it was created by other
    /// means and does not yet have an asset. Or, for some implementations of
    /// [`Extractable`][crate::Extractable], you can use this to change the asset of the given
    /// extractable object, which will lead to a change in its state to
    /// match the new asset `property::Asset::id`.
    /// ## `asset`
    /// The asset to set
    ///
    /// # Returns
    ///
    /// [`true`] if `asset` could be successfully set on `self`.
    #[doc(alias = "ges_extractable_set_asset")]
    fn set_asset<P: IsA<Asset>>(&self, asset: &P) -> Result<(), glib::error::BoolError>;
}

impl<O: IsA<Extractable>> ExtractableExt for O {
    fn asset(&self) -> Option<Asset> {
        unsafe {
            from_glib_none(ffi::ges_extractable_get_asset(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn id(&self) -> Option<glib::GString> {
        unsafe { from_glib_full(ffi::ges_extractable_get_id(self.as_ref().to_glib_none().0)) }
    }

    fn set_asset<P: IsA<Asset>>(&self, asset: &P) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::ges_extractable_set_asset(
                    self.as_ref().to_glib_none().0,
                    asset.as_ref().to_glib_none().0
                ),
                "Failed to set asset"
            )
        }
    }
}