gtk4/auto/
cell_area_box.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4#![allow(deprecated)]
5
6use crate::{ffi, Buildable, CellArea, CellLayout, CellRenderer, Orientable, Orientation};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GtkCellAreaBox")]
16    pub struct CellAreaBox(Object<ffi::GtkCellAreaBox>) @extends CellArea, @implements Buildable, CellLayout, Orientable;
17
18    match fn {
19        type_ => || ffi::gtk_cell_area_box_get_type(),
20    }
21}
22
23impl CellAreaBox {
24    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
25    #[allow(deprecated)]
26    #[doc(alias = "gtk_cell_area_box_new")]
27    pub fn new() -> CellAreaBox {
28        assert_initialized_main_thread!();
29        unsafe { CellArea::from_glib_none(ffi::gtk_cell_area_box_new()).unsafe_cast() }
30    }
31
32    // rustdoc-stripper-ignore-next
33    /// Creates a new builder-pattern struct instance to construct [`CellAreaBox`] objects.
34    ///
35    /// This method returns an instance of [`CellAreaBoxBuilder`](crate::builders::CellAreaBoxBuilder) which can be used to create [`CellAreaBox`] objects.
36    pub fn builder() -> CellAreaBoxBuilder {
37        CellAreaBoxBuilder::new()
38    }
39
40    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
41    #[allow(deprecated)]
42    #[doc(alias = "gtk_cell_area_box_get_spacing")]
43    #[doc(alias = "get_spacing")]
44    pub fn spacing(&self) -> i32 {
45        unsafe { ffi::gtk_cell_area_box_get_spacing(self.to_glib_none().0) }
46    }
47
48    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
49    #[allow(deprecated)]
50    #[doc(alias = "gtk_cell_area_box_pack_end")]
51    pub fn pack_end(
52        &self,
53        renderer: &impl IsA<CellRenderer>,
54        expand: bool,
55        align: bool,
56        fixed: bool,
57    ) {
58        unsafe {
59            ffi::gtk_cell_area_box_pack_end(
60                self.to_glib_none().0,
61                renderer.as_ref().to_glib_none().0,
62                expand.into_glib(),
63                align.into_glib(),
64                fixed.into_glib(),
65            );
66        }
67    }
68
69    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
70    #[allow(deprecated)]
71    #[doc(alias = "gtk_cell_area_box_pack_start")]
72    pub fn pack_start(
73        &self,
74        renderer: &impl IsA<CellRenderer>,
75        expand: bool,
76        align: bool,
77        fixed: bool,
78    ) {
79        unsafe {
80            ffi::gtk_cell_area_box_pack_start(
81                self.to_glib_none().0,
82                renderer.as_ref().to_glib_none().0,
83                expand.into_glib(),
84                align.into_glib(),
85                fixed.into_glib(),
86            );
87        }
88    }
89
90    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
91    #[allow(deprecated)]
92    #[doc(alias = "gtk_cell_area_box_set_spacing")]
93    #[doc(alias = "spacing")]
94    pub fn set_spacing(&self, spacing: i32) {
95        unsafe {
96            ffi::gtk_cell_area_box_set_spacing(self.to_glib_none().0, spacing);
97        }
98    }
99
100    #[doc(alias = "spacing")]
101    pub fn connect_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
102        unsafe extern "C" fn notify_spacing_trampoline<F: Fn(&CellAreaBox) + 'static>(
103            this: *mut ffi::GtkCellAreaBox,
104            _param_spec: glib::ffi::gpointer,
105            f: glib::ffi::gpointer,
106        ) {
107            let f: &F = &*(f as *const F);
108            f(&from_glib_borrow(this))
109        }
110        unsafe {
111            let f: Box_<F> = Box_::new(f);
112            connect_raw(
113                self.as_ptr() as *mut _,
114                c"notify::spacing".as_ptr() as *const _,
115                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
116                    notify_spacing_trampoline::<F> as *const (),
117                )),
118                Box_::into_raw(f),
119            )
120        }
121    }
122}
123
124impl Default for CellAreaBox {
125    fn default() -> Self {
126        Self::new()
127    }
128}
129
130// rustdoc-stripper-ignore-next
131/// A [builder-pattern] type to construct [`CellAreaBox`] objects.
132///
133/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
134#[must_use = "The builder must be built to be used"]
135pub struct CellAreaBoxBuilder {
136    builder: glib::object::ObjectBuilder<'static, CellAreaBox>,
137}
138
139impl CellAreaBoxBuilder {
140    fn new() -> Self {
141        Self {
142            builder: glib::object::Object::builder(),
143        }
144    }
145
146    pub fn spacing(self, spacing: i32) -> Self {
147        Self {
148            builder: self.builder.property("spacing", spacing),
149        }
150    }
151
152    pub fn focus_cell(self, focus_cell: &impl IsA<CellRenderer>) -> Self {
153        Self {
154            builder: self
155                .builder
156                .property("focus-cell", focus_cell.clone().upcast()),
157        }
158    }
159
160    pub fn orientation(self, orientation: Orientation) -> Self {
161        Self {
162            builder: self.builder.property("orientation", orientation),
163        }
164    }
165
166    // rustdoc-stripper-ignore-next
167    /// Build the [`CellAreaBox`].
168    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
169    pub fn build(self) -> CellAreaBox {
170        assert_initialized_main_thread!();
171        self.builder.build()
172    }
173}