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