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    #[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            unsafe {
107                let f: &F = &*(f as *const F);
108                f(&from_glib_borrow(this), position, &from_glib_borrow(marker))
109            }
110        }
111        unsafe {
112            let f: Box_<F> = Box_::new(f);
113            connect_raw(
114                self.as_ptr() as *mut _,
115                c"marker-added".as_ptr(),
116                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
117                    marker_added_trampoline::<F> as *const (),
118                )),
119                Box_::into_raw(f),
120            )
121        }
122    }
123
124    #[cfg(feature = "v1_18")]
125    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
126    #[doc(alias = "marker-moved")]
127    pub fn connect_marker_moved<F: Fn(&Self, u64, u64, &Marker) + 'static>(
128        &self,
129        f: F,
130    ) -> SignalHandlerId {
131        unsafe extern "C" fn marker_moved_trampoline<
132            F: Fn(&MarkerList, u64, u64, &Marker) + 'static,
133        >(
134            this: *mut ffi::GESMarkerList,
135            previous_position: u64,
136            new_position: u64,
137            marker: *mut ffi::GESMarker,
138            f: glib::ffi::gpointer,
139        ) {
140            unsafe {
141                let f: &F = &*(f as *const F);
142                f(
143                    &from_glib_borrow(this),
144                    previous_position,
145                    new_position,
146                    &from_glib_borrow(marker),
147                )
148            }
149        }
150        unsafe {
151            let f: Box_<F> = Box_::new(f);
152            connect_raw(
153                self.as_ptr() as *mut _,
154                c"marker-moved".as_ptr(),
155                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
156                    marker_moved_trampoline::<F> as *const (),
157                )),
158                Box_::into_raw(f),
159            )
160        }
161    }
162
163    #[cfg(feature = "v1_18")]
164    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
165    #[doc(alias = "marker-removed")]
166    pub fn connect_marker_removed<F: Fn(&Self, &Marker) + 'static>(&self, f: F) -> SignalHandlerId {
167        unsafe extern "C" fn marker_removed_trampoline<F: Fn(&MarkerList, &Marker) + 'static>(
168            this: *mut ffi::GESMarkerList,
169            marker: *mut ffi::GESMarker,
170            f: glib::ffi::gpointer,
171        ) {
172            unsafe {
173                let f: &F = &*(f as *const F);
174                f(&from_glib_borrow(this), &from_glib_borrow(marker))
175            }
176        }
177        unsafe {
178            let f: Box_<F> = Box_::new(f);
179            connect_raw(
180                self.as_ptr() as *mut _,
181                c"marker-removed".as_ptr(),
182                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
183                    marker_removed_trampoline::<F> as *const (),
184                )),
185                Box_::into_raw(f),
186            )
187        }
188    }
189
190    #[cfg(feature = "v1_20")]
191    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
192    #[doc(alias = "flags")]
193    pub fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
194        unsafe extern "C" fn notify_flags_trampoline<F: Fn(&MarkerList) + 'static>(
195            this: *mut ffi::GESMarkerList,
196            _param_spec: glib::ffi::gpointer,
197            f: glib::ffi::gpointer,
198        ) {
199            unsafe {
200                let f: &F = &*(f as *const F);
201                f(&from_glib_borrow(this))
202            }
203        }
204        unsafe {
205            let f: Box_<F> = Box_::new(f);
206            connect_raw(
207                self.as_ptr() as *mut _,
208                c"notify::flags".as_ptr(),
209                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
210                    notify_flags_trampoline::<F> as *const (),
211                )),
212                Box_::into_raw(f),
213            )
214        }
215    }
216}
217
218#[cfg(feature = "v1_18")]
219#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
220impl Default for MarkerList {
221    fn default() -> Self {
222        Self::new()
223    }
224}