gstreamer_editing_services/auto/
marker_list.rs1#![allow(deprecated)]
6
7#[cfg(feature = "v1_20")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
9use crate::MarkerFlags;
10use crate::{Marker, ffi};
11use glib::{
12 object::ObjectType as _,
13 prelude::*,
14 signal::{SignalHandlerId, connect_raw},
15 translate::*,
16};
17use std::boxed::Box as Box_;
18
19glib::wrapper! {
20 #[doc(alias = "GESMarkerList")]
54 pub struct MarkerList(Object<ffi::GESMarkerList, ffi::GESMarkerListClass>);
55
56 match fn {
57 type_ => || ffi::ges_marker_list_get_type(),
58 }
59}
60
61impl MarkerList {
62 #[doc(alias = "ges_marker_list_new")]
68 pub fn new() -> MarkerList {
69 assert_initialized_main_thread!();
70 unsafe { from_glib_full(ffi::ges_marker_list_new()) }
71 }
72
73 #[cfg_attr(feature = "v1_30", deprecated = "Since 1.30")]
85 #[allow(deprecated)]
86 #[doc(alias = "ges_marker_list_add")]
87 pub fn add(&self, position: impl Into<Option<gst::ClockTime>>) -> Marker {
88 unsafe {
89 from_glib_none(ffi::ges_marker_list_add(
90 self.to_glib_none().0,
91 position.into().into_glib(),
92 ))
93 }
94 }
95
96 #[cfg(feature = "v1_30")]
105 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
106 #[doc(alias = "ges_marker_list_add_full")]
107 pub fn add_full(&self, position: impl Into<Option<gst::ClockTime>>) -> Marker {
108 unsafe {
109 from_glib_full(ffi::ges_marker_list_add_full(
110 self.to_glib_none().0,
111 position.into().into_glib(),
112 ))
113 }
114 }
115
116 #[doc(alias = "ges_marker_list_get_markers")]
123 #[doc(alias = "get_markers")]
124 pub fn markers(&self) -> Vec<Marker> {
125 unsafe {
126 FromGlibPtrContainer::from_glib_full(ffi::ges_marker_list_get_markers(
127 self.to_glib_none().0,
128 ))
129 }
130 }
131
132 #[doc(alias = "ges_marker_list_move")]
139 #[doc(alias = "move")]
140 pub fn move_(&self, marker: &Marker, position: impl Into<Option<gst::ClockTime>>) -> bool {
141 unsafe {
142 from_glib(ffi::ges_marker_list_move(
143 self.to_glib_none().0,
144 marker.to_glib_none().0,
145 position.into().into_glib(),
146 ))
147 }
148 }
149
150 #[doc(alias = "ges_marker_list_remove")]
158 pub fn remove(&self, marker: &Marker) -> bool {
159 unsafe {
160 from_glib(ffi::ges_marker_list_remove(
161 self.to_glib_none().0,
162 marker.to_glib_none().0,
163 ))
164 }
165 }
166
167 #[doc(alias = "ges_marker_list_size")]
172 pub fn size(&self) -> u32 {
173 unsafe { ffi::ges_marker_list_size(self.to_glib_none().0) }
174 }
175
176 #[cfg(feature = "v1_20")]
178 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
179 pub fn flags(&self) -> MarkerFlags {
180 ObjectExt::property(self, "flags")
181 }
182
183 #[cfg(feature = "v1_20")]
185 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
186 pub fn set_flags(&self, flags: MarkerFlags) {
187 ObjectExt::set_property(self, "flags", flags)
188 }
189
190 #[cfg(feature = "v1_18")]
196 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
197 #[doc(alias = "marker-added")]
198 pub fn connect_marker_added<F: Fn(&Self, u64, &Marker) + 'static>(
199 &self,
200 f: F,
201 ) -> SignalHandlerId {
202 unsafe extern "C" fn marker_added_trampoline<F: Fn(&MarkerList, u64, &Marker) + 'static>(
203 this: *mut ffi::GESMarkerList,
204 position: u64,
205 marker: *mut ffi::GESMarker,
206 f: glib::ffi::gpointer,
207 ) {
208 unsafe {
209 let f: &F = &*(f as *const F);
210 f(&from_glib_borrow(this), position, &from_glib_borrow(marker))
211 }
212 }
213 unsafe {
214 let f: Box_<F> = Box_::new(f);
215 connect_raw(
216 self.as_ptr() as *mut _,
217 c"marker-added".as_ptr(),
218 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
219 marker_added_trampoline::<F> as *const (),
220 )),
221 Box_::into_raw(f),
222 )
223 }
224 }
225
226 #[cfg(feature = "v1_18")]
234 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
235 #[doc(alias = "marker-moved")]
236 pub fn connect_marker_moved<F: Fn(&Self, u64, u64, &Marker) + 'static>(
237 &self,
238 f: F,
239 ) -> SignalHandlerId {
240 unsafe extern "C" fn marker_moved_trampoline<
241 F: Fn(&MarkerList, u64, u64, &Marker) + 'static,
242 >(
243 this: *mut ffi::GESMarkerList,
244 previous_position: u64,
245 new_position: u64,
246 marker: *mut ffi::GESMarker,
247 f: glib::ffi::gpointer,
248 ) {
249 unsafe {
250 let f: &F = &*(f as *const F);
251 f(
252 &from_glib_borrow(this),
253 previous_position,
254 new_position,
255 &from_glib_borrow(marker),
256 )
257 }
258 }
259 unsafe {
260 let f: Box_<F> = Box_::new(f);
261 connect_raw(
262 self.as_ptr() as *mut _,
263 c"marker-moved".as_ptr(),
264 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
265 marker_moved_trampoline::<F> as *const (),
266 )),
267 Box_::into_raw(f),
268 )
269 }
270 }
271
272 #[cfg(feature = "v1_18")]
276 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
277 #[doc(alias = "marker-removed")]
278 pub fn connect_marker_removed<F: Fn(&Self, &Marker) + 'static>(&self, f: F) -> SignalHandlerId {
279 unsafe extern "C" fn marker_removed_trampoline<F: Fn(&MarkerList, &Marker) + 'static>(
280 this: *mut ffi::GESMarkerList,
281 marker: *mut ffi::GESMarker,
282 f: glib::ffi::gpointer,
283 ) {
284 unsafe {
285 let f: &F = &*(f as *const F);
286 f(&from_glib_borrow(this), &from_glib_borrow(marker))
287 }
288 }
289 unsafe {
290 let f: Box_<F> = Box_::new(f);
291 connect_raw(
292 self.as_ptr() as *mut _,
293 c"marker-removed".as_ptr(),
294 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
295 marker_removed_trampoline::<F> as *const (),
296 )),
297 Box_::into_raw(f),
298 )
299 }
300 }
301
302 #[cfg(feature = "v1_20")]
303 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
304 #[doc(alias = "flags")]
305 pub fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
306 unsafe extern "C" fn notify_flags_trampoline<F: Fn(&MarkerList) + 'static>(
307 this: *mut ffi::GESMarkerList,
308 _param_spec: glib::ffi::gpointer,
309 f: glib::ffi::gpointer,
310 ) {
311 unsafe {
312 let f: &F = &*(f as *const F);
313 f(&from_glib_borrow(this))
314 }
315 }
316 unsafe {
317 let f: Box_<F> = Box_::new(f);
318 connect_raw(
319 self.as_ptr() as *mut _,
320 c"notify::flags".as_ptr(),
321 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
322 notify_flags_trampoline::<F> as *const (),
323 )),
324 Box_::into_raw(f),
325 )
326 }
327 }
328}
329
330#[cfg(feature = "v1_18")]
331#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
332impl Default for MarkerList {
333 fn default() -> Self {
334 Self::new()
335 }
336}