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::{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    /// 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            let f: &F = &*(f as *const F);
182            f(&from_glib_borrow(this), position, &from_glib_borrow(marker))
183        }
184        unsafe {
185            let f: Box_<F> = Box_::new(f);
186            connect_raw(
187                self.as_ptr() as *mut _,
188                c"marker-added".as_ptr() as *const _,
189                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
190                    marker_added_trampoline::<F> as *const (),
191                )),
192                Box_::into_raw(f),
193            )
194        }
195    }
196
197    /// Will be emitted after the marker was moved to.
198    /// ## `previous_position`
199    /// the previous position of the marker
200    /// ## `new_position`
201    /// the new position of the marker
202    /// ## `marker`
203    /// the [`Marker`][crate::Marker] that was moved.
204    #[cfg(feature = "v1_18")]
205    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
206    #[doc(alias = "marker-moved")]
207    pub fn connect_marker_moved<F: Fn(&Self, u64, u64, &Marker) + 'static>(
208        &self,
209        f: F,
210    ) -> SignalHandlerId {
211        unsafe extern "C" fn marker_moved_trampoline<
212            F: Fn(&MarkerList, u64, u64, &Marker) + 'static,
213        >(
214            this: *mut ffi::GESMarkerList,
215            previous_position: u64,
216            new_position: u64,
217            marker: *mut ffi::GESMarker,
218            f: glib::ffi::gpointer,
219        ) {
220            let f: &F = &*(f as *const F);
221            f(
222                &from_glib_borrow(this),
223                previous_position,
224                new_position,
225                &from_glib_borrow(marker),
226            )
227        }
228        unsafe {
229            let f: Box_<F> = Box_::new(f);
230            connect_raw(
231                self.as_ptr() as *mut _,
232                c"marker-moved".as_ptr() as *const _,
233                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
234                    marker_moved_trampoline::<F> as *const (),
235                )),
236                Box_::into_raw(f),
237            )
238        }
239    }
240
241    /// Will be emitted after the marker was removed the marker-list.
242    /// ## `marker`
243    /// the [`Marker`][crate::Marker] that was removed.
244    #[cfg(feature = "v1_18")]
245    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
246    #[doc(alias = "marker-removed")]
247    pub fn connect_marker_removed<F: Fn(&Self, &Marker) + 'static>(&self, f: F) -> SignalHandlerId {
248        unsafe extern "C" fn marker_removed_trampoline<F: Fn(&MarkerList, &Marker) + 'static>(
249            this: *mut ffi::GESMarkerList,
250            marker: *mut ffi::GESMarker,
251            f: glib::ffi::gpointer,
252        ) {
253            let f: &F = &*(f as *const F);
254            f(&from_glib_borrow(this), &from_glib_borrow(marker))
255        }
256        unsafe {
257            let f: Box_<F> = Box_::new(f);
258            connect_raw(
259                self.as_ptr() as *mut _,
260                c"marker-removed".as_ptr() as *const _,
261                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
262                    marker_removed_trampoline::<F> as *const (),
263                )),
264                Box_::into_raw(f),
265            )
266        }
267    }
268
269    #[cfg(feature = "v1_20")]
270    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
271    #[doc(alias = "flags")]
272    pub fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
273        unsafe extern "C" fn notify_flags_trampoline<F: Fn(&MarkerList) + 'static>(
274            this: *mut ffi::GESMarkerList,
275            _param_spec: glib::ffi::gpointer,
276            f: glib::ffi::gpointer,
277        ) {
278            let f: &F = &*(f as *const F);
279            f(&from_glib_borrow(this))
280        }
281        unsafe {
282            let f: Box_<F> = Box_::new(f);
283            connect_raw(
284                self.as_ptr() as *mut _,
285                c"notify::flags".as_ptr() as *const _,
286                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
287                    notify_flags_trampoline::<F> as *const (),
288                )),
289                Box_::into_raw(f),
290            )
291        }
292    }
293}
294
295#[cfg(feature = "v1_18")]
296#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
297impl Default for MarkerList {
298    fn default() -> Self {
299        Self::new()
300    }
301}