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