Skip to main content

gstreamer_editing_services/auto/
marker_list.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6#[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    /// A [`Marker`][crate::Marker] can be colored by setting the `GES_META_MARKER_COLOR` meta.
20    ///
21    /// ## Properties
22    ///
23    ///
24    /// #### `flags`
25    ///  Flags indicating how markers on the list should be treated.
26    ///
27    /// Readable | Writeable | Construct
28    ///
29    /// ## Signals
30    ///
31    ///
32    /// #### `marker-added`
33    ///  Will be emitted after the marker was added to the marker-list.
34    ///
35    ///
36    ///
37    ///
38    /// #### `marker-moved`
39    ///  Will be emitted after the marker was moved to.
40    ///
41    ///
42    ///
43    ///
44    /// #### `marker-removed`
45    ///  Will be emitted after the marker was removed the marker-list.
46    ///
47    ///
48    ///
49    /// # Implements
50    ///
51    /// [`trait@glib::ObjectExt`]
52    #[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    /// Creates a new [`MarkerList`][crate::MarkerList].
62    ///
63    /// # Returns
64    ///
65    /// A new [`MarkerList`][crate::MarkerList]
66    #[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    /// ## `position`
73    /// The position of the new marker
74    ///
75    /// # Returns
76    ///
77    /// The newly-added marker, the list keeps ownership
78    /// of the marker
79    #[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    ///
90    /// # Returns
91    ///
92    /// a `GList`
93    /// of the [`Marker`][crate::Marker] within the GESMarkerList. The user will have
94    /// to unref each [`Marker`][crate::Marker] and free the `GList`.
95    #[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    /// Moves a `marker` in a `self` to a new `position`
106    ///
107    /// # Returns
108    ///
109    /// [`true`] if the marker could be moved, [`false`] otherwise
110    ///  (if the marker was not present in the list for example)
111    #[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    /// Removes `marker` from `self`, this decreases the refcount of the
124    /// marker by 1.
125    ///
126    /// # Returns
127    ///
128    /// [`true`] if the marker could be removed, [`false`] otherwise
129    ///  (if the marker was not present in the list for example)
130    #[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    ///
141    /// # Returns
142    ///
143    /// The number of markers in `self`
144    #[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    /// Flags indicating how markers on the list should be treated.
150    #[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    /// Flags indicating how markers on the list should be treated.
157    #[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    /// Will be emitted after the marker was added to the marker-list.
164    /// ## `position`
165    /// the position of the added marker
166    /// ## `marker`
167    /// the [`Marker`][crate::Marker] that was added.
168    #[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    /// Will be emitted after the marker was moved to.
200    /// ## `previous_position`
201    /// the previous position of the marker
202    /// ## `new_position`
203    /// the new position of the marker
204    /// ## `marker`
205    /// the [`Marker`][crate::Marker] that was moved.
206    #[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    /// Will be emitted after the marker was removed the marker-list.
246    /// ## `marker`
247    /// the [`Marker`][crate::Marker] that was removed.
248    #[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}