libadwaita/auto/
clamp_layout.rsuse crate::ffi;
#[cfg(feature = "v1_4")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
use crate::LengthUnit;
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "AdwClampLayout")]
pub struct ClampLayout(Object<ffi::AdwClampLayout, ffi::AdwClampLayoutClass>) @extends gtk::LayoutManager, @implements gtk::Orientable;
match fn {
type_ => || ffi::adw_clamp_layout_get_type(),
}
}
impl ClampLayout {
#[doc(alias = "adw_clamp_layout_new")]
pub fn new() -> ClampLayout {
assert_initialized_main_thread!();
unsafe { gtk::LayoutManager::from_glib_full(ffi::adw_clamp_layout_new()).unsafe_cast() }
}
pub fn builder() -> ClampLayoutBuilder {
ClampLayoutBuilder::new()
}
#[doc(alias = "adw_clamp_layout_get_maximum_size")]
#[doc(alias = "get_maximum_size")]
#[doc(alias = "maximum-size")]
pub fn maximum_size(&self) -> i32 {
unsafe { ffi::adw_clamp_layout_get_maximum_size(self.to_glib_none().0) }
}
#[doc(alias = "adw_clamp_layout_get_tightening_threshold")]
#[doc(alias = "get_tightening_threshold")]
#[doc(alias = "tightening-threshold")]
pub fn tightening_threshold(&self) -> i32 {
unsafe { ffi::adw_clamp_layout_get_tightening_threshold(self.to_glib_none().0) }
}
#[cfg(feature = "v1_4")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
#[doc(alias = "adw_clamp_layout_get_unit")]
#[doc(alias = "get_unit")]
pub fn unit(&self) -> LengthUnit {
unsafe { from_glib(ffi::adw_clamp_layout_get_unit(self.to_glib_none().0)) }
}
#[doc(alias = "adw_clamp_layout_set_maximum_size")]
#[doc(alias = "maximum-size")]
pub fn set_maximum_size(&self, maximum_size: i32) {
unsafe {
ffi::adw_clamp_layout_set_maximum_size(self.to_glib_none().0, maximum_size);
}
}
#[doc(alias = "adw_clamp_layout_set_tightening_threshold")]
#[doc(alias = "tightening-threshold")]
pub fn set_tightening_threshold(&self, tightening_threshold: i32) {
unsafe {
ffi::adw_clamp_layout_set_tightening_threshold(
self.to_glib_none().0,
tightening_threshold,
);
}
}
#[cfg(feature = "v1_4")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
#[doc(alias = "adw_clamp_layout_set_unit")]
#[doc(alias = "unit")]
pub fn set_unit(&self, unit: LengthUnit) {
unsafe {
ffi::adw_clamp_layout_set_unit(self.to_glib_none().0, unit.into_glib());
}
}
#[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(&ClampLayout) + 'static>(
this: *mut ffi::AdwClampLayout,
_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(&ClampLayout) + 'static,
>(
this: *mut ffi::AdwClampLayout,
_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),
)
}
}
#[cfg(feature = "v1_4")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
#[doc(alias = "unit")]
pub fn connect_unit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_unit_trampoline<F: Fn(&ClampLayout) + 'static>(
this: *mut ffi::AdwClampLayout,
_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::unit\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_unit_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl Default for ClampLayout {
fn default() -> Self {
Self::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct ClampLayoutBuilder {
builder: glib::object::ObjectBuilder<'static, ClampLayout>,
}
impl ClampLayoutBuilder {
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),
}
}
#[cfg(feature = "v1_4")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
pub fn unit(self, unit: LengthUnit) -> Self {
Self {
builder: self.builder.property("unit", unit),
}
}
pub fn orientation(self, orientation: gtk::Orientation) -> Self {
Self {
builder: self.builder.property("orientation", orientation),
}
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> ClampLayout {
assert_initialized_main_thread!();
self.builder.build()
}
}