1use crate::{ffi, Gravity, PopupLayout, Surface};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 #[doc(alias = "GdkPopup")]
10 pub struct Popup(Interface<ffi::GdkPopup, ffi::GdkPopupInterface>) @requires Surface;
11
12 match fn {
13 type_ => || ffi::gdk_popup_get_type(),
14 }
15}
16
17impl Popup {
18 pub const NONE: Option<&'static Popup> = None;
19}
20
21pub trait PopupExt: IsA<Popup> + 'static {
22 #[doc(alias = "gdk_popup_get_autohide")]
23 #[doc(alias = "get_autohide")]
24 #[doc(alias = "autohide")]
25 fn is_autohide(&self) -> bool {
26 unsafe { from_glib(ffi::gdk_popup_get_autohide(self.as_ref().to_glib_none().0)) }
27 }
28
29 #[doc(alias = "gdk_popup_get_parent")]
30 #[doc(alias = "get_parent")]
31 fn parent(&self) -> Option<Surface> {
32 unsafe { from_glib_none(ffi::gdk_popup_get_parent(self.as_ref().to_glib_none().0)) }
33 }
34
35 #[doc(alias = "gdk_popup_get_position_x")]
36 #[doc(alias = "get_position_x")]
37 fn position_x(&self) -> i32 {
38 unsafe { ffi::gdk_popup_get_position_x(self.as_ref().to_glib_none().0) }
39 }
40
41 #[doc(alias = "gdk_popup_get_position_y")]
42 #[doc(alias = "get_position_y")]
43 fn position_y(&self) -> i32 {
44 unsafe { ffi::gdk_popup_get_position_y(self.as_ref().to_glib_none().0) }
45 }
46
47 #[doc(alias = "gdk_popup_get_rect_anchor")]
48 #[doc(alias = "get_rect_anchor")]
49 fn rect_anchor(&self) -> Gravity {
50 unsafe {
51 from_glib(ffi::gdk_popup_get_rect_anchor(
52 self.as_ref().to_glib_none().0,
53 ))
54 }
55 }
56
57 #[doc(alias = "gdk_popup_get_surface_anchor")]
58 #[doc(alias = "get_surface_anchor")]
59 fn surface_anchor(&self) -> Gravity {
60 unsafe {
61 from_glib(ffi::gdk_popup_get_surface_anchor(
62 self.as_ref().to_glib_none().0,
63 ))
64 }
65 }
66
67 #[doc(alias = "gdk_popup_present")]
68 fn present(&self, width: i32, height: i32, layout: &PopupLayout) -> bool {
69 unsafe {
70 from_glib(ffi::gdk_popup_present(
71 self.as_ref().to_glib_none().0,
72 width,
73 height,
74 layout.to_glib_none().0,
75 ))
76 }
77 }
78}
79
80impl<O: IsA<Popup>> PopupExt for O {}