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