gstreamer_video/auto/
color_balance.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
6use crate::{ffi, ColorBalanceChannel, ColorBalanceType};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "GstColorBalance")]
17    pub struct ColorBalance(Interface<ffi::GstColorBalance, ffi::GstColorBalanceInterface>);
18
19    match fn {
20        type_ => || ffi::gst_color_balance_get_type(),
21    }
22}
23
24impl ColorBalance {
25    pub const NONE: Option<&'static ColorBalance> = None;
26}
27
28unsafe impl Send for ColorBalance {}
29unsafe impl Sync for ColorBalance {}
30
31pub trait ColorBalanceExt: IsA<ColorBalance> + 'static {
32    #[doc(alias = "gst_color_balance_get_balance_type")]
33    #[doc(alias = "get_balance_type")]
34    fn balance_type(&self) -> ColorBalanceType {
35        unsafe {
36            from_glib(ffi::gst_color_balance_get_balance_type(
37                self.as_ref().to_glib_none().0,
38            ))
39        }
40    }
41
42    #[doc(alias = "gst_color_balance_get_value")]
43    #[doc(alias = "get_value")]
44    fn value(&self, channel: &impl IsA<ColorBalanceChannel>) -> i32 {
45        unsafe {
46            ffi::gst_color_balance_get_value(
47                self.as_ref().to_glib_none().0,
48                channel.as_ref().to_glib_none().0,
49            )
50        }
51    }
52
53    #[doc(alias = "gst_color_balance_list_channels")]
54    fn list_channels(&self) -> Vec<ColorBalanceChannel> {
55        unsafe {
56            FromGlibPtrContainer::from_glib_none(ffi::gst_color_balance_list_channels(
57                self.as_ref().to_glib_none().0,
58            ))
59        }
60    }
61
62    #[doc(alias = "gst_color_balance_set_value")]
63    fn set_value(&self, channel: &impl IsA<ColorBalanceChannel>, value: i32) {
64        unsafe {
65            ffi::gst_color_balance_set_value(
66                self.as_ref().to_glib_none().0,
67                channel.as_ref().to_glib_none().0,
68                value,
69            );
70        }
71    }
72
73    #[doc(alias = "gst_color_balance_value_changed")]
74    fn value_changed(&self, channel: &impl IsA<ColorBalanceChannel>, value: i32) {
75        unsafe {
76            ffi::gst_color_balance_value_changed(
77                self.as_ref().to_glib_none().0,
78                channel.as_ref().to_glib_none().0,
79                value,
80            );
81        }
82    }
83
84    #[doc(alias = "value-changed")]
85    fn connect_value_changed<F: Fn(&Self, &ColorBalanceChannel, i32) + Send + Sync + 'static>(
86        &self,
87        f: F,
88    ) -> SignalHandlerId {
89        unsafe extern "C" fn value_changed_trampoline<
90            P: IsA<ColorBalance>,
91            F: Fn(&P, &ColorBalanceChannel, i32) + Send + Sync + 'static,
92        >(
93            this: *mut ffi::GstColorBalance,
94            channel: *mut ffi::GstColorBalanceChannel,
95            value: std::ffi::c_int,
96            f: glib::ffi::gpointer,
97        ) {
98            let f: &F = &*(f as *const F);
99            f(
100                ColorBalance::from_glib_borrow(this).unsafe_cast_ref(),
101                &from_glib_borrow(channel),
102                value,
103            )
104        }
105        unsafe {
106            let f: Box_<F> = Box_::new(f);
107            connect_raw(
108                self.as_ptr() as *mut _,
109                c"value-changed".as_ptr() as *const _,
110                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
111                    value_changed_trampoline::<Self, F> as *const (),
112                )),
113                Box_::into_raw(f),
114            )
115        }
116    }
117}
118
119impl<O: IsA<ColorBalance>> ColorBalanceExt for O {}