Skip to main content

gstreamer_editing_services/auto/
container.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5#![allow(deprecated)]
6
7use crate::{Edge, EditMode, Extractable, Layer, MetaContainer, TimelineElement, ffi};
8use glib::{
9    object::ObjectType as _,
10    prelude::*,
11    signal::{SignalHandlerId, connect_raw},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    #[doc(alias = "GESContainer")]
18    pub struct Container(Object<ffi::GESContainer, ffi::GESContainerClass>) @extends TimelineElement, @implements Extractable, MetaContainer;
19
20    match fn {
21        type_ => || ffi::ges_container_get_type(),
22    }
23}
24
25impl Container {
26    pub const NONE: Option<&'static Container> = None;
27
28    #[doc(alias = "ges_container_group")]
29    pub fn group(containers: &[Container]) -> Option<Container> {
30        assert_initialized_main_thread!();
31        unsafe { from_glib_none(ffi::ges_container_group(containers.to_glib_none().0)) }
32    }
33}
34
35pub trait GESContainerExt: IsA<Container> + 'static {
36    #[doc(alias = "ges_container_add")]
37    fn add(&self, child: &impl IsA<TimelineElement>) -> Result<(), glib::error::BoolError> {
38        unsafe {
39            glib::result_from_gboolean!(
40                ffi::ges_container_add(
41                    self.as_ref().to_glib_none().0,
42                    child.as_ref().to_glib_none().0
43                ),
44                "Failed to add element"
45            )
46        }
47    }
48
49    #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")]
50    #[allow(deprecated)]
51    #[doc(alias = "ges_container_edit")]
52    fn edit(
53        &self,
54        layers: &[Layer],
55        new_layer_priority: i32,
56        mode: EditMode,
57        edge: Edge,
58        position: u64,
59    ) -> Result<(), glib::error::BoolError> {
60        unsafe {
61            glib::result_from_gboolean!(
62                ffi::ges_container_edit(
63                    self.as_ref().to_glib_none().0,
64                    layers.to_glib_none().0,
65                    new_layer_priority,
66                    mode.into_glib(),
67                    edge.into_glib(),
68                    position
69                ),
70                "Failed to edit container"
71            )
72        }
73    }
74
75    #[doc(alias = "ges_container_get_children")]
76    #[doc(alias = "get_children")]
77    fn children(&self, recursive: bool) -> Vec<TimelineElement> {
78        unsafe {
79            FromGlibPtrContainer::from_glib_full(ffi::ges_container_get_children(
80                self.as_ref().to_glib_none().0,
81                recursive.into_glib(),
82            ))
83        }
84    }
85
86    #[cfg(feature = "v1_30")]
87    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
88    #[doc(alias = "ges_container_get_height")]
89    #[doc(alias = "get_height")]
90    fn height(&self) -> u32 {
91        unsafe { ffi::ges_container_get_height(self.as_ref().to_glib_none().0) }
92    }
93
94    #[doc(alias = "ges_container_remove")]
95    fn remove(&self, child: &impl IsA<TimelineElement>) -> Result<(), glib::error::BoolError> {
96        unsafe {
97            glib::result_from_gboolean!(
98                ffi::ges_container_remove(
99                    self.as_ref().to_glib_none().0,
100                    child.as_ref().to_glib_none().0
101                ),
102                "Failed to remove element"
103            )
104        }
105    }
106
107    #[doc(alias = "ges_container_ungroup")]
108    fn ungroup(self, recursive: bool) -> Vec<Container> {
109        unsafe {
110            FromGlibPtrContainer::from_glib_full(ffi::ges_container_ungroup(
111                self.upcast().into_glib_ptr(),
112                recursive.into_glib(),
113            ))
114        }
115    }
116
117    #[cfg(not(feature = "v1_30"))]
118    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_30"))))]
119    fn height(&self) -> u32 {
120        ObjectExt::property(self.as_ref(), "height")
121    }
122
123    #[doc(alias = "child-added")]
124    fn connect_child_added<F: Fn(&Self, &TimelineElement) + 'static>(
125        &self,
126        f: F,
127    ) -> SignalHandlerId {
128        unsafe extern "C" fn child_added_trampoline<
129            P: IsA<Container>,
130            F: Fn(&P, &TimelineElement) + 'static,
131        >(
132            this: *mut ffi::GESContainer,
133            element: *mut ffi::GESTimelineElement,
134            f: glib::ffi::gpointer,
135        ) {
136            unsafe {
137                let f: &F = &*(f as *const F);
138                f(
139                    Container::from_glib_borrow(this).unsafe_cast_ref(),
140                    &from_glib_borrow(element),
141                )
142            }
143        }
144        unsafe {
145            let f: Box_<F> = Box_::new(f);
146            connect_raw(
147                self.as_ptr() as *mut _,
148                c"child-added".as_ptr(),
149                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
150                    child_added_trampoline::<Self, F> as *const (),
151                )),
152                Box_::into_raw(f),
153            )
154        }
155    }
156
157    #[doc(alias = "child-removed")]
158    fn connect_child_removed<F: Fn(&Self, &TimelineElement) + 'static>(
159        &self,
160        f: F,
161    ) -> SignalHandlerId {
162        unsafe extern "C" fn child_removed_trampoline<
163            P: IsA<Container>,
164            F: Fn(&P, &TimelineElement) + 'static,
165        >(
166            this: *mut ffi::GESContainer,
167            element: *mut ffi::GESTimelineElement,
168            f: glib::ffi::gpointer,
169        ) {
170            unsafe {
171                let f: &F = &*(f as *const F);
172                f(
173                    Container::from_glib_borrow(this).unsafe_cast_ref(),
174                    &from_glib_borrow(element),
175                )
176            }
177        }
178        unsafe {
179            let f: Box_<F> = Box_::new(f);
180            connect_raw(
181                self.as_ptr() as *mut _,
182                c"child-removed".as_ptr(),
183                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
184                    child_removed_trampoline::<Self, F> as *const (),
185                )),
186                Box_::into_raw(f),
187            )
188        }
189    }
190
191    #[doc(alias = "height")]
192    fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
193        unsafe extern "C" fn notify_height_trampoline<P: IsA<Container>, F: Fn(&P) + 'static>(
194            this: *mut ffi::GESContainer,
195            _param_spec: glib::ffi::gpointer,
196            f: glib::ffi::gpointer,
197        ) {
198            unsafe {
199                let f: &F = &*(f as *const F);
200                f(Container::from_glib_borrow(this).unsafe_cast_ref())
201            }
202        }
203        unsafe {
204            let f: Box_<F> = Box_::new(f);
205            connect_raw(
206                self.as_ptr() as *mut _,
207                c"notify::height".as_ptr(),
208                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
209                    notify_height_trampoline::<Self, F> as *const (),
210                )),
211                Box_::into_raw(f),
212            )
213        }
214    }
215}
216
217impl<O: IsA<Container>> GESContainerExt for O {}