Skip to main content

gtk4/auto/
grid_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
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::Accessible;
8use crate::{
9    AccessibleRole, Adjustment, Align, Buildable, ConstraintTarget, LayoutManager, ListBase,
10    ListItemFactory, Orientable, Orientation, Overflow, Scrollable, ScrollablePolicy,
11    SelectionModel, Widget, ffi,
12};
13#[cfg(feature = "v4_12")]
14#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
15use crate::{ListScrollFlags, ListTabBehavior, ScrollInfo};
16use glib::{
17    object::ObjectType as _,
18    prelude::*,
19    signal::{SignalHandlerId, connect_raw},
20    translate::*,
21};
22use std::boxed::Box as Box_;
23
24#[cfg(feature = "v4_10")]
25#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
26glib::wrapper! {
27    /// Presents a large dynamic grid of items.
28    ///
29    /// [`GridView`][crate::GridView] uses its factory to generate one child widget for each
30    /// visible item and shows them in a grid. The orientation of the grid view
31    /// determines if the grid reflows vertically or horizontally.
32    ///
33    /// Setting [`header-factory`][struct@crate::GridView#header-factory] displays section headers
34    /// supplied by the model's [`SectionModel`][crate::SectionModel] implementation. Each
35    /// section starts a new row and its header spans all columns. Headers scroll
36    /// with the items and do not participate in selection.
37    ///
38    /// [`GridView`][crate::GridView] allows the user to select items according to the selection
39    /// characteristics of the model. For models that allow multiple selected items,
40    /// it is possible to turn on _rubberband selection_, using
41    /// [`enable-rubberband`][struct@crate::GridView#enable-rubberband].
42    ///
43    /// To learn more about the list widget framework, see the
44    /// [overview](section-list-widget.html).
45    ///
46    /// # Actions
47    ///
48    /// [`GridView`][crate::GridView] defines a set of built-in actions:
49    ///
50    /// - `list.activate-item` activates the item at given position by emitting the
51    ///   the [`activate`][struct@crate::GridView#activate] signal.
52    ///
53    /// # CSS nodes
54    ///
55    /// ```text
56    /// gridview
57    /// ├── header
58    /// ├── child[.activatable]
59    /// │
60    /// ├── header
61    /// ├── child[.activatable]
62    /// │
63    /// ┊
64    /// ╰── [rubberband]
65    /// ```
66    ///
67    /// [`GridView`][crate::GridView] uses a single CSS node with name `gridview`. Each child uses
68    /// a single CSS node with name `child`. If the [`activatable`][struct@crate::ListItem#activatable]
69    /// property is set, the corresponding row will have the `.activatable` style
70    /// class. Section headers use CSS nodes with name `header`. For rubberband
71    /// selection, a subnode with name `rubberband` is used.
72    ///
73    /// # Accessibility
74    ///
75    /// [`GridView`][crate::GridView] uses the [enum@Gtk.AccessibleRole.grid] role, and the items
76    /// use the [enum@Gtk.AccessibleRole.grid_cell] role.
77    ///
78    /// ## Properties
79    ///
80    ///
81    /// #### `enable-rubberband`
82    ///  Allow rubberband selection.
83    ///
84    /// Readable | Writable
85    ///
86    ///
87    /// #### `factory`
88    ///  Factory for populating list items.
89    ///
90    /// The factory must be for configuring [`ListItem`][crate::ListItem] objects.
91    ///
92    /// Readable | Writable
93    ///
94    ///
95    /// #### `header-factory`
96    ///  Factory for creating header widgets.
97    ///
98    /// The factory must be for configuring [`ListHeader`][crate::ListHeader] objects.
99    ///
100    /// Readable | Writable
101    ///
102    ///
103    /// #### `max-columns`
104    ///  Maximum number of columns per row.
105    ///
106    /// If this number is smaller than [`min-columns`][struct@crate::GridView#min-columns],
107    /// that value is used instead.
108    ///
109    /// Readable | Writable
110    ///
111    ///
112    /// #### `min-columns`
113    ///  Minimum number of columns per row.
114    ///
115    /// Readable | Writable
116    ///
117    ///
118    /// #### `model`
119    ///  Model for the items displayed.
120    ///
121    /// Readable | Writable
122    ///
123    ///
124    /// #### `single-click-activate`
125    ///  Activate rows on single click and select them on hover.
126    ///
127    /// Readable | Writable
128    ///
129    ///
130    /// #### `tab-behavior`
131    ///  Behavior of the <kbd>Tab</kbd> key
132    ///
133    /// Readable | Writable
134    /// <details><summary><h4>ListBase</h4></summary>
135    ///
136    ///
137    /// #### `orientation`
138    ///  The orientation of the list. See GtkOrientable:orientation
139    /// for details.
140    ///
141    /// Readable | Writable
142    /// </details>
143    /// <details><summary><h4>Widget</h4></summary>
144    ///
145    ///
146    /// #### `can-focus`
147    ///  Whether the widget or any of its descendents can accept
148    /// the input focus.
149    ///
150    /// This property is meant to be set by widget implementations,
151    /// typically in their instance init function.
152    ///
153    /// Readable | Writable
154    ///
155    ///
156    /// #### `can-target`
157    ///  Whether the widget can receive pointer events.
158    ///
159    /// Readable | Writable
160    ///
161    ///
162    /// #### `css-classes`
163    ///  A list of css classes applied to this widget.
164    ///
165    /// Readable | Writable
166    ///
167    ///
168    /// #### `css-name`
169    ///  The name of this widget in the CSS tree.
170    ///
171    /// This property is meant to be set by widget implementations,
172    /// typically in their instance init function.
173    ///
174    /// Readable | Writable | Construct Only
175    ///
176    ///
177    /// #### `cursor`
178    ///  The cursor used by @widget.
179    ///
180    /// Readable | Writable
181    ///
182    ///
183    /// #### `focus-on-click`
184    ///  Whether the widget should grab focus when it is clicked with the mouse.
185    ///
186    /// This property is only relevant for widgets that can take focus.
187    ///
188    /// Readable | Writable
189    ///
190    ///
191    /// #### `focusable`
192    ///  Whether this widget itself will accept the input focus.
193    ///
194    /// Readable | Writable
195    ///
196    ///
197    /// #### `halign`
198    ///  How to distribute horizontal space if widget gets extra space.
199    ///
200    /// Readable | Writable
201    ///
202    ///
203    /// #### `has-default`
204    ///  Whether the widget is the default widget.
205    ///
206    /// Readable
207    ///
208    ///
209    /// #### `has-focus`
210    ///  Whether the widget has the input focus.
211    ///
212    /// Readable
213    ///
214    ///
215    /// #### `has-tooltip`
216    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
217    /// signal on @widget.
218    ///
219    /// A true value indicates that @widget can have a tooltip, in this case
220    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
221    /// determine whether it will provide a tooltip or not.
222    ///
223    /// Readable | Writable
224    ///
225    ///
226    /// #### `height-request`
227    ///  Overrides for height request of the widget.
228    ///
229    /// If this is -1, the natural request will be used.
230    ///
231    /// Readable | Writable
232    ///
233    ///
234    /// #### `hexpand`
235    ///  Whether to expand horizontally.
236    ///
237    /// Readable | Writable
238    ///
239    ///
240    /// #### `hexpand-set`
241    ///  Whether to use the `hexpand` property.
242    ///
243    /// Readable | Writable
244    ///
245    ///
246    /// #### `layout-manager`
247    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
248    /// the preferred size of the widget, and allocate its children.
249    ///
250    /// This property is meant to be set by widget implementations,
251    /// typically in their instance init function.
252    ///
253    /// Readable | Writable
254    ///
255    ///
256    /// #### `limit-events`
257    ///  Makes this widget act like a modal dialog, with respect to
258    /// event delivery.
259    ///
260    /// Global event controllers will not handle events with targets
261    /// inside the widget, unless they are set up to ignore propagation
262    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
263    ///
264    /// Readable | Writable
265    ///
266    ///
267    /// #### `margin-bottom`
268    ///  Margin on bottom side of widget.
269    ///
270    /// This property adds margin outside of the widget's normal size
271    /// request, the margin will be added in addition to the size from
272    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
273    ///
274    /// Readable | Writable
275    ///
276    ///
277    /// #### `margin-end`
278    ///  Margin on end of widget, horizontally.
279    ///
280    /// This property supports left-to-right and right-to-left text
281    /// directions.
282    ///
283    /// This property adds margin outside of the widget's normal size
284    /// request, the margin will be added in addition to the size from
285    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
286    ///
287    /// Readable | Writable
288    ///
289    ///
290    /// #### `margin-start`
291    ///  Margin on start of widget, horizontally.
292    ///
293    /// This property supports left-to-right and right-to-left text
294    /// directions.
295    ///
296    /// This property adds margin outside of the widget's normal size
297    /// request, the margin will be added in addition to the size from
298    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
299    ///
300    /// Readable | Writable
301    ///
302    ///
303    /// #### `margin-top`
304    ///  Margin on top side of widget.
305    ///
306    /// This property adds margin outside of the widget's normal size
307    /// request, the margin will be added in addition to the size from
308    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
309    ///
310    /// Readable | Writable
311    ///
312    ///
313    /// #### `name`
314    ///  The name of the widget.
315    ///
316    /// Readable | Writable
317    ///
318    ///
319    /// #### `opacity`
320    ///  The requested opacity of the widget.
321    ///
322    /// Readable | Writable
323    ///
324    ///
325    /// #### `overflow`
326    ///  How content outside the widget's content area is treated.
327    ///
328    /// This property is meant to be set by widget implementations,
329    /// typically in their instance init function.
330    ///
331    /// Readable | Writable
332    ///
333    ///
334    /// #### `parent`
335    ///  The parent widget of this widget.
336    ///
337    /// Readable
338    ///
339    ///
340    /// #### `receives-default`
341    ///  Whether the widget will receive the default action when it is focused.
342    ///
343    /// Readable | Writable
344    ///
345    ///
346    /// #### `root`
347    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
348    ///
349    /// This will be `NULL` if the widget is not contained in a root widget.
350    ///
351    /// Readable
352    ///
353    ///
354    /// #### `scale-factor`
355    ///  The scale factor of the widget.
356    ///
357    /// Readable
358    ///
359    ///
360    /// #### `sensitive`
361    ///  Whether the widget responds to input.
362    ///
363    /// Readable | Writable
364    ///
365    ///
366    /// #### `tooltip-markup`
367    ///  Sets the text of tooltip to be the given string, which is marked up
368    /// with Pango markup.
369    ///
370    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
371    ///
372    /// This is a convenience property which will take care of getting the
373    /// tooltip shown if the given string is not `NULL`:
374    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
375    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
376    /// the default signal handler.
377    ///
378    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
379    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
380    ///
381    /// Readable | Writable
382    ///
383    ///
384    /// #### `tooltip-text`
385    ///  Sets the text of tooltip to be the given string.
386    ///
387    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
388    ///
389    /// This is a convenience property which will take care of getting the
390    /// tooltip shown if the given string is not `NULL`:
391    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
392    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
393    /// the default signal handler.
394    ///
395    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
396    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
397    ///
398    /// Readable | Writable
399    ///
400    ///
401    /// #### `valign`
402    ///  How to distribute vertical space if widget gets extra space.
403    ///
404    /// Readable | Writable
405    ///
406    ///
407    /// #### `vexpand`
408    ///  Whether to expand vertically.
409    ///
410    /// Readable | Writable
411    ///
412    ///
413    /// #### `vexpand-set`
414    ///  Whether to use the `vexpand` property.
415    ///
416    /// Readable | Writable
417    ///
418    ///
419    /// #### `visible`
420    ///  Whether the widget is visible.
421    ///
422    /// Readable | Writable
423    ///
424    ///
425    /// #### `width-request`
426    ///  Overrides for width request of the widget.
427    ///
428    /// If this is -1, the natural request will be used.
429    ///
430    /// Readable | Writable
431    /// </details>
432    /// <details><summary><h4>Accessible</h4></summary>
433    ///
434    ///
435    /// #### `accessible-role`
436    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
437    ///
438    /// The accessible role cannot be changed once set.
439    ///
440    /// Readable | Writable
441    /// </details>
442    /// <details><summary><h4>Orientable</h4></summary>
443    ///
444    ///
445    /// #### `orientation`
446    ///  The orientation of the orientable.
447    ///
448    /// Readable | Writable
449    /// </details>
450    /// <details><summary><h4>Scrollable</h4></summary>
451    ///
452    ///
453    /// #### `hadjustment`
454    ///  Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
455    ///
456    /// This adjustment is shared between the scrollable widget and its parent.
457    ///
458    /// Readable | Writable | Construct
459    ///
460    ///
461    /// #### `hscroll-policy`
462    ///  Determines when horizontal scrolling should start.
463    ///
464    /// Readable | Writable
465    ///
466    ///
467    /// #### `vadjustment`
468    ///  Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
469    ///
470    /// This adjustment is shared between the scrollable widget and its parent.
471    ///
472    /// Readable | Writable | Construct
473    ///
474    ///
475    /// #### `vscroll-policy`
476    ///  Determines when vertical scrolling should start.
477    ///
478    /// Readable | Writable
479    /// </details>
480    ///
481    /// ## Signals
482    ///
483    ///
484    /// #### `activate`
485    ///  Emitted when a cell has been activated by the user,
486    /// usually via activating the GtkGridView|list.activate-item action.
487    ///
488    /// This allows for a convenient way to handle activation in a gridview.
489    /// See [`activatable`][struct@crate::ListItem#activatable] for details on how to use
490    /// this signal.
491    ///
492    ///
493    /// <details><summary><h4>Widget</h4></summary>
494    ///
495    ///
496    /// #### `destroy`
497    ///  Signals that all holders of a reference to the widget should release
498    /// the reference that they hold.
499    ///
500    /// May result in finalization of the widget if all references are released.
501    ///
502    /// This signal is not suitable for saving widget state.
503    ///
504    ///
505    ///
506    ///
507    /// #### `direction-changed`
508    ///  Emitted when the text direction of a widget changes.
509    ///
510    ///
511    ///
512    ///
513    /// #### `hide`
514    ///  Emitted when @widget is hidden.
515    ///
516    ///
517    ///
518    ///
519    /// #### `keynav-failed`
520    ///  Emitted if keyboard navigation fails.
521    ///
522    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
523    ///
524    ///
525    ///
526    ///
527    /// #### `map`
528    ///  Emitted when @widget is going to be mapped.
529    ///
530    /// A widget is mapped when the widget is visible (which is controlled with
531    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
532    /// are also visible.
533    ///
534    /// The `::map` signal can be used to determine whether a widget will be drawn,
535    /// for instance it can resume an animation that was stopped during the
536    /// emission of [`unmap`][struct@crate::Widget#unmap].
537    ///
538    ///
539    ///
540    ///
541    /// #### `mnemonic-activate`
542    ///  Emitted when a widget is activated via a mnemonic.
543    ///
544    /// The default handler for this signal activates @widget if @group_cycling
545    /// is false, or just makes @widget grab focus if @group_cycling is true.
546    ///
547    ///
548    ///
549    ///
550    /// #### `move-focus`
551    ///  Emitted when the focus is moved.
552    ///
553    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
554    ///
555    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
556    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
557    ///
558    /// Action
559    ///
560    ///
561    /// #### `query-tooltip`
562    ///  Emitted when the widget’s tooltip is about to be shown.
563    ///
564    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
565    /// is true and the hover timeout has expired with the cursor hovering
566    /// above @widget; or emitted when @widget got focus in keyboard mode.
567    ///
568    /// Using the given coordinates, the signal handler should determine
569    /// whether a tooltip should be shown for @widget. If this is the case
570    /// true should be returned, false otherwise. Note that if @keyboard_mode
571    /// is true, the values of @x and @y are undefined and should not be used.
572    ///
573    /// The signal handler is free to manipulate @tooltip with the therefore
574    /// destined function calls.
575    ///
576    ///
577    ///
578    ///
579    /// #### `realize`
580    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
581    ///
582    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
583    /// or the widget has been mapped (that is, it is going to be drawn).
584    ///
585    ///
586    ///
587    ///
588    /// #### `show`
589    ///  Emitted when @widget is shown.
590    ///
591    ///
592    ///
593    ///
594    /// #### `state-flags-changed`
595    ///  Emitted when the widget state changes.
596    ///
597    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
598    ///
599    ///
600    ///
601    ///
602    /// #### `unmap`
603    ///  Emitted when @widget is going to be unmapped.
604    ///
605    /// A widget is unmapped when either it or any of its parents up to the
606    /// toplevel widget have been set as hidden.
607    ///
608    /// As `::unmap` indicates that a widget will not be shown any longer,
609    /// it can be used to, for example, stop an animation on the widget.
610    ///
611    ///
612    ///
613    ///
614    /// #### `unrealize`
615    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
616    ///
617    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
618    /// or the widget has been unmapped (that is, it is going to be hidden).
619    ///
620    ///
621    /// </details>
622    ///
623    /// # Implements
624    ///
625    /// [`ListBaseExt`][trait@crate::prelude::ListBaseExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`ScrollableExt`][trait@crate::prelude::ScrollableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
626    #[doc(alias = "GtkGridView")]
627    pub struct GridView(Object<ffi::GtkGridView, ffi::GtkGridViewClass>) @extends ListBase, Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable, Scrollable;
628
629    match fn {
630        type_ => || ffi::gtk_grid_view_get_type(),
631    }
632}
633
634#[cfg(not(feature = "v4_10"))]
635glib::wrapper! {
636    #[doc(alias = "GtkGridView")]
637    pub struct GridView(Object<ffi::GtkGridView, ffi::GtkGridViewClass>) @extends ListBase, Widget, @implements Buildable, ConstraintTarget, Orientable, Scrollable;
638
639    match fn {
640        type_ => || ffi::gtk_grid_view_get_type(),
641    }
642}
643
644impl GridView {
645    /// Creates a new [`GridView`][crate::GridView] that uses the given @factory for
646    /// mapping items to widgets.
647    ///
648    /// The function takes ownership of the
649    /// arguments, so you can write code like
650    /// **⚠️ The following code is in c ⚠️**
651    ///
652    /// ```c
653    /// grid_view = gtk_grid_view_new (create_model (),
654    ///   gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));
655    /// ```
656    /// ## `model`
657    /// the model to use
658    /// ## `factory`
659    /// The factory to populate items with
660    ///
661    /// # Returns
662    ///
663    /// a new [`GridView`][crate::GridView] using the given @model and @factory
664    #[doc(alias = "gtk_grid_view_new")]
665    pub fn new(
666        model: Option<impl IsA<SelectionModel>>,
667        factory: Option<impl IsA<ListItemFactory>>,
668    ) -> GridView {
669        assert_initialized_main_thread!();
670        unsafe {
671            Widget::from_glib_none(ffi::gtk_grid_view_new(
672                model.map(|p| p.upcast()).into_glib_ptr(),
673                factory.map(|p| p.upcast()).into_glib_ptr(),
674            ))
675            .unsafe_cast()
676        }
677    }
678
679    // rustdoc-stripper-ignore-next
680    /// Creates a new builder-pattern struct instance to construct [`GridView`] objects.
681    ///
682    /// This method returns an instance of [`GridViewBuilder`](crate::builders::GridViewBuilder) which can be used to create [`GridView`] objects.
683    pub fn builder() -> GridViewBuilder {
684        GridViewBuilder::new()
685    }
686
687    /// Returns whether rows can be selected by dragging with the mouse.
688    ///
689    /// # Returns
690    ///
691    /// [`true`] if rubberband selection is enabled
692    #[doc(alias = "gtk_grid_view_get_enable_rubberband")]
693    #[doc(alias = "get_enable_rubberband")]
694    #[doc(alias = "enable-rubberband")]
695    pub fn enables_rubberband(&self) -> bool {
696        unsafe {
697            from_glib(ffi::gtk_grid_view_get_enable_rubberband(
698                self.to_glib_none().0,
699            ))
700        }
701    }
702
703    /// Gets the factory that's currently used to populate list items.
704    ///
705    /// # Returns
706    ///
707    /// The factory in use
708    #[doc(alias = "gtk_grid_view_get_factory")]
709    #[doc(alias = "get_factory")]
710    pub fn factory(&self) -> Option<ListItemFactory> {
711        unsafe { from_glib_none(ffi::gtk_grid_view_get_factory(self.to_glib_none().0)) }
712    }
713
714    /// Gets the factory that's currently used to populate section headers.
715    ///
716    /// # Returns
717    ///
718    /// The factory in use
719    #[cfg(feature = "v4_26")]
720    #[cfg_attr(docsrs, doc(cfg(feature = "v4_26")))]
721    #[doc(alias = "gtk_grid_view_get_header_factory")]
722    #[doc(alias = "get_header_factory")]
723    #[doc(alias = "header-factory")]
724    pub fn header_factory(&self) -> Option<ListItemFactory> {
725        unsafe { from_glib_none(ffi::gtk_grid_view_get_header_factory(self.to_glib_none().0)) }
726    }
727
728    /// Gets the maximum number of columns that the grid will use.
729    ///
730    /// # Returns
731    ///
732    /// The maximum number of columns
733    #[doc(alias = "gtk_grid_view_get_max_columns")]
734    #[doc(alias = "get_max_columns")]
735    #[doc(alias = "max-columns")]
736    pub fn max_columns(&self) -> u32 {
737        unsafe { ffi::gtk_grid_view_get_max_columns(self.to_glib_none().0) }
738    }
739
740    /// Gets the minimum number of columns that the grid will use.
741    ///
742    /// # Returns
743    ///
744    /// The minimum number of columns
745    #[doc(alias = "gtk_grid_view_get_min_columns")]
746    #[doc(alias = "get_min_columns")]
747    #[doc(alias = "min-columns")]
748    pub fn min_columns(&self) -> u32 {
749        unsafe { ffi::gtk_grid_view_get_min_columns(self.to_glib_none().0) }
750    }
751
752    /// Gets the model that's currently used to read the items displayed.
753    ///
754    /// # Returns
755    ///
756    /// The model in use
757    #[doc(alias = "gtk_grid_view_get_model")]
758    #[doc(alias = "get_model")]
759    pub fn model(&self) -> Option<SelectionModel> {
760        unsafe { from_glib_none(ffi::gtk_grid_view_get_model(self.to_glib_none().0)) }
761    }
762
763    /// Returns whether items will be activated on single click and
764    /// selected on hover.
765    ///
766    /// # Returns
767    ///
768    /// [`true`] if items are activated on single click
769    #[doc(alias = "gtk_grid_view_get_single_click_activate")]
770    #[doc(alias = "get_single_click_activate")]
771    #[doc(alias = "single-click-activate")]
772    pub fn is_single_click_activate(&self) -> bool {
773        unsafe {
774            from_glib(ffi::gtk_grid_view_get_single_click_activate(
775                self.to_glib_none().0,
776            ))
777        }
778    }
779
780    /// Gets the behavior set for the <kbd>Tab</kbd> key.
781    ///
782    /// # Returns
783    ///
784    /// The behavior of the <kbd>Tab</kbd> key
785    #[cfg(feature = "v4_12")]
786    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
787    #[doc(alias = "gtk_grid_view_get_tab_behavior")]
788    #[doc(alias = "get_tab_behavior")]
789    #[doc(alias = "tab-behavior")]
790    pub fn tab_behavior(&self) -> ListTabBehavior {
791        unsafe { from_glib(ffi::gtk_grid_view_get_tab_behavior(self.to_glib_none().0)) }
792    }
793
794    /// Scrolls to the item at the given position and performs the actions
795    /// specified in @flags.
796    ///
797    /// This function works no matter if the gridview is shown or focused.
798    /// If it isn't, then the changes will take effect once that happens.
799    /// ## `pos`
800    /// position of the item. Must be less than the number of
801    ///   items in the view.
802    /// ## `flags`
803    /// actions to perform
804    /// ## `scroll`
805    /// details of how to perform
806    ///   the scroll operation or [`None`] to scroll into view
807    #[cfg(feature = "v4_12")]
808    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
809    #[doc(alias = "gtk_grid_view_scroll_to")]
810    pub fn scroll_to(&self, pos: u32, flags: ListScrollFlags, scroll: Option<ScrollInfo>) {
811        unsafe {
812            ffi::gtk_grid_view_scroll_to(
813                self.to_glib_none().0,
814                pos,
815                flags.into_glib(),
816                scroll.into_glib_ptr(),
817            );
818        }
819    }
820
821    /// Sets whether selections can be changed by dragging with the mouse.
822    /// ## `enable_rubberband`
823    /// [`true`] to enable rubberband selection
824    #[doc(alias = "gtk_grid_view_set_enable_rubberband")]
825    #[doc(alias = "enable-rubberband")]
826    pub fn set_enable_rubberband(&self, enable_rubberband: bool) {
827        unsafe {
828            ffi::gtk_grid_view_set_enable_rubberband(
829                self.to_glib_none().0,
830                enable_rubberband.into_glib(),
831            );
832        }
833    }
834
835    /// Sets the [`ListItemFactory`][crate::ListItemFactory] to use for populating list items.
836    /// ## `factory`
837    /// the factory to use
838    #[doc(alias = "gtk_grid_view_set_factory")]
839    #[doc(alias = "factory")]
840    pub fn set_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
841        unsafe {
842            ffi::gtk_grid_view_set_factory(
843                self.to_glib_none().0,
844                factory.map(|p| p.as_ref()).to_glib_none().0,
845            );
846        }
847    }
848
849    /// Sets the [`ListItemFactory`][crate::ListItemFactory] to use for populating the
850    /// [`ListHeader`][crate::ListHeader] objects used in section headers.
851    ///
852    /// If this factory is set to `NULL`, the list will not show
853    /// section headers.
854    /// ## `factory`
855    /// the factory to use
856    #[cfg(feature = "v4_26")]
857    #[cfg_attr(docsrs, doc(cfg(feature = "v4_26")))]
858    #[doc(alias = "gtk_grid_view_set_header_factory")]
859    #[doc(alias = "header-factory")]
860    pub fn set_header_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
861        unsafe {
862            ffi::gtk_grid_view_set_header_factory(
863                self.to_glib_none().0,
864                factory.map(|p| p.as_ref()).to_glib_none().0,
865            );
866        }
867    }
868
869    /// Sets the maximum number of columns to use.
870    ///
871    /// This number must be at least 1.
872    ///
873    /// If @max_columns is smaller than the minimum set via
874    /// [`set_min_columns()`][Self::set_min_columns()], that value is used instead.
875    /// ## `max_columns`
876    /// The maximum number of columns
877    #[doc(alias = "gtk_grid_view_set_max_columns")]
878    #[doc(alias = "max-columns")]
879    pub fn set_max_columns(&self, max_columns: u32) {
880        unsafe {
881            ffi::gtk_grid_view_set_max_columns(self.to_glib_none().0, max_columns);
882        }
883    }
884
885    /// Sets the minimum number of columns to use.
886    ///
887    /// This number must be at least 1.
888    ///
889    /// If @min_columns is smaller than the minimum set via
890    /// [`set_max_columns()`][Self::set_max_columns()], that value is ignored.
891    /// ## `min_columns`
892    /// The minimum number of columns
893    #[doc(alias = "gtk_grid_view_set_min_columns")]
894    #[doc(alias = "min-columns")]
895    pub fn set_min_columns(&self, min_columns: u32) {
896        unsafe {
897            ffi::gtk_grid_view_set_min_columns(self.to_glib_none().0, min_columns);
898        }
899    }
900
901    /// Sets the model to use.
902    ///
903    /// This must be a [`SelectionModel`][crate::SelectionModel].
904    /// ## `model`
905    /// the model to use
906    #[doc(alias = "gtk_grid_view_set_model")]
907    #[doc(alias = "model")]
908    pub fn set_model(&self, model: Option<&impl IsA<SelectionModel>>) {
909        unsafe {
910            ffi::gtk_grid_view_set_model(
911                self.to_glib_none().0,
912                model.map(|p| p.as_ref()).to_glib_none().0,
913            );
914        }
915    }
916
917    /// Sets whether items should be activated on single click and
918    /// selected on hover.
919    /// ## `single_click_activate`
920    /// [`true`] to activate items on single click
921    #[doc(alias = "gtk_grid_view_set_single_click_activate")]
922    #[doc(alias = "single-click-activate")]
923    pub fn set_single_click_activate(&self, single_click_activate: bool) {
924        unsafe {
925            ffi::gtk_grid_view_set_single_click_activate(
926                self.to_glib_none().0,
927                single_click_activate.into_glib(),
928            );
929        }
930    }
931
932    /// Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
933    /// ## `tab_behavior`
934    /// The desired tab behavior
935    #[cfg(feature = "v4_12")]
936    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
937    #[doc(alias = "gtk_grid_view_set_tab_behavior")]
938    #[doc(alias = "tab-behavior")]
939    pub fn set_tab_behavior(&self, tab_behavior: ListTabBehavior) {
940        unsafe {
941            ffi::gtk_grid_view_set_tab_behavior(self.to_glib_none().0, tab_behavior.into_glib());
942        }
943    }
944
945    /// Emitted when a cell has been activated by the user,
946    /// usually via activating the GtkGridView|list.activate-item action.
947    ///
948    /// This allows for a convenient way to handle activation in a gridview.
949    /// See [`activatable`][struct@crate::ListItem#activatable] for details on how to use
950    /// this signal.
951    /// ## `position`
952    /// position of item to activate
953    #[doc(alias = "activate")]
954    pub fn connect_activate<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
955        unsafe extern "C" fn activate_trampoline<F: Fn(&GridView, u32) + 'static>(
956            this: *mut ffi::GtkGridView,
957            position: std::ffi::c_uint,
958            f: glib::ffi::gpointer,
959        ) {
960            unsafe {
961                let f: &F = &*(f as *const F);
962                f(&from_glib_borrow(this), position)
963            }
964        }
965        unsafe {
966            let f: Box_<F> = Box_::new(f);
967            connect_raw(
968                self.as_ptr() as *mut _,
969                c"activate".as_ptr(),
970                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
971                    activate_trampoline::<F> as *const (),
972                )),
973                Box_::into_raw(f),
974            )
975        }
976    }
977
978    #[doc(alias = "enable-rubberband")]
979    pub fn connect_enable_rubberband_notify<F: Fn(&Self) + 'static>(
980        &self,
981        f: F,
982    ) -> SignalHandlerId {
983        unsafe extern "C" fn notify_enable_rubberband_trampoline<F: Fn(&GridView) + 'static>(
984            this: *mut ffi::GtkGridView,
985            _param_spec: glib::ffi::gpointer,
986            f: glib::ffi::gpointer,
987        ) {
988            unsafe {
989                let f: &F = &*(f as *const F);
990                f(&from_glib_borrow(this))
991            }
992        }
993        unsafe {
994            let f: Box_<F> = Box_::new(f);
995            connect_raw(
996                self.as_ptr() as *mut _,
997                c"notify::enable-rubberband".as_ptr(),
998                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
999                    notify_enable_rubberband_trampoline::<F> as *const (),
1000                )),
1001                Box_::into_raw(f),
1002            )
1003        }
1004    }
1005
1006    #[doc(alias = "factory")]
1007    pub fn connect_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1008        unsafe extern "C" fn notify_factory_trampoline<F: Fn(&GridView) + 'static>(
1009            this: *mut ffi::GtkGridView,
1010            _param_spec: glib::ffi::gpointer,
1011            f: glib::ffi::gpointer,
1012        ) {
1013            unsafe {
1014                let f: &F = &*(f as *const F);
1015                f(&from_glib_borrow(this))
1016            }
1017        }
1018        unsafe {
1019            let f: Box_<F> = Box_::new(f);
1020            connect_raw(
1021                self.as_ptr() as *mut _,
1022                c"notify::factory".as_ptr(),
1023                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1024                    notify_factory_trampoline::<F> as *const (),
1025                )),
1026                Box_::into_raw(f),
1027            )
1028        }
1029    }
1030
1031    #[cfg(feature = "v4_26")]
1032    #[cfg_attr(docsrs, doc(cfg(feature = "v4_26")))]
1033    #[doc(alias = "header-factory")]
1034    pub fn connect_header_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1035        unsafe extern "C" fn notify_header_factory_trampoline<F: Fn(&GridView) + 'static>(
1036            this: *mut ffi::GtkGridView,
1037            _param_spec: glib::ffi::gpointer,
1038            f: glib::ffi::gpointer,
1039        ) {
1040            unsafe {
1041                let f: &F = &*(f as *const F);
1042                f(&from_glib_borrow(this))
1043            }
1044        }
1045        unsafe {
1046            let f: Box_<F> = Box_::new(f);
1047            connect_raw(
1048                self.as_ptr() as *mut _,
1049                c"notify::header-factory".as_ptr(),
1050                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1051                    notify_header_factory_trampoline::<F> as *const (),
1052                )),
1053                Box_::into_raw(f),
1054            )
1055        }
1056    }
1057
1058    #[doc(alias = "max-columns")]
1059    pub fn connect_max_columns_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1060        unsafe extern "C" fn notify_max_columns_trampoline<F: Fn(&GridView) + 'static>(
1061            this: *mut ffi::GtkGridView,
1062            _param_spec: glib::ffi::gpointer,
1063            f: glib::ffi::gpointer,
1064        ) {
1065            unsafe {
1066                let f: &F = &*(f as *const F);
1067                f(&from_glib_borrow(this))
1068            }
1069        }
1070        unsafe {
1071            let f: Box_<F> = Box_::new(f);
1072            connect_raw(
1073                self.as_ptr() as *mut _,
1074                c"notify::max-columns".as_ptr(),
1075                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1076                    notify_max_columns_trampoline::<F> as *const (),
1077                )),
1078                Box_::into_raw(f),
1079            )
1080        }
1081    }
1082
1083    #[doc(alias = "min-columns")]
1084    pub fn connect_min_columns_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1085        unsafe extern "C" fn notify_min_columns_trampoline<F: Fn(&GridView) + 'static>(
1086            this: *mut ffi::GtkGridView,
1087            _param_spec: glib::ffi::gpointer,
1088            f: glib::ffi::gpointer,
1089        ) {
1090            unsafe {
1091                let f: &F = &*(f as *const F);
1092                f(&from_glib_borrow(this))
1093            }
1094        }
1095        unsafe {
1096            let f: Box_<F> = Box_::new(f);
1097            connect_raw(
1098                self.as_ptr() as *mut _,
1099                c"notify::min-columns".as_ptr(),
1100                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1101                    notify_min_columns_trampoline::<F> as *const (),
1102                )),
1103                Box_::into_raw(f),
1104            )
1105        }
1106    }
1107
1108    #[doc(alias = "model")]
1109    pub fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1110        unsafe extern "C" fn notify_model_trampoline<F: Fn(&GridView) + 'static>(
1111            this: *mut ffi::GtkGridView,
1112            _param_spec: glib::ffi::gpointer,
1113            f: glib::ffi::gpointer,
1114        ) {
1115            unsafe {
1116                let f: &F = &*(f as *const F);
1117                f(&from_glib_borrow(this))
1118            }
1119        }
1120        unsafe {
1121            let f: Box_<F> = Box_::new(f);
1122            connect_raw(
1123                self.as_ptr() as *mut _,
1124                c"notify::model".as_ptr(),
1125                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1126                    notify_model_trampoline::<F> as *const (),
1127                )),
1128                Box_::into_raw(f),
1129            )
1130        }
1131    }
1132
1133    #[doc(alias = "single-click-activate")]
1134    pub fn connect_single_click_activate_notify<F: Fn(&Self) + 'static>(
1135        &self,
1136        f: F,
1137    ) -> SignalHandlerId {
1138        unsafe extern "C" fn notify_single_click_activate_trampoline<F: Fn(&GridView) + 'static>(
1139            this: *mut ffi::GtkGridView,
1140            _param_spec: glib::ffi::gpointer,
1141            f: glib::ffi::gpointer,
1142        ) {
1143            unsafe {
1144                let f: &F = &*(f as *const F);
1145                f(&from_glib_borrow(this))
1146            }
1147        }
1148        unsafe {
1149            let f: Box_<F> = Box_::new(f);
1150            connect_raw(
1151                self.as_ptr() as *mut _,
1152                c"notify::single-click-activate".as_ptr(),
1153                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1154                    notify_single_click_activate_trampoline::<F> as *const (),
1155                )),
1156                Box_::into_raw(f),
1157            )
1158        }
1159    }
1160
1161    #[cfg(feature = "v4_12")]
1162    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1163    #[doc(alias = "tab-behavior")]
1164    pub fn connect_tab_behavior_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1165        unsafe extern "C" fn notify_tab_behavior_trampoline<F: Fn(&GridView) + 'static>(
1166            this: *mut ffi::GtkGridView,
1167            _param_spec: glib::ffi::gpointer,
1168            f: glib::ffi::gpointer,
1169        ) {
1170            unsafe {
1171                let f: &F = &*(f as *const F);
1172                f(&from_glib_borrow(this))
1173            }
1174        }
1175        unsafe {
1176            let f: Box_<F> = Box_::new(f);
1177            connect_raw(
1178                self.as_ptr() as *mut _,
1179                c"notify::tab-behavior".as_ptr(),
1180                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1181                    notify_tab_behavior_trampoline::<F> as *const (),
1182                )),
1183                Box_::into_raw(f),
1184            )
1185        }
1186    }
1187}
1188
1189impl Default for GridView {
1190    fn default() -> Self {
1191        glib::object::Object::new::<Self>()
1192    }
1193}
1194
1195// rustdoc-stripper-ignore-next
1196/// A [builder-pattern] type to construct [`GridView`] objects.
1197///
1198/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1199#[must_use = "The builder must be built to be used"]
1200pub struct GridViewBuilder {
1201    builder: glib::object::ObjectBuilder<'static, GridView>,
1202}
1203
1204impl GridViewBuilder {
1205    fn new() -> Self {
1206        Self {
1207            builder: glib::object::Object::builder(),
1208        }
1209    }
1210
1211    /// Allow rubberband selection.
1212    pub fn enable_rubberband(self, enable_rubberband: bool) -> Self {
1213        Self {
1214            builder: self
1215                .builder
1216                .property("enable-rubberband", enable_rubberband),
1217        }
1218    }
1219
1220    /// Factory for populating list items.
1221    ///
1222    /// The factory must be for configuring [`ListItem`][crate::ListItem] objects.
1223    pub fn factory(self, factory: &impl IsA<ListItemFactory>) -> Self {
1224        Self {
1225            builder: self.builder.property("factory", factory.clone().upcast()),
1226        }
1227    }
1228
1229    /// Factory for creating header widgets.
1230    ///
1231    /// The factory must be for configuring [`ListHeader`][crate::ListHeader] objects.
1232    #[cfg(feature = "v4_26")]
1233    #[cfg_attr(docsrs, doc(cfg(feature = "v4_26")))]
1234    pub fn header_factory(self, header_factory: &impl IsA<ListItemFactory>) -> Self {
1235        Self {
1236            builder: self
1237                .builder
1238                .property("header-factory", header_factory.clone().upcast()),
1239        }
1240    }
1241
1242    /// Maximum number of columns per row.
1243    ///
1244    /// If this number is smaller than [`min-columns`][struct@crate::GridView#min-columns],
1245    /// that value is used instead.
1246    pub fn max_columns(self, max_columns: u32) -> Self {
1247        Self {
1248            builder: self.builder.property("max-columns", max_columns),
1249        }
1250    }
1251
1252    /// Minimum number of columns per row.
1253    pub fn min_columns(self, min_columns: u32) -> Self {
1254        Self {
1255            builder: self.builder.property("min-columns", min_columns),
1256        }
1257    }
1258
1259    /// Model for the items displayed.
1260    pub fn model(self, model: &impl IsA<SelectionModel>) -> Self {
1261        Self {
1262            builder: self.builder.property("model", model.clone().upcast()),
1263        }
1264    }
1265
1266    /// Activate rows on single click and select them on hover.
1267    pub fn single_click_activate(self, single_click_activate: bool) -> Self {
1268        Self {
1269            builder: self
1270                .builder
1271                .property("single-click-activate", single_click_activate),
1272        }
1273    }
1274
1275    /// Behavior of the <kbd>Tab</kbd> key
1276    #[cfg(feature = "v4_12")]
1277    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1278    pub fn tab_behavior(self, tab_behavior: ListTabBehavior) -> Self {
1279        Self {
1280            builder: self.builder.property("tab-behavior", tab_behavior),
1281        }
1282    }
1283
1284    /// The orientation of the list. See GtkOrientable:orientation
1285    /// for details.
1286    pub fn orientation(self, orientation: Orientation) -> Self {
1287        Self {
1288            builder: self.builder.property("orientation", orientation),
1289        }
1290    }
1291
1292    /// Whether the widget or any of its descendents can accept
1293    /// the input focus.
1294    ///
1295    /// This property is meant to be set by widget implementations,
1296    /// typically in their instance init function.
1297    pub fn can_focus(self, can_focus: bool) -> Self {
1298        Self {
1299            builder: self.builder.property("can-focus", can_focus),
1300        }
1301    }
1302
1303    /// Whether the widget can receive pointer events.
1304    pub fn can_target(self, can_target: bool) -> Self {
1305        Self {
1306            builder: self.builder.property("can-target", can_target),
1307        }
1308    }
1309
1310    /// A list of css classes applied to this widget.
1311    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1312        Self {
1313            builder: self.builder.property("css-classes", css_classes.into()),
1314        }
1315    }
1316
1317    /// The name of this widget in the CSS tree.
1318    ///
1319    /// This property is meant to be set by widget implementations,
1320    /// typically in their instance init function.
1321    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1322        Self {
1323            builder: self.builder.property("css-name", css_name.into()),
1324        }
1325    }
1326
1327    /// The cursor used by @widget.
1328    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1329        Self {
1330            builder: self.builder.property("cursor", cursor.clone()),
1331        }
1332    }
1333
1334    /// Whether the widget should grab focus when it is clicked with the mouse.
1335    ///
1336    /// This property is only relevant for widgets that can take focus.
1337    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1338        Self {
1339            builder: self.builder.property("focus-on-click", focus_on_click),
1340        }
1341    }
1342
1343    /// Whether this widget itself will accept the input focus.
1344    pub fn focusable(self, focusable: bool) -> Self {
1345        Self {
1346            builder: self.builder.property("focusable", focusable),
1347        }
1348    }
1349
1350    /// How to distribute horizontal space if widget gets extra space.
1351    pub fn halign(self, halign: Align) -> Self {
1352        Self {
1353            builder: self.builder.property("halign", halign),
1354        }
1355    }
1356
1357    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1358    /// signal on @widget.
1359    ///
1360    /// A true value indicates that @widget can have a tooltip, in this case
1361    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1362    /// determine whether it will provide a tooltip or not.
1363    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1364        Self {
1365            builder: self.builder.property("has-tooltip", has_tooltip),
1366        }
1367    }
1368
1369    /// Overrides for height request of the widget.
1370    ///
1371    /// If this is -1, the natural request will be used.
1372    pub fn height_request(self, height_request: i32) -> Self {
1373        Self {
1374            builder: self.builder.property("height-request", height_request),
1375        }
1376    }
1377
1378    /// Whether to expand horizontally.
1379    pub fn hexpand(self, hexpand: bool) -> Self {
1380        Self {
1381            builder: self.builder.property("hexpand", hexpand),
1382        }
1383    }
1384
1385    /// Whether to use the `hexpand` property.
1386    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1387        Self {
1388            builder: self.builder.property("hexpand-set", hexpand_set),
1389        }
1390    }
1391
1392    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1393    /// the preferred size of the widget, and allocate its children.
1394    ///
1395    /// This property is meant to be set by widget implementations,
1396    /// typically in their instance init function.
1397    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1398        Self {
1399            builder: self
1400                .builder
1401                .property("layout-manager", layout_manager.clone().upcast()),
1402        }
1403    }
1404
1405    /// Makes this widget act like a modal dialog, with respect to
1406    /// event delivery.
1407    ///
1408    /// Global event controllers will not handle events with targets
1409    /// inside the widget, unless they are set up to ignore propagation
1410    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1411    #[cfg(feature = "v4_18")]
1412    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1413    pub fn limit_events(self, limit_events: bool) -> Self {
1414        Self {
1415            builder: self.builder.property("limit-events", limit_events),
1416        }
1417    }
1418
1419    /// Margin on bottom side of widget.
1420    ///
1421    /// This property adds margin outside of the widget's normal size
1422    /// request, the margin will be added in addition to the size from
1423    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1424    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1425        Self {
1426            builder: self.builder.property("margin-bottom", margin_bottom),
1427        }
1428    }
1429
1430    /// Margin on end of widget, horizontally.
1431    ///
1432    /// This property supports left-to-right and right-to-left text
1433    /// directions.
1434    ///
1435    /// This property adds margin outside of the widget's normal size
1436    /// request, the margin will be added in addition to the size from
1437    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1438    pub fn margin_end(self, margin_end: i32) -> Self {
1439        Self {
1440            builder: self.builder.property("margin-end", margin_end),
1441        }
1442    }
1443
1444    /// Margin on start of widget, horizontally.
1445    ///
1446    /// This property supports left-to-right and right-to-left text
1447    /// directions.
1448    ///
1449    /// This property adds margin outside of the widget's normal size
1450    /// request, the margin will be added in addition to the size from
1451    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1452    pub fn margin_start(self, margin_start: i32) -> Self {
1453        Self {
1454            builder: self.builder.property("margin-start", margin_start),
1455        }
1456    }
1457
1458    /// Margin on top side of widget.
1459    ///
1460    /// This property adds margin outside of the widget's normal size
1461    /// request, the margin will be added in addition to the size from
1462    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1463    pub fn margin_top(self, margin_top: i32) -> Self {
1464        Self {
1465            builder: self.builder.property("margin-top", margin_top),
1466        }
1467    }
1468
1469    /// The name of the widget.
1470    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1471        Self {
1472            builder: self.builder.property("name", name.into()),
1473        }
1474    }
1475
1476    /// The requested opacity of the widget.
1477    pub fn opacity(self, opacity: f64) -> Self {
1478        Self {
1479            builder: self.builder.property("opacity", opacity),
1480        }
1481    }
1482
1483    /// How content outside the widget's content area is treated.
1484    ///
1485    /// This property is meant to be set by widget implementations,
1486    /// typically in their instance init function.
1487    pub fn overflow(self, overflow: Overflow) -> Self {
1488        Self {
1489            builder: self.builder.property("overflow", overflow),
1490        }
1491    }
1492
1493    /// Whether the widget will receive the default action when it is focused.
1494    pub fn receives_default(self, receives_default: bool) -> Self {
1495        Self {
1496            builder: self.builder.property("receives-default", receives_default),
1497        }
1498    }
1499
1500    /// Whether the widget responds to input.
1501    pub fn sensitive(self, sensitive: bool) -> Self {
1502        Self {
1503            builder: self.builder.property("sensitive", sensitive),
1504        }
1505    }
1506
1507    /// Sets the text of tooltip to be the given string, which is marked up
1508    /// with Pango markup.
1509    ///
1510    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1511    ///
1512    /// This is a convenience property which will take care of getting the
1513    /// tooltip shown if the given string is not `NULL`:
1514    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1515    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1516    /// the default signal handler.
1517    ///
1518    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1519    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1520    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1521        Self {
1522            builder: self
1523                .builder
1524                .property("tooltip-markup", tooltip_markup.into()),
1525        }
1526    }
1527
1528    /// Sets the text of tooltip to be the given string.
1529    ///
1530    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1531    ///
1532    /// This is a convenience property which will take care of getting the
1533    /// tooltip shown if the given string is not `NULL`:
1534    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1535    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1536    /// the default signal handler.
1537    ///
1538    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1539    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1540    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1541        Self {
1542            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1543        }
1544    }
1545
1546    /// How to distribute vertical space if widget gets extra space.
1547    pub fn valign(self, valign: Align) -> Self {
1548        Self {
1549            builder: self.builder.property("valign", valign),
1550        }
1551    }
1552
1553    /// Whether to expand vertically.
1554    pub fn vexpand(self, vexpand: bool) -> Self {
1555        Self {
1556            builder: self.builder.property("vexpand", vexpand),
1557        }
1558    }
1559
1560    /// Whether to use the `vexpand` property.
1561    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1562        Self {
1563            builder: self.builder.property("vexpand-set", vexpand_set),
1564        }
1565    }
1566
1567    /// Whether the widget is visible.
1568    pub fn visible(self, visible: bool) -> Self {
1569        Self {
1570            builder: self.builder.property("visible", visible),
1571        }
1572    }
1573
1574    /// Overrides for width request of the widget.
1575    ///
1576    /// If this is -1, the natural request will be used.
1577    pub fn width_request(self, width_request: i32) -> Self {
1578        Self {
1579            builder: self.builder.property("width-request", width_request),
1580        }
1581    }
1582
1583    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1584    ///
1585    /// The accessible role cannot be changed once set.
1586    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1587        Self {
1588            builder: self.builder.property("accessible-role", accessible_role),
1589        }
1590    }
1591
1592    /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
1593    ///
1594    /// This adjustment is shared between the scrollable widget and its parent.
1595    pub fn hadjustment(self, hadjustment: &impl IsA<Adjustment>) -> Self {
1596        Self {
1597            builder: self
1598                .builder
1599                .property("hadjustment", hadjustment.clone().upcast()),
1600        }
1601    }
1602
1603    /// Determines when horizontal scrolling should start.
1604    pub fn hscroll_policy(self, hscroll_policy: ScrollablePolicy) -> Self {
1605        Self {
1606            builder: self.builder.property("hscroll-policy", hscroll_policy),
1607        }
1608    }
1609
1610    /// Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
1611    ///
1612    /// This adjustment is shared between the scrollable widget and its parent.
1613    pub fn vadjustment(self, vadjustment: &impl IsA<Adjustment>) -> Self {
1614        Self {
1615            builder: self
1616                .builder
1617                .property("vadjustment", vadjustment.clone().upcast()),
1618        }
1619    }
1620
1621    /// Determines when vertical scrolling should start.
1622    pub fn vscroll_policy(self, vscroll_policy: ScrollablePolicy) -> Self {
1623        Self {
1624            builder: self.builder.property("vscroll-policy", vscroll_policy),
1625        }
1626    }
1627
1628    // rustdoc-stripper-ignore-next
1629    /// Build the [`GridView`].
1630    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1631    pub fn build(self) -> GridView {
1632        assert_initialized_main_thread!();
1633        self.builder.build()
1634    }
1635}