use Bin;
use Buildable;
use Container;
#[cfg(any(feature = "v3_20", feature = "dox"))]
use PopoverConstraint;
use PositionType;
use Widget;
use ffi;
use gdk;
use gio;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::translate::*;
use glib_ffi;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
glib_wrapper! {
pub struct Popover(Object<ffi::GtkPopover, ffi::GtkPopoverClass, PopoverClass>) @extends Bin, Container, Widget, @implements Buildable;
match fn {
get_type => || ffi::gtk_popover_get_type(),
}
}
impl Popover {
pub fn new<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>>(relative_to: Q) -> Popover {
assert_initialized_main_thread!();
let relative_to = relative_to.into();
unsafe {
Widget::from_glib_none(ffi::gtk_popover_new(relative_to.map(|p| p.as_ref()).to_glib_none().0)).unsafe_cast()
}
}
pub fn new_from_model<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>, R: IsA<gio::MenuModel>>(relative_to: Q, model: &R) -> Popover {
assert_initialized_main_thread!();
let relative_to = relative_to.into();
unsafe {
Widget::from_glib_none(ffi::gtk_popover_new_from_model(relative_to.map(|p| p.as_ref()).to_glib_none().0, model.as_ref().to_glib_none().0)).unsafe_cast()
}
}
}
pub const NONE_POPOVER: Option<&Popover> = None;
pub trait PopoverExt: 'static {
fn bind_model<'a, 'b, P: IsA<gio::MenuModel> + 'a, Q: Into<Option<&'a P>>, R: Into<Option<&'b str>>>(&self, model: Q, action_namespace: R);
#[cfg(any(feature = "v3_20", feature = "dox"))]
fn get_constrain_to(&self) -> PopoverConstraint;
#[cfg(any(feature = "v3_18", feature = "dox"))]
fn get_default_widget(&self) -> Option<Widget>;
fn get_modal(&self) -> bool;
fn get_pointing_to(&self) -> Option<gdk::Rectangle>;
fn get_position(&self) -> PositionType;
fn get_relative_to(&self) -> Option<Widget>;
#[cfg_attr(feature = "v3_22", deprecated)]
#[cfg(any(feature = "v3_16", feature = "dox"))]
fn get_transitions_enabled(&self) -> bool;
#[cfg(any(feature = "v3_22", feature = "dox"))]
fn popdown(&self);
#[cfg(any(feature = "v3_22", feature = "dox"))]
fn popup(&self);
#[cfg(any(feature = "v3_20", feature = "dox"))]
fn set_constrain_to(&self, constraint: PopoverConstraint);
#[cfg(any(feature = "v3_18", feature = "dox"))]
fn set_default_widget<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>>(&self, widget: Q);
fn set_modal(&self, modal: bool);
fn set_pointing_to(&self, rect: &gdk::Rectangle);
fn set_position(&self, position: PositionType);
fn set_relative_to<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>>(&self, relative_to: Q);
#[cfg_attr(feature = "v3_22", deprecated)]
#[cfg(any(feature = "v3_16", feature = "dox"))]
fn set_transitions_enabled(&self, transitions_enabled: bool);
fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[cfg(any(feature = "v3_20", feature = "dox"))]
fn connect_property_constrain_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_pointing_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_relative_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
#[cfg_attr(feature = "v3_22", deprecated)]
#[cfg(any(feature = "v3_16", feature = "dox"))]
fn connect_property_transitions_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<Popover>> PopoverExt for O {
fn bind_model<'a, 'b, P: IsA<gio::MenuModel> + 'a, Q: Into<Option<&'a P>>, R: Into<Option<&'b str>>>(&self, model: Q, action_namespace: R) {
let model = model.into();
let action_namespace = action_namespace.into();
unsafe {
ffi::gtk_popover_bind_model(self.as_ref().to_glib_none().0, model.map(|p| p.as_ref()).to_glib_none().0, action_namespace.to_glib_none().0);
}
}
#[cfg(any(feature = "v3_20", feature = "dox"))]
fn get_constrain_to(&self) -> PopoverConstraint {
unsafe {
from_glib(ffi::gtk_popover_get_constrain_to(self.as_ref().to_glib_none().0))
}
}
#[cfg(any(feature = "v3_18", feature = "dox"))]
fn get_default_widget(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_popover_get_default_widget(self.as_ref().to_glib_none().0))
}
}
fn get_modal(&self) -> bool {
unsafe {
from_glib(ffi::gtk_popover_get_modal(self.as_ref().to_glib_none().0))
}
}
fn get_pointing_to(&self) -> Option<gdk::Rectangle> {
unsafe {
let mut rect = gdk::Rectangle::uninitialized();
let ret = from_glib(ffi::gtk_popover_get_pointing_to(self.as_ref().to_glib_none().0, rect.to_glib_none_mut().0));
if ret { Some(rect) } else { None }
}
}
fn get_position(&self) -> PositionType {
unsafe {
from_glib(ffi::gtk_popover_get_position(self.as_ref().to_glib_none().0))
}
}
fn get_relative_to(&self) -> Option<Widget> {
unsafe {
from_glib_none(ffi::gtk_popover_get_relative_to(self.as_ref().to_glib_none().0))
}
}
#[cfg(any(feature = "v3_16", feature = "dox"))]
fn get_transitions_enabled(&self) -> bool {
unsafe {
from_glib(ffi::gtk_popover_get_transitions_enabled(self.as_ref().to_glib_none().0))
}
}
#[cfg(any(feature = "v3_22", feature = "dox"))]
fn popdown(&self) {
unsafe {
ffi::gtk_popover_popdown(self.as_ref().to_glib_none().0);
}
}
#[cfg(any(feature = "v3_22", feature = "dox"))]
fn popup(&self) {
unsafe {
ffi::gtk_popover_popup(self.as_ref().to_glib_none().0);
}
}
#[cfg(any(feature = "v3_20", feature = "dox"))]
fn set_constrain_to(&self, constraint: PopoverConstraint) {
unsafe {
ffi::gtk_popover_set_constrain_to(self.as_ref().to_glib_none().0, constraint.to_glib());
}
}
#[cfg(any(feature = "v3_18", feature = "dox"))]
fn set_default_widget<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>>(&self, widget: Q) {
let widget = widget.into();
unsafe {
ffi::gtk_popover_set_default_widget(self.as_ref().to_glib_none().0, widget.map(|p| p.as_ref()).to_glib_none().0);
}
}
fn set_modal(&self, modal: bool) {
unsafe {
ffi::gtk_popover_set_modal(self.as_ref().to_glib_none().0, modal.to_glib());
}
}
fn set_pointing_to(&self, rect: &gdk::Rectangle) {
unsafe {
ffi::gtk_popover_set_pointing_to(self.as_ref().to_glib_none().0, rect.to_glib_none().0);
}
}
fn set_position(&self, position: PositionType) {
unsafe {
ffi::gtk_popover_set_position(self.as_ref().to_glib_none().0, position.to_glib());
}
}
fn set_relative_to<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>>(&self, relative_to: Q) {
let relative_to = relative_to.into();
unsafe {
ffi::gtk_popover_set_relative_to(self.as_ref().to_glib_none().0, relative_to.map(|p| p.as_ref()).to_glib_none().0);
}
}
#[cfg(any(feature = "v3_16", feature = "dox"))]
fn set_transitions_enabled(&self, transitions_enabled: bool) {
unsafe {
ffi::gtk_popover_set_transitions_enabled(self.as_ref().to_glib_none().0, transitions_enabled.to_glib());
}
}
fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"closed\0".as_ptr() as *const _,
Some(transmute(closed_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
#[cfg(any(feature = "v3_20", feature = "dox"))]
fn connect_property_constrain_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::constrain-to\0".as_ptr() as *const _,
Some(transmute(notify_constrain_to_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::modal\0".as_ptr() as *const _,
Some(transmute(notify_modal_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_pointing_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::pointing-to\0".as_ptr() as *const _,
Some(transmute(notify_pointing_to_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::position\0".as_ptr() as *const _,
Some(transmute(notify_position_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
fn connect_property_relative_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::relative-to\0".as_ptr() as *const _,
Some(transmute(notify_relative_to_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
#[cfg(any(feature = "v3_16", feature = "dox"))]
fn connect_property_transitions_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::transitions-enabled\0".as_ptr() as *const _,
Some(transmute(notify_transitions_enabled_trampoline::<Self, F> as usize)), Box_::into_raw(f))
}
}
}
unsafe extern "C" fn closed_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkPopover, f: glib_ffi::gpointer)
where P: IsA<Popover> {
let f: &F = transmute(f);
f(&Popover::from_glib_borrow(this).unsafe_cast())
}
#[cfg(any(feature = "v3_20", feature = "dox"))]
unsafe extern "C" fn notify_constrain_to_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkPopover, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Popover> {
let f: &F = transmute(f);
f(&Popover::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_modal_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkPopover, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Popover> {
let f: &F = transmute(f);
f(&Popover::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_pointing_to_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkPopover, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Popover> {
let f: &F = transmute(f);
f(&Popover::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_position_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkPopover, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Popover> {
let f: &F = transmute(f);
f(&Popover::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_relative_to_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkPopover, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Popover> {
let f: &F = transmute(f);
f(&Popover::from_glib_borrow(this).unsafe_cast())
}
#[cfg(any(feature = "v3_16", feature = "dox"))]
unsafe extern "C" fn notify_transitions_enabled_trampoline<P, F: Fn(&P) + 'static>(this: *mut ffi::GtkPopover, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<Popover> {
let f: &F = transmute(f);
f(&Popover::from_glib_borrow(this).unsafe_cast())
}
impl fmt::Display for Popover {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Popover")
}
}