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