Skip to main content

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