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    /// Sets the row of the model that is currently displayed
639    /// by the [`CellView`][crate::CellView]. If the path is unset, then the
640    /// contents of the cellview “stick” at their last value;
641    /// this is not normally a desired result, but may be
642    /// a needed intermediate state if say, the model for
643    /// the [`CellView`][crate::CellView] becomes temporarily empty.
644    ///
645    /// # Deprecated since 4.10
646    ///
647    /// ## `path`
648    /// a [`TreePath`][crate::TreePath] or [`None`] to unset.
649    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
650    #[allow(deprecated)]
651    #[doc(alias = "gtk_cell_view_set_displayed_row")]
652    pub fn set_displayed_row(&self, path: Option<&TreePath>) {
653        unsafe {
654            ffi::gtk_cell_view_set_displayed_row(
655                self.to_glib_none().0,
656                mut_override(path.to_glib_none().0),
657            );
658        }
659    }
660
661    /// Sets whether @self should draw all of its
662    /// cells in a sensitive state, this is used by [`ComboBox`][crate::ComboBox] menus
663    /// to ensure that rows with insensitive cells that contain
664    /// children appear sensitive in the parent menu item.
665    ///
666    /// # Deprecated since 4.10
667    ///
668    /// ## `draw_sensitive`
669    /// whether to draw all cells in a sensitive state.
670    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
671    #[allow(deprecated)]
672    #[doc(alias = "gtk_cell_view_set_draw_sensitive")]
673    #[doc(alias = "draw-sensitive")]
674    pub fn set_draw_sensitive(&self, draw_sensitive: bool) {
675        unsafe {
676            ffi::gtk_cell_view_set_draw_sensitive(
677                self.to_glib_none().0,
678                draw_sensitive.into_glib(),
679            );
680        }
681    }
682
683    /// Sets whether @self should request space to fit the entire [`TreeModel`][crate::TreeModel].
684    ///
685    /// This is used by [`ComboBox`][crate::ComboBox] to ensure that the cell view displayed on
686    /// the combo box’s button always gets enough space and does not resize
687    /// when selection changes.
688    ///
689    /// # Deprecated since 4.10
690    ///
691    /// ## `fit_model`
692    /// whether @self should request space for the whole model.
693    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
694    #[allow(deprecated)]
695    #[doc(alias = "gtk_cell_view_set_fit_model")]
696    #[doc(alias = "fit-model")]
697    pub fn set_fit_model(&self, fit_model: bool) {
698        unsafe {
699            ffi::gtk_cell_view_set_fit_model(self.to_glib_none().0, fit_model.into_glib());
700        }
701    }
702
703    /// Sets the model for @self.  If @self already has a model
704    /// set, it will remove it before setting the new model.  If @model is
705    /// [`None`], then it will unset the old model.
706    ///
707    /// # Deprecated since 4.10
708    ///
709    /// ## `model`
710    /// a [`TreeModel`][crate::TreeModel]
711    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
712    #[allow(deprecated)]
713    #[doc(alias = "gtk_cell_view_set_model")]
714    #[doc(alias = "model")]
715    pub fn set_model(&self, model: Option<&impl IsA<TreeModel>>) {
716        unsafe {
717            ffi::gtk_cell_view_set_model(
718                self.to_glib_none().0,
719                model.map(|p| p.as_ref()).to_glib_none().0,
720            );
721        }
722    }
723
724    /// The [`CellArea`][crate::CellArea] rendering cells
725    ///
726    /// If no area is specified when creating the cell view with gtk_cell_view_new_with_context()
727    /// a horizontally oriented [`CellArea`][crate::CellArea]Box will be used.
728    ///
729    /// since 3.0
730    #[doc(alias = "cell-area")]
731    pub fn cell_area(&self) -> Option<CellArea> {
732        ObjectExt::property(self, "cell-area")
733    }
734
735    /// The [`CellAreaContext`][crate::CellAreaContext] used to compute the geometry of the cell view.
736    ///
737    /// A group of cell views can be assigned the same context in order to
738    /// ensure the sizes and cell alignments match across all the views with
739    /// the same context.
740    ///
741    /// [`ComboBox`][crate::ComboBox] menus uses this to assign the same context to all cell views
742    /// in the menu items for a single menu (each submenu creates its own
743    /// context since the size of each submenu does not depend on parent
744    /// or sibling menus).
745    ///
746    /// since 3.0
747    #[doc(alias = "cell-area-context")]
748    pub fn cell_area_context(&self) -> Option<CellAreaContext> {
749        ObjectExt::property(self, "cell-area-context")
750    }
751
752    #[doc(alias = "draw-sensitive")]
753    pub fn connect_draw_sensitive_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
754        unsafe extern "C" fn notify_draw_sensitive_trampoline<F: Fn(&CellView) + 'static>(
755            this: *mut ffi::GtkCellView,
756            _param_spec: glib::ffi::gpointer,
757            f: glib::ffi::gpointer,
758        ) {
759            unsafe {
760                let f: &F = &*(f as *const F);
761                f(&from_glib_borrow(this))
762            }
763        }
764        unsafe {
765            let f: Box_<F> = Box_::new(f);
766            connect_raw(
767                self.as_ptr() as *mut _,
768                c"notify::draw-sensitive".as_ptr(),
769                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
770                    notify_draw_sensitive_trampoline::<F> as *const (),
771                )),
772                Box_::into_raw(f),
773            )
774        }
775    }
776
777    #[doc(alias = "fit-model")]
778    pub fn connect_fit_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
779        unsafe extern "C" fn notify_fit_model_trampoline<F: Fn(&CellView) + 'static>(
780            this: *mut ffi::GtkCellView,
781            _param_spec: glib::ffi::gpointer,
782            f: glib::ffi::gpointer,
783        ) {
784            unsafe {
785                let f: &F = &*(f as *const F);
786                f(&from_glib_borrow(this))
787            }
788        }
789        unsafe {
790            let f: Box_<F> = Box_::new(f);
791            connect_raw(
792                self.as_ptr() as *mut _,
793                c"notify::fit-model".as_ptr(),
794                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
795                    notify_fit_model_trampoline::<F> as *const (),
796                )),
797                Box_::into_raw(f),
798            )
799        }
800    }
801
802    #[doc(alias = "model")]
803    pub fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
804        unsafe extern "C" fn notify_model_trampoline<F: Fn(&CellView) + 'static>(
805            this: *mut ffi::GtkCellView,
806            _param_spec: glib::ffi::gpointer,
807            f: glib::ffi::gpointer,
808        ) {
809            unsafe {
810                let f: &F = &*(f as *const F);
811                f(&from_glib_borrow(this))
812            }
813        }
814        unsafe {
815            let f: Box_<F> = Box_::new(f);
816            connect_raw(
817                self.as_ptr() as *mut _,
818                c"notify::model".as_ptr(),
819                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
820                    notify_model_trampoline::<F> as *const (),
821                )),
822                Box_::into_raw(f),
823            )
824        }
825    }
826}
827
828impl Default for CellView {
829    fn default() -> Self {
830        Self::new()
831    }
832}
833
834// rustdoc-stripper-ignore-next
835/// A [builder-pattern] type to construct [`CellView`] objects.
836///
837/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
838#[must_use = "The builder must be built to be used"]
839pub struct CellViewBuilder {
840    builder: glib::object::ObjectBuilder<'static, CellView>,
841}
842
843impl CellViewBuilder {
844    fn new() -> Self {
845        Self {
846            builder: glib::object::Object::builder(),
847        }
848    }
849
850    /// The [`CellArea`][crate::CellArea] rendering cells
851    ///
852    /// If no area is specified when creating the cell view with gtk_cell_view_new_with_context()
853    /// a horizontally oriented [`CellArea`][crate::CellArea]Box will be used.
854    ///
855    /// since 3.0
856    pub fn cell_area(self, cell_area: &impl IsA<CellArea>) -> Self {
857        Self {
858            builder: self
859                .builder
860                .property("cell-area", cell_area.clone().upcast()),
861        }
862    }
863
864    /// The [`CellAreaContext`][crate::CellAreaContext] used to compute the geometry of the cell view.
865    ///
866    /// A group of cell views can be assigned the same context in order to
867    /// ensure the sizes and cell alignments match across all the views with
868    /// the same context.
869    ///
870    /// [`ComboBox`][crate::ComboBox] menus uses this to assign the same context to all cell views
871    /// in the menu items for a single menu (each submenu creates its own
872    /// context since the size of each submenu does not depend on parent
873    /// or sibling menus).
874    ///
875    /// since 3.0
876    pub fn cell_area_context(self, cell_area_context: &impl IsA<CellAreaContext>) -> Self {
877        Self {
878            builder: self
879                .builder
880                .property("cell-area-context", cell_area_context.clone().upcast()),
881        }
882    }
883
884    /// Whether all cells should be draw as sensitive for this view regardless
885    /// of the actual cell properties (used to make menus with submenus appear
886    /// sensitive when the items in submenus might be insensitive).
887    ///
888    /// since 3.0
889    pub fn draw_sensitive(self, draw_sensitive: bool) -> Self {
890        Self {
891            builder: self.builder.property("draw-sensitive", draw_sensitive),
892        }
893    }
894
895    /// Whether the view should request enough space to always fit
896    /// the size of every row in the model (used by the combo box to
897    /// ensure the combo box size doesn't change when different items
898    /// are selected).
899    ///
900    /// since 3.0
901    pub fn fit_model(self, fit_model: bool) -> Self {
902        Self {
903            builder: self.builder.property("fit-model", fit_model),
904        }
905    }
906
907    /// The model for cell view
908    ///
909    /// since 2.10
910    pub fn model(self, model: &impl IsA<TreeModel>) -> Self {
911        Self {
912            builder: self.builder.property("model", model.clone().upcast()),
913        }
914    }
915
916    /// Whether the widget or any of its descendents can accept
917    /// the input focus.
918    ///
919    /// This property is meant to be set by widget implementations,
920    /// typically in their instance init function.
921    pub fn can_focus(self, can_focus: bool) -> Self {
922        Self {
923            builder: self.builder.property("can-focus", can_focus),
924        }
925    }
926
927    /// Whether the widget can receive pointer events.
928    pub fn can_target(self, can_target: bool) -> Self {
929        Self {
930            builder: self.builder.property("can-target", can_target),
931        }
932    }
933
934    /// A list of css classes applied to this widget.
935    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
936        Self {
937            builder: self.builder.property("css-classes", css_classes.into()),
938        }
939    }
940
941    /// The name of this widget in the CSS tree.
942    ///
943    /// This property is meant to be set by widget implementations,
944    /// typically in their instance init function.
945    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
946        Self {
947            builder: self.builder.property("css-name", css_name.into()),
948        }
949    }
950
951    /// The cursor used by @widget.
952    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
953        Self {
954            builder: self.builder.property("cursor", cursor.clone()),
955        }
956    }
957
958    /// Whether the widget should grab focus when it is clicked with the mouse.
959    ///
960    /// This property is only relevant for widgets that can take focus.
961    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
962        Self {
963            builder: self.builder.property("focus-on-click", focus_on_click),
964        }
965    }
966
967    /// Whether this widget itself will accept the input focus.
968    pub fn focusable(self, focusable: bool) -> Self {
969        Self {
970            builder: self.builder.property("focusable", focusable),
971        }
972    }
973
974    /// How to distribute horizontal space if widget gets extra space.
975    pub fn halign(self, halign: Align) -> Self {
976        Self {
977            builder: self.builder.property("halign", halign),
978        }
979    }
980
981    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
982    /// signal on @widget.
983    ///
984    /// A true value indicates that @widget can have a tooltip, in this case
985    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
986    /// determine whether it will provide a tooltip or not.
987    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
988        Self {
989            builder: self.builder.property("has-tooltip", has_tooltip),
990        }
991    }
992
993    /// Overrides for height request of the widget.
994    ///
995    /// If this is -1, the natural request will be used.
996    pub fn height_request(self, height_request: i32) -> Self {
997        Self {
998            builder: self.builder.property("height-request", height_request),
999        }
1000    }
1001
1002    /// Whether to expand horizontally.
1003    pub fn hexpand(self, hexpand: bool) -> Self {
1004        Self {
1005            builder: self.builder.property("hexpand", hexpand),
1006        }
1007    }
1008
1009    /// Whether to use the `hexpand` property.
1010    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1011        Self {
1012            builder: self.builder.property("hexpand-set", hexpand_set),
1013        }
1014    }
1015
1016    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1017    /// the preferred size of the widget, and allocate its children.
1018    ///
1019    /// This property is meant to be set by widget implementations,
1020    /// typically in their instance init function.
1021    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1022        Self {
1023            builder: self
1024                .builder
1025                .property("layout-manager", layout_manager.clone().upcast()),
1026        }
1027    }
1028
1029    /// Makes this widget act like a modal dialog, with respect to
1030    /// event delivery.
1031    ///
1032    /// Global event controllers will not handle events with targets
1033    /// inside the widget, unless they are set up to ignore propagation
1034    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1035    #[cfg(feature = "v4_18")]
1036    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1037    pub fn limit_events(self, limit_events: bool) -> Self {
1038        Self {
1039            builder: self.builder.property("limit-events", limit_events),
1040        }
1041    }
1042
1043    /// Margin on bottom side of widget.
1044    ///
1045    /// This property adds margin outside of the widget's normal size
1046    /// request, the margin will be added in addition to the size from
1047    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1048    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1049        Self {
1050            builder: self.builder.property("margin-bottom", margin_bottom),
1051        }
1052    }
1053
1054    /// Margin on end of widget, horizontally.
1055    ///
1056    /// This property supports left-to-right and right-to-left text
1057    /// directions.
1058    ///
1059    /// This property adds margin outside of the widget's normal size
1060    /// request, the margin will be added in addition to the size from
1061    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1062    pub fn margin_end(self, margin_end: i32) -> Self {
1063        Self {
1064            builder: self.builder.property("margin-end", margin_end),
1065        }
1066    }
1067
1068    /// Margin on start of widget, horizontally.
1069    ///
1070    /// This property supports left-to-right and right-to-left text
1071    /// directions.
1072    ///
1073    /// This property adds margin outside of the widget's normal size
1074    /// request, the margin will be added in addition to the size from
1075    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1076    pub fn margin_start(self, margin_start: i32) -> Self {
1077        Self {
1078            builder: self.builder.property("margin-start", margin_start),
1079        }
1080    }
1081
1082    /// Margin on top side of widget.
1083    ///
1084    /// This property adds margin outside of the widget's normal size
1085    /// request, the margin will be added in addition to the size from
1086    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1087    pub fn margin_top(self, margin_top: i32) -> Self {
1088        Self {
1089            builder: self.builder.property("margin-top", margin_top),
1090        }
1091    }
1092
1093    /// The name of the widget.
1094    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1095        Self {
1096            builder: self.builder.property("name", name.into()),
1097        }
1098    }
1099
1100    /// The requested opacity of the widget.
1101    pub fn opacity(self, opacity: f64) -> Self {
1102        Self {
1103            builder: self.builder.property("opacity", opacity),
1104        }
1105    }
1106
1107    /// How content outside the widget's content area is treated.
1108    ///
1109    /// This property is meant to be set by widget implementations,
1110    /// typically in their instance init function.
1111    pub fn overflow(self, overflow: Overflow) -> Self {
1112        Self {
1113            builder: self.builder.property("overflow", overflow),
1114        }
1115    }
1116
1117    /// Whether the widget will receive the default action when it is focused.
1118    pub fn receives_default(self, receives_default: bool) -> Self {
1119        Self {
1120            builder: self.builder.property("receives-default", receives_default),
1121        }
1122    }
1123
1124    /// Whether the widget responds to input.
1125    pub fn sensitive(self, sensitive: bool) -> Self {
1126        Self {
1127            builder: self.builder.property("sensitive", sensitive),
1128        }
1129    }
1130
1131    /// Sets the text of tooltip to be the given string, which is marked up
1132    /// with Pango markup.
1133    ///
1134    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
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_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1145        Self {
1146            builder: self
1147                .builder
1148                .property("tooltip-markup", tooltip_markup.into()),
1149        }
1150    }
1151
1152    /// Sets the text of tooltip to be the given string.
1153    ///
1154    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1155    ///
1156    /// This is a convenience property which will take care of getting the
1157    /// tooltip shown if the given string is not `NULL`:
1158    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1159    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1160    /// the default signal handler.
1161    ///
1162    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1163    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1164    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1165        Self {
1166            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1167        }
1168    }
1169
1170    /// How to distribute vertical space if widget gets extra space.
1171    pub fn valign(self, valign: Align) -> Self {
1172        Self {
1173            builder: self.builder.property("valign", valign),
1174        }
1175    }
1176
1177    /// Whether to expand vertically.
1178    pub fn vexpand(self, vexpand: bool) -> Self {
1179        Self {
1180            builder: self.builder.property("vexpand", vexpand),
1181        }
1182    }
1183
1184    /// Whether to use the `vexpand` property.
1185    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1186        Self {
1187            builder: self.builder.property("vexpand-set", vexpand_set),
1188        }
1189    }
1190
1191    /// Whether the widget is visible.
1192    pub fn visible(self, visible: bool) -> Self {
1193        Self {
1194            builder: self.builder.property("visible", visible),
1195        }
1196    }
1197
1198    /// Overrides for width request of the widget.
1199    ///
1200    /// If this is -1, the natural request will be used.
1201    pub fn width_request(self, width_request: i32) -> Self {
1202        Self {
1203            builder: self.builder.property("width-request", width_request),
1204        }
1205    }
1206
1207    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1208    ///
1209    /// The accessible role cannot be changed once set.
1210    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1211        Self {
1212            builder: self.builder.property("accessible-role", accessible_role),
1213        }
1214    }
1215
1216    /// The orientation of the orientable.
1217    pub fn orientation(self, orientation: Orientation) -> Self {
1218        Self {
1219            builder: self.builder.property("orientation", orientation),
1220        }
1221    }
1222
1223    // rustdoc-stripper-ignore-next
1224    /// Build the [`CellView`].
1225    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1226    pub fn build(self) -> CellView {
1227        assert_initialized_main_thread!();
1228        self.builder.build()
1229    }
1230}