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    /// [`ListView`][crate::ListView] 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 [`AccessibleRole::List`][crate::AccessibleRole::List] role, and the list
127    /// items use the [`AccessibleRole::ListItem`][crate::AccessibleRole::ListItem] 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    /// usually via activating the GtkListView|list.activate-item action.
529    ///
530    /// This allows for a convenient way to handle activation in a listview.
531    /// See [`ListItemExt::set_activatable()`][crate::prelude::ListItemExt::set_activatable()] for details on how to use
532    /// this signal.
533    ///
534    ///
535    /// <details><summary><h4>Widget</h4></summary>
536    ///
537    ///
538    /// #### `destroy`
539    ///  Signals that all holders of a reference to the widget should release
540    /// the reference that they hold.
541    ///
542    /// May result in finalization of the widget if all references are released.
543    ///
544    /// This signal is not suitable for saving widget state.
545    ///
546    ///
547    ///
548    ///
549    /// #### `direction-changed`
550    ///  Emitted when the text direction of a widget changes.
551    ///
552    ///
553    ///
554    ///
555    /// #### `hide`
556    ///  Emitted when @widget is hidden.
557    ///
558    ///
559    ///
560    ///
561    /// #### `keynav-failed`
562    ///  Emitted if keyboard navigation fails.
563    ///
564    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
565    ///
566    ///
567    ///
568    ///
569    /// #### `map`
570    ///  Emitted when @widget is going to be mapped.
571    ///
572    /// A widget is mapped when the widget is visible (which is controlled with
573    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
574    /// are also visible.
575    ///
576    /// The `::map` signal can be used to determine whether a widget will be drawn,
577    /// for instance it can resume an animation that was stopped during the
578    /// emission of [`unmap`][struct@crate::Widget#unmap].
579    ///
580    ///
581    ///
582    ///
583    /// #### `mnemonic-activate`
584    ///  Emitted when a widget is activated via a mnemonic.
585    ///
586    /// The default handler for this signal activates @widget if @group_cycling
587    /// is false, or just makes @widget grab focus if @group_cycling is true.
588    ///
589    ///
590    ///
591    ///
592    /// #### `move-focus`
593    ///  Emitted when the focus is moved.
594    ///
595    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
596    ///
597    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
598    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
599    ///
600    /// Action
601    ///
602    ///
603    /// #### `query-tooltip`
604    ///  Emitted when the widget’s tooltip is about to be shown.
605    ///
606    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
607    /// is true and the hover timeout has expired with the cursor hovering
608    /// above @widget; or emitted when @widget got focus in keyboard mode.
609    ///
610    /// Using the given coordinates, the signal handler should determine
611    /// whether a tooltip should be shown for @widget. If this is the case
612    /// true should be returned, false otherwise. Note that if @keyboard_mode
613    /// is true, the values of @x and @y are undefined and should not be used.
614    ///
615    /// The signal handler is free to manipulate @tooltip with the therefore
616    /// destined function calls.
617    ///
618    ///
619    ///
620    ///
621    /// #### `realize`
622    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
623    ///
624    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
625    /// or the widget has been mapped (that is, it is going to be drawn).
626    ///
627    ///
628    ///
629    ///
630    /// #### `show`
631    ///  Emitted when @widget is shown.
632    ///
633    ///
634    ///
635    ///
636    /// #### `state-flags-changed`
637    ///  Emitted when the widget state changes.
638    ///
639    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
640    ///
641    ///
642    ///
643    ///
644    /// #### `unmap`
645    ///  Emitted when @widget is going to be unmapped.
646    ///
647    /// A widget is unmapped when either it or any of its parents up to the
648    /// toplevel widget have been set as hidden.
649    ///
650    /// As `::unmap` indicates that a widget will not be shown any longer,
651    /// it can be used to, for example, stop an animation on the widget.
652    ///
653    ///
654    ///
655    ///
656    /// #### `unrealize`
657    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
658    ///
659    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
660    /// or the widget has been unmapped (that is, it is going to be hidden).
661    ///
662    ///
663    /// </details>
664    ///
665    /// # Implements
666    ///
667    /// [`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]
668    #[doc(alias = "GtkListView")]
669    pub struct ListView(Object<ffi::GtkListView, ffi::GtkListViewClass>) @extends ListBase, Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable, Scrollable;
670
671    match fn {
672        type_ => || ffi::gtk_list_view_get_type(),
673    }
674}
675
676impl ListView {
677    /// Creates a new [`ListView`][crate::ListView] that uses the given @factory for
678    /// mapping items to widgets.
679    ///
680    /// The function takes ownership of the
681    /// arguments, so you can write code like
682    /// **⚠️ The following code is in c ⚠️**
683    ///
684    /// ```c
685    /// list_view = gtk_list_view_new (create_model (),
686    ///   gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));
687    /// ```
688    /// ## `model`
689    /// the model to use
690    /// ## `factory`
691    /// The factory to populate items with
692    ///
693    /// # Returns
694    ///
695    /// a new [`ListView`][crate::ListView] using the given @model and @factory
696    #[doc(alias = "gtk_list_view_new")]
697    pub fn new(
698        model: Option<impl IsA<SelectionModel>>,
699        factory: Option<impl IsA<ListItemFactory>>,
700    ) -> ListView {
701        assert_initialized_main_thread!();
702        unsafe {
703            Widget::from_glib_none(ffi::gtk_list_view_new(
704                model.map(|p| p.upcast()).into_glib_ptr(),
705                factory.map(|p| p.upcast()).into_glib_ptr(),
706            ))
707            .unsafe_cast()
708        }
709    }
710
711    // rustdoc-stripper-ignore-next
712    /// Creates a new builder-pattern struct instance to construct [`ListView`] objects.
713    ///
714    /// This method returns an instance of [`ListViewBuilder`](crate::builders::ListViewBuilder) which can be used to create [`ListView`] objects.
715    pub fn builder() -> ListViewBuilder {
716        ListViewBuilder::new()
717    }
718
719    /// Returns whether rows can be selected by dragging with the mouse.
720    ///
721    /// # Returns
722    ///
723    /// [`true`] if rubberband selection is enabled
724    #[doc(alias = "gtk_list_view_get_enable_rubberband")]
725    #[doc(alias = "get_enable_rubberband")]
726    #[doc(alias = "enable-rubberband")]
727    pub fn enables_rubberband(&self) -> bool {
728        unsafe {
729            from_glib(ffi::gtk_list_view_get_enable_rubberband(
730                self.to_glib_none().0,
731            ))
732        }
733    }
734
735    /// Gets the factory that's currently used to populate list items.
736    ///
737    /// # Returns
738    ///
739    /// The factory in use
740    #[doc(alias = "gtk_list_view_get_factory")]
741    #[doc(alias = "get_factory")]
742    pub fn factory(&self) -> Option<ListItemFactory> {
743        unsafe { from_glib_none(ffi::gtk_list_view_get_factory(self.to_glib_none().0)) }
744    }
745
746    /// Gets the factory that's currently used to populate section headers.
747    ///
748    /// # Returns
749    ///
750    /// The factory in use
751    #[cfg(feature = "v4_12")]
752    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
753    #[doc(alias = "gtk_list_view_get_header_factory")]
754    #[doc(alias = "get_header_factory")]
755    #[doc(alias = "header-factory")]
756    pub fn header_factory(&self) -> Option<ListItemFactory> {
757        unsafe { from_glib_none(ffi::gtk_list_view_get_header_factory(self.to_glib_none().0)) }
758    }
759
760    /// Gets the model that's currently used to read the items displayed.
761    ///
762    /// # Returns
763    ///
764    /// The model in use
765    #[doc(alias = "gtk_list_view_get_model")]
766    #[doc(alias = "get_model")]
767    pub fn model(&self) -> Option<SelectionModel> {
768        unsafe { from_glib_none(ffi::gtk_list_view_get_model(self.to_glib_none().0)) }
769    }
770
771    /// Returns whether the list box should show separators
772    /// between rows.
773    ///
774    /// # Returns
775    ///
776    /// [`true`] if the list box shows separators
777    #[doc(alias = "gtk_list_view_get_show_separators")]
778    #[doc(alias = "get_show_separators")]
779    #[doc(alias = "show-separators")]
780    pub fn shows_separators(&self) -> bool {
781        unsafe {
782            from_glib(ffi::gtk_list_view_get_show_separators(
783                self.to_glib_none().0,
784            ))
785        }
786    }
787
788    /// Returns whether rows will be activated on single click and
789    /// selected on hover.
790    ///
791    /// # Returns
792    ///
793    /// [`true`] if rows are activated on single click
794    #[doc(alias = "gtk_list_view_get_single_click_activate")]
795    #[doc(alias = "get_single_click_activate")]
796    #[doc(alias = "single-click-activate")]
797    pub fn is_single_click_activate(&self) -> bool {
798        unsafe {
799            from_glib(ffi::gtk_list_view_get_single_click_activate(
800                self.to_glib_none().0,
801            ))
802        }
803    }
804
805    /// Gets the behavior set for the <kbd>Tab</kbd> key.
806    ///
807    /// # Returns
808    ///
809    /// The behavior of the <kbd>Tab</kbd> key
810    #[cfg(feature = "v4_12")]
811    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
812    #[doc(alias = "gtk_list_view_get_tab_behavior")]
813    #[doc(alias = "get_tab_behavior")]
814    #[doc(alias = "tab-behavior")]
815    pub fn tab_behavior(&self) -> ListTabBehavior {
816        unsafe { from_glib(ffi::gtk_list_view_get_tab_behavior(self.to_glib_none().0)) }
817    }
818
819    /// Scrolls to the item at the given position and performs the actions
820    /// specified in @flags.
821    ///
822    /// This function works no matter if the listview is shown or focused.
823    /// If it isn't, then the changes will take effect once that happens.
824    /// ## `pos`
825    /// position of the item. Must be less than the number of
826    ///   items in the view.
827    /// ## `flags`
828    /// actions to perform
829    /// ## `scroll`
830    /// details of how to perform
831    ///   the scroll operation or [`None`] to scroll into view
832    #[cfg(feature = "v4_12")]
833    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
834    #[doc(alias = "gtk_list_view_scroll_to")]
835    pub fn scroll_to(&self, pos: u32, flags: ListScrollFlags, scroll: Option<ScrollInfo>) {
836        unsafe {
837            ffi::gtk_list_view_scroll_to(
838                self.to_glib_none().0,
839                pos,
840                flags.into_glib(),
841                scroll.into_glib_ptr(),
842            );
843        }
844    }
845
846    /// Sets whether selections can be changed by dragging with the mouse.
847    /// ## `enable_rubberband`
848    /// [`true`] to enable rubberband selection
849    #[doc(alias = "gtk_list_view_set_enable_rubberband")]
850    #[doc(alias = "enable-rubberband")]
851    pub fn set_enable_rubberband(&self, enable_rubberband: bool) {
852        unsafe {
853            ffi::gtk_list_view_set_enable_rubberband(
854                self.to_glib_none().0,
855                enable_rubberband.into_glib(),
856            );
857        }
858    }
859
860    /// Sets the [`ListItemFactory`][crate::ListItemFactory] to use for populating list items.
861    /// ## `factory`
862    /// the factory to use
863    #[doc(alias = "gtk_list_view_set_factory")]
864    #[doc(alias = "factory")]
865    pub fn set_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
866        unsafe {
867            ffi::gtk_list_view_set_factory(
868                self.to_glib_none().0,
869                factory.map(|p| p.as_ref()).to_glib_none().0,
870            );
871        }
872    }
873
874    /// Sets the [`ListItemFactory`][crate::ListItemFactory] to use for populating the
875    /// [`ListHeader`][crate::ListHeader] objects used in section headers.
876    ///
877    /// If this factory is set to [`None`], the list will not show section headers.
878    /// ## `factory`
879    /// the factory to use
880    #[cfg(feature = "v4_12")]
881    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
882    #[doc(alias = "gtk_list_view_set_header_factory")]
883    #[doc(alias = "header-factory")]
884    pub fn set_header_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
885        unsafe {
886            ffi::gtk_list_view_set_header_factory(
887                self.to_glib_none().0,
888                factory.map(|p| p.as_ref()).to_glib_none().0,
889            );
890        }
891    }
892
893    /// Sets the model to use.
894    ///
895    /// This must be a [`SelectionModel`][crate::SelectionModel] to use.
896    /// ## `model`
897    /// the model to use
898    #[doc(alias = "gtk_list_view_set_model")]
899    #[doc(alias = "model")]
900    pub fn set_model(&self, model: Option<&impl IsA<SelectionModel>>) {
901        unsafe {
902            ffi::gtk_list_view_set_model(
903                self.to_glib_none().0,
904                model.map(|p| p.as_ref()).to_glib_none().0,
905            );
906        }
907    }
908
909    /// Sets whether the list box should show separators
910    /// between rows.
911    /// ## `show_separators`
912    /// [`true`] to show separators
913    #[doc(alias = "gtk_list_view_set_show_separators")]
914    #[doc(alias = "show-separators")]
915    pub fn set_show_separators(&self, show_separators: bool) {
916        unsafe {
917            ffi::gtk_list_view_set_show_separators(
918                self.to_glib_none().0,
919                show_separators.into_glib(),
920            );
921        }
922    }
923
924    /// Sets whether rows should be activated on single click and
925    /// selected on hover.
926    /// ## `single_click_activate`
927    /// [`true`] to activate items on single click
928    #[doc(alias = "gtk_list_view_set_single_click_activate")]
929    #[doc(alias = "single-click-activate")]
930    pub fn set_single_click_activate(&self, single_click_activate: bool) {
931        unsafe {
932            ffi::gtk_list_view_set_single_click_activate(
933                self.to_glib_none().0,
934                single_click_activate.into_glib(),
935            );
936        }
937    }
938
939    /// Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
940    /// ## `tab_behavior`
941    /// The desired tab behavior
942    #[cfg(feature = "v4_12")]
943    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
944    #[doc(alias = "gtk_list_view_set_tab_behavior")]
945    #[doc(alias = "tab-behavior")]
946    pub fn set_tab_behavior(&self, tab_behavior: ListTabBehavior) {
947        unsafe {
948            ffi::gtk_list_view_set_tab_behavior(self.to_glib_none().0, tab_behavior.into_glib());
949        }
950    }
951
952    /// Emitted when a row has been activated by the user,
953    /// usually via activating the GtkListView|list.activate-item action.
954    ///
955    /// This allows for a convenient way to handle activation in a listview.
956    /// See [`ListItemExt::set_activatable()`][crate::prelude::ListItemExt::set_activatable()] for details on how to use
957    /// this signal.
958    /// ## `position`
959    /// position of item to activate
960    #[doc(alias = "activate")]
961    pub fn connect_activate<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
962        unsafe extern "C" fn activate_trampoline<F: Fn(&ListView, u32) + 'static>(
963            this: *mut ffi::GtkListView,
964            position: std::ffi::c_uint,
965            f: glib::ffi::gpointer,
966        ) {
967            let f: &F = &*(f as *const F);
968            f(&from_glib_borrow(this), position)
969        }
970        unsafe {
971            let f: Box_<F> = Box_::new(f);
972            connect_raw(
973                self.as_ptr() as *mut _,
974                b"activate\0".as_ptr() as *const _,
975                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
976                    activate_trampoline::<F> as *const (),
977                )),
978                Box_::into_raw(f),
979            )
980        }
981    }
982
983    #[doc(alias = "enable-rubberband")]
984    pub fn connect_enable_rubberband_notify<F: Fn(&Self) + 'static>(
985        &self,
986        f: F,
987    ) -> SignalHandlerId {
988        unsafe extern "C" fn notify_enable_rubberband_trampoline<F: Fn(&ListView) + 'static>(
989            this: *mut ffi::GtkListView,
990            _param_spec: glib::ffi::gpointer,
991            f: glib::ffi::gpointer,
992        ) {
993            let f: &F = &*(f as *const F);
994            f(&from_glib_borrow(this))
995        }
996        unsafe {
997            let f: Box_<F> = Box_::new(f);
998            connect_raw(
999                self.as_ptr() as *mut _,
1000                b"notify::enable-rubberband\0".as_ptr() as *const _,
1001                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1002                    notify_enable_rubberband_trampoline::<F> as *const (),
1003                )),
1004                Box_::into_raw(f),
1005            )
1006        }
1007    }
1008
1009    #[doc(alias = "factory")]
1010    pub fn connect_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1011        unsafe extern "C" fn notify_factory_trampoline<F: Fn(&ListView) + 'static>(
1012            this: *mut ffi::GtkListView,
1013            _param_spec: glib::ffi::gpointer,
1014            f: glib::ffi::gpointer,
1015        ) {
1016            let f: &F = &*(f as *const F);
1017            f(&from_glib_borrow(this))
1018        }
1019        unsafe {
1020            let f: Box_<F> = Box_::new(f);
1021            connect_raw(
1022                self.as_ptr() as *mut _,
1023                b"notify::factory\0".as_ptr() as *const _,
1024                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1025                    notify_factory_trampoline::<F> as *const (),
1026                )),
1027                Box_::into_raw(f),
1028            )
1029        }
1030    }
1031
1032    #[cfg(feature = "v4_12")]
1033    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1034    #[doc(alias = "header-factory")]
1035    pub fn connect_header_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1036        unsafe extern "C" fn notify_header_factory_trampoline<F: Fn(&ListView) + 'static>(
1037            this: *mut ffi::GtkListView,
1038            _param_spec: glib::ffi::gpointer,
1039            f: glib::ffi::gpointer,
1040        ) {
1041            let f: &F = &*(f as *const F);
1042            f(&from_glib_borrow(this))
1043        }
1044        unsafe {
1045            let f: Box_<F> = Box_::new(f);
1046            connect_raw(
1047                self.as_ptr() as *mut _,
1048                b"notify::header-factory\0".as_ptr() as *const _,
1049                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1050                    notify_header_factory_trampoline::<F> as *const (),
1051                )),
1052                Box_::into_raw(f),
1053            )
1054        }
1055    }
1056
1057    #[doc(alias = "model")]
1058    pub fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1059        unsafe extern "C" fn notify_model_trampoline<F: Fn(&ListView) + 'static>(
1060            this: *mut ffi::GtkListView,
1061            _param_spec: glib::ffi::gpointer,
1062            f: glib::ffi::gpointer,
1063        ) {
1064            let f: &F = &*(f as *const F);
1065            f(&from_glib_borrow(this))
1066        }
1067        unsafe {
1068            let f: Box_<F> = Box_::new(f);
1069            connect_raw(
1070                self.as_ptr() as *mut _,
1071                b"notify::model\0".as_ptr() as *const _,
1072                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1073                    notify_model_trampoline::<F> as *const (),
1074                )),
1075                Box_::into_raw(f),
1076            )
1077        }
1078    }
1079
1080    #[doc(alias = "show-separators")]
1081    pub fn connect_show_separators_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1082        unsafe extern "C" fn notify_show_separators_trampoline<F: Fn(&ListView) + 'static>(
1083            this: *mut ffi::GtkListView,
1084            _param_spec: glib::ffi::gpointer,
1085            f: glib::ffi::gpointer,
1086        ) {
1087            let f: &F = &*(f as *const F);
1088            f(&from_glib_borrow(this))
1089        }
1090        unsafe {
1091            let f: Box_<F> = Box_::new(f);
1092            connect_raw(
1093                self.as_ptr() as *mut _,
1094                b"notify::show-separators\0".as_ptr() as *const _,
1095                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1096                    notify_show_separators_trampoline::<F> as *const (),
1097                )),
1098                Box_::into_raw(f),
1099            )
1100        }
1101    }
1102
1103    #[doc(alias = "single-click-activate")]
1104    pub fn connect_single_click_activate_notify<F: Fn(&Self) + 'static>(
1105        &self,
1106        f: F,
1107    ) -> SignalHandlerId {
1108        unsafe extern "C" fn notify_single_click_activate_trampoline<F: Fn(&ListView) + 'static>(
1109            this: *mut ffi::GtkListView,
1110            _param_spec: glib::ffi::gpointer,
1111            f: glib::ffi::gpointer,
1112        ) {
1113            let f: &F = &*(f as *const F);
1114            f(&from_glib_borrow(this))
1115        }
1116        unsafe {
1117            let f: Box_<F> = Box_::new(f);
1118            connect_raw(
1119                self.as_ptr() as *mut _,
1120                b"notify::single-click-activate\0".as_ptr() as *const _,
1121                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1122                    notify_single_click_activate_trampoline::<F> as *const (),
1123                )),
1124                Box_::into_raw(f),
1125            )
1126        }
1127    }
1128
1129    #[cfg(feature = "v4_12")]
1130    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1131    #[doc(alias = "tab-behavior")]
1132    pub fn connect_tab_behavior_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1133        unsafe extern "C" fn notify_tab_behavior_trampoline<F: Fn(&ListView) + 'static>(
1134            this: *mut ffi::GtkListView,
1135            _param_spec: glib::ffi::gpointer,
1136            f: glib::ffi::gpointer,
1137        ) {
1138            let f: &F = &*(f as *const F);
1139            f(&from_glib_borrow(this))
1140        }
1141        unsafe {
1142            let f: Box_<F> = Box_::new(f);
1143            connect_raw(
1144                self.as_ptr() as *mut _,
1145                b"notify::tab-behavior\0".as_ptr() as *const _,
1146                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1147                    notify_tab_behavior_trampoline::<F> as *const (),
1148                )),
1149                Box_::into_raw(f),
1150            )
1151        }
1152    }
1153}
1154
1155impl Default for ListView {
1156    fn default() -> Self {
1157        glib::object::Object::new::<Self>()
1158    }
1159}
1160
1161// rustdoc-stripper-ignore-next
1162/// A [builder-pattern] type to construct [`ListView`] objects.
1163///
1164/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1165#[must_use = "The builder must be built to be used"]
1166pub struct ListViewBuilder {
1167    builder: glib::object::ObjectBuilder<'static, ListView>,
1168}
1169
1170impl ListViewBuilder {
1171    fn new() -> Self {
1172        Self {
1173            builder: glib::object::Object::builder(),
1174        }
1175    }
1176
1177    /// Allow rubberband selection.
1178    pub fn enable_rubberband(self, enable_rubberband: bool) -> Self {
1179        Self {
1180            builder: self
1181                .builder
1182                .property("enable-rubberband", enable_rubberband),
1183        }
1184    }
1185
1186    /// Factory for populating list items.
1187    ///
1188    /// The factory must be for configuring [`ListItem`][crate::ListItem] objects.
1189    pub fn factory(self, factory: &impl IsA<ListItemFactory>) -> Self {
1190        Self {
1191            builder: self.builder.property("factory", factory.clone().upcast()),
1192        }
1193    }
1194
1195    /// Factory for creating header widgets.
1196    ///
1197    /// The factory must be for configuring [`ListHeader`][crate::ListHeader] objects.
1198    #[cfg(feature = "v4_12")]
1199    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1200    pub fn header_factory(self, header_factory: &impl IsA<ListItemFactory>) -> Self {
1201        Self {
1202            builder: self
1203                .builder
1204                .property("header-factory", header_factory.clone().upcast()),
1205        }
1206    }
1207
1208    /// Model for the items displayed.
1209    pub fn model(self, model: &impl IsA<SelectionModel>) -> Self {
1210        Self {
1211            builder: self.builder.property("model", model.clone().upcast()),
1212        }
1213    }
1214
1215    /// Show separators between rows.
1216    pub fn show_separators(self, show_separators: bool) -> Self {
1217        Self {
1218            builder: self.builder.property("show-separators", show_separators),
1219        }
1220    }
1221
1222    /// Activate rows on single click and select them on hover.
1223    pub fn single_click_activate(self, single_click_activate: bool) -> Self {
1224        Self {
1225            builder: self
1226                .builder
1227                .property("single-click-activate", single_click_activate),
1228        }
1229    }
1230
1231    /// Behavior of the <kbd>Tab</kbd> key
1232    #[cfg(feature = "v4_12")]
1233    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1234    pub fn tab_behavior(self, tab_behavior: ListTabBehavior) -> Self {
1235        Self {
1236            builder: self.builder.property("tab-behavior", tab_behavior),
1237        }
1238    }
1239
1240    /// The orientation of the list. See GtkOrientable:orientation
1241    /// for details.
1242    pub fn orientation(self, orientation: Orientation) -> Self {
1243        Self {
1244            builder: self.builder.property("orientation", orientation),
1245        }
1246    }
1247
1248    /// Whether the widget or any of its descendents can accept
1249    /// the input focus.
1250    ///
1251    /// This property is meant to be set by widget implementations,
1252    /// typically in their instance init function.
1253    pub fn can_focus(self, can_focus: bool) -> Self {
1254        Self {
1255            builder: self.builder.property("can-focus", can_focus),
1256        }
1257    }
1258
1259    /// Whether the widget can receive pointer events.
1260    pub fn can_target(self, can_target: bool) -> Self {
1261        Self {
1262            builder: self.builder.property("can-target", can_target),
1263        }
1264    }
1265
1266    /// A list of css classes applied to this widget.
1267    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1268        Self {
1269            builder: self.builder.property("css-classes", css_classes.into()),
1270        }
1271    }
1272
1273    /// The name of this widget in the CSS tree.
1274    ///
1275    /// This property is meant to be set by widget implementations,
1276    /// typically in their instance init function.
1277    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1278        Self {
1279            builder: self.builder.property("css-name", css_name.into()),
1280        }
1281    }
1282
1283    /// The cursor used by @widget.
1284    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1285        Self {
1286            builder: self.builder.property("cursor", cursor.clone()),
1287        }
1288    }
1289
1290    /// Whether the widget should grab focus when it is clicked with the mouse.
1291    ///
1292    /// This property is only relevant for widgets that can take focus.
1293    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1294        Self {
1295            builder: self.builder.property("focus-on-click", focus_on_click),
1296        }
1297    }
1298
1299    /// Whether this widget itself will accept the input focus.
1300    pub fn focusable(self, focusable: bool) -> Self {
1301        Self {
1302            builder: self.builder.property("focusable", focusable),
1303        }
1304    }
1305
1306    /// How to distribute horizontal space if widget gets extra space.
1307    pub fn halign(self, halign: Align) -> Self {
1308        Self {
1309            builder: self.builder.property("halign", halign),
1310        }
1311    }
1312
1313    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1314    /// signal on @widget.
1315    ///
1316    /// A true value indicates that @widget can have a tooltip, in this case
1317    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1318    /// determine whether it will provide a tooltip or not.
1319    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1320        Self {
1321            builder: self.builder.property("has-tooltip", has_tooltip),
1322        }
1323    }
1324
1325    /// Overrides for height request of the widget.
1326    ///
1327    /// If this is -1, the natural request will be used.
1328    pub fn height_request(self, height_request: i32) -> Self {
1329        Self {
1330            builder: self.builder.property("height-request", height_request),
1331        }
1332    }
1333
1334    /// Whether to expand horizontally.
1335    pub fn hexpand(self, hexpand: bool) -> Self {
1336        Self {
1337            builder: self.builder.property("hexpand", hexpand),
1338        }
1339    }
1340
1341    /// Whether to use the `hexpand` property.
1342    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1343        Self {
1344            builder: self.builder.property("hexpand-set", hexpand_set),
1345        }
1346    }
1347
1348    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1349    /// the preferred size of the widget, and allocate its children.
1350    ///
1351    /// This property is meant to be set by widget implementations,
1352    /// typically in their instance init function.
1353    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1354        Self {
1355            builder: self
1356                .builder
1357                .property("layout-manager", layout_manager.clone().upcast()),
1358        }
1359    }
1360
1361    /// Makes this widget act like a modal dialog, with respect to
1362    /// event delivery.
1363    ///
1364    /// Global event controllers will not handle events with targets
1365    /// inside the widget, unless they are set up to ignore propagation
1366    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1367    #[cfg(feature = "v4_18")]
1368    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1369    pub fn limit_events(self, limit_events: bool) -> Self {
1370        Self {
1371            builder: self.builder.property("limit-events", limit_events),
1372        }
1373    }
1374
1375    /// Margin on bottom side of widget.
1376    ///
1377    /// This property adds margin outside of the widget's normal size
1378    /// request, the margin will be added in addition to the size from
1379    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1380    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1381        Self {
1382            builder: self.builder.property("margin-bottom", margin_bottom),
1383        }
1384    }
1385
1386    /// Margin on end of widget, horizontally.
1387    ///
1388    /// This property supports left-to-right and right-to-left text
1389    /// directions.
1390    ///
1391    /// This property adds margin outside of the widget's normal size
1392    /// request, the margin will be added in addition to the size from
1393    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1394    pub fn margin_end(self, margin_end: i32) -> Self {
1395        Self {
1396            builder: self.builder.property("margin-end", margin_end),
1397        }
1398    }
1399
1400    /// Margin on start of widget, horizontally.
1401    ///
1402    /// This property supports left-to-right and right-to-left text
1403    /// directions.
1404    ///
1405    /// This property adds margin outside of the widget's normal size
1406    /// request, the margin will be added in addition to the size from
1407    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1408    pub fn margin_start(self, margin_start: i32) -> Self {
1409        Self {
1410            builder: self.builder.property("margin-start", margin_start),
1411        }
1412    }
1413
1414    /// Margin on top side of widget.
1415    ///
1416    /// This property adds margin outside of the widget's normal size
1417    /// request, the margin will be added in addition to the size from
1418    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1419    pub fn margin_top(self, margin_top: i32) -> Self {
1420        Self {
1421            builder: self.builder.property("margin-top", margin_top),
1422        }
1423    }
1424
1425    /// The name of the widget.
1426    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1427        Self {
1428            builder: self.builder.property("name", name.into()),
1429        }
1430    }
1431
1432    /// The requested opacity of the widget.
1433    pub fn opacity(self, opacity: f64) -> Self {
1434        Self {
1435            builder: self.builder.property("opacity", opacity),
1436        }
1437    }
1438
1439    /// How content outside the widget's content area is treated.
1440    ///
1441    /// This property is meant to be set by widget implementations,
1442    /// typically in their instance init function.
1443    pub fn overflow(self, overflow: Overflow) -> Self {
1444        Self {
1445            builder: self.builder.property("overflow", overflow),
1446        }
1447    }
1448
1449    /// Whether the widget will receive the default action when it is focused.
1450    pub fn receives_default(self, receives_default: bool) -> Self {
1451        Self {
1452            builder: self.builder.property("receives-default", receives_default),
1453        }
1454    }
1455
1456    /// Whether the widget responds to input.
1457    pub fn sensitive(self, sensitive: bool) -> Self {
1458        Self {
1459            builder: self.builder.property("sensitive", sensitive),
1460        }
1461    }
1462
1463    /// Sets the text of tooltip to be the given string, which is marked up
1464    /// with Pango markup.
1465    ///
1466    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1467    ///
1468    /// This is a convenience property which will take care of getting the
1469    /// tooltip shown if the given string is not `NULL`:
1470    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1471    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1472    /// the default signal handler.
1473    ///
1474    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1475    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1476    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1477        Self {
1478            builder: self
1479                .builder
1480                .property("tooltip-markup", tooltip_markup.into()),
1481        }
1482    }
1483
1484    /// Sets the text of tooltip to be the given string.
1485    ///
1486    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1487    ///
1488    /// This is a convenience property which will take care of getting the
1489    /// tooltip shown if the given string is not `NULL`:
1490    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1491    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1492    /// the default signal handler.
1493    ///
1494    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1495    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1496    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1497        Self {
1498            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1499        }
1500    }
1501
1502    /// How to distribute vertical space if widget gets extra space.
1503    pub fn valign(self, valign: Align) -> Self {
1504        Self {
1505            builder: self.builder.property("valign", valign),
1506        }
1507    }
1508
1509    /// Whether to expand vertically.
1510    pub fn vexpand(self, vexpand: bool) -> Self {
1511        Self {
1512            builder: self.builder.property("vexpand", vexpand),
1513        }
1514    }
1515
1516    /// Whether to use the `vexpand` property.
1517    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1518        Self {
1519            builder: self.builder.property("vexpand-set", vexpand_set),
1520        }
1521    }
1522
1523    /// Whether the widget is visible.
1524    pub fn visible(self, visible: bool) -> Self {
1525        Self {
1526            builder: self.builder.property("visible", visible),
1527        }
1528    }
1529
1530    /// Overrides for width request of the widget.
1531    ///
1532    /// If this is -1, the natural request will be used.
1533    pub fn width_request(self, width_request: i32) -> Self {
1534        Self {
1535            builder: self.builder.property("width-request", width_request),
1536        }
1537    }
1538
1539    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1540    ///
1541    /// The accessible role cannot be changed once set.
1542    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1543        Self {
1544            builder: self.builder.property("accessible-role", accessible_role),
1545        }
1546    }
1547
1548    /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
1549    ///
1550    /// This adjustment is shared between the scrollable widget and its parent.
1551    pub fn hadjustment(self, hadjustment: &impl IsA<Adjustment>) -> Self {
1552        Self {
1553            builder: self
1554                .builder
1555                .property("hadjustment", hadjustment.clone().upcast()),
1556        }
1557    }
1558
1559    /// Determines when horizontal scrolling should start.
1560    pub fn hscroll_policy(self, hscroll_policy: ScrollablePolicy) -> Self {
1561        Self {
1562            builder: self.builder.property("hscroll-policy", hscroll_policy),
1563        }
1564    }
1565
1566    /// Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
1567    ///
1568    /// This adjustment is shared between the scrollable widget and its parent.
1569    pub fn vadjustment(self, vadjustment: &impl IsA<Adjustment>) -> Self {
1570        Self {
1571            builder: self
1572                .builder
1573                .property("vadjustment", vadjustment.clone().upcast()),
1574        }
1575    }
1576
1577    /// Determines when vertical scrolling should start.
1578    pub fn vscroll_policy(self, vscroll_policy: ScrollablePolicy) -> Self {
1579        Self {
1580            builder: self.builder.property("vscroll-policy", vscroll_policy),
1581        }
1582    }
1583
1584    // rustdoc-stripper-ignore-next
1585    /// Build the [`ListView`].
1586    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1587    pub fn build(self) -> ListView {
1588        assert_initialized_main_thread!();
1589        self.builder.build()
1590    }
1591}