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
31mod sealed {
32 pub trait Sealed {}
33 impl<T: super::IsA<super::ColorBalance>> Sealed for T {}
34}
35
36pub trait ColorBalanceExt: IsA<ColorBalance> + sealed::Sealed + 'static {
37 #[doc(alias = "gst_color_balance_get_balance_type")]
38 #[doc(alias = "get_balance_type")]
39 fn balance_type(&self) -> ColorBalanceType {
40 unsafe {
41 from_glib(ffi::gst_color_balance_get_balance_type(
42 self.as_ref().to_glib_none().0,
43 ))
44 }
45 }
46
47 #[doc(alias = "gst_color_balance_get_value")]
48 #[doc(alias = "get_value")]
49 fn value(&self, channel: &impl IsA<ColorBalanceChannel>) -> i32 {
50 unsafe {
51 ffi::gst_color_balance_get_value(
52 self.as_ref().to_glib_none().0,
53 channel.as_ref().to_glib_none().0,
54 )
55 }
56 }
57
58 #[doc(alias = "gst_color_balance_list_channels")]
59 fn list_channels(&self) -> Vec<ColorBalanceChannel> {
60 unsafe {
61 FromGlibPtrContainer::from_glib_none(ffi::gst_color_balance_list_channels(
62 self.as_ref().to_glib_none().0,
63 ))
64 }
65 }
66
67 #[doc(alias = "gst_color_balance_set_value")]
68 fn set_value(&self, channel: &impl IsA<ColorBalanceChannel>, value: i32) {
69 unsafe {
70 ffi::gst_color_balance_set_value(
71 self.as_ref().to_glib_none().0,
72 channel.as_ref().to_glib_none().0,
73 value,
74 );
75 }
76 }
77
78 #[doc(alias = "gst_color_balance_value_changed")]
79 fn value_changed(&self, channel: &impl IsA<ColorBalanceChannel>, value: i32) {
80 unsafe {
81 ffi::gst_color_balance_value_changed(
82 self.as_ref().to_glib_none().0,
83 channel.as_ref().to_glib_none().0,
84 value,
85 );
86 }
87 }
88
89 #[doc(alias = "value-changed")]
90 fn connect_value_changed<F: Fn(&Self, &ColorBalanceChannel, i32) + Send + Sync + 'static>(
91 &self,
92 f: F,
93 ) -> SignalHandlerId {
94 unsafe extern "C" fn value_changed_trampoline<
95 P: IsA<ColorBalance>,
96 F: Fn(&P, &ColorBalanceChannel, i32) + Send + Sync + 'static,
97 >(
98 this: *mut ffi::GstColorBalance,
99 channel: *mut ffi::GstColorBalanceChannel,
100 value: std::ffi::c_int,
101 f: glib::ffi::gpointer,
102 ) {
103 let f: &F = &*(f as *const F);
104 f(
105 ColorBalance::from_glib_borrow(this).unsafe_cast_ref(),
106 &from_glib_borrow(channel),
107 value,
108 )
109 }
110 unsafe {
111 let f: Box_<F> = Box_::new(f);
112 connect_raw(
113 self.as_ptr() as *mut _,
114 b"value-changed\0".as_ptr() as *const _,
115 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
116 value_changed_trampoline::<Self, F> as *const (),
117 )),
118 Box_::into_raw(f),
119 )
120 }
121 }
122}
123
124impl<O: IsA<ColorBalance>> ColorBalanceExt for O {}
125