use crate::LayoutChild;
use crate::LayoutManager;
use crate::Widget;
use glib::object::Cast;
use glib::object::IsA;
use glib::StaticType;
use glib::ToValue;
use std::fmt;
glib::wrapper! {
#[doc(alias = "GtkConstraintLayoutChild")]
pub struct ConstraintLayoutChild(Object<ffi::GtkConstraintLayoutChild, ffi::GtkConstraintLayoutChildClass>) @extends LayoutChild;
match fn {
type_ => || ffi::gtk_constraint_layout_child_get_type(),
}
}
impl ConstraintLayoutChild {
pub fn builder() -> ConstraintLayoutChildBuilder {
ConstraintLayoutChildBuilder::default()
}
}
#[derive(Clone, Default)]
pub struct ConstraintLayoutChildBuilder {
child_widget: Option<Widget>,
layout_manager: Option<LayoutManager>,
}
impl ConstraintLayoutChildBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn build(self) -> ConstraintLayoutChild {
let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
if let Some(ref child_widget) = self.child_widget {
properties.push(("child-widget", child_widget));
}
if let Some(ref layout_manager) = self.layout_manager {
properties.push(("layout-manager", layout_manager));
}
glib::Object::new::<ConstraintLayoutChild>(&properties)
.expect("Failed to create an instance of ConstraintLayoutChild")
}
pub fn child_widget<P: IsA<Widget>>(mut self, child_widget: &P) -> Self {
self.child_widget = Some(child_widget.clone().upcast());
self
}
pub fn layout_manager<P: IsA<LayoutManager>>(mut self, layout_manager: &P) -> Self {
self.layout_manager = Some(layout_manager.clone().upcast());
self
}
}
impl fmt::Display for ConstraintLayoutChild {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("ConstraintLayoutChild")
}
}