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#![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    /// A [`Marker`][crate::Marker] can be colored by setting the `GES_META_MARKER_COLOR` meta.
21    ///
22    /// ## Properties
23    ///
24    ///
25    /// #### `flags`
26    ///  Flags indicating how markers on the list should be treated.
27    ///
28    /// Readable | Writable | Construct
29    ///
30    /// ## Signals
31    ///
32    ///
33    /// #### `marker-added`
34    ///  Will be emitted after the marker was added to the marker-list.
35    ///
36    ///
37    ///
38    ///
39    /// #### `marker-moved`
40    ///  Will be emitted after the marker was moved to.
41    ///
42    ///
43    ///
44    ///
45    /// #### `marker-removed`
46    ///  Will be emitted after the marker was removed the marker-list.
47    ///
48    ///
49    ///
50    /// # Implements
51    ///
52    /// [`trait@glib::ObjectExt`]
53    #[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    /// Creates a new [`MarkerList`][crate::MarkerList].
63    ///
64    /// # Returns
65    ///
66    /// A new [`MarkerList`][crate::MarkerList]
67    #[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    ///
74    /// # Deprecated since 1.30
75    ///
76    /// Use [`add_full()`][Self::add_full()] instead for MT-safety.
77    /// ## `position`
78    /// The position of the new marker
79    ///
80    /// # Returns
81    ///
82    /// The newly-added marker, the list keeps ownership
83    /// of the marker
84    #[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    /// Adds a new marker to the list at the given position. The caller owns a
97    /// reference to the returned marker.
98    /// ## `position`
99    /// The position of the new marker
100    ///
101    /// # Returns
102    ///
103    /// The newly-added marker
104    #[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    ///
117    /// # Returns
118    ///
119    /// a `GList`
120    /// of the [`Marker`][crate::Marker] within the GESMarkerList. The user will have
121    /// to unref each [`Marker`][crate::Marker] and free the `GList`.
122    #[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    /// Moves a `marker` in a `self` to a new `position`
133    ///
134    /// # Returns
135    ///
136    /// [`true`] if the marker could be moved, [`false`] otherwise
137    ///  (if the marker was not present in the list for example)
138    #[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    /// Removes `marker` from `self`, this decreases the refcount of the
151    /// marker by 1.
152    ///
153    /// # Returns
154    ///
155    /// [`true`] if the marker could be removed, [`false`] otherwise
156    ///  (if the marker was not present in the list for example)
157    #[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    ///
168    /// # Returns
169    ///
170    /// The number of markers in `self`
171    #[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    /// Flags indicating how markers on the list should be treated.
177    #[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    /// Flags indicating how markers on the list should be treated.
184    #[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    /// Will be emitted after the marker was added to the marker-list.
191    /// ## `position`
192    /// the position of the added marker
193    /// ## `marker`
194    /// the [`Marker`][crate::Marker] that was added.
195    #[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    /// Will be emitted after the marker was moved to.
227    /// ## `previous_position`
228    /// the previous position of the marker
229    /// ## `new_position`
230    /// the new position of the marker
231    /// ## `marker`
232    /// the [`Marker`][crate::Marker] that was moved.
233    #[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    /// Will be emitted after the marker was removed the marker-list.
273    /// ## `marker`
274    /// the [`Marker`][crate::Marker] that was removed.
275    #[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}