1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::Gravity;
use crate::PopupLayout;
use crate::Surface;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;

glib::wrapper! {
    #[doc(alias = "GdkPopup")]
    pub struct Popup(Interface<ffi::GdkPopup, ffi::GdkPopupInterface>) @requires Surface;

    match fn {
        type_ => || ffi::gdk_popup_get_type(),
    }
}

impl Popup {
    pub const NONE: Option<&'static Popup> = None;
}

pub trait PopupExt: 'static {
    #[doc(alias = "gdk_popup_get_autohide")]
    #[doc(alias = "get_autohide")]
    fn is_autohide(&self) -> bool;

    #[doc(alias = "gdk_popup_get_parent")]
    #[doc(alias = "get_parent")]
    fn parent(&self) -> Option<Surface>;

    #[doc(alias = "gdk_popup_get_position_x")]
    #[doc(alias = "get_position_x")]
    fn position_x(&self) -> i32;

    #[doc(alias = "gdk_popup_get_position_y")]
    #[doc(alias = "get_position_y")]
    fn position_y(&self) -> i32;

    #[doc(alias = "gdk_popup_get_rect_anchor")]
    #[doc(alias = "get_rect_anchor")]
    fn rect_anchor(&self) -> Gravity;

    #[doc(alias = "gdk_popup_get_surface_anchor")]
    #[doc(alias = "get_surface_anchor")]
    fn surface_anchor(&self) -> Gravity;

    #[doc(alias = "gdk_popup_present")]
    fn present(&self, width: i32, height: i32, layout: &PopupLayout) -> bool;
}

impl<O: IsA<Popup>> PopupExt for O {
    fn is_autohide(&self) -> bool {
        unsafe { from_glib(ffi::gdk_popup_get_autohide(self.as_ref().to_glib_none().0)) }
    }

    fn parent(&self) -> Option<Surface> {
        unsafe { from_glib_none(ffi::gdk_popup_get_parent(self.as_ref().to_glib_none().0)) }
    }

    fn position_x(&self) -> i32 {
        unsafe { ffi::gdk_popup_get_position_x(self.as_ref().to_glib_none().0) }
    }

    fn position_y(&self) -> i32 {
        unsafe { ffi::gdk_popup_get_position_y(self.as_ref().to_glib_none().0) }
    }

    fn rect_anchor(&self) -> Gravity {
        unsafe {
            from_glib(ffi::gdk_popup_get_rect_anchor(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn surface_anchor(&self) -> Gravity {
        unsafe {
            from_glib(ffi::gdk_popup_get_surface_anchor(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn present(&self, width: i32, height: i32, layout: &PopupLayout) -> bool {
        unsafe {
            from_glib(ffi::gdk_popup_present(
                self.as_ref().to_glib_none().0,
                width,
                height,
                layout.to_glib_none().0,
            ))
        }
    }
}

impl fmt::Display for Popup {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("Popup")
    }
}