gtk4/auto/cell_layout.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::{CellArea, CellRenderer, TreeIter, TreeModel, ffi};
7use glib::{prelude::*, translate::*};
8use std::boxed::Box as Box_;
9
10glib::wrapper! {
11 /// List views use widgets to display their contents.
12 /// See [`LayoutManager`][crate::LayoutManager] for layout manager delegate objects
13 ///
14 /// ```text
15 ///
16 /// ## Subclassing GtkCellLayout implementations
17 ///
18 /// When subclassing a widget that implements `GtkCellLayout` like
19 /// `GtkIconView` or `GtkComboBox`, there are some considerations related
20 /// to the fact that these widgets internally use a `GtkCellArea`.
21 /// The cell area is exposed as a construct-only property by these
22 /// widgets. This means that it is possible to e.g. do
23 ///
24 /// ```c
25 /// GtkWIdget *combo =
26 /// g_object_new (GTK_TYPE_COMBO_BOX, "cell-area", my_cell_area, NULL);
27 /// ```text
28 ///
29 /// to use a custom cell area with a combo box. But construct properties
30 /// are only initialized after instance `init()`
31 /// functions have run, which means that using functions which rely on
32 /// the existence of the cell area in your subclass `init()` function will
33 /// cause the default cell area to be instantiated. In this case, a provided
34 /// construct property value will be ignored (with a warning, to alert
35 /// you to the problem).
36 ///
37 /// ```c
38 /// static void
39 /// my_combo_box_init (MyComboBox *b)
40 /// {
41 /// GtkCellRenderer *cell;
42 ///
43 /// cell = gtk_cell_renderer_pixbuf_new ();
44 ///
45 /// // The following call causes the default cell area for combo boxes,
46 /// // a GtkCellAreaBox, to be instantiated
47 /// gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (b), cell, FALSE);
48 /// ...
49 /// }
50 ///
51 /// GtkWidget *
52 /// my_combo_box_new (GtkCellArea *area)
53 /// {
54 /// // This call is going to cause a warning about area being ignored
55 /// return g_object_new (MY_TYPE_COMBO_BOX, "cell-area", area, NULL);
56 /// }
57 /// ```text
58 ///
59 /// If supporting alternative cell areas with your derived widget is
60 /// not important, then this does not have to concern you. If you want
61 /// to support alternative cell areas, you can do so by moving the
62 /// problematic calls out of `init()` and into a `constructor()`
63 /// for your class.
64 ///
65 /// # Implements
66 ///
67 /// [`CellLayoutExt`][trait@crate::prelude::CellLayoutExt], [`CellLayoutExtManual`][trait@crate::prelude::CellLayoutExtManual]
68 #[doc(alias = "GtkCellLayout")]
69 pub struct CellLayout(Interface<ffi::GtkCellLayout, ffi::GtkCellLayoutIface>);
70
71 match fn {
72 type_ => || ffi::gtk_cell_layout_get_type(),
73 }
74}
75
76impl CellLayout {
77 pub const NONE: Option<&'static CellLayout> = None;
78}
79
80/// Trait containing all [`struct@CellLayout`] methods.
81///
82/// # Implementors
83///
84/// [`CellAreaBox`][struct@crate::CellAreaBox], [`CellArea`][struct@crate::CellArea], [`CellLayout`][struct@crate::CellLayout], [`CellView`][struct@crate::CellView], [`ComboBoxText`][struct@crate::ComboBoxText], [`ComboBox`][struct@crate::ComboBox], [`EntryCompletion`][struct@crate::EntryCompletion], [`IconView`][struct@crate::IconView], [`TreeViewColumn`][struct@crate::TreeViewColumn]
85pub trait CellLayoutExt: IsA<CellLayout> + 'static {
86 /// attribute of a [`CellRendererText`][crate::CellRendererText] get its values from column 2.
87 /// In this context "attribute" and "property" are used interchangeably.
88 ///
89 /// # Deprecated since 4.10
90 ///
91 /// ## `cell`
92 /// a [`CellRenderer`][crate::CellRenderer]
93 /// ## `attribute`
94 /// a property on the renderer
95 /// ## `column`
96 /// the column position on the model to get the attribute from
97 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
98 #[allow(deprecated)]
99 #[doc(alias = "gtk_cell_layout_add_attribute")]
100 fn add_attribute(&self, cell: &impl IsA<CellRenderer>, attribute: &str, column: i32) {
101 unsafe {
102 ffi::gtk_cell_layout_add_attribute(
103 self.as_ref().to_glib_none().0,
104 cell.as_ref().to_glib_none().0,
105 attribute.to_glib_none().0,
106 column,
107 );
108 }
109 }
110
111 /// Unsets all the mappings on all renderers on @self and
112 /// removes all renderers from @self.
113 ///
114 /// # Deprecated since 4.10
115 ///
116 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
117 #[allow(deprecated)]
118 #[doc(alias = "gtk_cell_layout_clear")]
119 fn clear(&self) {
120 unsafe {
121 ffi::gtk_cell_layout_clear(self.as_ref().to_glib_none().0);
122 }
123 }
124
125 /// Clears all existing attributes previously set with
126 /// gtk_cell_layout_set_attributes().
127 ///
128 /// # Deprecated since 4.10
129 ///
130 /// ## `cell`
131 /// a [`CellRenderer`][crate::CellRenderer] to clear the attribute mapping on
132 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
133 #[allow(deprecated)]
134 #[doc(alias = "gtk_cell_layout_clear_attributes")]
135 fn clear_attributes(&self, cell: &impl IsA<CellRenderer>) {
136 unsafe {
137 ffi::gtk_cell_layout_clear_attributes(
138 self.as_ref().to_glib_none().0,
139 cell.as_ref().to_glib_none().0,
140 );
141 }
142 }
143
144 /// Returns the underlying [`CellArea`][crate::CellArea] which might be @self
145 /// if called on a [`CellArea`][crate::CellArea] or might be [`None`] if no [`CellArea`][crate::CellArea]
146 /// is used by @self.
147 ///
148 /// # Deprecated since 4.10
149 ///
150 ///
151 /// # Returns
152 ///
153 /// the cell area used by @self
154 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
155 #[allow(deprecated)]
156 #[doc(alias = "gtk_cell_layout_get_area")]
157 #[doc(alias = "get_area")]
158 fn area(&self) -> Option<CellArea> {
159 unsafe {
160 from_glib_none(ffi::gtk_cell_layout_get_area(
161 self.as_ref().to_glib_none().0,
162 ))
163 }
164 }
165
166 /// Returns the cell renderers which have been added to @self.
167 ///
168 /// # Deprecated since 4.10
169 ///
170 ///
171 /// # Returns
172 ///
173 ///
174 /// a list of cell renderers. The list, but not the renderers has
175 /// been newly allocated and should be freed with g_list_free()
176 /// when no longer needed.
177 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
178 #[allow(deprecated)]
179 #[doc(alias = "gtk_cell_layout_get_cells")]
180 #[doc(alias = "get_cells")]
181 fn cells(&self) -> Vec<CellRenderer> {
182 unsafe {
183 FromGlibPtrContainer::from_glib_container(ffi::gtk_cell_layout_get_cells(
184 self.as_ref().to_glib_none().0,
185 ))
186 }
187 }
188
189 /// Adds the @cell to the end of @self. If @expand is [`false`], then the
190 /// @cell is allocated no more space than it needs. Any unused space is
191 /// divided evenly between cells for which @expand is [`true`].
192 ///
193 /// Note that reusing the same cell renderer is not supported.
194 ///
195 /// # Deprecated since 4.10
196 ///
197 /// ## `cell`
198 /// a [`CellRenderer`][crate::CellRenderer]
199 /// ## `expand`
200 /// [`true`] if @cell is to be given extra space allocated to @self
201 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
202 #[allow(deprecated)]
203 #[doc(alias = "gtk_cell_layout_pack_end")]
204 fn pack_end(&self, cell: &impl IsA<CellRenderer>, expand: bool) {
205 unsafe {
206 ffi::gtk_cell_layout_pack_end(
207 self.as_ref().to_glib_none().0,
208 cell.as_ref().to_glib_none().0,
209 expand.into_glib(),
210 );
211 }
212 }
213
214 /// Packs the @cell into the beginning of @self. If @expand is [`false`],
215 /// then the @cell is allocated no more space than it needs. Any unused space
216 /// is divided evenly between cells for which @expand is [`true`].
217 ///
218 /// Note that reusing the same cell renderer is not supported.
219 ///
220 /// # Deprecated since 4.10
221 ///
222 /// ## `cell`
223 /// a [`CellRenderer`][crate::CellRenderer]
224 /// ## `expand`
225 /// [`true`] if @cell is to be given extra space allocated to @self
226 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
227 #[allow(deprecated)]
228 #[doc(alias = "gtk_cell_layout_pack_start")]
229 fn pack_start(&self, cell: &impl IsA<CellRenderer>, expand: bool) {
230 unsafe {
231 ffi::gtk_cell_layout_pack_start(
232 self.as_ref().to_glib_none().0,
233 cell.as_ref().to_glib_none().0,
234 expand.into_glib(),
235 );
236 }
237 }
238
239 /// Re-inserts @cell at @position.
240 ///
241 /// Note that @cell has already to be packed into @self
242 /// for this to function properly.
243 ///
244 /// # Deprecated since 4.10
245 ///
246 /// ## `cell`
247 /// a [`CellRenderer`][crate::CellRenderer] to reorder
248 /// ## `position`
249 /// new position to insert @cell at
250 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
251 #[allow(deprecated)]
252 #[doc(alias = "gtk_cell_layout_reorder")]
253 fn reorder(&self, cell: &impl IsA<CellRenderer>, position: i32) {
254 unsafe {
255 ffi::gtk_cell_layout_reorder(
256 self.as_ref().to_glib_none().0,
257 cell.as_ref().to_glib_none().0,
258 position,
259 );
260 }
261 }
262
263 /// s
264 /// cell renderer(s) as appropriate.
265 ///
266 /// @func may be [`None`] to remove a previously set function.
267 ///
268 /// # Deprecated since 4.10
269 ///
270 /// ## `cell`
271 /// a [`CellRenderer`][crate::CellRenderer]
272 /// ## `func`
273 /// the [`CellLayout`][crate::CellLayout]DataFunc to use
274 /// ## `func_data`
275 /// user data for @func
276 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
277 #[allow(deprecated)]
278 #[doc(alias = "gtk_cell_layout_set_cell_data_func")]
279 fn set_cell_data_func<P: Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static>(
280 &self,
281 cell: &impl IsA<CellRenderer>,
282 func: P,
283 ) {
284 let func_data: Box_<P> = Box_::new(func);
285 unsafe extern "C" fn func_func<
286 P: Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static,
287 >(
288 cell_layout: *mut ffi::GtkCellLayout,
289 cell: *mut ffi::GtkCellRenderer,
290 tree_model: *mut ffi::GtkTreeModel,
291 iter: *mut ffi::GtkTreeIter,
292 data: glib::ffi::gpointer,
293 ) {
294 unsafe {
295 let cell_layout = from_glib_borrow(cell_layout);
296 let cell = from_glib_borrow(cell);
297 let tree_model = from_glib_borrow(tree_model);
298 let iter = from_glib_borrow(iter);
299 let callback = &*(data as *mut P);
300 (*callback)(&cell_layout, &cell, &tree_model, &iter)
301 }
302 }
303 let func = Some(func_func::<P> as _);
304 unsafe extern "C" fn destroy_func<
305 P: Fn(&CellLayout, &CellRenderer, &TreeModel, &TreeIter) + 'static,
306 >(
307 data: glib::ffi::gpointer,
308 ) {
309 unsafe {
310 let _callback = Box_::from_raw(data as *mut P);
311 }
312 }
313 let destroy_call4 = Some(destroy_func::<P> as _);
314 let super_callback0: Box_<P> = func_data;
315 unsafe {
316 ffi::gtk_cell_layout_set_cell_data_func(
317 self.as_ref().to_glib_none().0,
318 cell.as_ref().to_glib_none().0,
319 func,
320 Box_::into_raw(super_callback0) as *mut _,
321 destroy_call4,
322 );
323 }
324 }
325}
326
327impl<O: IsA<CellLayout>> CellLayoutExt for O {}