1 // Take a look at the license at the top of the repository in the LICENSE file.
2 
3 use crate::Gravity;
4 use glib::translate::*;
5 
6 #[derive(Clone, Copy, Debug, PartialEq)]
7 #[repr(C)]
8 #[doc(alias = "GdkGeometry")]
9 pub struct Geometry {
10     pub min_width: i32,
11     pub min_height: i32,
12     pub max_width: i32,
13     pub max_height: i32,
14     pub base_width: i32,
15     pub base_height: i32,
16     pub width_inc: i32,
17     pub height_inc: i32,
18     pub min_aspect: f64,
19     pub max_aspect: f64,
20     pub win_gravity: Gravity,
21 }
22 
23 #[doc(hidden)]
24 impl<'a> ToGlibPtr<'a, *const ffi::GdkGeometry> for Geometry {
25     type Storage = &'a Self;
26 
27     #[inline]
to_glib_none(&'a self) -> Stash<'a, *const ffi::GdkGeometry, Self>28     fn to_glib_none(&'a self) -> Stash<'a, *const ffi::GdkGeometry, Self> {
29         let ptr: *const Geometry = &*self;
30         Stash(ptr as *const ffi::GdkGeometry, self)
31     }
32 }
33 
34 #[doc(hidden)]
35 impl<'a> ToGlibPtrMut<'a, *mut ffi::GdkGeometry> for Geometry {
36     type Storage = &'a mut Self;
37 
38     #[inline]
to_glib_none_mut(&'a mut self) -> StashMut<'a, *mut ffi::GdkGeometry, Self>39     fn to_glib_none_mut(&'a mut self) -> StashMut<'a, *mut ffi::GdkGeometry, Self> {
40         let ptr: *mut Geometry = &mut *self;
41         StashMut(ptr as *mut ffi::GdkGeometry, self)
42     }
43 }
44 
45 #[doc(hidden)]
46 impl FromGlibPtrNone<*const ffi::GdkGeometry> for Geometry {
from_glib_none(ptr: *const ffi::GdkGeometry) -> Self47     unsafe fn from_glib_none(ptr: *const ffi::GdkGeometry) -> Self {
48         *(ptr as *const Geometry)
49     }
50 }
51 
52 #[doc(hidden)]
53 impl FromGlibPtrNone<*mut ffi::GdkGeometry> for Geometry {
from_glib_none(ptr: *mut ffi::GdkGeometry) -> Self54     unsafe fn from_glib_none(ptr: *mut ffi::GdkGeometry) -> Self {
55         *(ptr as *mut Geometry)
56     }
57 }
58 
59 #[doc(hidden)]
60 impl FromGlibPtrFull<*mut ffi::GdkGeometry> for Geometry {
61     #[inline]
from_glib_full(ptr: *mut ffi::GdkGeometry) -> Self62     unsafe fn from_glib_full(ptr: *mut ffi::GdkGeometry) -> Self {
63         let geom = *(ptr as *mut Geometry);
64         glib::ffi::g_free(ptr as *mut _);
65         geom
66     }
67 }
68