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)
// DO NOT EDIT

use ges_sys;
use glib;
use glib::object::IsA;
use glib::translate::*;
use glib::GString;
use Asset;

glib_wrapper! {
    /// A `gobject::Object` that implements the `Extractable` interface can be
    /// extracted from a `Asset` using `AssetExt::extract`.
    ///
    /// Each extractable type will have its own way of interpreting the
    /// `Asset:id` of an asset (or, if it is associated with a specific
    /// subclass of `Asset`, the asset subclass may handle the
    /// interpretation of the `Asset:id`). By default, the requested asset
    /// `Asset:id` will be ignored by a `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 `Extractable::get_asset`.
    ///
    /// # Implements
    ///
    /// [`ExtractableExt`](trait.ExtractableExt.html), [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html)
    pub struct Extractable(Interface<ges_sys::GESExtractable>);

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

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

/// Trait containing all `Extractable` methods.
///
/// # Implementors
///
/// [`BaseEffect`](struct.BaseEffect.html), [`BaseTransitionClip`](struct.BaseTransitionClip.html), [`Clip`](struct.Clip.html), [`Container`](struct.Container.html), [`Effect`](struct.Effect.html), [`Extractable`](struct.Extractable.html), [`Group`](struct.Group.html), [`Layer`](struct.Layer.html), [`OperationClip`](struct.OperationClip.html), [`TimelineElement`](struct.TimelineElement.html), [`Timeline`](struct.Timeline.html), [`TrackElement`](struct.TrackElement.html), [`TransitionClip`](struct.TransitionClip.html), [`UriClip`](struct.UriClip.html)
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.
    fn get_asset(&self) -> Option<Asset>;

    /// Gets the `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
    /// `Asset:id` that is _compatible_ with the current state of the object,
    /// as determined by the `Extractable` implementer. If it was indeed
    /// extracted from an asset, this should return the same as its
    /// corresponding asset `Asset:id`.
    ///
    /// # Returns
    ///
    /// The `Asset:id` of some associated `Asset`
    /// that is compatible with `self`'s current state.
    fn get_id(&self) -> Option<GString>;

    /// Sets the asset for this extractable object.
    ///
    /// When an object is extracted from an asset using `AssetExt::extract` its
    /// asset will be automatically set. Note that many classes that implement
    /// `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`, 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 `Asset:id`.
    /// ## `asset`
    /// The asset to set
    ///
    /// # Returns
    ///
    /// `true` if `asset` could be successfully set on `self`.
    fn set_asset<P: IsA<Asset>>(&self, asset: &P) -> Result<(), glib::error::BoolError>;
}

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

    fn get_id(&self) -> Option<GString> {
        unsafe {
            from_glib_full(ges_sys::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!(
                ges_sys::ges_extractable_set_asset(
                    self.as_ref().to_glib_none().0,
                    asset.as_ref().to_glib_none().0
                ),
                "Failed to set asset"
            )
        }
    }
}