Skip to main content

gtk4/auto/
cell_view.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
6#[cfg(feature = "v4_10")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
8use crate::Accessible;
9use crate::{
10    AccessibleRole, Align, Buildable, CellArea, CellAreaContext, CellLayout, ConstraintTarget,
11    LayoutManager, Orientable, Orientation, Overflow, TreeModel, TreePath, Widget, ffi,
12};
13use glib::{
14    prelude::*,
15    signal::{SignalHandlerId, connect_raw},
16    translate::*,
17};
18use std::boxed::Box as Box_;
19
20#[cfg(feature = "v4_10")]
21#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
22glib::wrapper! {
23    /// List views use widgets to display their contents.
24    ///   You can use [`Box`][crate::Box] instead
25    /// A widget displaying a single row of a GtkTreeModel
26    ///
27    /// A [`CellView`][crate::CellView] displays a single row of a [`TreeModel`][crate::TreeModel] using a [`CellArea`][crate::CellArea]
28    /// and [`CellAreaContext`][crate::CellAreaContext]. A [`CellAreaContext`][crate::CellAreaContext] can be provided to the
29    /// [`CellView`][crate::CellView] at construction time in order to keep the cellview in context
30    /// of a group of cell views, this ensures that the renderers displayed will
31    /// be properly aligned with each other (like the aligned cells in the menus
32    /// of [`ComboBox`][crate::ComboBox]).
33    ///
34    /// [`CellView`][crate::CellView] is [`Orientable`][crate::Orientable] in order to decide in which orientation
35    /// the underlying [`CellAreaContext`][crate::CellAreaContext] should be allocated. Taking the [`ComboBox`][crate::ComboBox]
36    /// menu as an example, cellviews should be oriented horizontally if the menus are
37    /// listed top-to-bottom and thus all share the same width but may have separate
38    /// individual heights (left-to-right menus should be allocated vertically since
39    /// they all share the same height but may have variable widths).
40    ///
41    /// ## CSS nodes
42    ///
43    /// GtkCellView has a single CSS node with name cellview.
44    ///
45    /// ## Properties
46    ///
47    ///
48    /// #### `cell-area`
49    ///  The [`CellArea`][crate::CellArea] rendering cells
50    ///
51    /// If no area is specified when creating the cell view with gtk_cell_view_new_with_context()
52    /// a horizontally oriented [`CellArea`][crate::CellArea]Box will be used.
53    ///
54    /// since 3.0
55    ///
56    /// Readable | Writable | Construct Only
57    ///
58    ///
59    /// #### `cell-area-context`
60    ///  The [`CellAreaContext`][crate::CellAreaContext] used to compute the geometry of the cell view.
61    ///
62    /// A group of cell views can be assigned the same context in order to
63    /// ensure the sizes and cell alignments match across all the views with
64    /// the same context.
65    ///
66    /// [`ComboBox`][crate::ComboBox] menus uses this to assign the same context to all cell views
67    /// in the menu items for a single menu (each submenu creates its own
68    /// context since the size of each submenu does not depend on parent
69    /// or sibling menus).
70    ///
71    /// since 3.0
72    ///
73    /// Readable | Writable | Construct Only
74    ///
75    ///
76    /// #### `draw-sensitive`
77    ///  Whether all cells should be draw as sensitive for this view regardless
78    /// of the actual cell properties (used to make menus with submenus appear
79    /// sensitive when the items in submenus might be insensitive).
80    ///
81    /// since 3.0
82    ///
83    /// Readable | Writable
84    ///
85    ///
86    /// #### `fit-model`
87    ///  Whether the view should request enough space to always fit
88    /// the size of every row in the model (used by the combo box to
89    /// ensure the combo box size doesn't change when different items
90    /// are selected).
91    ///
92    /// since 3.0
93    ///
94    /// Readable | Writable
95    ///
96    ///
97    /// #### `model`
98    ///  The model for cell view
99    ///
100    /// since 2.10
101    ///
102    /// Readable | Writable
103    /// <details><summary><h4>Widget</h4></summary>
104    ///
105    ///
106    /// #### `can-focus`
107    ///  Whether the widget or any of its descendents can accept
108    /// the input focus.
109    ///
110    /// This property is meant to be set by widget implementations,
111    /// typically in their instance init function.
112    ///
113    /// Readable | Writable
114    ///
115    ///
116    /// #### `can-target`
117    ///  Whether the widget can receive pointer events.
118    ///
119    /// Readable | Writable
120    ///
121    ///
122    /// #### `css-classes`
123    ///  A list of css classes applied to this widget.
124    ///
125    /// Readable | Writable
126    ///
127    ///
128    /// #### `css-name`
129    ///  The name of this widget in the CSS tree.
130    ///
131    /// This property is meant to be set by widget implementations,
132    /// typically in their instance init function.
133    ///
134    /// Readable | Writable | Construct Only
135    ///
136    ///
137    /// #### `cursor`
138    ///  The cursor used by @widget.
139    ///
140    /// Readable | Writable
141    ///
142    ///
143    /// #### `focus-on-click`
144    ///  Whether the widget should grab focus when it is clicked with the mouse.
145    ///
146    /// This property is only relevant for widgets that can take focus.
147    ///
148    /// Readable | Writable
149    ///
150    ///
151    /// #### `focusable`
152    ///  Whether this widget itself will accept the input focus.
153    ///
154    /// Readable | Writable
155    ///
156    ///
157    /// #### `halign`
158    ///  How to distribute horizontal space if widget gets extra space.
159    ///
160    /// Readable | Writable
161    ///
162    ///
163    /// #### `has-default`
164    ///  Whether the widget is the default widget.
165    ///
166    /// Readable
167    ///
168    ///
169    /// #### `has-focus`
170    ///  Whether the widget has the input focus.
171    ///
172    /// Readable
173    ///
174    ///
175    /// #### `has-tooltip`
176    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
177    /// signal on @widget.
178    ///
179    /// A true value indicates that @widget can have a tooltip, in this case
180    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
181    /// determine whether it will provide a tooltip or not.
182    ///
183    /// Readable | Writable
184    ///
185    ///
186    /// #### `height-request`
187    ///  Overrides for height request of the widget.
188    ///
189    /// If this is -1, the natural request will be used.
190    ///
191    /// Readable | Writable
192    ///
193    ///
194    /// #### `hexpand`
195    ///  Whether to expand horizontally.
196    ///
197    /// Readable | Writable
198    ///
199    ///
200    /// #### `hexpand-set`
201    ///  Whether to use the `hexpand` property.
202    ///
203    /// Readable | Writable
204    ///
205    ///
206    /// #### `layout-manager`
207    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
208    /// the preferred size of the widget, and allocate its children.
209    ///
210    /// This property is meant to be set by widget implementations,
211    /// typically in their instance init function.
212    ///
213    /// Readable | Writable
214    ///
215    ///
216    /// #### `limit-events`
217    ///  Makes this widget act like a modal dialog, with respect to
218    /// event delivery.
219    ///
220    /// Global event controllers will not handle events with targets
221    /// inside the widget, unless they are set up to ignore propagation
222    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
223    ///
224    /// Readable | Writable
225    ///
226    ///
227    /// #### `margin-bottom`
228    ///  Margin on bottom side of widget.
229    ///
230    /// This property adds margin outside of the widget's normal size
231    /// request, the margin will be added in addition to the size from
232    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
233    ///
234    /// Readable | Writable
235    ///
236    ///
237    /// #### `margin-end`
238    ///  Margin on end of widget, horizontally.
239    ///
240    /// This property supports left-to-right and right-to-left text
241    /// directions.
242    ///
243    /// This property adds margin outside of the widget's normal size
244    /// request, the margin will be added in addition to the size from
245    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
246    ///
247    /// Readable | Writable
248    ///
249    ///
250    /// #### `margin-start`
251    ///  Margin on start of widget, horizontally.
252    ///
253    /// This property supports left-to-right and right-to-left text
254    /// directions.
255    ///
256    /// This property adds margin outside of the widget's normal size
257    /// request, the margin will be added in addition to the size from
258    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
259    ///
260    /// Readable | Writable
261    ///
262    ///
263    /// #### `margin-top`
264    ///  Margin on top side of widget.
265    ///
266    /// This property adds margin outside of the widget's normal size
267    /// request, the margin will be added in addition to the size from
268    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
269    ///
270    /// Readable | Writable
271    ///
272    ///
273    /// #### `name`
274    ///  The name of the widget.
275    ///
276    /// Readable | Writable
277    ///
278    ///
279    /// #### `opacity`
280    ///  The requested opacity of the widget.
281    ///
282    /// Readable | Writable
283    ///
284    ///
285    /// #### `overflow`
286    ///  How content outside the widget's content area is treated.
287    ///
288    /// This property is meant to be set by widget implementations,
289    /// typically in their instance init function.
290    ///
291    /// Readable | Writable
292    ///
293    ///
294    /// #### `parent`
295    ///  The parent widget of this widget.
296    ///
297    /// Readable
298    ///
299    ///
300    /// #### `receives-default`
301    ///  Whether the widget will receive the default action when it is focused.
302    ///
303    /// Readable | Writable
304    ///
305    ///
306    /// #### `root`
307    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
308    ///
309    /// This will be `NULL` if the widget is not contained in a root widget.
310    ///
311    /// Readable
312    ///
313    ///
314    /// #### `scale-factor`
315    ///  The scale factor of the widget.
316    ///
317    /// Readable
318    ///
319    ///
320    /// #### `sensitive`
321    ///  Whether the widget responds to input.
322    ///
323    /// Readable | Writable
324    ///
325    ///
326    /// #### `tooltip-markup`
327    ///  Sets the text of tooltip to be the given string, which is marked up
328    /// with Pango markup.
329    ///
330    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
331    ///
332    /// This is a convenience property which will take care of getting the
333    /// tooltip shown if the given string is not `NULL`:
334    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
335    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
336    /// the default signal handler.
337    ///
338    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
339    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
340    ///
341    /// Readable | Writable
342    ///
343    ///
344    /// #### `tooltip-text`
345    ///  Sets the text of tooltip to be the given string.
346    ///
347    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
348    ///
349    /// This is a convenience property which will take care of getting the
350    /// tooltip shown if the given string is not `NULL`:
351    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
352    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
353    /// the default signal handler.
354    ///
355    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
356    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
357    ///
358    /// Readable | Writable
359    ///
360    ///
361    /// #### `valign`
362    ///  How to distribute vertical space if widget gets extra space.
363    ///
364    /// Readable | Writable
365    ///
366    ///
367    /// #### `vexpand`
368    ///  Whether to expand vertically.
369    ///
370    /// Readable | Writable
371    ///
372    ///
373    /// #### `vexpand-set`
374    ///  Whether to use the `vexpand` property.
375    ///
376    /// Readable | Writable
377    ///
378    ///
379    /// #### `visible`
380    ///  Whether the widget is visible.
381    ///
382    /// Readable | Writable
383    ///
384    ///
385    /// #### `width-request`
386    ///  Overrides for width request of the widget.
387    ///
388    /// If this is -1, the natural request will be used.
389    ///
390    /// Readable | Writable
391    /// </details>
392    /// <details><summary><h4>Accessible</h4></summary>
393    ///
394    ///
395    /// #### `accessible-role`
396    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
397    ///
398    /// The accessible role cannot be changed once set.
399    ///
400    /// Readable | Writable
401    /// </details>
402    /// <details><summary><h4>Orientable</h4></summary>
403    ///
404    ///
405    /// #### `orientation`
406    ///  The orientation of the orientable.
407    ///
408    /// Readable | Writable
409    /// </details>
410    ///
411    /// # Implements
412    ///
413    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`CellLayoutExt`][trait@crate::prelude::CellLayoutExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual], [`CellLayoutExtManual`][trait@crate::prelude::CellLayoutExtManual]
414    #[doc(alias = "GtkCellView")]
415    pub struct CellView(Object<ffi::GtkCellView>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, CellLayout, Orientable;
416
417    match fn {
418        type_ => || ffi::gtk_cell_view_get_type(),
419    }
420}
421
422#[cfg(not(feature = "v4_10"))]
423glib::wrapper! {
424    #[doc(alias = "GtkCellView")]
425    pub struct CellView(Object<ffi::GtkCellView>) @extends Widget, @implements Buildable, ConstraintTarget, CellLayout, Orientable;
426
427    match fn {
428        type_ => || ffi::gtk_cell_view_get_type(),
429    }
430}
431
432impl CellView {
433    /// Creates a new [`CellView`][crate::CellView] widget.
434    ///
435    /// # Deprecated since 4.10
436    ///
437    ///
438    /// # Returns
439    ///
440    /// A newly created [`CellView`][crate::CellView] widget.
441    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
442    #[allow(deprecated)]
443    #[doc(alias = "gtk_cell_view_new")]
444    pub fn new() -> CellView {
445        assert_initialized_main_thread!();
446        unsafe { Widget::from_glib_none(ffi::gtk_cell_view_new()).unsafe_cast() }
447    }
448
449    /// Creates a new [`CellView`][crate::CellView] widget with a specific [`CellArea`][crate::CellArea]
450    /// to layout cells and a specific [`CellAreaContext`][crate::CellAreaContext].
451    ///
452    /// Specifying the same context for a handful of cells lets
453    /// the underlying area synchronize the geometry for those cells,
454    /// in this way alignments with cellviews for other rows are
455    /// possible.
456    ///
457    /// # Deprecated since 4.10
458    ///
459    /// ## `area`
460    /// the [`CellArea`][crate::CellArea] to layout cells
461    /// ## `context`
462    /// the [`CellAreaContext`][crate::CellAreaContext] in which to calculate cell geometry
463    ///
464    /// # Returns
465    ///
466    /// A newly created [`CellView`][crate::CellView] widget.
467    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
468    #[allow(deprecated)]
469    #[doc(alias = "gtk_cell_view_new_with_context")]
470    #[doc(alias = "new_with_context")]
471    pub fn with_context(
472        area: &impl IsA<CellArea>,
473        context: &impl IsA<CellAreaContext>,
474    ) -> CellView {
475        skip_assert_initialized!();
476        unsafe {
477            Widget::from_glib_none(ffi::gtk_cell_view_new_with_context(
478                area.as_ref().to_glib_none().0,
479                context.as_ref().to_glib_none().0,
480            ))
481            .unsafe_cast()
482        }
483    }
484
485    /// Creates a new [`CellView`][crate::CellView] widget, adds a [`CellRendererText`][crate::CellRendererText]
486    /// to it, and makes it show @markup. The text can be marked up with
487    /// the [Pango text markup language](https://docs.gtk.org/Pango/pango_markup.html).
488    ///
489    /// # Deprecated since 4.10
490    ///
491    /// ## `markup`
492    /// the text to display in the cell view
493    ///
494    /// # Returns
495    ///
496    /// A newly created [`CellView`][crate::CellView] widget.
497    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
498    #[allow(deprecated)]
499    #[doc(alias = "gtk_cell_view_new_with_markup")]
500    #[doc(alias = "new_with_markup")]
501    pub fn with_markup(markup: &str) -> CellView {
502        assert_initialized_main_thread!();
503        unsafe {
504            Widget::from_glib_none(ffi::gtk_cell_view_new_with_markup(markup.to_glib_none().0))
505                .unsafe_cast()
506        }
507    }
508
509    /// Creates a new [`CellView`][crate::CellView] widget, adds a [`CellRendererText`][crate::CellRendererText]
510    /// to it, and makes it show @text.
511    ///
512    /// # Deprecated since 4.10
513    ///
514    /// ## `text`
515    /// the text to display in the cell view
516    ///
517    /// # Returns
518    ///
519    /// A newly created [`CellView`][crate::CellView] widget.
520    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
521    #[allow(deprecated)]
522    #[doc(alias = "gtk_cell_view_new_with_text")]
523    #[doc(alias = "new_with_text")]
524    pub fn with_text(text: &str) -> CellView {
525        assert_initialized_main_thread!();
526        unsafe {
527            Widget::from_glib_none(ffi::gtk_cell_view_new_with_text(text.to_glib_none().0))
528                .unsafe_cast()
529        }
530    }
531
532    /// Creates a new [`CellView`][crate::CellView] widget, adds a [`CellRendererPixbuf`][crate::CellRendererPixbuf]
533    /// to it, and makes it show @texture.
534    ///
535    /// # Deprecated since 4.10
536    ///
537    /// ## `texture`
538    /// the image to display in the cell view
539    ///
540    /// # Returns
541    ///
542    /// A newly created [`CellView`][crate::CellView] widget.
543    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
544    #[allow(deprecated)]
545    #[doc(alias = "gtk_cell_view_new_with_texture")]
546    #[doc(alias = "new_with_texture")]
547    pub fn with_texture(texture: &impl IsA<gdk::Texture>) -> CellView {
548        assert_initialized_main_thread!();
549        unsafe {
550            Widget::from_glib_none(ffi::gtk_cell_view_new_with_texture(
551                texture.as_ref().to_glib_none().0,
552            ))
553            .unsafe_cast()
554        }
555    }
556
557    // rustdoc-stripper-ignore-next
558    /// Creates a new builder-pattern struct instance to construct [`CellView`] objects.
559    ///
560    /// This method returns an instance of [`CellViewBuilder`](crate::builders::CellViewBuilder) which can be used to create [`CellView`] objects.
561    pub fn builder() -> CellViewBuilder {
562        CellViewBuilder::new()
563    }
564
565    /// Returns a [`TreePath`][crate::TreePath] referring to the currently
566    /// displayed row. If no row is currently displayed,
567    /// [`None`] is returned.
568    ///
569    /// # Deprecated since 4.10
570    ///
571    ///
572    /// # Returns
573    ///
574    /// the currently displayed row
575    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
576    #[allow(deprecated)]
577    #[doc(alias = "gtk_cell_view_get_displayed_row")]
578    #[doc(alias = "get_displayed_row")]
579    pub fn displayed_row(&self) -> Option<TreePath> {
580        unsafe { from_glib_full(ffi::gtk_cell_view_get_displayed_row(self.to_glib_none().0)) }
581    }
582
583    /// Gets whether @self is configured to draw all of its
584    /// cells in a sensitive state.
585    ///
586    /// # Deprecated since 4.10
587    ///
588    ///
589    /// # Returns
590    ///
591    /// whether @self draws all of its
592    /// cells in a sensitive state
593    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
594    #[allow(deprecated)]
595    #[doc(alias = "gtk_cell_view_get_draw_sensitive")]
596    #[doc(alias = "get_draw_sensitive")]
597    #[doc(alias = "draw-sensitive")]
598    pub fn draws_sensitive(&self) -> bool {
599        unsafe { from_glib(ffi::gtk_cell_view_get_draw_sensitive(self.to_glib_none().0)) }
600    }
601
602    /// Gets whether @self is configured to request space
603    /// to fit the entire [`TreeModel`][crate::TreeModel].
604    ///
605    /// # Deprecated since 4.10
606    ///
607    ///
608    /// # Returns
609    ///
610    /// whether @self requests space to fit
611    /// the entire [`TreeModel`][crate::TreeModel].
612    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
613    #[allow(deprecated)]
614    #[doc(alias = "gtk_cell_view_get_fit_model")]
615    #[doc(alias = "get_fit_model")]
616    #[doc(alias = "fit-model")]
617    pub fn fits_model(&self) -> bool {
618        unsafe { from_glib(ffi::gtk_cell_view_get_fit_model(self.to_glib_none().0)) }
619    }
620
621    /// Returns the model for @self. If no model is used [`None`] is
622    /// returned.
623    ///
624    /// # Deprecated since 4.10
625    ///
626    ///
627    /// # Returns
628    ///
629    /// a [`TreeModel`][crate::TreeModel] used
630    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
631    #[allow(deprecated)]
632    #[doc(alias = "gtk_cell_view_get_model")]
633    #[doc(alias = "get_model")]
634    pub fn model(&self) -> Option<TreeModel> {
635        unsafe { from_glib_none(ffi::gtk_cell_view_get_model(self.to_glib_none().0)) }
636    }
637
638    ///  at their last value;
639    /// this is not normally a desired result, but may be
640    /// a needed intermediate state if say, the model for
641    /// the [`CellView`][crate::CellView] becomes temporarily empty.
642    ///
643    /// # Deprecated since 4.10
644    ///
645    /// ## `path`
646    /// a [`TreePath`][crate::TreePath] or [`None`] to unset.
647    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
648    #[allow(deprecated)]
649    #[doc(alias = "gtk_cell_view_set_displayed_row")]
650    pub fn set_displayed_row(&self, path: Option<&TreePath>) {
651        unsafe {
652            ffi::gtk_cell_view_set_displayed_row(
653                self.to_glib_none().0,
654                mut_override(path.to_glib_none().0),
655            );
656        }
657    }
658
659    /// Sets whether @self should draw all of its
660    /// cells in a sensitive state, this is used by [`ComboBox`][crate::ComboBox] menus
661    /// to ensure that rows with insensitive cells that contain
662    /// children appear sensitive in the parent menu item.
663    ///
664    /// # Deprecated since 4.10
665    ///
666    /// ## `draw_sensitive`
667    /// whether to draw all cells in a sensitive state.
668    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
669    #[allow(deprecated)]
670    #[doc(alias = "gtk_cell_view_set_draw_sensitive")]
671    #[doc(alias = "draw-sensitive")]
672    pub fn set_draw_sensitive(&self, draw_sensitive: bool) {
673        unsafe {
674            ffi::gtk_cell_view_set_draw_sensitive(
675                self.to_glib_none().0,
676                draw_sensitive.into_glib(),
677            );
678        }
679    }
680
681    /// s button always gets enough space and does not resize
682    /// when selection changes.
683    ///
684    /// # Deprecated since 4.10
685    ///
686    /// ## `fit_model`
687    /// whether @self should request space for the whole model.
688    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
689    #[allow(deprecated)]
690    #[doc(alias = "gtk_cell_view_set_fit_model")]
691    #[doc(alias = "fit-model")]
692    pub fn set_fit_model(&self, fit_model: bool) {
693        unsafe {
694            ffi::gtk_cell_view_set_fit_model(self.to_glib_none().0, fit_model.into_glib());
695        }
696    }
697
698    /// Sets the model for @self.  If @self already has a model
699    /// set, it will remove it before setting the new model.  If @model is
700    /// [`None`], then it will unset the old model.
701    ///
702    /// # Deprecated since 4.10
703    ///
704    /// ## `model`
705    /// a [`TreeModel`][crate::TreeModel]
706    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
707    #[allow(deprecated)]
708    #[doc(alias = "gtk_cell_view_set_model")]
709    #[doc(alias = "model")]
710    pub fn set_model(&self, model: Option<&impl IsA<TreeModel>>) {
711        unsafe {
712            ffi::gtk_cell_view_set_model(
713                self.to_glib_none().0,
714                model.map(|p| p.as_ref()).to_glib_none().0,
715            );
716        }
717    }
718
719    /// The [`CellArea`][crate::CellArea] rendering cells
720    ///
721    /// If no area is specified when creating the cell view with gtk_cell_view_new_with_context()
722    /// a horizontally oriented [`CellArea`][crate::CellArea]Box will be used.
723    ///
724    /// since 3.0
725    #[doc(alias = "cell-area")]
726    pub fn cell_area(&self) -> Option<CellArea> {
727        ObjectExt::property(self, "cell-area")
728    }
729
730    /// The [`CellAreaContext`][crate::CellAreaContext] used to compute the geometry of the cell view.
731    ///
732    /// A group of cell views can be assigned the same context in order to
733    /// ensure the sizes and cell alignments match across all the views with
734    /// the same context.
735    ///
736    /// [`ComboBox`][crate::ComboBox] menus uses this to assign the same context to all cell views
737    /// in the menu items for a single menu (each submenu creates its own
738    /// context since the size of each submenu does not depend on parent
739    /// or sibling menus).
740    ///
741    /// since 3.0
742    #[doc(alias = "cell-area-context")]
743    pub fn cell_area_context(&self) -> Option<CellAreaContext> {
744        ObjectExt::property(self, "cell-area-context")
745    }
746
747    #[doc(alias = "draw-sensitive")]
748    pub fn connect_draw_sensitive_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
749        unsafe extern "C" fn notify_draw_sensitive_trampoline<F: Fn(&CellView) + 'static>(
750            this: *mut ffi::GtkCellView,
751            _param_spec: glib::ffi::gpointer,
752            f: glib::ffi::gpointer,
753        ) {
754            unsafe {
755                let f: &F = &*(f as *const F);
756                f(&from_glib_borrow(this))
757            }
758        }
759        unsafe {
760            let f: Box_<F> = Box_::new(f);
761            connect_raw(
762                self.as_ptr() as *mut _,
763                c"notify::draw-sensitive".as_ptr(),
764                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
765                    notify_draw_sensitive_trampoline::<F> as *const (),
766                )),
767                Box_::into_raw(f),
768            )
769        }
770    }
771
772    #[doc(alias = "fit-model")]
773    pub fn connect_fit_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
774        unsafe extern "C" fn notify_fit_model_trampoline<F: Fn(&CellView) + 'static>(
775            this: *mut ffi::GtkCellView,
776            _param_spec: glib::ffi::gpointer,
777            f: glib::ffi::gpointer,
778        ) {
779            unsafe {
780                let f: &F = &*(f as *const F);
781                f(&from_glib_borrow(this))
782            }
783        }
784        unsafe {
785            let f: Box_<F> = Box_::new(f);
786            connect_raw(
787                self.as_ptr() as *mut _,
788                c"notify::fit-model".as_ptr(),
789                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
790                    notify_fit_model_trampoline::<F> as *const (),
791                )),
792                Box_::into_raw(f),
793            )
794        }
795    }
796
797    #[doc(alias = "model")]
798    pub fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
799        unsafe extern "C" fn notify_model_trampoline<F: Fn(&CellView) + 'static>(
800            this: *mut ffi::GtkCellView,
801            _param_spec: glib::ffi::gpointer,
802            f: glib::ffi::gpointer,
803        ) {
804            unsafe {
805                let f: &F = &*(f as *const F);
806                f(&from_glib_borrow(this))
807            }
808        }
809        unsafe {
810            let f: Box_<F> = Box_::new(f);
811            connect_raw(
812                self.as_ptr() as *mut _,
813                c"notify::model".as_ptr(),
814                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
815                    notify_model_trampoline::<F> as *const (),
816                )),
817                Box_::into_raw(f),
818            )
819        }
820    }
821}
822
823impl Default for CellView {
824    fn default() -> Self {
825        Self::new()
826    }
827}
828
829// rustdoc-stripper-ignore-next
830/// A [builder-pattern] type to construct [`CellView`] objects.
831///
832/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
833#[must_use = "The builder must be built to be used"]
834pub struct CellViewBuilder {
835    builder: glib::object::ObjectBuilder<'static, CellView>,
836}
837
838impl CellViewBuilder {
839    fn new() -> Self {
840        Self {
841            builder: glib::object::Object::builder(),
842        }
843    }
844
845    /// The [`CellArea`][crate::CellArea] rendering cells
846    ///
847    /// If no area is specified when creating the cell view with gtk_cell_view_new_with_context()
848    /// a horizontally oriented [`CellArea`][crate::CellArea]Box will be used.
849    ///
850    /// since 3.0
851    pub fn cell_area(self, cell_area: &impl IsA<CellArea>) -> Self {
852        Self {
853            builder: self
854                .builder
855                .property("cell-area", cell_area.clone().upcast()),
856        }
857    }
858
859    /// The [`CellAreaContext`][crate::CellAreaContext] used to compute the geometry of the cell view.
860    ///
861    /// A group of cell views can be assigned the same context in order to
862    /// ensure the sizes and cell alignments match across all the views with
863    /// the same context.
864    ///
865    /// [`ComboBox`][crate::ComboBox] menus uses this to assign the same context to all cell views
866    /// in the menu items for a single menu (each submenu creates its own
867    /// context since the size of each submenu does not depend on parent
868    /// or sibling menus).
869    ///
870    /// since 3.0
871    pub fn cell_area_context(self, cell_area_context: &impl IsA<CellAreaContext>) -> Self {
872        Self {
873            builder: self
874                .builder
875                .property("cell-area-context", cell_area_context.clone().upcast()),
876        }
877    }
878
879    /// Whether all cells should be draw as sensitive for this view regardless
880    /// of the actual cell properties (used to make menus with submenus appear
881    /// sensitive when the items in submenus might be insensitive).
882    ///
883    /// since 3.0
884    pub fn draw_sensitive(self, draw_sensitive: bool) -> Self {
885        Self {
886            builder: self.builder.property("draw-sensitive", draw_sensitive),
887        }
888    }
889
890    /// Whether the view should request enough space to always fit
891    /// the size of every row in the model (used by the combo box to
892    /// ensure the combo box size doesn't change when different items
893    /// are selected).
894    ///
895    /// since 3.0
896    pub fn fit_model(self, fit_model: bool) -> Self {
897        Self {
898            builder: self.builder.property("fit-model", fit_model),
899        }
900    }
901
902    /// The model for cell view
903    ///
904    /// since 2.10
905    pub fn model(self, model: &impl IsA<TreeModel>) -> Self {
906        Self {
907            builder: self.builder.property("model", model.clone().upcast()),
908        }
909    }
910
911    /// Whether the widget or any of its descendents can accept
912    /// the input focus.
913    ///
914    /// This property is meant to be set by widget implementations,
915    /// typically in their instance init function.
916    pub fn can_focus(self, can_focus: bool) -> Self {
917        Self {
918            builder: self.builder.property("can-focus", can_focus),
919        }
920    }
921
922    /// Whether the widget can receive pointer events.
923    pub fn can_target(self, can_target: bool) -> Self {
924        Self {
925            builder: self.builder.property("can-target", can_target),
926        }
927    }
928
929    /// A list of css classes applied to this widget.
930    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
931        Self {
932            builder: self.builder.property("css-classes", css_classes.into()),
933        }
934    }
935
936    /// The name of this widget in the CSS tree.
937    ///
938    /// This property is meant to be set by widget implementations,
939    /// typically in their instance init function.
940    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
941        Self {
942            builder: self.builder.property("css-name", css_name.into()),
943        }
944    }
945
946    /// The cursor used by @widget.
947    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
948        Self {
949            builder: self.builder.property("cursor", cursor.clone()),
950        }
951    }
952
953    /// Whether the widget should grab focus when it is clicked with the mouse.
954    ///
955    /// This property is only relevant for widgets that can take focus.
956    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
957        Self {
958            builder: self.builder.property("focus-on-click", focus_on_click),
959        }
960    }
961
962    /// Whether this widget itself will accept the input focus.
963    pub fn focusable(self, focusable: bool) -> Self {
964        Self {
965            builder: self.builder.property("focusable", focusable),
966        }
967    }
968
969    /// How to distribute horizontal space if widget gets extra space.
970    pub fn halign(self, halign: Align) -> Self {
971        Self {
972            builder: self.builder.property("halign", halign),
973        }
974    }
975
976    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
977    /// signal on @widget.
978    ///
979    /// A true value indicates that @widget can have a tooltip, in this case
980    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
981    /// determine whether it will provide a tooltip or not.
982    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
983        Self {
984            builder: self.builder.property("has-tooltip", has_tooltip),
985        }
986    }
987
988    /// Overrides for height request of the widget.
989    ///
990    /// If this is -1, the natural request will be used.
991    pub fn height_request(self, height_request: i32) -> Self {
992        Self {
993            builder: self.builder.property("height-request", height_request),
994        }
995    }
996
997    /// Whether to expand horizontally.
998    pub fn hexpand(self, hexpand: bool) -> Self {
999        Self {
1000            builder: self.builder.property("hexpand", hexpand),
1001        }
1002    }
1003
1004    /// Whether to use the `hexpand` property.
1005    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1006        Self {
1007            builder: self.builder.property("hexpand-set", hexpand_set),
1008        }
1009    }
1010
1011    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1012    /// the preferred size of the widget, and allocate its children.
1013    ///
1014    /// This property is meant to be set by widget implementations,
1015    /// typically in their instance init function.
1016    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1017        Self {
1018            builder: self
1019                .builder
1020                .property("layout-manager", layout_manager.clone().upcast()),
1021        }
1022    }
1023
1024    /// Makes this widget act like a modal dialog, with respect to
1025    /// event delivery.
1026    ///
1027    /// Global event controllers will not handle events with targets
1028    /// inside the widget, unless they are set up to ignore propagation
1029    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1030    #[cfg(feature = "v4_18")]
1031    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1032    pub fn limit_events(self, limit_events: bool) -> Self {
1033        Self {
1034            builder: self.builder.property("limit-events", limit_events),
1035        }
1036    }
1037
1038    /// Margin on bottom side of widget.
1039    ///
1040    /// This property adds margin outside of the widget's normal size
1041    /// request, the margin will be added in addition to the size from
1042    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1043    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1044        Self {
1045            builder: self.builder.property("margin-bottom", margin_bottom),
1046        }
1047    }
1048
1049    /// Margin on end of widget, horizontally.
1050    ///
1051    /// This property supports left-to-right and right-to-left text
1052    /// directions.
1053    ///
1054    /// This property adds margin outside of the widget's normal size
1055    /// request, the margin will be added in addition to the size from
1056    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1057    pub fn margin_end(self, margin_end: i32) -> Self {
1058        Self {
1059            builder: self.builder.property("margin-end", margin_end),
1060        }
1061    }
1062
1063    /// Margin on start of widget, horizontally.
1064    ///
1065    /// This property supports left-to-right and right-to-left text
1066    /// directions.
1067    ///
1068    /// This property adds margin outside of the widget's normal size
1069    /// request, the margin will be added in addition to the size from
1070    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1071    pub fn margin_start(self, margin_start: i32) -> Self {
1072        Self {
1073            builder: self.builder.property("margin-start", margin_start),
1074        }
1075    }
1076
1077    /// Margin on top side of widget.
1078    ///
1079    /// This property adds margin outside of the widget's normal size
1080    /// request, the margin will be added in addition to the size from
1081    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1082    pub fn margin_top(self, margin_top: i32) -> Self {
1083        Self {
1084            builder: self.builder.property("margin-top", margin_top),
1085        }
1086    }
1087
1088    /// The name of the widget.
1089    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1090        Self {
1091            builder: self.builder.property("name", name.into()),
1092        }
1093    }
1094
1095    /// The requested opacity of the widget.
1096    pub fn opacity(self, opacity: f64) -> Self {
1097        Self {
1098            builder: self.builder.property("opacity", opacity),
1099        }
1100    }
1101
1102    /// How content outside the widget's content area is treated.
1103    ///
1104    /// This property is meant to be set by widget implementations,
1105    /// typically in their instance init function.
1106    pub fn overflow(self, overflow: Overflow) -> Self {
1107        Self {
1108            builder: self.builder.property("overflow", overflow),
1109        }
1110    }
1111
1112    /// Whether the widget will receive the default action when it is focused.
1113    pub fn receives_default(self, receives_default: bool) -> Self {
1114        Self {
1115            builder: self.builder.property("receives-default", receives_default),
1116        }
1117    }
1118
1119    /// Whether the widget responds to input.
1120    pub fn sensitive(self, sensitive: bool) -> Self {
1121        Self {
1122            builder: self.builder.property("sensitive", sensitive),
1123        }
1124    }
1125
1126    /// Sets the text of tooltip to be the given string, which is marked up
1127    /// with Pango markup.
1128    ///
1129    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1130    ///
1131    /// This is a convenience property which will take care of getting the
1132    /// tooltip shown if the given string is not `NULL`:
1133    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1134    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1135    /// the default signal handler.
1136    ///
1137    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1138    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1139    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1140        Self {
1141            builder: self
1142                .builder
1143                .property("tooltip-markup", tooltip_markup.into()),
1144        }
1145    }
1146
1147    /// Sets the text of tooltip to be the given string.
1148    ///
1149    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1150    ///
1151    /// This is a convenience property which will take care of getting the
1152    /// tooltip shown if the given string is not `NULL`:
1153    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1154    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1155    /// the default signal handler.
1156    ///
1157    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1158    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1159    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1160        Self {
1161            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1162        }
1163    }
1164
1165    /// How to distribute vertical space if widget gets extra space.
1166    pub fn valign(self, valign: Align) -> Self {
1167        Self {
1168            builder: self.builder.property("valign", valign),
1169        }
1170    }
1171
1172    /// Whether to expand vertically.
1173    pub fn vexpand(self, vexpand: bool) -> Self {
1174        Self {
1175            builder: self.builder.property("vexpand", vexpand),
1176        }
1177    }
1178
1179    /// Whether to use the `vexpand` property.
1180    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1181        Self {
1182            builder: self.builder.property("vexpand-set", vexpand_set),
1183        }
1184    }
1185
1186    /// Whether the widget is visible.
1187    pub fn visible(self, visible: bool) -> Self {
1188        Self {
1189            builder: self.builder.property("visible", visible),
1190        }
1191    }
1192
1193    /// Overrides for width request of the widget.
1194    ///
1195    /// If this is -1, the natural request will be used.
1196    pub fn width_request(self, width_request: i32) -> Self {
1197        Self {
1198            builder: self.builder.property("width-request", width_request),
1199        }
1200    }
1201
1202    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1203    ///
1204    /// The accessible role cannot be changed once set.
1205    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1206        Self {
1207            builder: self.builder.property("accessible-role", accessible_role),
1208        }
1209    }
1210
1211    /// The orientation of the orientable.
1212    pub fn orientation(self, orientation: Orientation) -> Self {
1213        Self {
1214            builder: self.builder.property("orientation", orientation),
1215        }
1216    }
1217
1218    // rustdoc-stripper-ignore-next
1219    /// Build the [`CellView`].
1220    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1221    pub fn build(self) -> CellView {
1222        assert_initialized_main_thread!();
1223        self.builder.build()
1224    }
1225}