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    /// List views use widgets for displaying their
16    ///   contents
17    /// A cell area that renders GtkCellRenderers into a row or a column
18    ///
19    /// The [`CellAreaBox`][crate::CellAreaBox] renders cell renderers into a row or a column
20    /// depending on its [`Orientation`][crate::Orientation].
21    ///
22    /// GtkCellAreaBox uses a notion of packing. Packing
23    /// refers to adding cell renderers with reference to a particular position
24    /// in a [`CellAreaBox`][crate::CellAreaBox]. There are two reference positions: the
25    /// start and the end of the box.
26    /// When the [`CellAreaBox`][crate::CellAreaBox] is oriented in the [`Orientation::Vertical`][crate::Orientation::Vertical]
27    /// orientation, the start is defined as the top of the box and the end is
28    /// defined as the bottom. In the [`Orientation::Horizontal`][crate::Orientation::Horizontal] orientation
29    /// start is defined as the left side and the end is defined as the right
30    /// side.
31    ///
32    /// Alignments of [`CellRenderer`][crate::CellRenderer]s rendered in adjacent rows can be
33    /// configured by configuring the [`CellAreaBox`][crate::CellAreaBox] align child cell property
34    /// with gtk_cell_area_cell_set_property() or by specifying the "align"
35    /// argument to gtk_cell_area_box_pack_start() and gtk_cell_area_box_pack_end().
36    ///
37    /// ## Properties
38    ///
39    ///
40    /// #### `spacing`
41    ///  The amount of space to reserve between cells.
42    ///
43    /// Readable | Writeable
44    /// <details><summary><h4>CellArea</h4></summary>
45    ///
46    ///
47    /// #### `edit-widget`
48    ///  The widget currently editing the edited cell
49    ///
50    /// This property is read-only and only changes as
51    /// a result of a call gtk_cell_area_activate_cell().
52    ///
53    /// Readable
54    ///
55    ///
56    /// #### `edited-cell`
57    ///  The cell in the area that is currently edited
58    ///
59    /// This property is read-only and only changes as
60    /// a result of a call gtk_cell_area_activate_cell().
61    ///
62    /// Readable
63    ///
64    ///
65    /// #### `focus-cell`
66    ///  The cell in the area that currently has focus
67    ///
68    /// Readable | Writeable
69    /// </details>
70    /// <details><summary><h4>Orientable</h4></summary>
71    ///
72    ///
73    /// #### `orientation`
74    ///  The orientation of the orientable.
75    ///
76    /// Readable | Writeable
77    /// </details>
78    ///
79    /// # Implements
80    ///
81    /// [`CellAreaExt`][trait@crate::prelude::CellAreaExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`CellLayoutExt`][trait@crate::prelude::CellLayoutExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`CellAreaExtManual`][trait@crate::prelude::CellAreaExtManual], [`CellLayoutExtManual`][trait@crate::prelude::CellLayoutExtManual]
82    #[doc(alias = "GtkCellAreaBox")]
83    pub struct CellAreaBox(Object<ffi::GtkCellAreaBox>) @extends CellArea, @implements Buildable, CellLayout, Orientable;
84
85    match fn {
86        type_ => || ffi::gtk_cell_area_box_get_type(),
87    }
88}
89
90impl CellAreaBox {
91    /// Creates a new [`CellAreaBox`][crate::CellAreaBox].
92    ///
93    /// # Deprecated since 4.10
94    ///
95    ///
96    /// # Returns
97    ///
98    /// a newly created [`CellAreaBox`][crate::CellAreaBox]
99    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
100    #[allow(deprecated)]
101    #[doc(alias = "gtk_cell_area_box_new")]
102    pub fn new() -> CellAreaBox {
103        assert_initialized_main_thread!();
104        unsafe { CellArea::from_glib_none(ffi::gtk_cell_area_box_new()).unsafe_cast() }
105    }
106
107    // rustdoc-stripper-ignore-next
108    /// Creates a new builder-pattern struct instance to construct [`CellAreaBox`] objects.
109    ///
110    /// This method returns an instance of [`CellAreaBoxBuilder`](crate::builders::CellAreaBoxBuilder) which can be used to create [`CellAreaBox`] objects.
111    pub fn builder() -> CellAreaBoxBuilder {
112        CellAreaBoxBuilder::new()
113    }
114
115    /// Gets the spacing added between cell renderers.
116    ///
117    /// # Deprecated since 4.10
118    ///
119    ///
120    /// # Returns
121    ///
122    /// the space added between cell renderers in @self.
123    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
124    #[allow(deprecated)]
125    #[doc(alias = "gtk_cell_area_box_get_spacing")]
126    #[doc(alias = "get_spacing")]
127    pub fn spacing(&self) -> i32 {
128        unsafe { ffi::gtk_cell_area_box_get_spacing(self.to_glib_none().0) }
129    }
130
131    /// Adds @renderer to @self, packed with reference to the end of @self.
132    ///
133    /// The @renderer is packed after (away from end of) any other
134    /// [`CellRenderer`][crate::CellRenderer] packed with reference to the end of @self.
135    ///
136    /// # Deprecated since 4.10
137    ///
138    /// ## `renderer`
139    /// the [`CellRenderer`][crate::CellRenderer] to add
140    /// ## `expand`
141    /// whether @renderer should receive extra space when the area receives
142    /// more than its natural size
143    /// ## `align`
144    /// whether @renderer should be aligned in adjacent rows
145    /// ## `fixed`
146    /// whether @renderer should have the same size in all rows
147    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
148    #[allow(deprecated)]
149    #[doc(alias = "gtk_cell_area_box_pack_end")]
150    pub fn pack_end(
151        &self,
152        renderer: &impl IsA<CellRenderer>,
153        expand: bool,
154        align: bool,
155        fixed: bool,
156    ) {
157        unsafe {
158            ffi::gtk_cell_area_box_pack_end(
159                self.to_glib_none().0,
160                renderer.as_ref().to_glib_none().0,
161                expand.into_glib(),
162                align.into_glib(),
163                fixed.into_glib(),
164            );
165        }
166    }
167
168    /// Adds @renderer to @self, packed with reference to the start of @self.
169    ///
170    /// The @renderer is packed after any other [`CellRenderer`][crate::CellRenderer] packed
171    /// with reference to the start of @self.
172    ///
173    /// # Deprecated since 4.10
174    ///
175    /// ## `renderer`
176    /// the [`CellRenderer`][crate::CellRenderer] to add
177    /// ## `expand`
178    /// whether @renderer should receive extra space when the area receives
179    /// more than its natural size
180    /// ## `align`
181    /// whether @renderer should be aligned in adjacent rows
182    /// ## `fixed`
183    /// whether @renderer should have the same size in all rows
184    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
185    #[allow(deprecated)]
186    #[doc(alias = "gtk_cell_area_box_pack_start")]
187    pub fn pack_start(
188        &self,
189        renderer: &impl IsA<CellRenderer>,
190        expand: bool,
191        align: bool,
192        fixed: bool,
193    ) {
194        unsafe {
195            ffi::gtk_cell_area_box_pack_start(
196                self.to_glib_none().0,
197                renderer.as_ref().to_glib_none().0,
198                expand.into_glib(),
199                align.into_glib(),
200                fixed.into_glib(),
201            );
202        }
203    }
204
205    /// Sets the spacing to add between cell renderers in @self.
206    ///
207    /// # Deprecated since 4.10
208    ///
209    /// ## `spacing`
210    /// the space to add between [`CellRenderer`][crate::CellRenderer]s
211    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
212    #[allow(deprecated)]
213    #[doc(alias = "gtk_cell_area_box_set_spacing")]
214    #[doc(alias = "spacing")]
215    pub fn set_spacing(&self, spacing: i32) {
216        unsafe {
217            ffi::gtk_cell_area_box_set_spacing(self.to_glib_none().0, spacing);
218        }
219    }
220
221    #[doc(alias = "spacing")]
222    pub fn connect_spacing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
223        unsafe extern "C" fn notify_spacing_trampoline<F: Fn(&CellAreaBox) + 'static>(
224            this: *mut ffi::GtkCellAreaBox,
225            _param_spec: glib::ffi::gpointer,
226            f: glib::ffi::gpointer,
227        ) {
228            let f: &F = &*(f as *const F);
229            f(&from_glib_borrow(this))
230        }
231        unsafe {
232            let f: Box_<F> = Box_::new(f);
233            connect_raw(
234                self.as_ptr() as *mut _,
235                b"notify::spacing\0".as_ptr() as *const _,
236                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
237                    notify_spacing_trampoline::<F> as *const (),
238                )),
239                Box_::into_raw(f),
240            )
241        }
242    }
243}
244
245impl Default for CellAreaBox {
246    fn default() -> Self {
247        Self::new()
248    }
249}
250
251// rustdoc-stripper-ignore-next
252/// A [builder-pattern] type to construct [`CellAreaBox`] objects.
253///
254/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
255#[must_use = "The builder must be built to be used"]
256pub struct CellAreaBoxBuilder {
257    builder: glib::object::ObjectBuilder<'static, CellAreaBox>,
258}
259
260impl CellAreaBoxBuilder {
261    fn new() -> Self {
262        Self {
263            builder: glib::object::Object::builder(),
264        }
265    }
266
267    /// The amount of space to reserve between cells.
268    pub fn spacing(self, spacing: i32) -> Self {
269        Self {
270            builder: self.builder.property("spacing", spacing),
271        }
272    }
273
274    /// The cell in the area that currently has focus
275    pub fn focus_cell(self, focus_cell: &impl IsA<CellRenderer>) -> Self {
276        Self {
277            builder: self
278                .builder
279                .property("focus-cell", focus_cell.clone().upcast()),
280        }
281    }
282
283    /// The orientation of the orientable.
284    pub fn orientation(self, orientation: Orientation) -> Self {
285        Self {
286            builder: self.builder.property("orientation", orientation),
287        }
288    }
289
290    // rustdoc-stripper-ignore-next
291    /// Build the [`CellAreaBox`].
292    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
293    pub fn build(self) -> CellAreaBox {
294        assert_initialized_main_thread!();
295        self.builder.build()
296    }
297}