gdk4/auto/
monitor.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// DO NOT EDIT
4
5use crate::{ffi, Display, Rectangle, SubpixelLayout};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GdkMonitor")]
16    pub struct Monitor(Object<ffi::GdkMonitor, ffi::GdkMonitorClass>);
17
18    match fn {
19        type_ => || ffi::gdk_monitor_get_type(),
20    }
21}
22
23impl Monitor {
24    pub const NONE: Option<&'static Monitor> = None;
25}
26
27pub trait MonitorExt: IsA<Monitor> + 'static {
28    #[doc(alias = "gdk_monitor_get_connector")]
29    #[doc(alias = "get_connector")]
30    fn connector(&self) -> Option<glib::GString> {
31        unsafe {
32            from_glib_none(ffi::gdk_monitor_get_connector(
33                self.as_ref().to_glib_none().0,
34            ))
35        }
36    }
37
38    #[cfg(feature = "v4_10")]
39    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
40    #[doc(alias = "gdk_monitor_get_description")]
41    #[doc(alias = "get_description")]
42    fn description(&self) -> Option<glib::GString> {
43        unsafe {
44            from_glib_none(ffi::gdk_monitor_get_description(
45                self.as_ref().to_glib_none().0,
46            ))
47        }
48    }
49
50    #[doc(alias = "gdk_monitor_get_display")]
51    #[doc(alias = "get_display")]
52    fn display(&self) -> Display {
53        unsafe { from_glib_none(ffi::gdk_monitor_get_display(self.as_ref().to_glib_none().0)) }
54    }
55
56    #[doc(alias = "gdk_monitor_get_geometry")]
57    #[doc(alias = "get_geometry")]
58    fn geometry(&self) -> Rectangle {
59        unsafe {
60            let mut geometry = Rectangle::uninitialized();
61            ffi::gdk_monitor_get_geometry(
62                self.as_ref().to_glib_none().0,
63                geometry.to_glib_none_mut().0,
64            );
65            geometry
66        }
67    }
68
69    #[doc(alias = "gdk_monitor_get_height_mm")]
70    #[doc(alias = "get_height_mm")]
71    #[doc(alias = "height-mm")]
72    fn height_mm(&self) -> i32 {
73        unsafe { ffi::gdk_monitor_get_height_mm(self.as_ref().to_glib_none().0) }
74    }
75
76    #[doc(alias = "gdk_monitor_get_manufacturer")]
77    #[doc(alias = "get_manufacturer")]
78    fn manufacturer(&self) -> Option<glib::GString> {
79        unsafe {
80            from_glib_none(ffi::gdk_monitor_get_manufacturer(
81                self.as_ref().to_glib_none().0,
82            ))
83        }
84    }
85
86    #[doc(alias = "gdk_monitor_get_model")]
87    #[doc(alias = "get_model")]
88    fn model(&self) -> Option<glib::GString> {
89        unsafe { from_glib_none(ffi::gdk_monitor_get_model(self.as_ref().to_glib_none().0)) }
90    }
91
92    #[doc(alias = "gdk_monitor_get_refresh_rate")]
93    #[doc(alias = "get_refresh_rate")]
94    #[doc(alias = "refresh-rate")]
95    fn refresh_rate(&self) -> i32 {
96        unsafe { ffi::gdk_monitor_get_refresh_rate(self.as_ref().to_glib_none().0) }
97    }
98
99    #[cfg(feature = "v4_14")]
100    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
101    #[doc(alias = "gdk_monitor_get_scale")]
102    #[doc(alias = "get_scale")]
103    fn scale(&self) -> f64 {
104        unsafe { ffi::gdk_monitor_get_scale(self.as_ref().to_glib_none().0) }
105    }
106
107    #[doc(alias = "gdk_monitor_get_scale_factor")]
108    #[doc(alias = "get_scale_factor")]
109    #[doc(alias = "scale-factor")]
110    fn scale_factor(&self) -> i32 {
111        unsafe { ffi::gdk_monitor_get_scale_factor(self.as_ref().to_glib_none().0) }
112    }
113
114    #[doc(alias = "gdk_monitor_get_subpixel_layout")]
115    #[doc(alias = "get_subpixel_layout")]
116    #[doc(alias = "subpixel-layout")]
117    fn subpixel_layout(&self) -> SubpixelLayout {
118        unsafe {
119            from_glib(ffi::gdk_monitor_get_subpixel_layout(
120                self.as_ref().to_glib_none().0,
121            ))
122        }
123    }
124
125    #[doc(alias = "gdk_monitor_get_width_mm")]
126    #[doc(alias = "get_width_mm")]
127    #[doc(alias = "width-mm")]
128    fn width_mm(&self) -> i32 {
129        unsafe { ffi::gdk_monitor_get_width_mm(self.as_ref().to_glib_none().0) }
130    }
131
132    #[doc(alias = "gdk_monitor_is_valid")]
133    #[doc(alias = "valid")]
134    fn is_valid(&self) -> bool {
135        unsafe { from_glib(ffi::gdk_monitor_is_valid(self.as_ref().to_glib_none().0)) }
136    }
137
138    #[doc(alias = "invalidate")]
139    fn connect_invalidate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
140        unsafe extern "C" fn invalidate_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
141            this: *mut ffi::GdkMonitor,
142            f: glib::ffi::gpointer,
143        ) {
144            let f: &F = &*(f as *const F);
145            f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
146        }
147        unsafe {
148            let f: Box_<F> = Box_::new(f);
149            connect_raw(
150                self.as_ptr() as *mut _,
151                c"invalidate".as_ptr() as *const _,
152                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
153                    invalidate_trampoline::<Self, F> as *const (),
154                )),
155                Box_::into_raw(f),
156            )
157        }
158    }
159
160    #[doc(alias = "connector")]
161    fn connect_connector_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
162        unsafe extern "C" fn notify_connector_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
163            this: *mut ffi::GdkMonitor,
164            _param_spec: glib::ffi::gpointer,
165            f: glib::ffi::gpointer,
166        ) {
167            let f: &F = &*(f as *const F);
168            f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
169        }
170        unsafe {
171            let f: Box_<F> = Box_::new(f);
172            connect_raw(
173                self.as_ptr() as *mut _,
174                c"notify::connector".as_ptr() as *const _,
175                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
176                    notify_connector_trampoline::<Self, F> as *const (),
177                )),
178                Box_::into_raw(f),
179            )
180        }
181    }
182
183    #[cfg(feature = "v4_10")]
184    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
185    #[doc(alias = "description")]
186    fn connect_description_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
187        unsafe extern "C" fn notify_description_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
188            this: *mut ffi::GdkMonitor,
189            _param_spec: glib::ffi::gpointer,
190            f: glib::ffi::gpointer,
191        ) {
192            let f: &F = &*(f as *const F);
193            f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
194        }
195        unsafe {
196            let f: Box_<F> = Box_::new(f);
197            connect_raw(
198                self.as_ptr() as *mut _,
199                c"notify::description".as_ptr() as *const _,
200                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
201                    notify_description_trampoline::<Self, F> as *const (),
202                )),
203                Box_::into_raw(f),
204            )
205        }
206    }
207
208    #[doc(alias = "geometry")]
209    fn connect_geometry_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
210        unsafe extern "C" fn notify_geometry_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
211            this: *mut ffi::GdkMonitor,
212            _param_spec: glib::ffi::gpointer,
213            f: glib::ffi::gpointer,
214        ) {
215            let f: &F = &*(f as *const F);
216            f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
217        }
218        unsafe {
219            let f: Box_<F> = Box_::new(f);
220            connect_raw(
221                self.as_ptr() as *mut _,
222                c"notify::geometry".as_ptr() as *const _,
223                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
224                    notify_geometry_trampoline::<Self, F> as *const (),
225                )),
226                Box_::into_raw(f),
227            )
228        }
229    }
230
231    #[doc(alias = "height-mm")]
232    fn connect_height_mm_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
233        unsafe extern "C" fn notify_height_mm_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
234            this: *mut ffi::GdkMonitor,
235            _param_spec: glib::ffi::gpointer,
236            f: glib::ffi::gpointer,
237        ) {
238            let f: &F = &*(f as *const F);
239            f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
240        }
241        unsafe {
242            let f: Box_<F> = Box_::new(f);
243            connect_raw(
244                self.as_ptr() as *mut _,
245                c"notify::height-mm".as_ptr() as *const _,
246                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
247                    notify_height_mm_trampoline::<Self, F> as *const (),
248                )),
249                Box_::into_raw(f),
250            )
251        }
252    }
253
254    #[doc(alias = "manufacturer")]
255    fn connect_manufacturer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
256        unsafe extern "C" fn notify_manufacturer_trampoline<
257            P: IsA<Monitor>,
258            F: Fn(&P) + 'static,
259        >(
260            this: *mut ffi::GdkMonitor,
261            _param_spec: glib::ffi::gpointer,
262            f: glib::ffi::gpointer,
263        ) {
264            let f: &F = &*(f as *const F);
265            f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
266        }
267        unsafe {
268            let f: Box_<F> = Box_::new(f);
269            connect_raw(
270                self.as_ptr() as *mut _,
271                c"notify::manufacturer".as_ptr() as *const _,
272                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
273                    notify_manufacturer_trampoline::<Self, F> as *const (),
274                )),
275                Box_::into_raw(f),
276            )
277        }
278    }
279
280    #[doc(alias = "model")]
281    fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
282        unsafe extern "C" fn notify_model_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
283            this: *mut ffi::GdkMonitor,
284            _param_spec: glib::ffi::gpointer,
285            f: glib::ffi::gpointer,
286        ) {
287            let f: &F = &*(f as *const F);
288            f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
289        }
290        unsafe {
291            let f: Box_<F> = Box_::new(f);
292            connect_raw(
293                self.as_ptr() as *mut _,
294                c"notify::model".as_ptr() as *const _,
295                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
296                    notify_model_trampoline::<Self, F> as *const (),
297                )),
298                Box_::into_raw(f),
299            )
300        }
301    }
302
303    #[doc(alias = "refresh-rate")]
304    fn connect_refresh_rate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
305        unsafe extern "C" fn notify_refresh_rate_trampoline<
306            P: IsA<Monitor>,
307            F: Fn(&P) + 'static,
308        >(
309            this: *mut ffi::GdkMonitor,
310            _param_spec: glib::ffi::gpointer,
311            f: glib::ffi::gpointer,
312        ) {
313            let f: &F = &*(f as *const F);
314            f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
315        }
316        unsafe {
317            let f: Box_<F> = Box_::new(f);
318            connect_raw(
319                self.as_ptr() as *mut _,
320                c"notify::refresh-rate".as_ptr() as *const _,
321                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
322                    notify_refresh_rate_trampoline::<Self, F> as *const (),
323                )),
324                Box_::into_raw(f),
325            )
326        }
327    }
328
329    #[cfg(feature = "v4_14")]
330    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
331    #[doc(alias = "scale")]
332    fn connect_scale_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
333        unsafe extern "C" fn notify_scale_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
334            this: *mut ffi::GdkMonitor,
335            _param_spec: glib::ffi::gpointer,
336            f: glib::ffi::gpointer,
337        ) {
338            let f: &F = &*(f as *const F);
339            f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
340        }
341        unsafe {
342            let f: Box_<F> = Box_::new(f);
343            connect_raw(
344                self.as_ptr() as *mut _,
345                c"notify::scale".as_ptr() as *const _,
346                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
347                    notify_scale_trampoline::<Self, F> as *const (),
348                )),
349                Box_::into_raw(f),
350            )
351        }
352    }
353
354    #[doc(alias = "scale-factor")]
355    fn connect_scale_factor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
356        unsafe extern "C" fn notify_scale_factor_trampoline<
357            P: IsA<Monitor>,
358            F: Fn(&P) + 'static,
359        >(
360            this: *mut ffi::GdkMonitor,
361            _param_spec: glib::ffi::gpointer,
362            f: glib::ffi::gpointer,
363        ) {
364            let f: &F = &*(f as *const F);
365            f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
366        }
367        unsafe {
368            let f: Box_<F> = Box_::new(f);
369            connect_raw(
370                self.as_ptr() as *mut _,
371                c"notify::scale-factor".as_ptr() as *const _,
372                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
373                    notify_scale_factor_trampoline::<Self, F> as *const (),
374                )),
375                Box_::into_raw(f),
376            )
377        }
378    }
379
380    #[doc(alias = "subpixel-layout")]
381    fn connect_subpixel_layout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
382        unsafe extern "C" fn notify_subpixel_layout_trampoline<
383            P: IsA<Monitor>,
384            F: Fn(&P) + 'static,
385        >(
386            this: *mut ffi::GdkMonitor,
387            _param_spec: glib::ffi::gpointer,
388            f: glib::ffi::gpointer,
389        ) {
390            let f: &F = &*(f as *const F);
391            f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
392        }
393        unsafe {
394            let f: Box_<F> = Box_::new(f);
395            connect_raw(
396                self.as_ptr() as *mut _,
397                c"notify::subpixel-layout".as_ptr() as *const _,
398                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
399                    notify_subpixel_layout_trampoline::<Self, F> as *const (),
400                )),
401                Box_::into_raw(f),
402            )
403        }
404    }
405
406    #[doc(alias = "valid")]
407    fn connect_valid_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
408        unsafe extern "C" fn notify_valid_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
409            this: *mut ffi::GdkMonitor,
410            _param_spec: glib::ffi::gpointer,
411            f: glib::ffi::gpointer,
412        ) {
413            let f: &F = &*(f as *const F);
414            f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
415        }
416        unsafe {
417            let f: Box_<F> = Box_::new(f);
418            connect_raw(
419                self.as_ptr() as *mut _,
420                c"notify::valid".as_ptr() as *const _,
421                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
422                    notify_valid_trampoline::<Self, F> as *const (),
423                )),
424                Box_::into_raw(f),
425            )
426        }
427    }
428
429    #[doc(alias = "width-mm")]
430    fn connect_width_mm_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
431        unsafe extern "C" fn notify_width_mm_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
432            this: *mut ffi::GdkMonitor,
433            _param_spec: glib::ffi::gpointer,
434            f: glib::ffi::gpointer,
435        ) {
436            let f: &F = &*(f as *const F);
437            f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
438        }
439        unsafe {
440            let f: Box_<F> = Box_::new(f);
441            connect_raw(
442                self.as_ptr() as *mut _,
443                c"notify::width-mm".as_ptr() as *const _,
444                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
445                    notify_width_mm_trampoline::<Self, F> as *const (),
446                )),
447                Box_::into_raw(f),
448            )
449        }
450    }
451}
452
453impl<O: IsA<Monitor>> MonitorExt for O {}