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