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