Skip to main content

gtk/
requisition.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4use std::mem;
5
6/// A [`Requisition`][crate::Requisition]-struct represents the desired size of a widget. See
7/// [GtkWidget’s geometry management section][geometry-management] for
8/// more information.
9#[repr(C)]
10pub struct Requisition {
11    pub width: i32,
12    pub height: i32,
13}
14
15#[doc(hidden)]
16impl Uninitialized for Requisition {
17    #[inline]
18    unsafe fn uninitialized() -> Self {
19        mem::zeroed()
20    }
21}
22
23#[doc(hidden)]
24impl<'a> ToGlibPtr<'a, *const ffi::GtkRequisition> for Requisition {
25    type Storage = &'a Self;
26
27    #[inline]
28    fn to_glib_none(&'a self) -> Stash<'a, *const ffi::GtkRequisition, Self> {
29        let ptr: *const Requisition = self;
30        Stash(ptr as *const ffi::GtkRequisition, self)
31    }
32}
33
34#[doc(hidden)]
35impl<'a> ToGlibPtrMut<'a, *mut ffi::GtkRequisition> for Requisition {
36    type Storage = &'a mut Self;
37
38    #[inline]
39    fn to_glib_none_mut(&'a mut self) -> StashMut<'a, *mut ffi::GtkRequisition, Self> {
40        let ptr: *mut Requisition = &mut *self;
41        StashMut(ptr as *mut ffi::GtkRequisition, self)
42    }
43}