use crate::LayoutChild;
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, fmt, mem::transmute};
glib::wrapper! {
#[doc(alias = "GtkOverlayLayoutChild")]
pub struct OverlayLayoutChild(Object<ffi::GtkOverlayLayoutChild, ffi::GtkOverlayLayoutChildClass>) @extends LayoutChild;
match fn {
type_ => || ffi::gtk_overlay_layout_child_get_type(),
}
}
impl OverlayLayoutChild {
#[doc(alias = "gtk_overlay_layout_child_get_clip_overlay")]
#[doc(alias = "get_clip_overlay")]
pub fn is_clip_overlay(&self) -> bool {
unsafe {
from_glib(ffi::gtk_overlay_layout_child_get_clip_overlay(
self.to_glib_none().0,
))
}
}
#[doc(alias = "gtk_overlay_layout_child_get_measure")]
#[doc(alias = "get_measure")]
pub fn is_measure(&self) -> bool {
unsafe {
from_glib(ffi::gtk_overlay_layout_child_get_measure(
self.to_glib_none().0,
))
}
}
#[doc(alias = "gtk_overlay_layout_child_set_clip_overlay")]
pub fn set_clip_overlay(&self, clip_overlay: bool) {
unsafe {
ffi::gtk_overlay_layout_child_set_clip_overlay(
self.to_glib_none().0,
clip_overlay.into_glib(),
);
}
}
#[doc(alias = "gtk_overlay_layout_child_set_measure")]
pub fn set_measure(&self, measure: bool) {
unsafe {
ffi::gtk_overlay_layout_child_set_measure(self.to_glib_none().0, measure.into_glib());
}
}
#[doc(alias = "clip-overlay")]
pub fn connect_clip_overlay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_clip_overlay_trampoline<
F: Fn(&OverlayLayoutChild) + 'static,
>(
this: *mut ffi::GtkOverlayLayoutChild,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::clip-overlay\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_clip_overlay_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "measure")]
pub fn connect_measure_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_measure_trampoline<F: Fn(&OverlayLayoutChild) + 'static>(
this: *mut ffi::GtkOverlayLayoutChild,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::measure\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_measure_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl fmt::Display for OverlayLayoutChild {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("OverlayLayoutChild")
}
}