gstreamer_editing_services/auto/
container.rs1#![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 #[doc(alias = "ges_container_remove")]
87 fn remove(&self, child: &impl IsA<TimelineElement>) -> Result<(), glib::error::BoolError> {
88 unsafe {
89 glib::result_from_gboolean!(
90 ffi::ges_container_remove(
91 self.as_ref().to_glib_none().0,
92 child.as_ref().to_glib_none().0
93 ),
94 "Failed to remove element"
95 )
96 }
97 }
98
99 #[doc(alias = "ges_container_ungroup")]
100 fn ungroup(self, recursive: bool) -> Vec<Container> {
101 unsafe {
102 FromGlibPtrContainer::from_glib_full(ffi::ges_container_ungroup(
103 self.upcast().into_glib_ptr(),
104 recursive.into_glib(),
105 ))
106 }
107 }
108
109 fn height(&self) -> u32 {
110 ObjectExt::property(self.as_ref(), "height")
111 }
112
113 #[doc(alias = "child-added")]
114 fn connect_child_added<F: Fn(&Self, &TimelineElement) + 'static>(
115 &self,
116 f: F,
117 ) -> SignalHandlerId {
118 unsafe extern "C" fn child_added_trampoline<
119 P: IsA<Container>,
120 F: Fn(&P, &TimelineElement) + 'static,
121 >(
122 this: *mut ffi::GESContainer,
123 element: *mut ffi::GESTimelineElement,
124 f: glib::ffi::gpointer,
125 ) {
126 unsafe {
127 let f: &F = &*(f as *const F);
128 f(
129 Container::from_glib_borrow(this).unsafe_cast_ref(),
130 &from_glib_borrow(element),
131 )
132 }
133 }
134 unsafe {
135 let f: Box_<F> = Box_::new(f);
136 connect_raw(
137 self.as_ptr() as *mut _,
138 c"child-added".as_ptr(),
139 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
140 child_added_trampoline::<Self, F> as *const (),
141 )),
142 Box_::into_raw(f),
143 )
144 }
145 }
146
147 #[doc(alias = "child-removed")]
148 fn connect_child_removed<F: Fn(&Self, &TimelineElement) + 'static>(
149 &self,
150 f: F,
151 ) -> SignalHandlerId {
152 unsafe extern "C" fn child_removed_trampoline<
153 P: IsA<Container>,
154 F: Fn(&P, &TimelineElement) + 'static,
155 >(
156 this: *mut ffi::GESContainer,
157 element: *mut ffi::GESTimelineElement,
158 f: glib::ffi::gpointer,
159 ) {
160 unsafe {
161 let f: &F = &*(f as *const F);
162 f(
163 Container::from_glib_borrow(this).unsafe_cast_ref(),
164 &from_glib_borrow(element),
165 )
166 }
167 }
168 unsafe {
169 let f: Box_<F> = Box_::new(f);
170 connect_raw(
171 self.as_ptr() as *mut _,
172 c"child-removed".as_ptr(),
173 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
174 child_removed_trampoline::<Self, F> as *const (),
175 )),
176 Box_::into_raw(f),
177 )
178 }
179 }
180
181 #[doc(alias = "height")]
182 fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
183 unsafe extern "C" fn notify_height_trampoline<P: IsA<Container>, F: Fn(&P) + 'static>(
184 this: *mut ffi::GESContainer,
185 _param_spec: glib::ffi::gpointer,
186 f: glib::ffi::gpointer,
187 ) {
188 unsafe {
189 let f: &F = &*(f as *const F);
190 f(Container::from_glib_borrow(this).unsafe_cast_ref())
191 }
192 }
193 unsafe {
194 let f: Box_<F> = Box_::new(f);
195 connect_raw(
196 self.as_ptr() as *mut _,
197 c"notify::height".as_ptr(),
198 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
199 notify_height_trampoline::<Self, F> as *const (),
200 )),
201 Box_::into_raw(f),
202 )
203 }
204 }
205}
206
207impl<O: IsA<Container>> GESContainerExt for O {}