gstreamer_editing_services/auto/
container.rs1#![allow(deprecated)]
6
7use crate::{ffi, Edge, EditMode, Extractable, Layer, MetaContainer, TimelineElement};
8use glib::{
9 object::ObjectType as _,
10 prelude::*,
11 signal::{connect_raw, SignalHandlerId},
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
35mod sealed {
36 pub trait Sealed {}
37 impl<T: super::IsA<super::Container>> Sealed for T {}
38}
39
40pub trait GESContainerExt: IsA<Container> + sealed::Sealed + 'static {
41 #[doc(alias = "ges_container_add")]
42 fn add(&self, child: &impl IsA<TimelineElement>) -> Result<(), glib::error::BoolError> {
43 unsafe {
44 glib::result_from_gboolean!(
45 ffi::ges_container_add(
46 self.as_ref().to_glib_none().0,
47 child.as_ref().to_glib_none().0
48 ),
49 "Failed to add element"
50 )
51 }
52 }
53
54 #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")]
55 #[allow(deprecated)]
56 #[doc(alias = "ges_container_edit")]
57 fn edit(
58 &self,
59 layers: &[Layer],
60 new_layer_priority: i32,
61 mode: EditMode,
62 edge: Edge,
63 position: u64,
64 ) -> Result<(), glib::error::BoolError> {
65 unsafe {
66 glib::result_from_gboolean!(
67 ffi::ges_container_edit(
68 self.as_ref().to_glib_none().0,
69 layers.to_glib_none().0,
70 new_layer_priority,
71 mode.into_glib(),
72 edge.into_glib(),
73 position
74 ),
75 "Failed to edit container"
76 )
77 }
78 }
79
80 #[doc(alias = "ges_container_get_children")]
81 #[doc(alias = "get_children")]
82 fn children(&self, recursive: bool) -> Vec<TimelineElement> {
83 unsafe {
84 FromGlibPtrContainer::from_glib_full(ffi::ges_container_get_children(
85 self.as_ref().to_glib_none().0,
86 recursive.into_glib(),
87 ))
88 }
89 }
90
91 #[doc(alias = "ges_container_remove")]
92 fn remove(&self, child: &impl IsA<TimelineElement>) -> Result<(), glib::error::BoolError> {
93 unsafe {
94 glib::result_from_gboolean!(
95 ffi::ges_container_remove(
96 self.as_ref().to_glib_none().0,
97 child.as_ref().to_glib_none().0
98 ),
99 "Failed to remove element"
100 )
101 }
102 }
103
104 #[doc(alias = "ges_container_ungroup")]
105 fn ungroup(self, recursive: bool) -> Vec<Container> {
106 unsafe {
107 FromGlibPtrContainer::from_glib_full(ffi::ges_container_ungroup(
108 self.upcast().into_glib_ptr(),
109 recursive.into_glib(),
110 ))
111 }
112 }
113
114 fn height(&self) -> u32 {
115 ObjectExt::property(self.as_ref(), "height")
116 }
117
118 #[doc(alias = "child-added")]
119 fn connect_child_added<F: Fn(&Self, &TimelineElement) + 'static>(
120 &self,
121 f: F,
122 ) -> SignalHandlerId {
123 unsafe extern "C" fn child_added_trampoline<
124 P: IsA<Container>,
125 F: Fn(&P, &TimelineElement) + 'static,
126 >(
127 this: *mut ffi::GESContainer,
128 element: *mut ffi::GESTimelineElement,
129 f: glib::ffi::gpointer,
130 ) {
131 let f: &F = &*(f as *const F);
132 f(
133 Container::from_glib_borrow(this).unsafe_cast_ref(),
134 &from_glib_borrow(element),
135 )
136 }
137 unsafe {
138 let f: Box_<F> = Box_::new(f);
139 connect_raw(
140 self.as_ptr() as *mut _,
141 b"child-added\0".as_ptr() as *const _,
142 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
143 child_added_trampoline::<Self, F> as *const (),
144 )),
145 Box_::into_raw(f),
146 )
147 }
148 }
149
150 #[doc(alias = "child-removed")]
151 fn connect_child_removed<F: Fn(&Self, &TimelineElement) + 'static>(
152 &self,
153 f: F,
154 ) -> SignalHandlerId {
155 unsafe extern "C" fn child_removed_trampoline<
156 P: IsA<Container>,
157 F: Fn(&P, &TimelineElement) + 'static,
158 >(
159 this: *mut ffi::GESContainer,
160 element: *mut ffi::GESTimelineElement,
161 f: glib::ffi::gpointer,
162 ) {
163 let f: &F = &*(f as *const F);
164 f(
165 Container::from_glib_borrow(this).unsafe_cast_ref(),
166 &from_glib_borrow(element),
167 )
168 }
169 unsafe {
170 let f: Box_<F> = Box_::new(f);
171 connect_raw(
172 self.as_ptr() as *mut _,
173 b"child-removed\0".as_ptr() as *const _,
174 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
175 child_removed_trampoline::<Self, F> as *const (),
176 )),
177 Box_::into_raw(f),
178 )
179 }
180 }
181
182 #[doc(alias = "height")]
183 fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
184 unsafe extern "C" fn notify_height_trampoline<P: IsA<Container>, F: Fn(&P) + 'static>(
185 this: *mut ffi::GESContainer,
186 _param_spec: glib::ffi::gpointer,
187 f: glib::ffi::gpointer,
188 ) {
189 let f: &F = &*(f as *const F);
190 f(Container::from_glib_borrow(this).unsafe_cast_ref())
191 }
192 unsafe {
193 let f: Box_<F> = Box_::new(f);
194 connect_raw(
195 self.as_ptr() as *mut _,
196 b"notify::height\0".as_ptr() as *const _,
197 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
198 notify_height_trampoline::<Self, F> as *const (),
199 )),
200 Box_::into_raw(f),
201 )
202 }
203 }
204}
205
206impl<O: IsA<Container>> GESContainerExt for O {}