1 // Copyright 2013-2015, The Gtk-rs Project Developers.
2 // See the COPYRIGHT file at the top-level directory of this distribution.
3 // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4 
5 use gdk_sys;
6 use glib::translate::*;
7 use glib_sys;
8 use Gravity;
9 
10 #[derive(Clone, Copy, Debug, PartialEq)]
11 #[repr(C)]
12 pub struct Geometry {
13     pub min_width: i32,
14     pub min_height: i32,
15     pub max_width: i32,
16     pub max_height: i32,
17     pub base_width: i32,
18     pub base_height: i32,
19     pub width_inc: i32,
20     pub height_inc: i32,
21     pub min_aspect: f64,
22     pub max_aspect: f64,
23     pub win_gravity: Gravity,
24 }
25 
26 #[doc(hidden)]
27 impl<'a> ToGlibPtr<'a, *const gdk_sys::GdkGeometry> for Geometry {
28     type Storage = &'a Self;
29 
30     #[inline]
to_glib_none(&'a self) -> Stash<'a, *const gdk_sys::GdkGeometry, Self>31     fn to_glib_none(&'a self) -> Stash<'a, *const gdk_sys::GdkGeometry, Self> {
32         let ptr: *const Geometry = &*self;
33         Stash(ptr as *const gdk_sys::GdkGeometry, self)
34     }
35 }
36 
37 #[doc(hidden)]
38 impl<'a> ToGlibPtrMut<'a, *mut gdk_sys::GdkGeometry> for Geometry {
39     type Storage = &'a mut Self;
40 
41     #[inline]
to_glib_none_mut(&'a mut self) -> StashMut<'a, *mut gdk_sys::GdkGeometry, Self>42     fn to_glib_none_mut(&'a mut self) -> StashMut<'a, *mut gdk_sys::GdkGeometry, Self> {
43         let ptr: *mut Geometry = &mut *self;
44         StashMut(ptr as *mut gdk_sys::GdkGeometry, self)
45     }
46 }
47 
48 #[doc(hidden)]
49 impl FromGlibPtrNone<*const gdk_sys::GdkGeometry> for Geometry {
from_glib_none(ptr: *const gdk_sys::GdkGeometry) -> Self50     unsafe fn from_glib_none(ptr: *const gdk_sys::GdkGeometry) -> Self {
51         *(ptr as *const Geometry)
52     }
53 }
54 
55 #[doc(hidden)]
56 impl FromGlibPtrNone<*mut gdk_sys::GdkGeometry> for Geometry {
from_glib_none(ptr: *mut gdk_sys::GdkGeometry) -> Self57     unsafe fn from_glib_none(ptr: *mut gdk_sys::GdkGeometry) -> Self {
58         *(ptr as *mut Geometry)
59     }
60 }
61 
62 #[doc(hidden)]
63 impl FromGlibPtrFull<*mut gdk_sys::GdkGeometry> for Geometry {
64     #[inline]
from_glib_full(ptr: *mut gdk_sys::GdkGeometry) -> Self65     unsafe fn from_glib_full(ptr: *mut gdk_sys::GdkGeometry) -> Self {
66         let geom = *(ptr as *mut Geometry);
67         glib_sys::g_free(ptr as *mut _);
68         geom
69     }
70 }
71