gdk/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 gdk_sys;
6use glib::object::ObjectType as ObjectType_;
7use glib::signal::connect_raw;
8use glib::signal::SignalHandlerId;
9use glib::translate::*;
10#[cfg(any(feature = "v3_22", feature = "dox"))]
11use glib::GString;
12use glib::StaticType;
13use glib::Value;
14use glib_sys;
15use gobject_sys;
16use std::boxed::Box as Box_;
17use std::fmt;
18use std::mem::transmute;
19use Display;
20use Rectangle;
21#[cfg(any(feature = "v3_22", feature = "dox"))]
22use SubpixelLayout;
23
24glib_wrapper! {
25    pub struct Monitor(Object<gdk_sys::GdkMonitor, gdk_sys::GdkMonitorClass, MonitorClass>);
26
27    match fn {
28        get_type => || gdk_sys::gdk_monitor_get_type(),
29    }
30}
31
32impl Monitor {
33    #[cfg(any(feature = "v3_22", feature = "dox"))]
34    pub fn get_display(&self) -> Option<Display> {
35        unsafe { from_glib_none(gdk_sys::gdk_monitor_get_display(self.to_glib_none().0)) }
36    }
37
38    #[cfg(any(feature = "v3_22", feature = "dox"))]
39    pub fn get_geometry(&self) -> Rectangle {
40        unsafe {
41            let mut geometry = Rectangle::uninitialized();
42            gdk_sys::gdk_monitor_get_geometry(self.to_glib_none().0, geometry.to_glib_none_mut().0);
43            geometry
44        }
45    }
46
47    #[cfg(any(feature = "v3_22", feature = "dox"))]
48    pub fn get_height_mm(&self) -> i32 {
49        unsafe { gdk_sys::gdk_monitor_get_height_mm(self.to_glib_none().0) }
50    }
51
52    #[cfg(any(feature = "v3_22", feature = "dox"))]
53    pub fn get_manufacturer(&self) -> Option<GString> {
54        unsafe { from_glib_none(gdk_sys::gdk_monitor_get_manufacturer(self.to_glib_none().0)) }
55    }
56
57    #[cfg(any(feature = "v3_22", feature = "dox"))]
58    pub fn get_model(&self) -> Option<GString> {
59        unsafe { from_glib_none(gdk_sys::gdk_monitor_get_model(self.to_glib_none().0)) }
60    }
61
62    #[cfg(any(feature = "v3_22", feature = "dox"))]
63    pub fn get_refresh_rate(&self) -> i32 {
64        unsafe { gdk_sys::gdk_monitor_get_refresh_rate(self.to_glib_none().0) }
65    }
66
67    #[cfg(any(feature = "v3_22", feature = "dox"))]
68    pub fn get_scale_factor(&self) -> i32 {
69        unsafe { gdk_sys::gdk_monitor_get_scale_factor(self.to_glib_none().0) }
70    }
71
72    #[cfg(any(feature = "v3_22", feature = "dox"))]
73    pub fn get_subpixel_layout(&self) -> SubpixelLayout {
74        unsafe {
75            from_glib(gdk_sys::gdk_monitor_get_subpixel_layout(
76                self.to_glib_none().0,
77            ))
78        }
79    }
80
81    #[cfg(any(feature = "v3_22", feature = "dox"))]
82    pub fn get_width_mm(&self) -> i32 {
83        unsafe { gdk_sys::gdk_monitor_get_width_mm(self.to_glib_none().0) }
84    }
85
86    #[cfg(any(feature = "v3_22", feature = "dox"))]
87    pub fn get_workarea(&self) -> Rectangle {
88        unsafe {
89            let mut workarea = Rectangle::uninitialized();
90            gdk_sys::gdk_monitor_get_workarea(self.to_glib_none().0, workarea.to_glib_none_mut().0);
91            workarea
92        }
93    }
94
95    #[cfg(any(feature = "v3_22", feature = "dox"))]
96    pub fn is_primary(&self) -> bool {
97        unsafe { from_glib(gdk_sys::gdk_monitor_is_primary(self.to_glib_none().0)) }
98    }
99
100    pub fn get_property_display(&self) -> Option<Display> {
101        unsafe {
102            let mut value = Value::from_type(<Display as StaticType>::static_type());
103            gobject_sys::g_object_get_property(
104                self.as_ptr() as *mut gobject_sys::GObject,
105                b"display\0".as_ptr() as *const _,
106                value.to_glib_none_mut().0,
107            );
108            value.get()
109        }
110    }
111
112    pub fn get_property_geometry(&self) -> Option<Rectangle> {
113        unsafe {
114            let mut value = Value::from_type(<Rectangle as StaticType>::static_type());
115            gobject_sys::g_object_get_property(
116                self.as_ptr() as *mut gobject_sys::GObject,
117                b"geometry\0".as_ptr() as *const _,
118                value.to_glib_none_mut().0,
119            );
120            value.get()
121        }
122    }
123
124    pub fn get_property_height_mm(&self) -> i32 {
125        unsafe {
126            let mut value = Value::from_type(<i32 as StaticType>::static_type());
127            gobject_sys::g_object_get_property(
128                self.as_ptr() as *mut gobject_sys::GObject,
129                b"height-mm\0".as_ptr() as *const _,
130                value.to_glib_none_mut().0,
131            );
132            value.get().unwrap()
133        }
134    }
135
136    pub fn get_property_refresh_rate(&self) -> i32 {
137        unsafe {
138            let mut value = Value::from_type(<i32 as StaticType>::static_type());
139            gobject_sys::g_object_get_property(
140                self.as_ptr() as *mut gobject_sys::GObject,
141                b"refresh-rate\0".as_ptr() as *const _,
142                value.to_glib_none_mut().0,
143            );
144            value.get().unwrap()
145        }
146    }
147
148    pub fn get_property_scale_factor(&self) -> i32 {
149        unsafe {
150            let mut value = Value::from_type(<i32 as StaticType>::static_type());
151            gobject_sys::g_object_get_property(
152                self.as_ptr() as *mut gobject_sys::GObject,
153                b"scale-factor\0".as_ptr() as *const _,
154                value.to_glib_none_mut().0,
155            );
156            value.get().unwrap()
157        }
158    }
159
160    pub fn get_property_width_mm(&self) -> i32 {
161        unsafe {
162            let mut value = Value::from_type(<i32 as StaticType>::static_type());
163            gobject_sys::g_object_get_property(
164                self.as_ptr() as *mut gobject_sys::GObject,
165                b"width-mm\0".as_ptr() as *const _,
166                value.to_glib_none_mut().0,
167            );
168            value.get().unwrap()
169        }
170    }
171
172    pub fn get_property_workarea(&self) -> Option<Rectangle> {
173        unsafe {
174            let mut value = Value::from_type(<Rectangle as StaticType>::static_type());
175            gobject_sys::g_object_get_property(
176                self.as_ptr() as *mut gobject_sys::GObject,
177                b"workarea\0".as_ptr() as *const _,
178                value.to_glib_none_mut().0,
179            );
180            value.get()
181        }
182    }
183
184    pub fn connect_invalidate<F: Fn(&Monitor) + 'static>(&self, f: F) -> SignalHandlerId {
185        unsafe extern "C" fn invalidate_trampoline<F: Fn(&Monitor) + 'static>(
186            this: *mut gdk_sys::GdkMonitor,
187            f: glib_sys::gpointer,
188        ) {
189            let f: &F = &*(f as *const F);
190            f(&from_glib_borrow(this))
191        }
192        unsafe {
193            let f: Box_<F> = Box_::new(f);
194            connect_raw(
195                self.as_ptr() as *mut _,
196                b"invalidate\0".as_ptr() as *const _,
197                Some(transmute(invalidate_trampoline::<F> as usize)),
198                Box_::into_raw(f),
199            )
200        }
201    }
202
203    pub fn connect_property_geometry_notify<F: Fn(&Monitor) + 'static>(
204        &self,
205        f: F,
206    ) -> SignalHandlerId {
207        unsafe extern "C" fn notify_geometry_trampoline<F: Fn(&Monitor) + 'static>(
208            this: *mut gdk_sys::GdkMonitor,
209            _param_spec: glib_sys::gpointer,
210            f: glib_sys::gpointer,
211        ) {
212            let f: &F = &*(f as *const F);
213            f(&from_glib_borrow(this))
214        }
215        unsafe {
216            let f: Box_<F> = Box_::new(f);
217            connect_raw(
218                self.as_ptr() as *mut _,
219                b"notify::geometry\0".as_ptr() as *const _,
220                Some(transmute(notify_geometry_trampoline::<F> as usize)),
221                Box_::into_raw(f),
222            )
223        }
224    }
225
226    pub fn connect_property_height_mm_notify<F: Fn(&Monitor) + 'static>(
227        &self,
228        f: F,
229    ) -> SignalHandlerId {
230        unsafe extern "C" fn notify_height_mm_trampoline<F: Fn(&Monitor) + 'static>(
231            this: *mut gdk_sys::GdkMonitor,
232            _param_spec: glib_sys::gpointer,
233            f: glib_sys::gpointer,
234        ) {
235            let f: &F = &*(f as *const F);
236            f(&from_glib_borrow(this))
237        }
238        unsafe {
239            let f: Box_<F> = Box_::new(f);
240            connect_raw(
241                self.as_ptr() as *mut _,
242                b"notify::height-mm\0".as_ptr() as *const _,
243                Some(transmute(notify_height_mm_trampoline::<F> as usize)),
244                Box_::into_raw(f),
245            )
246        }
247    }
248
249    #[cfg(any(feature = "v3_22", feature = "dox"))]
250    pub fn connect_property_manufacturer_notify<F: Fn(&Monitor) + 'static>(
251        &self,
252        f: F,
253    ) -> SignalHandlerId {
254        unsafe extern "C" fn notify_manufacturer_trampoline<F: Fn(&Monitor) + 'static>(
255            this: *mut gdk_sys::GdkMonitor,
256            _param_spec: glib_sys::gpointer,
257            f: glib_sys::gpointer,
258        ) {
259            let f: &F = &*(f as *const F);
260            f(&from_glib_borrow(this))
261        }
262        unsafe {
263            let f: Box_<F> = Box_::new(f);
264            connect_raw(
265                self.as_ptr() as *mut _,
266                b"notify::manufacturer\0".as_ptr() as *const _,
267                Some(transmute(notify_manufacturer_trampoline::<F> as usize)),
268                Box_::into_raw(f),
269            )
270        }
271    }
272
273    #[cfg(any(feature = "v3_22", feature = "dox"))]
274    pub fn connect_property_model_notify<F: Fn(&Monitor) + 'static>(
275        &self,
276        f: F,
277    ) -> SignalHandlerId {
278        unsafe extern "C" fn notify_model_trampoline<F: Fn(&Monitor) + 'static>(
279            this: *mut gdk_sys::GdkMonitor,
280            _param_spec: glib_sys::gpointer,
281            f: glib_sys::gpointer,
282        ) {
283            let f: &F = &*(f as *const F);
284            f(&from_glib_borrow(this))
285        }
286        unsafe {
287            let f: Box_<F> = Box_::new(f);
288            connect_raw(
289                self.as_ptr() as *mut _,
290                b"notify::model\0".as_ptr() as *const _,
291                Some(transmute(notify_model_trampoline::<F> as usize)),
292                Box_::into_raw(f),
293            )
294        }
295    }
296
297    pub fn connect_property_refresh_rate_notify<F: Fn(&Monitor) + 'static>(
298        &self,
299        f: F,
300    ) -> SignalHandlerId {
301        unsafe extern "C" fn notify_refresh_rate_trampoline<F: Fn(&Monitor) + 'static>(
302            this: *mut gdk_sys::GdkMonitor,
303            _param_spec: glib_sys::gpointer,
304            f: glib_sys::gpointer,
305        ) {
306            let f: &F = &*(f as *const F);
307            f(&from_glib_borrow(this))
308        }
309        unsafe {
310            let f: Box_<F> = Box_::new(f);
311            connect_raw(
312                self.as_ptr() as *mut _,
313                b"notify::refresh-rate\0".as_ptr() as *const _,
314                Some(transmute(notify_refresh_rate_trampoline::<F> as usize)),
315                Box_::into_raw(f),
316            )
317        }
318    }
319
320    pub fn connect_property_scale_factor_notify<F: Fn(&Monitor) + 'static>(
321        &self,
322        f: F,
323    ) -> SignalHandlerId {
324        unsafe extern "C" fn notify_scale_factor_trampoline<F: Fn(&Monitor) + 'static>(
325            this: *mut gdk_sys::GdkMonitor,
326            _param_spec: glib_sys::gpointer,
327            f: glib_sys::gpointer,
328        ) {
329            let f: &F = &*(f as *const F);
330            f(&from_glib_borrow(this))
331        }
332        unsafe {
333            let f: Box_<F> = Box_::new(f);
334            connect_raw(
335                self.as_ptr() as *mut _,
336                b"notify::scale-factor\0".as_ptr() as *const _,
337                Some(transmute(notify_scale_factor_trampoline::<F> as usize)),
338                Box_::into_raw(f),
339            )
340        }
341    }
342
343    #[cfg(any(feature = "v3_22", feature = "dox"))]
344    pub fn connect_property_subpixel_layout_notify<F: Fn(&Monitor) + 'static>(
345        &self,
346        f: F,
347    ) -> SignalHandlerId {
348        unsafe extern "C" fn notify_subpixel_layout_trampoline<F: Fn(&Monitor) + 'static>(
349            this: *mut gdk_sys::GdkMonitor,
350            _param_spec: glib_sys::gpointer,
351            f: glib_sys::gpointer,
352        ) {
353            let f: &F = &*(f as *const F);
354            f(&from_glib_borrow(this))
355        }
356        unsafe {
357            let f: Box_<F> = Box_::new(f);
358            connect_raw(
359                self.as_ptr() as *mut _,
360                b"notify::subpixel-layout\0".as_ptr() as *const _,
361                Some(transmute(notify_subpixel_layout_trampoline::<F> as usize)),
362                Box_::into_raw(f),
363            )
364        }
365    }
366
367    pub fn connect_property_width_mm_notify<F: Fn(&Monitor) + 'static>(
368        &self,
369        f: F,
370    ) -> SignalHandlerId {
371        unsafe extern "C" fn notify_width_mm_trampoline<F: Fn(&Monitor) + 'static>(
372            this: *mut gdk_sys::GdkMonitor,
373            _param_spec: glib_sys::gpointer,
374            f: glib_sys::gpointer,
375        ) {
376            let f: &F = &*(f as *const F);
377            f(&from_glib_borrow(this))
378        }
379        unsafe {
380            let f: Box_<F> = Box_::new(f);
381            connect_raw(
382                self.as_ptr() as *mut _,
383                b"notify::width-mm\0".as_ptr() as *const _,
384                Some(transmute(notify_width_mm_trampoline::<F> as usize)),
385                Box_::into_raw(f),
386            )
387        }
388    }
389
390    pub fn connect_property_workarea_notify<F: Fn(&Monitor) + 'static>(
391        &self,
392        f: F,
393    ) -> SignalHandlerId {
394        unsafe extern "C" fn notify_workarea_trampoline<F: Fn(&Monitor) + 'static>(
395            this: *mut gdk_sys::GdkMonitor,
396            _param_spec: glib_sys::gpointer,
397            f: glib_sys::gpointer,
398        ) {
399            let f: &F = &*(f as *const F);
400            f(&from_glib_borrow(this))
401        }
402        unsafe {
403            let f: Box_<F> = Box_::new(f);
404            connect_raw(
405                self.as_ptr() as *mut _,
406                b"notify::workarea\0".as_ptr() as *const _,
407                Some(transmute(notify_workarea_trampoline::<F> as usize)),
408                Box_::into_raw(f),
409            )
410        }
411    }
412}
413
414impl fmt::Display for Monitor {
415    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
416        write!(f, "Monitor")
417    }
418}