gdk4/auto/
cicp_params.rs
1use crate::{ffi, CicpRange, ColorState};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GdkCicpParams")]
87 pub struct CicpParams(Object<ffi::GdkCicpParams, ffi::GdkCicpParamsClass>);
88
89 match fn {
90 type_ => || ffi::gdk_cicp_params_get_type(),
91 }
92}
93
94impl CicpParams {
95 #[doc(alias = "gdk_cicp_params_new")]
104 pub fn new() -> CicpParams {
105 assert_initialized_main_thread!();
106 unsafe { from_glib_full(ffi::gdk_cicp_params_new()) }
107 }
108
109 #[doc(alias = "gdk_cicp_params_build_color_state")]
119 pub fn build_color_state(&self) -> Result<ColorState, glib::Error> {
120 unsafe {
121 let mut error = std::ptr::null_mut();
122 let ret = ffi::gdk_cicp_params_build_color_state(self.to_glib_none().0, &mut error);
123 if error.is_null() {
124 Ok(from_glib_full(ret))
125 } else {
126 Err(from_glib_full(error))
127 }
128 }
129 }
130
131 #[doc(alias = "gdk_cicp_params_get_color_primaries")]
138 #[doc(alias = "get_color_primaries")]
139 #[doc(alias = "color-primaries")]
140 pub fn color_primaries(&self) -> u32 {
141 unsafe { ffi::gdk_cicp_params_get_color_primaries(self.to_glib_none().0) }
142 }
143
144 #[doc(alias = "gdk_cicp_params_get_matrix_coefficients")]
150 #[doc(alias = "get_matrix_coefficients")]
151 #[doc(alias = "matrix-coefficients")]
152 pub fn matrix_coefficients(&self) -> u32 {
153 unsafe { ffi::gdk_cicp_params_get_matrix_coefficients(self.to_glib_none().0) }
154 }
155
156 #[doc(alias = "gdk_cicp_params_get_range")]
162 #[doc(alias = "get_range")]
163 pub fn range(&self) -> CicpRange {
164 unsafe { from_glib(ffi::gdk_cicp_params_get_range(self.to_glib_none().0)) }
165 }
166
167 #[doc(alias = "gdk_cicp_params_get_transfer_function")]
173 #[doc(alias = "get_transfer_function")]
174 #[doc(alias = "transfer-function")]
175 pub fn transfer_function(&self) -> u32 {
176 unsafe { ffi::gdk_cicp_params_get_transfer_function(self.to_glib_none().0) }
177 }
178
179 #[doc(alias = "gdk_cicp_params_set_color_primaries")]
183 #[doc(alias = "color-primaries")]
184 pub fn set_color_primaries(&self, color_primaries: u32) {
185 unsafe {
186 ffi::gdk_cicp_params_set_color_primaries(self.to_glib_none().0, color_primaries);
187 }
188 }
189
190 #[doc(alias = "gdk_cicp_params_set_matrix_coefficients")]
195 #[doc(alias = "matrix-coefficients")]
196 pub fn set_matrix_coefficients(&self, matrix_coefficients: u32) {
197 unsafe {
198 ffi::gdk_cicp_params_set_matrix_coefficients(
199 self.to_glib_none().0,
200 matrix_coefficients,
201 );
202 }
203 }
204
205 #[doc(alias = "gdk_cicp_params_set_range")]
209 #[doc(alias = "range")]
210 pub fn set_range(&self, range: CicpRange) {
211 unsafe {
212 ffi::gdk_cicp_params_set_range(self.to_glib_none().0, range.into_glib());
213 }
214 }
215
216 #[doc(alias = "gdk_cicp_params_set_transfer_function")]
220 #[doc(alias = "transfer-function")]
221 pub fn set_transfer_function(&self, transfer_function: u32) {
222 unsafe {
223 ffi::gdk_cicp_params_set_transfer_function(self.to_glib_none().0, transfer_function);
224 }
225 }
226
227 #[cfg(feature = "v4_16")]
228 #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
229 #[doc(alias = "color-primaries")]
230 pub fn connect_color_primaries_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
231 unsafe extern "C" fn notify_color_primaries_trampoline<F: Fn(&CicpParams) + 'static>(
232 this: *mut ffi::GdkCicpParams,
233 _param_spec: glib::ffi::gpointer,
234 f: glib::ffi::gpointer,
235 ) {
236 let f: &F = &*(f as *const F);
237 f(&from_glib_borrow(this))
238 }
239 unsafe {
240 let f: Box_<F> = Box_::new(f);
241 connect_raw(
242 self.as_ptr() as *mut _,
243 c"notify::color-primaries".as_ptr() as *const _,
244 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
245 notify_color_primaries_trampoline::<F> as *const (),
246 )),
247 Box_::into_raw(f),
248 )
249 }
250 }
251
252 #[cfg(feature = "v4_16")]
253 #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
254 #[doc(alias = "matrix-coefficients")]
255 pub fn connect_matrix_coefficients_notify<F: Fn(&Self) + 'static>(
256 &self,
257 f: F,
258 ) -> SignalHandlerId {
259 unsafe extern "C" fn notify_matrix_coefficients_trampoline<F: Fn(&CicpParams) + 'static>(
260 this: *mut ffi::GdkCicpParams,
261 _param_spec: glib::ffi::gpointer,
262 f: glib::ffi::gpointer,
263 ) {
264 let f: &F = &*(f as *const F);
265 f(&from_glib_borrow(this))
266 }
267 unsafe {
268 let f: Box_<F> = Box_::new(f);
269 connect_raw(
270 self.as_ptr() as *mut _,
271 c"notify::matrix-coefficients".as_ptr() as *const _,
272 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
273 notify_matrix_coefficients_trampoline::<F> as *const (),
274 )),
275 Box_::into_raw(f),
276 )
277 }
278 }
279
280 #[cfg(feature = "v4_16")]
281 #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
282 #[doc(alias = "range")]
283 pub fn connect_range_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
284 unsafe extern "C" fn notify_range_trampoline<F: Fn(&CicpParams) + 'static>(
285 this: *mut ffi::GdkCicpParams,
286 _param_spec: glib::ffi::gpointer,
287 f: glib::ffi::gpointer,
288 ) {
289 let f: &F = &*(f as *const F);
290 f(&from_glib_borrow(this))
291 }
292 unsafe {
293 let f: Box_<F> = Box_::new(f);
294 connect_raw(
295 self.as_ptr() as *mut _,
296 c"notify::range".as_ptr() as *const _,
297 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
298 notify_range_trampoline::<F> as *const (),
299 )),
300 Box_::into_raw(f),
301 )
302 }
303 }
304
305 #[cfg(feature = "v4_16")]
306 #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
307 #[doc(alias = "transfer-function")]
308 pub fn connect_transfer_function_notify<F: Fn(&Self) + 'static>(
309 &self,
310 f: F,
311 ) -> SignalHandlerId {
312 unsafe extern "C" fn notify_transfer_function_trampoline<F: Fn(&CicpParams) + 'static>(
313 this: *mut ffi::GdkCicpParams,
314 _param_spec: glib::ffi::gpointer,
315 f: glib::ffi::gpointer,
316 ) {
317 let f: &F = &*(f as *const F);
318 f(&from_glib_borrow(this))
319 }
320 unsafe {
321 let f: Box_<F> = Box_::new(f);
322 connect_raw(
323 self.as_ptr() as *mut _,
324 c"notify::transfer-function".as_ptr() as *const _,
325 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
326 notify_transfer_function_trampoline::<F> as *const (),
327 )),
328 Box_::into_raw(f),
329 )
330 }
331 }
332}
333
334#[cfg(feature = "v4_16")]
335#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
336impl Default for CicpParams {
337 fn default() -> Self {
338 Self::new()
339 }
340}