use crate::{ffi};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};
glib::wrapper! {
#[doc(alias = "BisLatchLayout")]
pub struct LatchLayout(Object<ffi::BisLatchLayout, ffi::BisLatchLayoutClass>) @extends gtk::LayoutManager, @implements gtk::Orientable;
match fn {
type_ => || ffi::bis_latch_layout_get_type(),
}
}
impl LatchLayout {
#[doc(alias = "bis_latch_layout_new")]
pub fn new() -> LatchLayout {
assert_initialized_main_thread!();
unsafe {
gtk::LayoutManager::from_glib_full(ffi::bis_latch_layout_new()).unsafe_cast()
}
}
pub fn builder() -> LatchLayoutBuilder {
LatchLayoutBuilder::new()
}
#[doc(alias = "bis_latch_layout_get_maximum_size")]
#[doc(alias = "get_maximum_size")]
#[doc(alias = "maximum-size")]
pub fn maximum_size(&self) -> i32 {
unsafe {
ffi::bis_latch_layout_get_maximum_size(self.to_glib_none().0)
}
}
#[doc(alias = "bis_latch_layout_get_tightening_threshold")]
#[doc(alias = "get_tightening_threshold")]
#[doc(alias = "tightening-threshold")]
pub fn tightening_threshold(&self) -> i32 {
unsafe {
ffi::bis_latch_layout_get_tightening_threshold(self.to_glib_none().0)
}
}
#[doc(alias = "bis_latch_layout_set_maximum_size")]
#[doc(alias = "maximum-size")]
pub fn set_maximum_size(&self, maximum_size: i32) {
unsafe {
ffi::bis_latch_layout_set_maximum_size(self.to_glib_none().0, maximum_size);
}
}
#[doc(alias = "bis_latch_layout_set_tightening_threshold")]
#[doc(alias = "tightening-threshold")]
pub fn set_tightening_threshold(&self, tightening_threshold: i32) {
unsafe {
ffi::bis_latch_layout_set_tightening_threshold(self.to_glib_none().0, tightening_threshold);
}
}
#[doc(alias = "maximum-size")]
pub fn connect_maximum_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_maximum_size_trampoline<F: Fn(&LatchLayout) + 'static>(this: *mut ffi::BisLatchLayout, _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::maximum-size\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_maximum_size_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "tightening-threshold")]
pub fn connect_tightening_threshold_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_tightening_threshold_trampoline<F: Fn(&LatchLayout) + 'static>(this: *mut ffi::BisLatchLayout, _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::tightening-threshold\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_tightening_threshold_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
}
impl Default for LatchLayout {
fn default() -> Self {
Self::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct LatchLayoutBuilder {
builder: glib::object::ObjectBuilder<'static, LatchLayout>,
}
impl LatchLayoutBuilder {
fn new() -> Self {
Self { builder: glib::object::Object::builder() }
}
pub fn maximum_size(self, maximum_size: i32) -> Self {
Self { builder: self.builder.property("maximum-size", maximum_size), }
}
pub fn tightening_threshold(self, tightening_threshold: i32) -> Self {
Self { builder: self.builder.property("tightening-threshold", tightening_threshold), }
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> LatchLayout {
self.builder.build() }
}