Skip to main content

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::{Display, Rectangle, SubpixelLayout, ffi};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
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            unsafe {
145                let f: &F = &*(f as *const F);
146                f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
147            }
148        }
149        unsafe {
150            let f: Box_<F> = Box_::new(f);
151            connect_raw(
152                self.as_ptr() as *mut _,
153                c"invalidate".as_ptr(),
154                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
155                    invalidate_trampoline::<Self, F> as *const (),
156                )),
157                Box_::into_raw(f),
158            )
159        }
160    }
161
162    #[doc(alias = "connector")]
163    fn connect_connector_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
164        unsafe extern "C" fn notify_connector_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
165            this: *mut ffi::GdkMonitor,
166            _param_spec: glib::ffi::gpointer,
167            f: glib::ffi::gpointer,
168        ) {
169            unsafe {
170                let f: &F = &*(f as *const F);
171                f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
172            }
173        }
174        unsafe {
175            let f: Box_<F> = Box_::new(f);
176            connect_raw(
177                self.as_ptr() as *mut _,
178                c"notify::connector".as_ptr(),
179                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
180                    notify_connector_trampoline::<Self, F> as *const (),
181                )),
182                Box_::into_raw(f),
183            )
184        }
185    }
186
187    #[cfg(feature = "v4_10")]
188    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
189    #[doc(alias = "description")]
190    fn connect_description_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
191        unsafe extern "C" fn notify_description_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
192            this: *mut ffi::GdkMonitor,
193            _param_spec: glib::ffi::gpointer,
194            f: glib::ffi::gpointer,
195        ) {
196            unsafe {
197                let f: &F = &*(f as *const F);
198                f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
199            }
200        }
201        unsafe {
202            let f: Box_<F> = Box_::new(f);
203            connect_raw(
204                self.as_ptr() as *mut _,
205                c"notify::description".as_ptr(),
206                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
207                    notify_description_trampoline::<Self, F> as *const (),
208                )),
209                Box_::into_raw(f),
210            )
211        }
212    }
213
214    #[doc(alias = "geometry")]
215    fn connect_geometry_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
216        unsafe extern "C" fn notify_geometry_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
217            this: *mut ffi::GdkMonitor,
218            _param_spec: glib::ffi::gpointer,
219            f: glib::ffi::gpointer,
220        ) {
221            unsafe {
222                let f: &F = &*(f as *const F);
223                f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
224            }
225        }
226        unsafe {
227            let f: Box_<F> = Box_::new(f);
228            connect_raw(
229                self.as_ptr() as *mut _,
230                c"notify::geometry".as_ptr(),
231                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
232                    notify_geometry_trampoline::<Self, F> as *const (),
233                )),
234                Box_::into_raw(f),
235            )
236        }
237    }
238
239    #[doc(alias = "height-mm")]
240    fn connect_height_mm_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
241        unsafe extern "C" fn notify_height_mm_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
242            this: *mut ffi::GdkMonitor,
243            _param_spec: glib::ffi::gpointer,
244            f: glib::ffi::gpointer,
245        ) {
246            unsafe {
247                let f: &F = &*(f as *const F);
248                f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
249            }
250        }
251        unsafe {
252            let f: Box_<F> = Box_::new(f);
253            connect_raw(
254                self.as_ptr() as *mut _,
255                c"notify::height-mm".as_ptr(),
256                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
257                    notify_height_mm_trampoline::<Self, F> as *const (),
258                )),
259                Box_::into_raw(f),
260            )
261        }
262    }
263
264    #[doc(alias = "manufacturer")]
265    fn connect_manufacturer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
266        unsafe extern "C" fn notify_manufacturer_trampoline<
267            P: IsA<Monitor>,
268            F: Fn(&P) + 'static,
269        >(
270            this: *mut ffi::GdkMonitor,
271            _param_spec: glib::ffi::gpointer,
272            f: glib::ffi::gpointer,
273        ) {
274            unsafe {
275                let f: &F = &*(f as *const F);
276                f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
277            }
278        }
279        unsafe {
280            let f: Box_<F> = Box_::new(f);
281            connect_raw(
282                self.as_ptr() as *mut _,
283                c"notify::manufacturer".as_ptr(),
284                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
285                    notify_manufacturer_trampoline::<Self, F> as *const (),
286                )),
287                Box_::into_raw(f),
288            )
289        }
290    }
291
292    #[doc(alias = "model")]
293    fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
294        unsafe extern "C" fn notify_model_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
295            this: *mut ffi::GdkMonitor,
296            _param_spec: glib::ffi::gpointer,
297            f: glib::ffi::gpointer,
298        ) {
299            unsafe {
300                let f: &F = &*(f as *const F);
301                f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
302            }
303        }
304        unsafe {
305            let f: Box_<F> = Box_::new(f);
306            connect_raw(
307                self.as_ptr() as *mut _,
308                c"notify::model".as_ptr(),
309                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
310                    notify_model_trampoline::<Self, F> as *const (),
311                )),
312                Box_::into_raw(f),
313            )
314        }
315    }
316
317    #[doc(alias = "refresh-rate")]
318    fn connect_refresh_rate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
319        unsafe extern "C" fn notify_refresh_rate_trampoline<
320            P: IsA<Monitor>,
321            F: Fn(&P) + 'static,
322        >(
323            this: *mut ffi::GdkMonitor,
324            _param_spec: glib::ffi::gpointer,
325            f: glib::ffi::gpointer,
326        ) {
327            unsafe {
328                let f: &F = &*(f as *const F);
329                f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
330            }
331        }
332        unsafe {
333            let f: Box_<F> = Box_::new(f);
334            connect_raw(
335                self.as_ptr() as *mut _,
336                c"notify::refresh-rate".as_ptr(),
337                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
338                    notify_refresh_rate_trampoline::<Self, F> as *const (),
339                )),
340                Box_::into_raw(f),
341            )
342        }
343    }
344
345    #[cfg(feature = "v4_14")]
346    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
347    #[doc(alias = "scale")]
348    fn connect_scale_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
349        unsafe extern "C" fn notify_scale_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
350            this: *mut ffi::GdkMonitor,
351            _param_spec: glib::ffi::gpointer,
352            f: glib::ffi::gpointer,
353        ) {
354            unsafe {
355                let f: &F = &*(f as *const F);
356                f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
357            }
358        }
359        unsafe {
360            let f: Box_<F> = Box_::new(f);
361            connect_raw(
362                self.as_ptr() as *mut _,
363                c"notify::scale".as_ptr(),
364                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
365                    notify_scale_trampoline::<Self, F> as *const (),
366                )),
367                Box_::into_raw(f),
368            )
369        }
370    }
371
372    #[doc(alias = "scale-factor")]
373    fn connect_scale_factor_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
374        unsafe extern "C" fn notify_scale_factor_trampoline<
375            P: IsA<Monitor>,
376            F: Fn(&P) + 'static,
377        >(
378            this: *mut ffi::GdkMonitor,
379            _param_spec: glib::ffi::gpointer,
380            f: glib::ffi::gpointer,
381        ) {
382            unsafe {
383                let f: &F = &*(f as *const F);
384                f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
385            }
386        }
387        unsafe {
388            let f: Box_<F> = Box_::new(f);
389            connect_raw(
390                self.as_ptr() as *mut _,
391                c"notify::scale-factor".as_ptr(),
392                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
393                    notify_scale_factor_trampoline::<Self, F> as *const (),
394                )),
395                Box_::into_raw(f),
396            )
397        }
398    }
399
400    #[doc(alias = "subpixel-layout")]
401    fn connect_subpixel_layout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
402        unsafe extern "C" fn notify_subpixel_layout_trampoline<
403            P: IsA<Monitor>,
404            F: Fn(&P) + 'static,
405        >(
406            this: *mut ffi::GdkMonitor,
407            _param_spec: glib::ffi::gpointer,
408            f: glib::ffi::gpointer,
409        ) {
410            unsafe {
411                let f: &F = &*(f as *const F);
412                f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
413            }
414        }
415        unsafe {
416            let f: Box_<F> = Box_::new(f);
417            connect_raw(
418                self.as_ptr() as *mut _,
419                c"notify::subpixel-layout".as_ptr(),
420                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
421                    notify_subpixel_layout_trampoline::<Self, F> as *const (),
422                )),
423                Box_::into_raw(f),
424            )
425        }
426    }
427
428    #[doc(alias = "valid")]
429    fn connect_valid_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
430        unsafe extern "C" fn notify_valid_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
431            this: *mut ffi::GdkMonitor,
432            _param_spec: glib::ffi::gpointer,
433            f: glib::ffi::gpointer,
434        ) {
435            unsafe {
436                let f: &F = &*(f as *const F);
437                f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
438            }
439        }
440        unsafe {
441            let f: Box_<F> = Box_::new(f);
442            connect_raw(
443                self.as_ptr() as *mut _,
444                c"notify::valid".as_ptr(),
445                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
446                    notify_valid_trampoline::<Self, F> as *const (),
447                )),
448                Box_::into_raw(f),
449            )
450        }
451    }
452
453    #[doc(alias = "width-mm")]
454    fn connect_width_mm_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
455        unsafe extern "C" fn notify_width_mm_trampoline<P: IsA<Monitor>, F: Fn(&P) + 'static>(
456            this: *mut ffi::GdkMonitor,
457            _param_spec: glib::ffi::gpointer,
458            f: glib::ffi::gpointer,
459        ) {
460            unsafe {
461                let f: &F = &*(f as *const F);
462                f(Monitor::from_glib_borrow(this).unsafe_cast_ref())
463            }
464        }
465        unsafe {
466            let f: Box_<F> = Box_::new(f);
467            connect_raw(
468                self.as_ptr() as *mut _,
469                c"notify::width-mm".as_ptr(),
470                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
471                    notify_width_mm_trampoline::<Self, F> as *const (),
472                )),
473                Box_::into_raw(f),
474            )
475        }
476    }
477}
478
479impl<O: IsA<Monitor>> MonitorExt for O {}