Skip to main content

gtk4/auto/
list_box.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5#[cfg(feature = "v4_18")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
7use crate::ListTabBehavior;
8use crate::{
9    Accessible, AccessibleRole, Adjustment, Align, Buildable, ConstraintTarget, LayoutManager,
10    ListBoxRow, MovementStep, Overflow, SelectionMode, Widget, ffi,
11};
12use glib::{
13    object::ObjectType as _,
14    prelude::*,
15    signal::{SignalHandlerId, connect_raw},
16    translate::*,
17};
18use std::boxed::Box as Box_;
19
20glib::wrapper! {
21    /// Shows a vertical list.
22    ///
23    /// <picture>
24    ///   <source srcset="list-box-dark.png" media="(prefers-color-scheme: dark)">
25    ///   <img alt="An example GtkListBox" src="list-box.png">
26    /// </picture>
27    ///
28    /// A [`ListBox`][crate::ListBox] only contains [`ListBoxRow`][crate::ListBoxRow] children. These rows can
29    /// by dynamically sorted and filtered, and headers can be added dynamically
30    /// depending on the row content. It also allows keyboard and mouse navigation
31    /// and selection like a typical list.
32    ///
33    /// Using [`ListBox`][crate::ListBox] is often an alternative to [`TreeView`][crate::TreeView], especially
34    /// when the list contents has a more complicated layout than what is allowed
35    /// by a [`CellRenderer`][crate::CellRenderer], or when the contents is interactive (i.e. has a
36    /// button in it).
37    ///
38    /// Although a [`ListBox`][crate::ListBox] must have only [`ListBoxRow`][crate::ListBoxRow] children, you can
39    /// add any kind of widget to it via [`prepend()`][Self::prepend()],
40    /// [`append()`][Self::append()] and [`insert()`][Self::insert()] and a
41    /// [`ListBoxRow`][crate::ListBoxRow] widget will automatically be inserted between the list
42    /// and the widget.
43    ///
44    /// `GtkListBoxRows` can be marked as activatable or selectable. If a row is
45    /// activatable, [`row-activated`][struct@crate::ListBox#row-activated] will be emitted for it when
46    /// the user tries to activate it. If it is selectable, the row will be marked
47    /// as selected when the user tries to select it.
48    ///
49    /// # GtkListBox as GtkBuildable
50    ///
51    /// The [`ListBox`][crate::ListBox] implementation of the [`Buildable`][crate::Buildable] interface supports
52    /// setting a child as the placeholder by specifying “placeholder” as the “type”
53    /// attribute of a `<child>` element. See [`set_placeholder()`][Self::set_placeholder()]
54    /// for info.
55    ///
56    /// # Shortcuts and Gestures
57    ///
58    /// The following signals have default keybindings:
59    ///
60    /// - [`move-cursor`][struct@crate::ListBox#move-cursor]
61    /// - [`select-all`][struct@crate::ListBox#select-all]
62    /// - [`toggle-cursor-row`][struct@crate::ListBox#toggle-cursor-row]
63    /// - [`unselect-all`][struct@crate::ListBox#unselect-all]
64    ///
65    /// # CSS nodes
66    ///
67    /// ```text
68    /// list[.separators][.rich-list][.navigation-sidebar][.boxed-list]
69    /// ╰── row[.activatable]
70    /// ```
71    ///
72    /// [`ListBox`][crate::ListBox] uses a single CSS node named list. It may carry the .separators
73    /// style class, when the [`show-separators`][struct@crate::ListBox#show-separators] property is set.
74    /// Each [`ListBoxRow`][crate::ListBoxRow] uses a single CSS node named row. The row nodes get the
75    /// .activatable style class added when appropriate.
76    ///
77    /// It may also carry the .boxed-list style class. In this case, the list will be
78    /// automatically surrounded by a frame and have separators.
79    ///
80    /// The main list node may also carry style classes to select
81    /// the style of [list presentation](section-list-widget.html#list-styles):
82    /// .rich-list, .navigation-sidebar or .data-table.
83    ///
84    /// # Accessibility
85    ///
86    /// [`ListBox`][crate::ListBox] uses the [enum@Gtk.AccessibleRole.list] role and [`ListBoxRow`][crate::ListBoxRow] uses
87    /// the [enum@Gtk.AccessibleRole.list_item] role.
88    ///
89    /// ## Properties
90    ///
91    ///
92    /// #### `accept-unpaired-release`
93    ///  Whether to accept unpaired release events.
94    ///
95    /// Readable | Writeable
96    ///
97    ///
98    /// #### `activate-on-single-click`
99    ///  Determines whether children can be activated with a single
100    /// click, or require a double-click.
101    ///
102    /// Readable | Writeable
103    ///
104    ///
105    /// #### `selection-mode`
106    ///  The selection mode used by the list box.
107    ///
108    /// Readable | Writeable
109    ///
110    ///
111    /// #### `show-separators`
112    ///  Whether to show separators between rows.
113    ///
114    /// Readable | Writeable
115    ///
116    ///
117    /// #### `tab-behavior`
118    ///  Behavior of the <kbd>Tab</kbd> key
119    ///
120    /// Readable | Writeable
121    /// <details><summary><h4>Widget</h4></summary>
122    ///
123    ///
124    /// #### `can-focus`
125    ///  Whether the widget or any of its descendents can accept
126    /// the input focus.
127    ///
128    /// This property is meant to be set by widget implementations,
129    /// typically in their instance init function.
130    ///
131    /// Readable | Writeable
132    ///
133    ///
134    /// #### `can-target`
135    ///  Whether the widget can receive pointer events.
136    ///
137    /// Readable | Writeable
138    ///
139    ///
140    /// #### `css-classes`
141    ///  A list of css classes applied to this widget.
142    ///
143    /// Readable | Writeable
144    ///
145    ///
146    /// #### `css-name`
147    ///  The name of this widget in the CSS tree.
148    ///
149    /// This property is meant to be set by widget implementations,
150    /// typically in their instance init function.
151    ///
152    /// Readable | Writeable | Construct Only
153    ///
154    ///
155    /// #### `cursor`
156    ///  The cursor used by @widget.
157    ///
158    /// Readable | Writeable
159    ///
160    ///
161    /// #### `focus-on-click`
162    ///  Whether the widget should grab focus when it is clicked with the mouse.
163    ///
164    /// This property is only relevant for widgets that can take focus.
165    ///
166    /// Readable | Writeable
167    ///
168    ///
169    /// #### `focusable`
170    ///  Whether this widget itself will accept the input focus.
171    ///
172    /// Readable | Writeable
173    ///
174    ///
175    /// #### `halign`
176    ///  How to distribute horizontal space if widget gets extra space.
177    ///
178    /// Readable | Writeable
179    ///
180    ///
181    /// #### `has-default`
182    ///  Whether the widget is the default widget.
183    ///
184    /// Readable
185    ///
186    ///
187    /// #### `has-focus`
188    ///  Whether the widget has the input focus.
189    ///
190    /// Readable
191    ///
192    ///
193    /// #### `has-tooltip`
194    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
195    /// signal on @widget.
196    ///
197    /// A true value indicates that @widget can have a tooltip, in this case
198    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
199    /// determine whether it will provide a tooltip or not.
200    ///
201    /// Readable | Writeable
202    ///
203    ///
204    /// #### `height-request`
205    ///  Overrides for height request of the widget.
206    ///
207    /// If this is -1, the natural request will be used.
208    ///
209    /// Readable | Writeable
210    ///
211    ///
212    /// #### `hexpand`
213    ///  Whether to expand horizontally.
214    ///
215    /// Readable | Writeable
216    ///
217    ///
218    /// #### `hexpand-set`
219    ///  Whether to use the `hexpand` property.
220    ///
221    /// Readable | Writeable
222    ///
223    ///
224    /// #### `layout-manager`
225    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
226    /// the preferred size of the widget, and allocate its children.
227    ///
228    /// This property is meant to be set by widget implementations,
229    /// typically in their instance init function.
230    ///
231    /// Readable | Writeable
232    ///
233    ///
234    /// #### `limit-events`
235    ///  Makes this widget act like a modal dialog, with respect to
236    /// event delivery.
237    ///
238    /// Global event controllers will not handle events with targets
239    /// inside the widget, unless they are set up to ignore propagation
240    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
241    ///
242    /// Readable | Writeable
243    ///
244    ///
245    /// #### `margin-bottom`
246    ///  Margin on bottom side of widget.
247    ///
248    /// This property adds margin outside of the widget's normal size
249    /// request, the margin will be added in addition to the size from
250    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
251    ///
252    /// Readable | Writeable
253    ///
254    ///
255    /// #### `margin-end`
256    ///  Margin on end of widget, horizontally.
257    ///
258    /// This property supports left-to-right and right-to-left text
259    /// directions.
260    ///
261    /// This property adds margin outside of the widget's normal size
262    /// request, the margin will be added in addition to the size from
263    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
264    ///
265    /// Readable | Writeable
266    ///
267    ///
268    /// #### `margin-start`
269    ///  Margin on start of widget, horizontally.
270    ///
271    /// This property supports left-to-right and right-to-left text
272    /// directions.
273    ///
274    /// This property adds margin outside of the widget's normal size
275    /// request, the margin will be added in addition to the size from
276    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
277    ///
278    /// Readable | Writeable
279    ///
280    ///
281    /// #### `margin-top`
282    ///  Margin on top side of widget.
283    ///
284    /// This property adds margin outside of the widget's normal size
285    /// request, the margin will be added in addition to the size from
286    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
287    ///
288    /// Readable | Writeable
289    ///
290    ///
291    /// #### `name`
292    ///  The name of the widget.
293    ///
294    /// Readable | Writeable
295    ///
296    ///
297    /// #### `opacity`
298    ///  The requested opacity of the widget.
299    ///
300    /// Readable | Writeable
301    ///
302    ///
303    /// #### `overflow`
304    ///  How content outside the widget's content area is treated.
305    ///
306    /// This property is meant to be set by widget implementations,
307    /// typically in their instance init function.
308    ///
309    /// Readable | Writeable
310    ///
311    ///
312    /// #### `parent`
313    ///  The parent widget of this widget.
314    ///
315    /// Readable
316    ///
317    ///
318    /// #### `receives-default`
319    ///  Whether the widget will receive the default action when it is focused.
320    ///
321    /// Readable | Writeable
322    ///
323    ///
324    /// #### `root`
325    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
326    ///
327    /// This will be `NULL` if the widget is not contained in a root widget.
328    ///
329    /// Readable
330    ///
331    ///
332    /// #### `scale-factor`
333    ///  The scale factor of the widget.
334    ///
335    /// Readable
336    ///
337    ///
338    /// #### `sensitive`
339    ///  Whether the widget responds to input.
340    ///
341    /// Readable | Writeable
342    ///
343    ///
344    /// #### `tooltip-markup`
345    ///  Sets the text of tooltip to be the given string, which is marked up
346    /// with Pango markup.
347    ///
348    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
349    ///
350    /// This is a convenience property which will take care of getting the
351    /// tooltip shown if the given string is not `NULL`:
352    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
353    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
354    /// the default signal handler.
355    ///
356    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
357    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
358    ///
359    /// Readable | Writeable
360    ///
361    ///
362    /// #### `tooltip-text`
363    ///  Sets the text of tooltip to be the given string.
364    ///
365    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
366    ///
367    /// This is a convenience property which will take care of getting the
368    /// tooltip shown if the given string is not `NULL`:
369    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
370    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
371    /// the default signal handler.
372    ///
373    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
374    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
375    ///
376    /// Readable | Writeable
377    ///
378    ///
379    /// #### `valign`
380    ///  How to distribute vertical space if widget gets extra space.
381    ///
382    /// Readable | Writeable
383    ///
384    ///
385    /// #### `vexpand`
386    ///  Whether to expand vertically.
387    ///
388    /// Readable | Writeable
389    ///
390    ///
391    /// #### `vexpand-set`
392    ///  Whether to use the `vexpand` property.
393    ///
394    /// Readable | Writeable
395    ///
396    ///
397    /// #### `visible`
398    ///  Whether the widget is visible.
399    ///
400    /// Readable | Writeable
401    ///
402    ///
403    /// #### `width-request`
404    ///  Overrides for width request of the widget.
405    ///
406    /// If this is -1, the natural request will be used.
407    ///
408    /// Readable | Writeable
409    /// </details>
410    /// <details><summary><h4>Accessible</h4></summary>
411    ///
412    ///
413    /// #### `accessible-role`
414    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
415    ///
416    /// The accessible role cannot be changed once set.
417    ///
418    /// Readable | Writeable
419    /// </details>
420    ///
421    /// ## Signals
422    ///
423    ///
424    /// #### `activate-cursor-row`
425    ///  Emitted when the cursor row is activated.
426    ///
427    /// Action
428    ///
429    ///
430    /// #### `move-cursor`
431    ///  Emitted when the user initiates a cursor movement.
432    ///
433    /// The default bindings for this signal come in two variants, the variant with
434    /// the Shift modifier extends the selection, the variant without the Shift
435    /// modifier does not. There are too many key combinations to list them all
436    /// here.
437    ///
438    /// - <kbd>←</kbd>, <kbd>→</kbd>, <kbd>↑</kbd>, <kbd>↓</kbd>
439    ///   move by individual children
440    /// - <kbd>Home</kbd>, <kbd>End</kbd> move to the ends of the box
441    /// - <kbd>PgUp</kbd>, <kbd>PgDn</kbd> move vertically by pages
442    ///
443    /// Action
444    ///
445    ///
446    /// #### `row-activated`
447    ///  Emitted when a row has been activated by the user.
448    ///
449    ///
450    ///
451    ///
452    /// #### `row-selected`
453    ///  Emitted when a new row is selected, or (with a [`None`] @row)
454    /// when the selection is cleared.
455    ///
456    /// When the @box_ is using [`SelectionMode::Multiple`][crate::SelectionMode::Multiple], this signal will not
457    /// give you the full picture of selection changes, and you should use
458    /// the [`selected-rows-changed`][struct@crate::ListBox#selected-rows-changed] signal instead.
459    ///
460    ///
461    ///
462    ///
463    /// #### `select-all`
464    ///  Emitted to select all children of the box, if the selection
465    /// mode permits it.
466    ///
467    /// This is a [keybinding signal](class.SignalAction.html).
468    ///
469    /// The default binding for this signal is <kbd>Ctrl</kbd>-<kbd>a</kbd>.
470    ///
471    /// Action
472    ///
473    ///
474    /// #### `selected-rows-changed`
475    ///  Emitted when the set of selected rows changes.
476    ///
477    ///
478    ///
479    ///
480    /// #### `toggle-cursor-row`
481    ///  Emitted when the cursor row is toggled.
482    ///
483    /// The default bindings for this signal is <kbd>Ctrl</kbd>+<kbd>␣</kbd>.
484    ///
485    /// Action
486    ///
487    ///
488    /// #### `unselect-all`
489    ///  Emitted to unselect all children of the box, if the selection
490    /// mode permits it.
491    ///
492    /// This is a [keybinding signal](class.SignalAction.html).
493    ///
494    /// The default binding for this signal is
495    /// <kbd>Ctrl</kbd>-<kbd>Shift</kbd>-<kbd>a</kbd>.
496    ///
497    /// Action
498    /// <details><summary><h4>Widget</h4></summary>
499    ///
500    ///
501    /// #### `destroy`
502    ///  Signals that all holders of a reference to the widget should release
503    /// the reference that they hold.
504    ///
505    /// May result in finalization of the widget if all references are released.
506    ///
507    /// This signal is not suitable for saving widget state.
508    ///
509    ///
510    ///
511    ///
512    /// #### `direction-changed`
513    ///  Emitted when the text direction of a widget changes.
514    ///
515    ///
516    ///
517    ///
518    /// #### `hide`
519    ///  Emitted when @widget is hidden.
520    ///
521    ///
522    ///
523    ///
524    /// #### `keynav-failed`
525    ///  Emitted if keyboard navigation fails.
526    ///
527    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
528    ///
529    ///
530    ///
531    ///
532    /// #### `map`
533    ///  Emitted when @widget is going to be mapped.
534    ///
535    /// A widget is mapped when the widget is visible (which is controlled with
536    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
537    /// are also visible.
538    ///
539    /// The `::map` signal can be used to determine whether a widget will be drawn,
540    /// for instance it can resume an animation that was stopped during the
541    /// emission of [`unmap`][struct@crate::Widget#unmap].
542    ///
543    ///
544    ///
545    ///
546    /// #### `mnemonic-activate`
547    ///  Emitted when a widget is activated via a mnemonic.
548    ///
549    /// The default handler for this signal activates @widget if @group_cycling
550    /// is false, or just makes @widget grab focus if @group_cycling is true.
551    ///
552    ///
553    ///
554    ///
555    /// #### `move-focus`
556    ///  Emitted when the focus is moved.
557    ///
558    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
559    ///
560    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
561    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
562    ///
563    /// Action
564    ///
565    ///
566    /// #### `query-tooltip`
567    ///  Emitted when the widget’s tooltip is about to be shown.
568    ///
569    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
570    /// is true and the hover timeout has expired with the cursor hovering
571    /// above @widget; or emitted when @widget got focus in keyboard mode.
572    ///
573    /// Using the given coordinates, the signal handler should determine
574    /// whether a tooltip should be shown for @widget. If this is the case
575    /// true should be returned, false otherwise. Note that if @keyboard_mode
576    /// is true, the values of @x and @y are undefined and should not be used.
577    ///
578    /// The signal handler is free to manipulate @tooltip with the therefore
579    /// destined function calls.
580    ///
581    ///
582    ///
583    ///
584    /// #### `realize`
585    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
586    ///
587    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
588    /// or the widget has been mapped (that is, it is going to be drawn).
589    ///
590    ///
591    ///
592    ///
593    /// #### `show`
594    ///  Emitted when @widget is shown.
595    ///
596    ///
597    ///
598    ///
599    /// #### `state-flags-changed`
600    ///  Emitted when the widget state changes.
601    ///
602    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
603    ///
604    ///
605    ///
606    ///
607    /// #### `unmap`
608    ///  Emitted when @widget is going to be unmapped.
609    ///
610    /// A widget is unmapped when either it or any of its parents up to the
611    /// toplevel widget have been set as hidden.
612    ///
613    /// As `::unmap` indicates that a widget will not be shown any longer,
614    /// it can be used to, for example, stop an animation on the widget.
615    ///
616    ///
617    ///
618    ///
619    /// #### `unrealize`
620    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
621    ///
622    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
623    /// or the widget has been unmapped (that is, it is going to be hidden).
624    ///
625    ///
626    /// </details>
627    ///
628    /// # Implements
629    ///
630    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
631    #[doc(alias = "GtkListBox")]
632    pub struct ListBox(Object<ffi::GtkListBox>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
633
634    match fn {
635        type_ => || ffi::gtk_list_box_get_type(),
636    }
637}
638
639impl ListBox {
640    /// Creates a new [`ListBox`][crate::ListBox] container.
641    ///
642    /// # Returns
643    ///
644    /// a new [`ListBox`][crate::ListBox]
645    #[doc(alias = "gtk_list_box_new")]
646    pub fn new() -> ListBox {
647        assert_initialized_main_thread!();
648        unsafe { Widget::from_glib_none(ffi::gtk_list_box_new()).unsafe_cast() }
649    }
650
651    // rustdoc-stripper-ignore-next
652    /// Creates a new builder-pattern struct instance to construct [`ListBox`] objects.
653    ///
654    /// This method returns an instance of [`ListBoxBuilder`](crate::builders::ListBoxBuilder) which can be used to create [`ListBox`] objects.
655    pub fn builder() -> ListBoxBuilder {
656        ListBoxBuilder::new()
657    }
658
659    /// Append a widget to the list.
660    ///
661    /// If a sort function is set, the widget will
662    /// actually be inserted at the calculated position.
663    /// ## `child`
664    /// the [`Widget`][crate::Widget] to add
665    #[doc(alias = "gtk_list_box_append")]
666    pub fn append(&self, child: &impl IsA<Widget>) {
667        unsafe {
668            ffi::gtk_list_box_append(self.to_glib_none().0, child.as_ref().to_glib_none().0);
669        }
670    }
671
672    /// Binds @model to @self.
673    ///
674    /// If @self was already bound to a model, that previous binding is
675    /// destroyed.
676    ///
677    /// The contents of @self are cleared and then filled with widgets that
678    /// represent items from @model. @self is updated whenever @model changes.
679    /// If @model is [`None`], @self is left empty.
680    ///
681    /// It is undefined to add or remove widgets directly (for example, with
682    /// [`insert()`][Self::insert()]) while @self is bound to a model.
683    ///
684    /// Note that using a model is incompatible with the filtering and sorting
685    /// functionality in [`ListBox`][crate::ListBox]. When using a model, filtering and sorting
686    /// should be implemented by the model.
687    /// ## `model`
688    /// the `GListModel` to be bound to @self
689    /// ## `create_widget_func`
690    /// a function
691    ///   that creates widgets for items or [`None`] in case you also passed [`None`] as @model
692    #[doc(alias = "gtk_list_box_bind_model")]
693    pub fn bind_model<P: Fn(&glib::Object) -> Widget + 'static>(
694        &self,
695        model: Option<&impl IsA<gio::ListModel>>,
696        create_widget_func: P,
697    ) {
698        let create_widget_func_data: Box_<P> = Box_::new(create_widget_func);
699        unsafe extern "C" fn create_widget_func_func<P: Fn(&glib::Object) -> Widget + 'static>(
700            item: *mut glib::gobject_ffi::GObject,
701            user_data: glib::ffi::gpointer,
702        ) -> *mut ffi::GtkWidget {
703            unsafe {
704                let item = from_glib_borrow(item);
705                let callback = &*(user_data as *mut P);
706                (*callback)(&item).to_glib_full()
707            }
708        }
709        let create_widget_func = Some(create_widget_func_func::<P> as _);
710        unsafe extern "C" fn user_data_free_func_func<P: Fn(&glib::Object) -> Widget + 'static>(
711            data: glib::ffi::gpointer,
712        ) {
713            unsafe {
714                let _callback = Box_::from_raw(data as *mut P);
715            }
716        }
717        let destroy_call4 = Some(user_data_free_func_func::<P> as _);
718        let super_callback0: Box_<P> = create_widget_func_data;
719        unsafe {
720            ffi::gtk_list_box_bind_model(
721                self.to_glib_none().0,
722                model.map(|p| p.as_ref()).to_glib_none().0,
723                create_widget_func,
724                Box_::into_raw(super_callback0) as *mut _,
725                destroy_call4,
726            );
727        }
728    }
729
730    /// Add a drag highlight to a row.
731    ///
732    /// This is a helper function for implementing DnD onto a [`ListBox`][crate::ListBox].
733    /// The passed in @row will be highlighted by setting the
734    /// [`StateFlags::DROP_ACTIVE`][crate::StateFlags::DROP_ACTIVE] state and any previously highlighted
735    /// row will be unhighlighted.
736    ///
737    /// The row will also be unhighlighted when the widget gets
738    /// a drag leave event.
739    /// ## `row`
740    /// a [`ListBoxRow`][crate::ListBoxRow]
741    #[doc(alias = "gtk_list_box_drag_highlight_row")]
742    pub fn drag_highlight_row(&self, row: &impl IsA<ListBoxRow>) {
743        unsafe {
744            ffi::gtk_list_box_drag_highlight_row(
745                self.to_glib_none().0,
746                row.as_ref().to_glib_none().0,
747            );
748        }
749    }
750
751    /// If a row has previously been highlighted via gtk_list_box_drag_highlight_row(),
752    /// it will have the highlight removed.
753    #[doc(alias = "gtk_list_box_drag_unhighlight_row")]
754    pub fn drag_unhighlight_row(&self) {
755        unsafe {
756            ffi::gtk_list_box_drag_unhighlight_row(self.to_glib_none().0);
757        }
758    }
759
760    /// Returns whether rows activate on single clicks.
761    ///
762    /// # Returns
763    ///
764    /// [`true`] if rows are activated on single click, [`false`] otherwise
765    #[doc(alias = "gtk_list_box_get_activate_on_single_click")]
766    #[doc(alias = "get_activate_on_single_click")]
767    #[doc(alias = "activate-on-single-click")]
768    pub fn activates_on_single_click(&self) -> bool {
769        unsafe {
770            from_glib(ffi::gtk_list_box_get_activate_on_single_click(
771                self.to_glib_none().0,
772            ))
773        }
774    }
775
776    /// Gets the adjustment (if any) that the widget uses to
777    /// for vertical scrolling.
778    ///
779    /// # Returns
780    ///
781    /// the adjustment
782    #[doc(alias = "gtk_list_box_get_adjustment")]
783    #[doc(alias = "get_adjustment")]
784    pub fn adjustment(&self) -> Option<Adjustment> {
785        unsafe { from_glib_none(ffi::gtk_list_box_get_adjustment(self.to_glib_none().0)) }
786    }
787
788    /// Gets the n-th child in the list (not counting headers).
789    ///
790    /// If @index_ is negative or larger than the number of items in the
791    /// list, [`None`] is returned.
792    /// ## `index_`
793    /// the index of the row
794    ///
795    /// # Returns
796    ///
797    /// the child [`Widget`][crate::Widget]
798    #[doc(alias = "gtk_list_box_get_row_at_index")]
799    #[doc(alias = "get_row_at_index")]
800    pub fn row_at_index(&self, index_: i32) -> Option<ListBoxRow> {
801        unsafe {
802            from_glib_none(ffi::gtk_list_box_get_row_at_index(
803                self.to_glib_none().0,
804                index_,
805            ))
806        }
807    }
808
809    /// Gets the row at the @y position.
810    /// ## `y`
811    /// position
812    ///
813    /// # Returns
814    ///
815    /// the row
816    #[doc(alias = "gtk_list_box_get_row_at_y")]
817    #[doc(alias = "get_row_at_y")]
818    pub fn row_at_y(&self, y: i32) -> Option<ListBoxRow> {
819        unsafe { from_glib_none(ffi::gtk_list_box_get_row_at_y(self.to_glib_none().0, y)) }
820    }
821
822    /// Gets the selected row, or [`None`] if no rows are selected.
823    ///
824    /// Note that the box may allow multiple selection, in which
825    /// case you should use [`selected_foreach()`][Self::selected_foreach()] to
826    /// find all selected rows.
827    ///
828    /// # Returns
829    ///
830    /// the selected row
831    #[doc(alias = "gtk_list_box_get_selected_row")]
832    #[doc(alias = "get_selected_row")]
833    pub fn selected_row(&self) -> Option<ListBoxRow> {
834        unsafe { from_glib_none(ffi::gtk_list_box_get_selected_row(self.to_glib_none().0)) }
835    }
836
837    /// Creates a list of all selected children.
838    ///
839    /// # Returns
840    ///
841    ///
842    ///   A `GList` containing the [`Widget`][crate::Widget] for each selected child.
843    ///   Free with g_list_free() when done.
844    #[doc(alias = "gtk_list_box_get_selected_rows")]
845    #[doc(alias = "get_selected_rows")]
846    pub fn selected_rows(&self) -> Vec<ListBoxRow> {
847        unsafe {
848            FromGlibPtrContainer::from_glib_container(ffi::gtk_list_box_get_selected_rows(
849                self.to_glib_none().0,
850            ))
851        }
852    }
853
854    /// Gets the selection mode of the listbox.
855    ///
856    /// # Returns
857    ///
858    /// a [`SelectionMode`][crate::SelectionMode]
859    #[doc(alias = "gtk_list_box_get_selection_mode")]
860    #[doc(alias = "get_selection_mode")]
861    #[doc(alias = "selection-mode")]
862    pub fn selection_mode(&self) -> SelectionMode {
863        unsafe { from_glib(ffi::gtk_list_box_get_selection_mode(self.to_glib_none().0)) }
864    }
865
866    /// Returns whether the list box should show separators
867    /// between rows.
868    ///
869    /// # Returns
870    ///
871    /// [`true`] if the list box shows separators
872    #[doc(alias = "gtk_list_box_get_show_separators")]
873    #[doc(alias = "get_show_separators")]
874    #[doc(alias = "show-separators")]
875    pub fn shows_separators(&self) -> bool {
876        unsafe { from_glib(ffi::gtk_list_box_get_show_separators(self.to_glib_none().0)) }
877    }
878
879    /// Returns the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
880    ///
881    /// # Returns
882    ///
883    /// the tab behavior
884    #[cfg(feature = "v4_18")]
885    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
886    #[doc(alias = "gtk_list_box_get_tab_behavior")]
887    #[doc(alias = "get_tab_behavior")]
888    #[doc(alias = "tab-behavior")]
889    pub fn tab_behavior(&self) -> ListTabBehavior {
890        unsafe { from_glib(ffi::gtk_list_box_get_tab_behavior(self.to_glib_none().0)) }
891    }
892
893    /// Insert the @child into the @self at @position.
894    ///
895    /// If a sort function is
896    /// set, the widget will actually be inserted at the calculated position.
897    ///
898    /// If @position is -1, or larger than the total number of items in the
899    /// @self, then the @child will be appended to the end.
900    /// ## `child`
901    /// the [`Widget`][crate::Widget] to add
902    /// ## `position`
903    /// the position to insert @child in
904    #[doc(alias = "gtk_list_box_insert")]
905    pub fn insert(&self, child: &impl IsA<Widget>, position: i32) {
906        unsafe {
907            ffi::gtk_list_box_insert(
908                self.to_glib_none().0,
909                child.as_ref().to_glib_none().0,
910                position,
911            );
912        }
913    }
914
915    /// Update the filtering for all rows.
916    ///
917    /// Call this when result
918    /// of the filter function on the @self is changed due
919    /// to an external factor. For instance, this would be used
920    /// if the filter function just looked for a specific search
921    /// string and the entry with the search string has changed.
922    #[doc(alias = "gtk_list_box_invalidate_filter")]
923    pub fn invalidate_filter(&self) {
924        unsafe {
925            ffi::gtk_list_box_invalidate_filter(self.to_glib_none().0);
926        }
927    }
928
929    /// Update the separators for all rows.
930    ///
931    /// Call this when result
932    /// of the header function on the @self is changed due
933    /// to an external factor.
934    #[doc(alias = "gtk_list_box_invalidate_headers")]
935    pub fn invalidate_headers(&self) {
936        unsafe {
937            ffi::gtk_list_box_invalidate_headers(self.to_glib_none().0);
938        }
939    }
940
941    /// Update the sorting for all rows.
942    ///
943    /// Call this when result
944    /// of the sort function on the @self is changed due
945    /// to an external factor.
946    #[doc(alias = "gtk_list_box_invalidate_sort")]
947    pub fn invalidate_sort(&self) {
948        unsafe {
949            ffi::gtk_list_box_invalidate_sort(self.to_glib_none().0);
950        }
951    }
952
953    /// Prepend a widget to the list.
954    ///
955    /// If a sort function is set, the widget will
956    /// actually be inserted at the calculated position.
957    /// ## `child`
958    /// the [`Widget`][crate::Widget] to add
959    #[doc(alias = "gtk_list_box_prepend")]
960    pub fn prepend(&self, child: &impl IsA<Widget>) {
961        unsafe {
962            ffi::gtk_list_box_prepend(self.to_glib_none().0, child.as_ref().to_glib_none().0);
963        }
964    }
965
966    /// Removes a child from @self.
967    /// ## `child`
968    /// the child to remove
969    #[doc(alias = "gtk_list_box_remove")]
970    pub fn remove(&self, child: &impl IsA<Widget>) {
971        unsafe {
972            ffi::gtk_list_box_remove(self.to_glib_none().0, child.as_ref().to_glib_none().0);
973        }
974    }
975
976    /// Removes all rows from @self.
977    ///
978    /// This function does nothing if @self is backed by a model.
979    #[cfg(feature = "v4_12")]
980    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
981    #[doc(alias = "gtk_list_box_remove_all")]
982    pub fn remove_all(&self) {
983        unsafe {
984            ffi::gtk_list_box_remove_all(self.to_glib_none().0);
985        }
986    }
987
988    /// Select all children of @self, if the selection mode allows it.
989    #[doc(alias = "gtk_list_box_select_all")]
990    pub fn select_all(&self) {
991        unsafe {
992            ffi::gtk_list_box_select_all(self.to_glib_none().0);
993        }
994    }
995
996    /// Make @row the currently selected row.
997    /// ## `row`
998    /// The row to select
999    #[doc(alias = "gtk_list_box_select_row")]
1000    pub fn select_row(&self, row: Option<&impl IsA<ListBoxRow>>) {
1001        unsafe {
1002            ffi::gtk_list_box_select_row(
1003                self.to_glib_none().0,
1004                row.map(|p| p.as_ref()).to_glib_none().0,
1005            );
1006        }
1007    }
1008
1009    /// Calls a function for each selected child.
1010    ///
1011    /// Note that the selection cannot be modified from within this function.
1012    /// ## `func`
1013    /// the function to call for each selected child
1014    #[doc(alias = "gtk_list_box_selected_foreach")]
1015    pub fn selected_foreach<P: FnMut(&ListBox, &ListBoxRow)>(&self, func: P) {
1016        let mut func_data: P = func;
1017        unsafe extern "C" fn func_func<P: FnMut(&ListBox, &ListBoxRow)>(
1018            box_: *mut ffi::GtkListBox,
1019            row: *mut ffi::GtkListBoxRow,
1020            user_data: glib::ffi::gpointer,
1021        ) {
1022            unsafe {
1023                let box_ = from_glib_borrow(box_);
1024                let row = from_glib_borrow(row);
1025                let callback = user_data as *mut P;
1026                (*callback)(&box_, &row)
1027            }
1028        }
1029        let func = Some(func_func::<P> as _);
1030        let super_callback0: &mut P = &mut func_data;
1031        unsafe {
1032            ffi::gtk_list_box_selected_foreach(
1033                self.to_glib_none().0,
1034                func,
1035                super_callback0 as *mut _ as *mut _,
1036            );
1037        }
1038    }
1039
1040    /// If @single is [`true`], rows will be activated when you click on them,
1041    /// otherwise you need to double-click.
1042    /// ## `single`
1043    /// a boolean
1044    #[doc(alias = "gtk_list_box_set_activate_on_single_click")]
1045    #[doc(alias = "activate-on-single-click")]
1046    pub fn set_activate_on_single_click(&self, single: bool) {
1047        unsafe {
1048            ffi::gtk_list_box_set_activate_on_single_click(
1049                self.to_glib_none().0,
1050                single.into_glib(),
1051            );
1052        }
1053    }
1054
1055    /// Sets the adjustment (if any) that the widget uses to
1056    /// for vertical scrolling.
1057    ///
1058    /// For instance, this is used to get the page size for
1059    /// PageUp/Down key handling.
1060    ///
1061    /// In the normal case when the @self is packed inside
1062    /// a [`ScrolledWindow`][crate::ScrolledWindow] the adjustment from that will
1063    /// be picked up automatically, so there is no need
1064    /// to manually do that.
1065    /// ## `adjustment`
1066    /// the adjustment
1067    #[doc(alias = "gtk_list_box_set_adjustment")]
1068    pub fn set_adjustment(&self, adjustment: Option<&impl IsA<Adjustment>>) {
1069        unsafe {
1070            ffi::gtk_list_box_set_adjustment(
1071                self.to_glib_none().0,
1072                adjustment.map(|p| p.as_ref()).to_glib_none().0,
1073            );
1074        }
1075    }
1076
1077    /// By setting a filter function on the @self one can decide dynamically which
1078    /// of the rows to show.
1079    ///
1080    /// For instance, to implement a search function on a list that
1081    /// filters the original list to only show the matching rows.
1082    ///
1083    /// The @filter_func will be called for each row after the call, and
1084    /// it will continue to be called each time a row changes (via
1085    /// [`ListBoxRowExt::changed()`][crate::prelude::ListBoxRowExt::changed()]) or when [`invalidate_filter()`][Self::invalidate_filter()]
1086    /// is called.
1087    ///
1088    /// Note that using a filter function is incompatible with using a model
1089    /// (see [`bind_model()`][Self::bind_model()]).
1090    /// ## `filter_func`
1091    /// callback
1092    ///   that lets you filter which rows to show
1093    #[doc(alias = "gtk_list_box_set_filter_func")]
1094    pub fn set_filter_func<P: Fn(&ListBoxRow) -> bool + 'static>(&self, filter_func: P) {
1095        let filter_func_data: Box_<P> = Box_::new(filter_func);
1096        unsafe extern "C" fn filter_func_func<P: Fn(&ListBoxRow) -> bool + 'static>(
1097            row: *mut ffi::GtkListBoxRow,
1098            user_data: glib::ffi::gpointer,
1099        ) -> glib::ffi::gboolean {
1100            unsafe {
1101                let row = from_glib_borrow(row);
1102                let callback = &*(user_data as *mut P);
1103                (*callback)(&row).into_glib()
1104            }
1105        }
1106        let filter_func = Some(filter_func_func::<P> as _);
1107        unsafe extern "C" fn destroy_func<P: Fn(&ListBoxRow) -> bool + 'static>(
1108            data: glib::ffi::gpointer,
1109        ) {
1110            unsafe {
1111                let _callback = Box_::from_raw(data as *mut P);
1112            }
1113        }
1114        let destroy_call3 = Some(destroy_func::<P> as _);
1115        let super_callback0: Box_<P> = filter_func_data;
1116        unsafe {
1117            ffi::gtk_list_box_set_filter_func(
1118                self.to_glib_none().0,
1119                filter_func,
1120                Box_::into_raw(super_callback0) as *mut _,
1121                destroy_call3,
1122            );
1123        }
1124    }
1125
1126    /// Sets a header function.
1127    ///
1128    /// By setting a header function on the @self one can dynamically add headers
1129    /// in front of rows, depending on the contents of the row and its position
1130    /// in the list.
1131    ///
1132    /// For instance, one could use it to add headers in front of the first item
1133    /// of a new kind, in a list sorted by the kind.
1134    ///
1135    /// The @update_header can look at the current header widget using
1136    /// [`ListBoxRowExt::header()`][crate::prelude::ListBoxRowExt::header()] and either update the state of the widget
1137    /// as needed, or set a new one using [`ListBoxRowExt::set_header()`][crate::prelude::ListBoxRowExt::set_header()]. If no
1138    /// header is needed, set the header to [`None`].
1139    ///
1140    /// Note that you may get many calls @update_header to this for a particular
1141    /// row when e.g. changing things that don’t affect the header. In this case
1142    /// it is important for performance to not blindly replace an existing header
1143    /// with an identical one.
1144    ///
1145    /// The @update_header function will be called for each row after the call,
1146    /// and it will continue to be called each time a row changes (via
1147    /// [`ListBoxRowExt::changed()`][crate::prelude::ListBoxRowExt::changed()]) and when the row before changes (either
1148    /// by [`ListBoxRowExt::changed()`][crate::prelude::ListBoxRowExt::changed()] on the previous row, or when the previous
1149    /// row becomes a different row). It is also called for all rows when
1150    /// [`invalidate_headers()`][Self::invalidate_headers()] is called.
1151    /// ## `update_header`
1152    /// callback
1153    ///   that lets you add row headers
1154    #[doc(alias = "gtk_list_box_set_header_func")]
1155    pub fn set_header_func<P: Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>(
1156        &self,
1157        update_header: P,
1158    ) {
1159        let update_header_data: Box_<P> = Box_::new(update_header);
1160        unsafe extern "C" fn update_header_func<
1161            P: Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static,
1162        >(
1163            row: *mut ffi::GtkListBoxRow,
1164            before: *mut ffi::GtkListBoxRow,
1165            user_data: glib::ffi::gpointer,
1166        ) {
1167            unsafe {
1168                let row = from_glib_borrow(row);
1169                let before: Borrowed<Option<ListBoxRow>> = from_glib_borrow(before);
1170                let callback = &*(user_data as *mut P);
1171                (*callback)(&row, before.as_ref().as_ref())
1172            }
1173        }
1174        let update_header = Some(update_header_func::<P> as _);
1175        unsafe extern "C" fn destroy_func<P: Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>(
1176            data: glib::ffi::gpointer,
1177        ) {
1178            unsafe {
1179                let _callback = Box_::from_raw(data as *mut P);
1180            }
1181        }
1182        let destroy_call3 = Some(destroy_func::<P> as _);
1183        let super_callback0: Box_<P> = update_header_data;
1184        unsafe {
1185            ffi::gtk_list_box_set_header_func(
1186                self.to_glib_none().0,
1187                update_header,
1188                Box_::into_raw(super_callback0) as *mut _,
1189                destroy_call3,
1190            );
1191        }
1192    }
1193
1194    /// Sets the placeholder widget that is shown in the list when
1195    /// it doesn't display any visible children.
1196    /// ## `placeholder`
1197    /// a [`Widget`][crate::Widget]
1198    #[doc(alias = "gtk_list_box_set_placeholder")]
1199    pub fn set_placeholder(&self, placeholder: Option<&impl IsA<Widget>>) {
1200        unsafe {
1201            ffi::gtk_list_box_set_placeholder(
1202                self.to_glib_none().0,
1203                placeholder.map(|p| p.as_ref()).to_glib_none().0,
1204            );
1205        }
1206    }
1207
1208    /// Sets how selection works in the listbox.
1209    /// ## `mode`
1210    /// The [`SelectionMode`][crate::SelectionMode]
1211    #[doc(alias = "gtk_list_box_set_selection_mode")]
1212    #[doc(alias = "selection-mode")]
1213    pub fn set_selection_mode(&self, mode: SelectionMode) {
1214        unsafe {
1215            ffi::gtk_list_box_set_selection_mode(self.to_glib_none().0, mode.into_glib());
1216        }
1217    }
1218
1219    /// Sets whether the list box should show separators
1220    /// between rows.
1221    /// ## `show_separators`
1222    /// [`true`] to show separators
1223    #[doc(alias = "gtk_list_box_set_show_separators")]
1224    #[doc(alias = "show-separators")]
1225    pub fn set_show_separators(&self, show_separators: bool) {
1226        unsafe {
1227            ffi::gtk_list_box_set_show_separators(
1228                self.to_glib_none().0,
1229                show_separators.into_glib(),
1230            );
1231        }
1232    }
1233
1234    /// Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
1235    /// ## `behavior`
1236    /// the tab behavior
1237    #[cfg(feature = "v4_18")]
1238    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1239    #[doc(alias = "gtk_list_box_set_tab_behavior")]
1240    #[doc(alias = "tab-behavior")]
1241    pub fn set_tab_behavior(&self, behavior: ListTabBehavior) {
1242        unsafe {
1243            ffi::gtk_list_box_set_tab_behavior(self.to_glib_none().0, behavior.into_glib());
1244        }
1245    }
1246
1247    /// Unselect all children of @self, if the selection mode allows it.
1248    #[doc(alias = "gtk_list_box_unselect_all")]
1249    pub fn unselect_all(&self) {
1250        unsafe {
1251            ffi::gtk_list_box_unselect_all(self.to_glib_none().0);
1252        }
1253    }
1254
1255    /// Unselects a single row of @self, if the selection mode allows it.
1256    /// ## `row`
1257    /// the row to unselect
1258    #[doc(alias = "gtk_list_box_unselect_row")]
1259    pub fn unselect_row(&self, row: &impl IsA<ListBoxRow>) {
1260        unsafe {
1261            ffi::gtk_list_box_unselect_row(self.to_glib_none().0, row.as_ref().to_glib_none().0);
1262        }
1263    }
1264
1265    /// Whether to accept unpaired release events.
1266    #[doc(alias = "accept-unpaired-release")]
1267    pub fn accepts_unpaired_release(&self) -> bool {
1268        ObjectExt::property(self, "accept-unpaired-release")
1269    }
1270
1271    /// Whether to accept unpaired release events.
1272    #[doc(alias = "accept-unpaired-release")]
1273    pub fn set_accept_unpaired_release(&self, accept_unpaired_release: bool) {
1274        ObjectExt::set_property(self, "accept-unpaired-release", accept_unpaired_release)
1275    }
1276
1277    /// Emitted when the cursor row is activated.
1278    #[doc(alias = "activate-cursor-row")]
1279    pub fn connect_activate_cursor_row<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1280        unsafe extern "C" fn activate_cursor_row_trampoline<F: Fn(&ListBox) + 'static>(
1281            this: *mut ffi::GtkListBox,
1282            f: glib::ffi::gpointer,
1283        ) {
1284            unsafe {
1285                let f: &F = &*(f as *const F);
1286                f(&from_glib_borrow(this))
1287            }
1288        }
1289        unsafe {
1290            let f: Box_<F> = Box_::new(f);
1291            connect_raw(
1292                self.as_ptr() as *mut _,
1293                c"activate-cursor-row".as_ptr() as *const _,
1294                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1295                    activate_cursor_row_trampoline::<F> as *const (),
1296                )),
1297                Box_::into_raw(f),
1298            )
1299        }
1300    }
1301
1302    pub fn emit_activate_cursor_row(&self) {
1303        self.emit_by_name::<()>("activate-cursor-row", &[]);
1304    }
1305
1306    /// Emitted when the user initiates a cursor movement.
1307    ///
1308    /// The default bindings for this signal come in two variants, the variant with
1309    /// the Shift modifier extends the selection, the variant without the Shift
1310    /// modifier does not. There are too many key combinations to list them all
1311    /// here.
1312    ///
1313    /// - <kbd>←</kbd>, <kbd>→</kbd>, <kbd>↑</kbd>, <kbd>↓</kbd>
1314    ///   move by individual children
1315    /// - <kbd>Home</kbd>, <kbd>End</kbd> move to the ends of the box
1316    /// - <kbd>PgUp</kbd>, <kbd>PgDn</kbd> move vertically by pages
1317    /// ## `step`
1318    /// the granularity of the move, as a [`MovementStep`][crate::MovementStep]
1319    /// ## `count`
1320    /// the number of @step units to move
1321    /// ## `extend`
1322    /// whether to extend the selection
1323    /// ## `modify`
1324    /// whether to modify the selection
1325    #[doc(alias = "move-cursor")]
1326    pub fn connect_move_cursor<F: Fn(&Self, MovementStep, i32, bool, bool) + 'static>(
1327        &self,
1328        f: F,
1329    ) -> SignalHandlerId {
1330        unsafe extern "C" fn move_cursor_trampoline<
1331            F: Fn(&ListBox, MovementStep, i32, bool, bool) + 'static,
1332        >(
1333            this: *mut ffi::GtkListBox,
1334            step: ffi::GtkMovementStep,
1335            count: std::ffi::c_int,
1336            extend: glib::ffi::gboolean,
1337            modify: glib::ffi::gboolean,
1338            f: glib::ffi::gpointer,
1339        ) {
1340            unsafe {
1341                let f: &F = &*(f as *const F);
1342                f(
1343                    &from_glib_borrow(this),
1344                    from_glib(step),
1345                    count,
1346                    from_glib(extend),
1347                    from_glib(modify),
1348                )
1349            }
1350        }
1351        unsafe {
1352            let f: Box_<F> = Box_::new(f);
1353            connect_raw(
1354                self.as_ptr() as *mut _,
1355                c"move-cursor".as_ptr() as *const _,
1356                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1357                    move_cursor_trampoline::<F> as *const (),
1358                )),
1359                Box_::into_raw(f),
1360            )
1361        }
1362    }
1363
1364    pub fn emit_move_cursor(&self, step: MovementStep, count: i32, extend: bool, modify: bool) {
1365        self.emit_by_name::<()>("move-cursor", &[&step, &count, &extend, &modify]);
1366    }
1367
1368    /// Emitted when a row has been activated by the user.
1369    /// ## `row`
1370    /// the activated row
1371    #[doc(alias = "row-activated")]
1372    pub fn connect_row_activated<F: Fn(&Self, &ListBoxRow) + 'static>(
1373        &self,
1374        f: F,
1375    ) -> SignalHandlerId {
1376        unsafe extern "C" fn row_activated_trampoline<F: Fn(&ListBox, &ListBoxRow) + 'static>(
1377            this: *mut ffi::GtkListBox,
1378            row: *mut ffi::GtkListBoxRow,
1379            f: glib::ffi::gpointer,
1380        ) {
1381            unsafe {
1382                let f: &F = &*(f as *const F);
1383                f(&from_glib_borrow(this), &from_glib_borrow(row))
1384            }
1385        }
1386        unsafe {
1387            let f: Box_<F> = Box_::new(f);
1388            connect_raw(
1389                self.as_ptr() as *mut _,
1390                c"row-activated".as_ptr() as *const _,
1391                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1392                    row_activated_trampoline::<F> as *const (),
1393                )),
1394                Box_::into_raw(f),
1395            )
1396        }
1397    }
1398
1399    /// Emitted when a new row is selected, or (with a [`None`] @row)
1400    /// when the selection is cleared.
1401    ///
1402    /// When the @box_ is using [`SelectionMode::Multiple`][crate::SelectionMode::Multiple], this signal will not
1403    /// give you the full picture of selection changes, and you should use
1404    /// the [`selected-rows-changed`][struct@crate::ListBox#selected-rows-changed] signal instead.
1405    /// ## `row`
1406    /// the selected row
1407    #[doc(alias = "row-selected")]
1408    pub fn connect_row_selected<F: Fn(&Self, Option<&ListBoxRow>) + 'static>(
1409        &self,
1410        f: F,
1411    ) -> SignalHandlerId {
1412        unsafe extern "C" fn row_selected_trampoline<
1413            F: Fn(&ListBox, Option<&ListBoxRow>) + 'static,
1414        >(
1415            this: *mut ffi::GtkListBox,
1416            row: *mut ffi::GtkListBoxRow,
1417            f: glib::ffi::gpointer,
1418        ) {
1419            unsafe {
1420                let f: &F = &*(f as *const F);
1421                f(
1422                    &from_glib_borrow(this),
1423                    Option::<ListBoxRow>::from_glib_borrow(row)
1424                        .as_ref()
1425                        .as_ref(),
1426                )
1427            }
1428        }
1429        unsafe {
1430            let f: Box_<F> = Box_::new(f);
1431            connect_raw(
1432                self.as_ptr() as *mut _,
1433                c"row-selected".as_ptr() as *const _,
1434                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1435                    row_selected_trampoline::<F> as *const (),
1436                )),
1437                Box_::into_raw(f),
1438            )
1439        }
1440    }
1441
1442    /// Emitted to select all children of the box, if the selection
1443    /// mode permits it.
1444    ///
1445    /// This is a [keybinding signal](class.SignalAction.html).
1446    ///
1447    /// The default binding for this signal is <kbd>Ctrl</kbd>-<kbd>a</kbd>.
1448    #[doc(alias = "select-all")]
1449    pub fn connect_select_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1450        unsafe extern "C" fn select_all_trampoline<F: Fn(&ListBox) + 'static>(
1451            this: *mut ffi::GtkListBox,
1452            f: glib::ffi::gpointer,
1453        ) {
1454            unsafe {
1455                let f: &F = &*(f as *const F);
1456                f(&from_glib_borrow(this))
1457            }
1458        }
1459        unsafe {
1460            let f: Box_<F> = Box_::new(f);
1461            connect_raw(
1462                self.as_ptr() as *mut _,
1463                c"select-all".as_ptr() as *const _,
1464                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1465                    select_all_trampoline::<F> as *const (),
1466                )),
1467                Box_::into_raw(f),
1468            )
1469        }
1470    }
1471
1472    pub fn emit_select_all(&self) {
1473        self.emit_by_name::<()>("select-all", &[]);
1474    }
1475
1476    /// Emitted when the set of selected rows changes.
1477    #[doc(alias = "selected-rows-changed")]
1478    pub fn connect_selected_rows_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1479        unsafe extern "C" fn selected_rows_changed_trampoline<F: Fn(&ListBox) + 'static>(
1480            this: *mut ffi::GtkListBox,
1481            f: glib::ffi::gpointer,
1482        ) {
1483            unsafe {
1484                let f: &F = &*(f as *const F);
1485                f(&from_glib_borrow(this))
1486            }
1487        }
1488        unsafe {
1489            let f: Box_<F> = Box_::new(f);
1490            connect_raw(
1491                self.as_ptr() as *mut _,
1492                c"selected-rows-changed".as_ptr() as *const _,
1493                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1494                    selected_rows_changed_trampoline::<F> as *const (),
1495                )),
1496                Box_::into_raw(f),
1497            )
1498        }
1499    }
1500
1501    /// Emitted when the cursor row is toggled.
1502    ///
1503    /// The default bindings for this signal is <kbd>Ctrl</kbd>+<kbd>␣</kbd>.
1504    #[doc(alias = "toggle-cursor-row")]
1505    pub fn connect_toggle_cursor_row<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1506        unsafe extern "C" fn toggle_cursor_row_trampoline<F: Fn(&ListBox) + 'static>(
1507            this: *mut ffi::GtkListBox,
1508            f: glib::ffi::gpointer,
1509        ) {
1510            unsafe {
1511                let f: &F = &*(f as *const F);
1512                f(&from_glib_borrow(this))
1513            }
1514        }
1515        unsafe {
1516            let f: Box_<F> = Box_::new(f);
1517            connect_raw(
1518                self.as_ptr() as *mut _,
1519                c"toggle-cursor-row".as_ptr() as *const _,
1520                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1521                    toggle_cursor_row_trampoline::<F> as *const (),
1522                )),
1523                Box_::into_raw(f),
1524            )
1525        }
1526    }
1527
1528    pub fn emit_toggle_cursor_row(&self) {
1529        self.emit_by_name::<()>("toggle-cursor-row", &[]);
1530    }
1531
1532    /// Emitted to unselect all children of the box, if the selection
1533    /// mode permits it.
1534    ///
1535    /// This is a [keybinding signal](class.SignalAction.html).
1536    ///
1537    /// The default binding for this signal is
1538    /// <kbd>Ctrl</kbd>-<kbd>Shift</kbd>-<kbd>a</kbd>.
1539    #[doc(alias = "unselect-all")]
1540    pub fn connect_unselect_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1541        unsafe extern "C" fn unselect_all_trampoline<F: Fn(&ListBox) + 'static>(
1542            this: *mut ffi::GtkListBox,
1543            f: glib::ffi::gpointer,
1544        ) {
1545            unsafe {
1546                let f: &F = &*(f as *const F);
1547                f(&from_glib_borrow(this))
1548            }
1549        }
1550        unsafe {
1551            let f: Box_<F> = Box_::new(f);
1552            connect_raw(
1553                self.as_ptr() as *mut _,
1554                c"unselect-all".as_ptr() as *const _,
1555                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1556                    unselect_all_trampoline::<F> as *const (),
1557                )),
1558                Box_::into_raw(f),
1559            )
1560        }
1561    }
1562
1563    pub fn emit_unselect_all(&self) {
1564        self.emit_by_name::<()>("unselect-all", &[]);
1565    }
1566
1567    #[doc(alias = "accept-unpaired-release")]
1568    pub fn connect_accept_unpaired_release_notify<F: Fn(&Self) + 'static>(
1569        &self,
1570        f: F,
1571    ) -> SignalHandlerId {
1572        unsafe extern "C" fn notify_accept_unpaired_release_trampoline<
1573            F: Fn(&ListBox) + 'static,
1574        >(
1575            this: *mut ffi::GtkListBox,
1576            _param_spec: glib::ffi::gpointer,
1577            f: glib::ffi::gpointer,
1578        ) {
1579            unsafe {
1580                let f: &F = &*(f as *const F);
1581                f(&from_glib_borrow(this))
1582            }
1583        }
1584        unsafe {
1585            let f: Box_<F> = Box_::new(f);
1586            connect_raw(
1587                self.as_ptr() as *mut _,
1588                c"notify::accept-unpaired-release".as_ptr() as *const _,
1589                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1590                    notify_accept_unpaired_release_trampoline::<F> as *const (),
1591                )),
1592                Box_::into_raw(f),
1593            )
1594        }
1595    }
1596
1597    #[doc(alias = "activate-on-single-click")]
1598    pub fn connect_activate_on_single_click_notify<F: Fn(&Self) + 'static>(
1599        &self,
1600        f: F,
1601    ) -> SignalHandlerId {
1602        unsafe extern "C" fn notify_activate_on_single_click_trampoline<
1603            F: Fn(&ListBox) + 'static,
1604        >(
1605            this: *mut ffi::GtkListBox,
1606            _param_spec: glib::ffi::gpointer,
1607            f: glib::ffi::gpointer,
1608        ) {
1609            unsafe {
1610                let f: &F = &*(f as *const F);
1611                f(&from_glib_borrow(this))
1612            }
1613        }
1614        unsafe {
1615            let f: Box_<F> = Box_::new(f);
1616            connect_raw(
1617                self.as_ptr() as *mut _,
1618                c"notify::activate-on-single-click".as_ptr() as *const _,
1619                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1620                    notify_activate_on_single_click_trampoline::<F> as *const (),
1621                )),
1622                Box_::into_raw(f),
1623            )
1624        }
1625    }
1626
1627    #[doc(alias = "selection-mode")]
1628    pub fn connect_selection_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1629        unsafe extern "C" fn notify_selection_mode_trampoline<F: Fn(&ListBox) + 'static>(
1630            this: *mut ffi::GtkListBox,
1631            _param_spec: glib::ffi::gpointer,
1632            f: glib::ffi::gpointer,
1633        ) {
1634            unsafe {
1635                let f: &F = &*(f as *const F);
1636                f(&from_glib_borrow(this))
1637            }
1638        }
1639        unsafe {
1640            let f: Box_<F> = Box_::new(f);
1641            connect_raw(
1642                self.as_ptr() as *mut _,
1643                c"notify::selection-mode".as_ptr() as *const _,
1644                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1645                    notify_selection_mode_trampoline::<F> as *const (),
1646                )),
1647                Box_::into_raw(f),
1648            )
1649        }
1650    }
1651
1652    #[doc(alias = "show-separators")]
1653    pub fn connect_show_separators_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1654        unsafe extern "C" fn notify_show_separators_trampoline<F: Fn(&ListBox) + 'static>(
1655            this: *mut ffi::GtkListBox,
1656            _param_spec: glib::ffi::gpointer,
1657            f: glib::ffi::gpointer,
1658        ) {
1659            unsafe {
1660                let f: &F = &*(f as *const F);
1661                f(&from_glib_borrow(this))
1662            }
1663        }
1664        unsafe {
1665            let f: Box_<F> = Box_::new(f);
1666            connect_raw(
1667                self.as_ptr() as *mut _,
1668                c"notify::show-separators".as_ptr() as *const _,
1669                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1670                    notify_show_separators_trampoline::<F> as *const (),
1671                )),
1672                Box_::into_raw(f),
1673            )
1674        }
1675    }
1676
1677    #[cfg(feature = "v4_18")]
1678    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1679    #[doc(alias = "tab-behavior")]
1680    pub fn connect_tab_behavior_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1681        unsafe extern "C" fn notify_tab_behavior_trampoline<F: Fn(&ListBox) + 'static>(
1682            this: *mut ffi::GtkListBox,
1683            _param_spec: glib::ffi::gpointer,
1684            f: glib::ffi::gpointer,
1685        ) {
1686            unsafe {
1687                let f: &F = &*(f as *const F);
1688                f(&from_glib_borrow(this))
1689            }
1690        }
1691        unsafe {
1692            let f: Box_<F> = Box_::new(f);
1693            connect_raw(
1694                self.as_ptr() as *mut _,
1695                c"notify::tab-behavior".as_ptr() as *const _,
1696                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1697                    notify_tab_behavior_trampoline::<F> as *const (),
1698                )),
1699                Box_::into_raw(f),
1700            )
1701        }
1702    }
1703}
1704
1705impl Default for ListBox {
1706    fn default() -> Self {
1707        Self::new()
1708    }
1709}
1710
1711// rustdoc-stripper-ignore-next
1712/// A [builder-pattern] type to construct [`ListBox`] objects.
1713///
1714/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1715#[must_use = "The builder must be built to be used"]
1716pub struct ListBoxBuilder {
1717    builder: glib::object::ObjectBuilder<'static, ListBox>,
1718}
1719
1720impl ListBoxBuilder {
1721    fn new() -> Self {
1722        Self {
1723            builder: glib::object::Object::builder(),
1724        }
1725    }
1726
1727    /// Whether to accept unpaired release events.
1728    pub fn accept_unpaired_release(self, accept_unpaired_release: bool) -> Self {
1729        Self {
1730            builder: self
1731                .builder
1732                .property("accept-unpaired-release", accept_unpaired_release),
1733        }
1734    }
1735
1736    /// Determines whether children can be activated with a single
1737    /// click, or require a double-click.
1738    pub fn activate_on_single_click(self, activate_on_single_click: bool) -> Self {
1739        Self {
1740            builder: self
1741                .builder
1742                .property("activate-on-single-click", activate_on_single_click),
1743        }
1744    }
1745
1746    /// The selection mode used by the list box.
1747    pub fn selection_mode(self, selection_mode: SelectionMode) -> Self {
1748        Self {
1749            builder: self.builder.property("selection-mode", selection_mode),
1750        }
1751    }
1752
1753    /// Whether to show separators between rows.
1754    pub fn show_separators(self, show_separators: bool) -> Self {
1755        Self {
1756            builder: self.builder.property("show-separators", show_separators),
1757        }
1758    }
1759
1760    /// Behavior of the <kbd>Tab</kbd> key
1761    #[cfg(feature = "v4_18")]
1762    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1763    pub fn tab_behavior(self, tab_behavior: ListTabBehavior) -> Self {
1764        Self {
1765            builder: self.builder.property("tab-behavior", tab_behavior),
1766        }
1767    }
1768
1769    /// Whether the widget or any of its descendents can accept
1770    /// the input focus.
1771    ///
1772    /// This property is meant to be set by widget implementations,
1773    /// typically in their instance init function.
1774    pub fn can_focus(self, can_focus: bool) -> Self {
1775        Self {
1776            builder: self.builder.property("can-focus", can_focus),
1777        }
1778    }
1779
1780    /// Whether the widget can receive pointer events.
1781    pub fn can_target(self, can_target: bool) -> Self {
1782        Self {
1783            builder: self.builder.property("can-target", can_target),
1784        }
1785    }
1786
1787    /// A list of css classes applied to this widget.
1788    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1789        Self {
1790            builder: self.builder.property("css-classes", css_classes.into()),
1791        }
1792    }
1793
1794    /// The name of this widget in the CSS tree.
1795    ///
1796    /// This property is meant to be set by widget implementations,
1797    /// typically in their instance init function.
1798    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1799        Self {
1800            builder: self.builder.property("css-name", css_name.into()),
1801        }
1802    }
1803
1804    /// The cursor used by @widget.
1805    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1806        Self {
1807            builder: self.builder.property("cursor", cursor.clone()),
1808        }
1809    }
1810
1811    /// Whether the widget should grab focus when it is clicked with the mouse.
1812    ///
1813    /// This property is only relevant for widgets that can take focus.
1814    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1815        Self {
1816            builder: self.builder.property("focus-on-click", focus_on_click),
1817        }
1818    }
1819
1820    /// Whether this widget itself will accept the input focus.
1821    pub fn focusable(self, focusable: bool) -> Self {
1822        Self {
1823            builder: self.builder.property("focusable", focusable),
1824        }
1825    }
1826
1827    /// How to distribute horizontal space if widget gets extra space.
1828    pub fn halign(self, halign: Align) -> Self {
1829        Self {
1830            builder: self.builder.property("halign", halign),
1831        }
1832    }
1833
1834    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1835    /// signal on @widget.
1836    ///
1837    /// A true value indicates that @widget can have a tooltip, in this case
1838    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1839    /// determine whether it will provide a tooltip or not.
1840    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1841        Self {
1842            builder: self.builder.property("has-tooltip", has_tooltip),
1843        }
1844    }
1845
1846    /// Overrides for height request of the widget.
1847    ///
1848    /// If this is -1, the natural request will be used.
1849    pub fn height_request(self, height_request: i32) -> Self {
1850        Self {
1851            builder: self.builder.property("height-request", height_request),
1852        }
1853    }
1854
1855    /// Whether to expand horizontally.
1856    pub fn hexpand(self, hexpand: bool) -> Self {
1857        Self {
1858            builder: self.builder.property("hexpand", hexpand),
1859        }
1860    }
1861
1862    /// Whether to use the `hexpand` property.
1863    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1864        Self {
1865            builder: self.builder.property("hexpand-set", hexpand_set),
1866        }
1867    }
1868
1869    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1870    /// the preferred size of the widget, and allocate its children.
1871    ///
1872    /// This property is meant to be set by widget implementations,
1873    /// typically in their instance init function.
1874    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1875        Self {
1876            builder: self
1877                .builder
1878                .property("layout-manager", layout_manager.clone().upcast()),
1879        }
1880    }
1881
1882    /// Makes this widget act like a modal dialog, with respect to
1883    /// event delivery.
1884    ///
1885    /// Global event controllers will not handle events with targets
1886    /// inside the widget, unless they are set up to ignore propagation
1887    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1888    #[cfg(feature = "v4_18")]
1889    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1890    pub fn limit_events(self, limit_events: bool) -> Self {
1891        Self {
1892            builder: self.builder.property("limit-events", limit_events),
1893        }
1894    }
1895
1896    /// Margin on bottom side of widget.
1897    ///
1898    /// This property adds margin outside of the widget's normal size
1899    /// request, the margin will be added in addition to the size from
1900    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1901    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1902        Self {
1903            builder: self.builder.property("margin-bottom", margin_bottom),
1904        }
1905    }
1906
1907    /// Margin on end of widget, horizontally.
1908    ///
1909    /// This property supports left-to-right and right-to-left text
1910    /// directions.
1911    ///
1912    /// This property adds margin outside of the widget's normal size
1913    /// request, the margin will be added in addition to the size from
1914    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1915    pub fn margin_end(self, margin_end: i32) -> Self {
1916        Self {
1917            builder: self.builder.property("margin-end", margin_end),
1918        }
1919    }
1920
1921    /// Margin on start of widget, horizontally.
1922    ///
1923    /// This property supports left-to-right and right-to-left text
1924    /// directions.
1925    ///
1926    /// This property adds margin outside of the widget's normal size
1927    /// request, the margin will be added in addition to the size from
1928    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1929    pub fn margin_start(self, margin_start: i32) -> Self {
1930        Self {
1931            builder: self.builder.property("margin-start", margin_start),
1932        }
1933    }
1934
1935    /// Margin on top side of widget.
1936    ///
1937    /// This property adds margin outside of the widget's normal size
1938    /// request, the margin will be added in addition to the size from
1939    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1940    pub fn margin_top(self, margin_top: i32) -> Self {
1941        Self {
1942            builder: self.builder.property("margin-top", margin_top),
1943        }
1944    }
1945
1946    /// The name of the widget.
1947    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1948        Self {
1949            builder: self.builder.property("name", name.into()),
1950        }
1951    }
1952
1953    /// The requested opacity of the widget.
1954    pub fn opacity(self, opacity: f64) -> Self {
1955        Self {
1956            builder: self.builder.property("opacity", opacity),
1957        }
1958    }
1959
1960    /// How content outside the widget's content area is treated.
1961    ///
1962    /// This property is meant to be set by widget implementations,
1963    /// typically in their instance init function.
1964    pub fn overflow(self, overflow: Overflow) -> Self {
1965        Self {
1966            builder: self.builder.property("overflow", overflow),
1967        }
1968    }
1969
1970    /// Whether the widget will receive the default action when it is focused.
1971    pub fn receives_default(self, receives_default: bool) -> Self {
1972        Self {
1973            builder: self.builder.property("receives-default", receives_default),
1974        }
1975    }
1976
1977    /// Whether the widget responds to input.
1978    pub fn sensitive(self, sensitive: bool) -> Self {
1979        Self {
1980            builder: self.builder.property("sensitive", sensitive),
1981        }
1982    }
1983
1984    /// Sets the text of tooltip to be the given string, which is marked up
1985    /// with Pango markup.
1986    ///
1987    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1988    ///
1989    /// This is a convenience property which will take care of getting the
1990    /// tooltip shown if the given string is not `NULL`:
1991    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1992    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1993    /// the default signal handler.
1994    ///
1995    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1996    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1997    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1998        Self {
1999            builder: self
2000                .builder
2001                .property("tooltip-markup", tooltip_markup.into()),
2002        }
2003    }
2004
2005    /// Sets the text of tooltip to be the given string.
2006    ///
2007    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
2008    ///
2009    /// This is a convenience property which will take care of getting the
2010    /// tooltip shown if the given string is not `NULL`:
2011    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2012    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2013    /// the default signal handler.
2014    ///
2015    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2016    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2017    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
2018        Self {
2019            builder: self.builder.property("tooltip-text", tooltip_text.into()),
2020        }
2021    }
2022
2023    /// How to distribute vertical space if widget gets extra space.
2024    pub fn valign(self, valign: Align) -> Self {
2025        Self {
2026            builder: self.builder.property("valign", valign),
2027        }
2028    }
2029
2030    /// Whether to expand vertically.
2031    pub fn vexpand(self, vexpand: bool) -> Self {
2032        Self {
2033            builder: self.builder.property("vexpand", vexpand),
2034        }
2035    }
2036
2037    /// Whether to use the `vexpand` property.
2038    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
2039        Self {
2040            builder: self.builder.property("vexpand-set", vexpand_set),
2041        }
2042    }
2043
2044    /// Whether the widget is visible.
2045    pub fn visible(self, visible: bool) -> Self {
2046        Self {
2047            builder: self.builder.property("visible", visible),
2048        }
2049    }
2050
2051    /// Overrides for width request of the widget.
2052    ///
2053    /// If this is -1, the natural request will be used.
2054    pub fn width_request(self, width_request: i32) -> Self {
2055        Self {
2056            builder: self.builder.property("width-request", width_request),
2057        }
2058    }
2059
2060    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
2061    ///
2062    /// The accessible role cannot be changed once set.
2063    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
2064        Self {
2065            builder: self.builder.property("accessible-role", accessible_role),
2066        }
2067    }
2068
2069    // rustdoc-stripper-ignore-next
2070    /// Build the [`ListBox`].
2071    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
2072    pub fn build(self) -> ListBox {
2073        assert_initialized_main_thread!();
2074        self.builder.build()
2075    }
2076}