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