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::{ffi, Marker};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{connect_raw, SignalHandlerId},
14 translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19 #[doc(alias = "GESMarkerList")]
20 pub struct MarkerList(Object<ffi::GESMarkerList, ffi::GESMarkerListClass>);
21
22 match fn {
23 type_ => || ffi::ges_marker_list_get_type(),
24 }
25}
26
27impl MarkerList {
28 #[doc(alias = "ges_marker_list_new")]
29 pub fn new() -> MarkerList {
30 assert_initialized_main_thread!();
31 unsafe { from_glib_full(ffi::ges_marker_list_new()) }
32 }
33
34 #[doc(alias = "ges_marker_list_add")]
35 pub fn add(&self, position: impl Into<Option<gst::ClockTime>>) -> Marker {
36 unsafe {
37 from_glib_none(ffi::ges_marker_list_add(
38 self.to_glib_none().0,
39 position.into().into_glib(),
40 ))
41 }
42 }
43
44 #[doc(alias = "ges_marker_list_get_markers")]
45 #[doc(alias = "get_markers")]
46 pub fn markers(&self) -> Vec<Marker> {
47 unsafe {
48 FromGlibPtrContainer::from_glib_full(ffi::ges_marker_list_get_markers(
49 self.to_glib_none().0,
50 ))
51 }
52 }
53
54 #[doc(alias = "ges_marker_list_move")]
55 #[doc(alias = "move")]
56 pub fn move_(&self, marker: &Marker, position: impl Into<Option<gst::ClockTime>>) -> bool {
57 unsafe {
58 from_glib(ffi::ges_marker_list_move(
59 self.to_glib_none().0,
60 marker.to_glib_none().0,
61 position.into().into_glib(),
62 ))
63 }
64 }
65
66 #[doc(alias = "ges_marker_list_remove")]
67 pub fn remove(&self, marker: &Marker) -> bool {
68 unsafe {
69 from_glib(ffi::ges_marker_list_remove(
70 self.to_glib_none().0,
71 marker.to_glib_none().0,
72 ))
73 }
74 }
75
76 #[doc(alias = "ges_marker_list_size")]
77 pub fn size(&self) -> u32 {
78 unsafe { ffi::ges_marker_list_size(self.to_glib_none().0) }
79 }
80
81 #[cfg(feature = "v1_20")]
82 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
83 pub fn flags(&self) -> MarkerFlags {
84 ObjectExt::property(self, "flags")
85 }
86
87 #[cfg(feature = "v1_20")]
88 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
89 pub fn set_flags(&self, flags: MarkerFlags) {
90 ObjectExt::set_property(self, "flags", flags)
91 }
92
93 #[cfg(feature = "v1_18")]
94 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
95 #[doc(alias = "marker-added")]
96 pub fn connect_marker_added<F: Fn(&Self, u64, &Marker) + 'static>(
97 &self,
98 f: F,
99 ) -> SignalHandlerId {
100 unsafe extern "C" fn marker_added_trampoline<F: Fn(&MarkerList, u64, &Marker) + 'static>(
101 this: *mut ffi::GESMarkerList,
102 position: u64,
103 marker: *mut ffi::GESMarker,
104 f: glib::ffi::gpointer,
105 ) {
106 let f: &F = &*(f as *const F);
107 f(&from_glib_borrow(this), position, &from_glib_borrow(marker))
108 }
109 unsafe {
110 let f: Box_<F> = Box_::new(f);
111 connect_raw(
112 self.as_ptr() as *mut _,
113 c"marker-added".as_ptr() as *const _,
114 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
115 marker_added_trampoline::<F> as *const (),
116 )),
117 Box_::into_raw(f),
118 )
119 }
120 }
121
122 #[cfg(feature = "v1_18")]
123 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
124 #[doc(alias = "marker-moved")]
125 pub fn connect_marker_moved<F: Fn(&Self, u64, u64, &Marker) + 'static>(
126 &self,
127 f: F,
128 ) -> SignalHandlerId {
129 unsafe extern "C" fn marker_moved_trampoline<
130 F: Fn(&MarkerList, u64, u64, &Marker) + 'static,
131 >(
132 this: *mut ffi::GESMarkerList,
133 previous_position: u64,
134 new_position: u64,
135 marker: *mut ffi::GESMarker,
136 f: glib::ffi::gpointer,
137 ) {
138 let f: &F = &*(f as *const F);
139 f(
140 &from_glib_borrow(this),
141 previous_position,
142 new_position,
143 &from_glib_borrow(marker),
144 )
145 }
146 unsafe {
147 let f: Box_<F> = Box_::new(f);
148 connect_raw(
149 self.as_ptr() as *mut _,
150 c"marker-moved".as_ptr() as *const _,
151 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
152 marker_moved_trampoline::<F> as *const (),
153 )),
154 Box_::into_raw(f),
155 )
156 }
157 }
158
159 #[cfg(feature = "v1_18")]
160 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
161 #[doc(alias = "marker-removed")]
162 pub fn connect_marker_removed<F: Fn(&Self, &Marker) + 'static>(&self, f: F) -> SignalHandlerId {
163 unsafe extern "C" fn marker_removed_trampoline<F: Fn(&MarkerList, &Marker) + 'static>(
164 this: *mut ffi::GESMarkerList,
165 marker: *mut ffi::GESMarker,
166 f: glib::ffi::gpointer,
167 ) {
168 let f: &F = &*(f as *const F);
169 f(&from_glib_borrow(this), &from_glib_borrow(marker))
170 }
171 unsafe {
172 let f: Box_<F> = Box_::new(f);
173 connect_raw(
174 self.as_ptr() as *mut _,
175 c"marker-removed".as_ptr() as *const _,
176 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
177 marker_removed_trampoline::<F> as *const (),
178 )),
179 Box_::into_raw(f),
180 )
181 }
182 }
183
184 #[cfg(feature = "v1_20")]
185 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
186 #[doc(alias = "flags")]
187 pub fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
188 unsafe extern "C" fn notify_flags_trampoline<F: Fn(&MarkerList) + 'static>(
189 this: *mut ffi::GESMarkerList,
190 _param_spec: glib::ffi::gpointer,
191 f: glib::ffi::gpointer,
192 ) {
193 let f: &F = &*(f as *const F);
194 f(&from_glib_borrow(this))
195 }
196 unsafe {
197 let f: Box_<F> = Box_::new(f);
198 connect_raw(
199 self.as_ptr() as *mut _,
200 c"notify::flags".as_ptr() as *const _,
201 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
202 notify_flags_trampoline::<F> as *const (),
203 )),
204 Box_::into_raw(f),
205 )
206 }
207 }
208}
209
210#[cfg(feature = "v1_18")]
211#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
212impl Default for MarkerList {
213 fn default() -> Self {
214 Self::new()
215 }
216}