gstreamer_editing_services/auto/
container.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
7use crate::{ffi, Edge, EditMode, Extractable, Layer, MetaContainer, TimelineElement};
8use glib::{
9    object::ObjectType as _,
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    #[doc(alias = "GESContainer")]
18    pub struct Container(Object<ffi::GESContainer, ffi::GESContainerClass>) @extends TimelineElement, @implements Extractable, MetaContainer;
19
20    match fn {
21        type_ => || ffi::ges_container_get_type(),
22    }
23}
24
25impl Container {
26    pub const NONE: Option<&'static Container> = None;
27
28    #[doc(alias = "ges_container_group")]
29    pub fn group(containers: &[Container]) -> Option<Container> {
30        assert_initialized_main_thread!();
31        unsafe { from_glib_none(ffi::ges_container_group(containers.to_glib_none().0)) }
32    }
33}
34
35pub trait GESContainerExt: IsA<Container> + 'static {
36    #[doc(alias = "ges_container_add")]
37    fn add(&self, child: &impl IsA<TimelineElement>) -> Result<(), glib::error::BoolError> {
38        unsafe {
39            glib::result_from_gboolean!(
40                ffi::ges_container_add(
41                    self.as_ref().to_glib_none().0,
42                    child.as_ref().to_glib_none().0
43                ),
44                "Failed to add element"
45            )
46        }
47    }
48
49    #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")]
50    #[allow(deprecated)]
51    #[doc(alias = "ges_container_edit")]
52    fn edit(
53        &self,
54        layers: &[Layer],
55        new_layer_priority: i32,
56        mode: EditMode,
57        edge: Edge,
58        position: u64,
59    ) -> Result<(), glib::error::BoolError> {
60        unsafe {
61            glib::result_from_gboolean!(
62                ffi::ges_container_edit(
63                    self.as_ref().to_glib_none().0,
64                    layers.to_glib_none().0,
65                    new_layer_priority,
66                    mode.into_glib(),
67                    edge.into_glib(),
68                    position
69                ),
70                "Failed to edit container"
71            )
72        }
73    }
74
75    #[doc(alias = "ges_container_get_children")]
76    #[doc(alias = "get_children")]
77    fn children(&self, recursive: bool) -> Vec<TimelineElement> {
78        unsafe {
79            FromGlibPtrContainer::from_glib_full(ffi::ges_container_get_children(
80                self.as_ref().to_glib_none().0,
81                recursive.into_glib(),
82            ))
83        }
84    }
85
86    #[doc(alias = "ges_container_remove")]
87    fn remove(&self, child: &impl IsA<TimelineElement>) -> Result<(), glib::error::BoolError> {
88        unsafe {
89            glib::result_from_gboolean!(
90                ffi::ges_container_remove(
91                    self.as_ref().to_glib_none().0,
92                    child.as_ref().to_glib_none().0
93                ),
94                "Failed to remove element"
95            )
96        }
97    }
98
99    #[doc(alias = "ges_container_ungroup")]
100    fn ungroup(self, recursive: bool) -> Vec<Container> {
101        unsafe {
102            FromGlibPtrContainer::from_glib_full(ffi::ges_container_ungroup(
103                self.upcast().into_glib_ptr(),
104                recursive.into_glib(),
105            ))
106        }
107    }
108
109    fn height(&self) -> u32 {
110        ObjectExt::property(self.as_ref(), "height")
111    }
112
113    #[doc(alias = "child-added")]
114    fn connect_child_added<F: Fn(&Self, &TimelineElement) + 'static>(
115        &self,
116        f: F,
117    ) -> SignalHandlerId {
118        unsafe extern "C" fn child_added_trampoline<
119            P: IsA<Container>,
120            F: Fn(&P, &TimelineElement) + 'static,
121        >(
122            this: *mut ffi::GESContainer,
123            element: *mut ffi::GESTimelineElement,
124            f: glib::ffi::gpointer,
125        ) {
126            let f: &F = &*(f as *const F);
127            f(
128                Container::from_glib_borrow(this).unsafe_cast_ref(),
129                &from_glib_borrow(element),
130            )
131        }
132        unsafe {
133            let f: Box_<F> = Box_::new(f);
134            connect_raw(
135                self.as_ptr() as *mut _,
136                c"child-added".as_ptr() as *const _,
137                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
138                    child_added_trampoline::<Self, F> as *const (),
139                )),
140                Box_::into_raw(f),
141            )
142        }
143    }
144
145    #[doc(alias = "child-removed")]
146    fn connect_child_removed<F: Fn(&Self, &TimelineElement) + 'static>(
147        &self,
148        f: F,
149    ) -> SignalHandlerId {
150        unsafe extern "C" fn child_removed_trampoline<
151            P: IsA<Container>,
152            F: Fn(&P, &TimelineElement) + 'static,
153        >(
154            this: *mut ffi::GESContainer,
155            element: *mut ffi::GESTimelineElement,
156            f: glib::ffi::gpointer,
157        ) {
158            let f: &F = &*(f as *const F);
159            f(
160                Container::from_glib_borrow(this).unsafe_cast_ref(),
161                &from_glib_borrow(element),
162            )
163        }
164        unsafe {
165            let f: Box_<F> = Box_::new(f);
166            connect_raw(
167                self.as_ptr() as *mut _,
168                c"child-removed".as_ptr() as *const _,
169                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
170                    child_removed_trampoline::<Self, F> as *const (),
171                )),
172                Box_::into_raw(f),
173            )
174        }
175    }
176
177    #[doc(alias = "height")]
178    fn connect_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
179        unsafe extern "C" fn notify_height_trampoline<P: IsA<Container>, F: Fn(&P) + 'static>(
180            this: *mut ffi::GESContainer,
181            _param_spec: glib::ffi::gpointer,
182            f: glib::ffi::gpointer,
183        ) {
184            let f: &F = &*(f as *const F);
185            f(Container::from_glib_borrow(this).unsafe_cast_ref())
186        }
187        unsafe {
188            let f: Box_<F> = Box_::new(f);
189            connect_raw(
190                self.as_ptr() as *mut _,
191                c"notify::height".as_ptr() as *const _,
192                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
193                    notify_height_trampoline::<Self, F> as *const (),
194                )),
195                Box_::into_raw(f),
196            )
197        }
198    }
199}
200
201impl<O: IsA<Container>> GESContainerExt for O {}