use crate::{Gravity, PopupLayout, Surface};
use glib::{prelude::*, translate::*};
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;
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Popup>> Sealed for T {}
}
pub trait PopupExt: IsA<Popup> + sealed::Sealed + 'static {
#[doc(alias = "gdk_popup_get_autohide")]
#[doc(alias = "get_autohide")]
fn is_autohide(&self) -> bool {
unsafe { from_glib(ffi::gdk_popup_get_autohide(self.as_ref().to_glib_none().0)) }
}
#[doc(alias = "gdk_popup_get_parent")]
#[doc(alias = "get_parent")]
fn parent(&self) -> Option<Surface> {
unsafe { from_glib_none(ffi::gdk_popup_get_parent(self.as_ref().to_glib_none().0)) }
}
#[doc(alias = "gdk_popup_get_position_x")]
#[doc(alias = "get_position_x")]
fn position_x(&self) -> i32 {
unsafe { ffi::gdk_popup_get_position_x(self.as_ref().to_glib_none().0) }
}
#[doc(alias = "gdk_popup_get_position_y")]
#[doc(alias = "get_position_y")]
fn position_y(&self) -> i32 {
unsafe { ffi::gdk_popup_get_position_y(self.as_ref().to_glib_none().0) }
}
#[doc(alias = "gdk_popup_get_rect_anchor")]
#[doc(alias = "get_rect_anchor")]
fn rect_anchor(&self) -> Gravity {
unsafe {
from_glib(ffi::gdk_popup_get_rect_anchor(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "gdk_popup_get_surface_anchor")]
#[doc(alias = "get_surface_anchor")]
fn surface_anchor(&self) -> Gravity {
unsafe {
from_glib(ffi::gdk_popup_get_surface_anchor(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "gdk_popup_present")]
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<O: IsA<Popup>> PopupExt for O {}