gstreamer_editing_services/auto/
marker_list.rs1#[cfg(feature = "v1_20")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
8use crate::MarkerFlags;
9use crate::{Marker, ffi};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{SignalHandlerId, connect_raw},
14 translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19 #[doc(alias = "GESMarkerList")]
53 pub struct MarkerList(Object<ffi::GESMarkerList, ffi::GESMarkerListClass>);
54
55 match fn {
56 type_ => || ffi::ges_marker_list_get_type(),
57 }
58}
59
60impl MarkerList {
61 #[doc(alias = "ges_marker_list_new")]
67 pub fn new() -> MarkerList {
68 assert_initialized_main_thread!();
69 unsafe { from_glib_full(ffi::ges_marker_list_new()) }
70 }
71
72 #[doc(alias = "ges_marker_list_add")]
80 pub fn add(&self, position: impl Into<Option<gst::ClockTime>>) -> Marker {
81 unsafe {
82 from_glib_none(ffi::ges_marker_list_add(
83 self.to_glib_none().0,
84 position.into().into_glib(),
85 ))
86 }
87 }
88
89 #[doc(alias = "ges_marker_list_get_markers")]
96 #[doc(alias = "get_markers")]
97 pub fn markers(&self) -> Vec<Marker> {
98 unsafe {
99 FromGlibPtrContainer::from_glib_full(ffi::ges_marker_list_get_markers(
100 self.to_glib_none().0,
101 ))
102 }
103 }
104
105 #[doc(alias = "ges_marker_list_move")]
112 #[doc(alias = "move")]
113 pub fn move_(&self, marker: &Marker, position: impl Into<Option<gst::ClockTime>>) -> bool {
114 unsafe {
115 from_glib(ffi::ges_marker_list_move(
116 self.to_glib_none().0,
117 marker.to_glib_none().0,
118 position.into().into_glib(),
119 ))
120 }
121 }
122
123 #[doc(alias = "ges_marker_list_remove")]
131 pub fn remove(&self, marker: &Marker) -> bool {
132 unsafe {
133 from_glib(ffi::ges_marker_list_remove(
134 self.to_glib_none().0,
135 marker.to_glib_none().0,
136 ))
137 }
138 }
139
140 #[doc(alias = "ges_marker_list_size")]
145 pub fn size(&self) -> u32 {
146 unsafe { ffi::ges_marker_list_size(self.to_glib_none().0) }
147 }
148
149 #[cfg(feature = "v1_20")]
151 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
152 pub fn flags(&self) -> MarkerFlags {
153 ObjectExt::property(self, "flags")
154 }
155
156 #[cfg(feature = "v1_20")]
158 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
159 pub fn set_flags(&self, flags: MarkerFlags) {
160 ObjectExt::set_property(self, "flags", flags)
161 }
162
163 #[cfg(feature = "v1_18")]
169 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
170 #[doc(alias = "marker-added")]
171 pub fn connect_marker_added<F: Fn(&Self, u64, &Marker) + 'static>(
172 &self,
173 f: F,
174 ) -> SignalHandlerId {
175 unsafe extern "C" fn marker_added_trampoline<F: Fn(&MarkerList, u64, &Marker) + 'static>(
176 this: *mut ffi::GESMarkerList,
177 position: u64,
178 marker: *mut ffi::GESMarker,
179 f: glib::ffi::gpointer,
180 ) {
181 unsafe {
182 let f: &F = &*(f as *const F);
183 f(&from_glib_borrow(this), position, &from_glib_borrow(marker))
184 }
185 }
186 unsafe {
187 let f: Box_<F> = Box_::new(f);
188 connect_raw(
189 self.as_ptr() as *mut _,
190 c"marker-added".as_ptr(),
191 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
192 marker_added_trampoline::<F> as *const (),
193 )),
194 Box_::into_raw(f),
195 )
196 }
197 }
198
199 #[cfg(feature = "v1_18")]
207 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
208 #[doc(alias = "marker-moved")]
209 pub fn connect_marker_moved<F: Fn(&Self, u64, u64, &Marker) + 'static>(
210 &self,
211 f: F,
212 ) -> SignalHandlerId {
213 unsafe extern "C" fn marker_moved_trampoline<
214 F: Fn(&MarkerList, u64, u64, &Marker) + 'static,
215 >(
216 this: *mut ffi::GESMarkerList,
217 previous_position: u64,
218 new_position: u64,
219 marker: *mut ffi::GESMarker,
220 f: glib::ffi::gpointer,
221 ) {
222 unsafe {
223 let f: &F = &*(f as *const F);
224 f(
225 &from_glib_borrow(this),
226 previous_position,
227 new_position,
228 &from_glib_borrow(marker),
229 )
230 }
231 }
232 unsafe {
233 let f: Box_<F> = Box_::new(f);
234 connect_raw(
235 self.as_ptr() as *mut _,
236 c"marker-moved".as_ptr(),
237 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
238 marker_moved_trampoline::<F> as *const (),
239 )),
240 Box_::into_raw(f),
241 )
242 }
243 }
244
245 #[cfg(feature = "v1_18")]
249 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
250 #[doc(alias = "marker-removed")]
251 pub fn connect_marker_removed<F: Fn(&Self, &Marker) + 'static>(&self, f: F) -> SignalHandlerId {
252 unsafe extern "C" fn marker_removed_trampoline<F: Fn(&MarkerList, &Marker) + 'static>(
253 this: *mut ffi::GESMarkerList,
254 marker: *mut ffi::GESMarker,
255 f: glib::ffi::gpointer,
256 ) {
257 unsafe {
258 let f: &F = &*(f as *const F);
259 f(&from_glib_borrow(this), &from_glib_borrow(marker))
260 }
261 }
262 unsafe {
263 let f: Box_<F> = Box_::new(f);
264 connect_raw(
265 self.as_ptr() as *mut _,
266 c"marker-removed".as_ptr(),
267 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
268 marker_removed_trampoline::<F> as *const (),
269 )),
270 Box_::into_raw(f),
271 )
272 }
273 }
274
275 #[cfg(feature = "v1_20")]
276 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
277 #[doc(alias = "flags")]
278 pub fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
279 unsafe extern "C" fn notify_flags_trampoline<F: Fn(&MarkerList) + 'static>(
280 this: *mut ffi::GESMarkerList,
281 _param_spec: glib::ffi::gpointer,
282 f: glib::ffi::gpointer,
283 ) {
284 unsafe {
285 let f: &F = &*(f as *const F);
286 f(&from_glib_borrow(this))
287 }
288 }
289 unsafe {
290 let f: Box_<F> = Box_::new(f);
291 connect_raw(
292 self.as_ptr() as *mut _,
293 c"notify::flags".as_ptr(),
294 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
295 notify_flags_trampoline::<F> as *const (),
296 )),
297 Box_::into_raw(f),
298 )
299 }
300 }
301}
302
303#[cfg(feature = "v1_18")]
304#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
305impl Default for MarkerList {
306 fn default() -> Self {
307 Self::new()
308 }
309}