gtk4/auto/list_view.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6 Accessible, AccessibleRole, Adjustment, Align, Buildable, ConstraintTarget, LayoutManager,
7 ListBase, ListItemFactory, Orientable, Orientation, Overflow, Scrollable, ScrollablePolicy,
8 SelectionModel, Widget, ffi,
9};
10#[cfg(feature = "v4_12")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
12use crate::{ListScrollFlags, ListTabBehavior, ScrollInfo};
13use glib::{
14 object::ObjectType as _,
15 prelude::*,
16 signal::{SignalHandlerId, connect_raw},
17 translate::*,
18};
19use std::boxed::Box as Box_;
20
21glib::wrapper! {
22 /// Presents a large dynamic list of items.
23 ///
24 /// [`ListView`][crate::ListView] uses its factory to generate one row widget for each visible
25 /// item and shows them in a linear display, either vertically or horizontally.
26 ///
27 /// The [`show-separators`][struct@crate::ListView#show-separators] property offers a simple way to
28 /// display separators between the rows.
29 ///
30 /// [`ListView`][crate::ListView] allows the user to select items according to the selection
31 /// characteristics of the model. For models that allow multiple selected items,
32 /// it is possible to turn on _rubberband selection_, using
33 /// [`enable-rubberband`][struct@crate::ListView#enable-rubberband].
34 ///
35 /// If you need multiple columns with headers, see [`ColumnView`][crate::ColumnView].
36 ///
37 /// To learn more about the list widget framework, see the
38 /// [overview](section-list-widget.html).
39 ///
40 /// An example of using [`ListView`][crate::ListView]:
41 /// **⚠️ The following code is in c ⚠️**
42 ///
43 /// ```c
44 /// static void
45 /// setup_listitem_cb (GtkListItemFactory *factory,
46 /// GtkListItem *list_item)
47 /// {
48 /// GtkWidget *image;
49 ///
50 /// image = gtk_image_new ();
51 /// gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
52 /// gtk_list_item_set_child (list_item, image);
53 /// }
54 ///
55 /// static void
56 /// bind_listitem_cb (GtkListItemFactory *factory,
57 /// GtkListItem *list_item)
58 /// {
59 /// GtkWidget *image;
60 /// GAppInfo *app_info;
61 ///
62 /// image = gtk_list_item_get_child (list_item);
63 /// app_info = gtk_list_item_get_item (list_item);
64 /// gtk_image_set_from_gicon (GTK_IMAGE (image), g_app_info_get_icon (app_info));
65 /// }
66 ///
67 /// static void
68 /// activate_cb (GtkListView *list,
69 /// guint position,
70 /// gpointer unused)
71 /// {
72 /// GAppInfo *app_info;
73 ///
74 /// app_info = g_list_model_get_item (G_LIST_MODEL (gtk_list_view_get_model (list)), position);
75 /// g_app_info_launch (app_info, NULL, NULL, NULL);
76 /// g_object_unref (app_info);
77 /// }
78 ///
79 /// ...
80 ///
81 /// model = create_application_list ();
82 ///
83 /// factory = gtk_signal_list_item_factory_new ();
84 /// g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL);
85 /// g_signal_connect (factory, "bind", G_CALLBACK (bind_listitem_cb), NULL);
86 ///
87 /// list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (model)), factory);
88 ///
89 /// g_signal_connect (list, "activate", G_CALLBACK (activate_cb), NULL);
90 ///
91 /// gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
92 /// ```
93 ///
94 /// # Actions
95 ///
96 /// [`ListView`][crate::ListView] defines a set of built-in actions:
97 ///
98 /// - `list.activate-item` activates the item at given position by emitting
99 /// the [`activate`][struct@crate::ListView#activate] signal.
100 ///
101 /// # CSS nodes
102 ///
103 /// ```text
104 /// listview[.separators][.rich-list][.navigation-sidebar][.data-table]
105 /// ├── row[.activatable]
106 /// │
107 /// ├── row[.activatable]
108 /// │
109 /// ┊
110 /// ╰── [rubberband]
111 /// ```
112 ///
113 /// [`ListView`][crate::ListView] uses a single CSS node named `listview`. It may carry the
114 /// `.separators` style class, when [`show-separators`][struct@crate::ListView#show-separators]
115 /// property is set. Each child widget uses a single CSS node named `row`.
116 /// If the [`activatable`][struct@crate::ListItem#activatable] property is set, the
117 /// corresponding row will have the `.activatable` style class. For
118 /// rubberband selection, a node with name `rubberband` is used.
119 ///
120 /// The main listview node may also carry style classes to select
121 /// the style of [list presentation](section-list-widget.html#list-styles):
122 /// .rich-list, .navigation-sidebar or .data-table.
123 ///
124 /// # Accessibility
125 ///
126 /// [`ListView`][crate::ListView] uses the [enum@Gtk.AccessibleRole.list] role, and the list
127 /// items use the [enum@Gtk.AccessibleRole.list_item] role.
128 ///
129 /// ## Properties
130 ///
131 ///
132 /// #### `enable-rubberband`
133 /// Allow rubberband selection.
134 ///
135 /// Readable | Writeable
136 ///
137 ///
138 /// #### `factory`
139 /// Factory for populating list items.
140 ///
141 /// The factory must be for configuring [`ListItem`][crate::ListItem] objects.
142 ///
143 /// Readable | Writeable
144 ///
145 ///
146 /// #### `header-factory`
147 /// Factory for creating header widgets.
148 ///
149 /// The factory must be for configuring [`ListHeader`][crate::ListHeader] objects.
150 ///
151 /// Readable | Writeable
152 ///
153 ///
154 /// #### `model`
155 /// Model for the items displayed.
156 ///
157 /// Readable | Writeable
158 ///
159 ///
160 /// #### `show-separators`
161 /// Show separators between rows.
162 ///
163 /// Readable | Writeable
164 ///
165 ///
166 /// #### `single-click-activate`
167 /// Activate rows on single click and select them on hover.
168 ///
169 /// Readable | Writeable
170 ///
171 ///
172 /// #### `tab-behavior`
173 /// Behavior of the <kbd>Tab</kbd> key
174 ///
175 /// Readable | Writeable
176 /// <details><summary><h4>ListBase</h4></summary>
177 ///
178 ///
179 /// #### `orientation`
180 /// The orientation of the list. See GtkOrientable:orientation
181 /// for details.
182 ///
183 /// Readable | Writeable
184 /// </details>
185 /// <details><summary><h4>Widget</h4></summary>
186 ///
187 ///
188 /// #### `can-focus`
189 /// Whether the widget or any of its descendents can accept
190 /// the input focus.
191 ///
192 /// This property is meant to be set by widget implementations,
193 /// typically in their instance init function.
194 ///
195 /// Readable | Writeable
196 ///
197 ///
198 /// #### `can-target`
199 /// Whether the widget can receive pointer events.
200 ///
201 /// Readable | Writeable
202 ///
203 ///
204 /// #### `css-classes`
205 /// A list of css classes applied to this widget.
206 ///
207 /// Readable | Writeable
208 ///
209 ///
210 /// #### `css-name`
211 /// The name of this widget in the CSS tree.
212 ///
213 /// This property is meant to be set by widget implementations,
214 /// typically in their instance init function.
215 ///
216 /// Readable | Writeable | Construct Only
217 ///
218 ///
219 /// #### `cursor`
220 /// The cursor used by @widget.
221 ///
222 /// Readable | Writeable
223 ///
224 ///
225 /// #### `focus-on-click`
226 /// Whether the widget should grab focus when it is clicked with the mouse.
227 ///
228 /// This property is only relevant for widgets that can take focus.
229 ///
230 /// Readable | Writeable
231 ///
232 ///
233 /// #### `focusable`
234 /// Whether this widget itself will accept the input focus.
235 ///
236 /// Readable | Writeable
237 ///
238 ///
239 /// #### `halign`
240 /// How to distribute horizontal space if widget gets extra space.
241 ///
242 /// Readable | Writeable
243 ///
244 ///
245 /// #### `has-default`
246 /// Whether the widget is the default widget.
247 ///
248 /// Readable
249 ///
250 ///
251 /// #### `has-focus`
252 /// Whether the widget has the input focus.
253 ///
254 /// Readable
255 ///
256 ///
257 /// #### `has-tooltip`
258 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
259 /// signal on @widget.
260 ///
261 /// A true value indicates that @widget can have a tooltip, in this case
262 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
263 /// determine whether it will provide a tooltip or not.
264 ///
265 /// Readable | Writeable
266 ///
267 ///
268 /// #### `height-request`
269 /// Overrides for height request of the widget.
270 ///
271 /// If this is -1, the natural request will be used.
272 ///
273 /// Readable | Writeable
274 ///
275 ///
276 /// #### `hexpand`
277 /// Whether to expand horizontally.
278 ///
279 /// Readable | Writeable
280 ///
281 ///
282 /// #### `hexpand-set`
283 /// Whether to use the `hexpand` property.
284 ///
285 /// Readable | Writeable
286 ///
287 ///
288 /// #### `layout-manager`
289 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
290 /// the preferred size of the widget, and allocate its children.
291 ///
292 /// This property is meant to be set by widget implementations,
293 /// typically in their instance init function.
294 ///
295 /// Readable | Writeable
296 ///
297 ///
298 /// #### `limit-events`
299 /// Makes this widget act like a modal dialog, with respect to
300 /// event delivery.
301 ///
302 /// Global event controllers will not handle events with targets
303 /// inside the widget, unless they are set up to ignore propagation
304 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
305 ///
306 /// Readable | Writeable
307 ///
308 ///
309 /// #### `margin-bottom`
310 /// Margin on bottom side of widget.
311 ///
312 /// This property adds margin outside of the widget's normal size
313 /// request, the margin will be added in addition to the size from
314 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
315 ///
316 /// Readable | Writeable
317 ///
318 ///
319 /// #### `margin-end`
320 /// Margin on end of widget, horizontally.
321 ///
322 /// This property supports left-to-right and right-to-left text
323 /// directions.
324 ///
325 /// This property adds margin outside of the widget's normal size
326 /// request, the margin will be added in addition to the size from
327 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
328 ///
329 /// Readable | Writeable
330 ///
331 ///
332 /// #### `margin-start`
333 /// Margin on start of widget, horizontally.
334 ///
335 /// This property supports left-to-right and right-to-left text
336 /// directions.
337 ///
338 /// This property adds margin outside of the widget's normal size
339 /// request, the margin will be added in addition to the size from
340 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
341 ///
342 /// Readable | Writeable
343 ///
344 ///
345 /// #### `margin-top`
346 /// Margin on top side of widget.
347 ///
348 /// This property adds margin outside of the widget's normal size
349 /// request, the margin will be added in addition to the size from
350 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
351 ///
352 /// Readable | Writeable
353 ///
354 ///
355 /// #### `name`
356 /// The name of the widget.
357 ///
358 /// Readable | Writeable
359 ///
360 ///
361 /// #### `opacity`
362 /// The requested opacity of the widget.
363 ///
364 /// Readable | Writeable
365 ///
366 ///
367 /// #### `overflow`
368 /// How content outside the widget's content area is treated.
369 ///
370 /// This property is meant to be set by widget implementations,
371 /// typically in their instance init function.
372 ///
373 /// Readable | Writeable
374 ///
375 ///
376 /// #### `parent`
377 /// The parent widget of this widget.
378 ///
379 /// Readable
380 ///
381 ///
382 /// #### `receives-default`
383 /// Whether the widget will receive the default action when it is focused.
384 ///
385 /// Readable | Writeable
386 ///
387 ///
388 /// #### `root`
389 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
390 ///
391 /// This will be `NULL` if the widget is not contained in a root widget.
392 ///
393 /// Readable
394 ///
395 ///
396 /// #### `scale-factor`
397 /// The scale factor of the widget.
398 ///
399 /// Readable
400 ///
401 ///
402 /// #### `sensitive`
403 /// Whether the widget responds to input.
404 ///
405 /// Readable | Writeable
406 ///
407 ///
408 /// #### `tooltip-markup`
409 /// Sets the text of tooltip to be the given string, which is marked up
410 /// with Pango markup.
411 ///
412 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
413 ///
414 /// This is a convenience property which will take care of getting the
415 /// tooltip shown if the given string is not `NULL`:
416 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
417 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
418 /// the default signal handler.
419 ///
420 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
421 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
422 ///
423 /// Readable | Writeable
424 ///
425 ///
426 /// #### `tooltip-text`
427 /// Sets the text of tooltip to be the given string.
428 ///
429 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
430 ///
431 /// This is a convenience property which will take care of getting the
432 /// tooltip shown if the given string is not `NULL`:
433 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
434 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
435 /// the default signal handler.
436 ///
437 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
438 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
439 ///
440 /// Readable | Writeable
441 ///
442 ///
443 /// #### `valign`
444 /// How to distribute vertical space if widget gets extra space.
445 ///
446 /// Readable | Writeable
447 ///
448 ///
449 /// #### `vexpand`
450 /// Whether to expand vertically.
451 ///
452 /// Readable | Writeable
453 ///
454 ///
455 /// #### `vexpand-set`
456 /// Whether to use the `vexpand` property.
457 ///
458 /// Readable | Writeable
459 ///
460 ///
461 /// #### `visible`
462 /// Whether the widget is visible.
463 ///
464 /// Readable | Writeable
465 ///
466 ///
467 /// #### `width-request`
468 /// Overrides for width request of the widget.
469 ///
470 /// If this is -1, the natural request will be used.
471 ///
472 /// Readable | Writeable
473 /// </details>
474 /// <details><summary><h4>Accessible</h4></summary>
475 ///
476 ///
477 /// #### `accessible-role`
478 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
479 ///
480 /// The accessible role cannot be changed once set.
481 ///
482 /// Readable | Writeable
483 /// </details>
484 /// <details><summary><h4>Orientable</h4></summary>
485 ///
486 ///
487 /// #### `orientation`
488 /// The orientation of the orientable.
489 ///
490 /// Readable | Writeable
491 /// </details>
492 /// <details><summary><h4>Scrollable</h4></summary>
493 ///
494 ///
495 /// #### `hadjustment`
496 /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
497 ///
498 /// This adjustment is shared between the scrollable widget and its parent.
499 ///
500 /// Readable | Writeable | Construct
501 ///
502 ///
503 /// #### `hscroll-policy`
504 /// Determines when horizontal scrolling should start.
505 ///
506 /// Readable | Writeable
507 ///
508 ///
509 /// #### `vadjustment`
510 /// Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
511 ///
512 /// This adjustment is shared between the scrollable widget and its parent.
513 ///
514 /// Readable | Writeable | Construct
515 ///
516 ///
517 /// #### `vscroll-policy`
518 /// Determines when vertical scrolling should start.
519 ///
520 /// Readable | Writeable
521 /// </details>
522 ///
523 /// ## Signals
524 ///
525 ///
526 /// #### `activate`
527 /// Emitted when a row has been activated by the user.
528 ///
529 /// Activation usually happens via the list.activate-item action of
530 /// the [`ListView`][crate::ListView].
531 ///
532 /// This allows for a convenient way to handle activation in a listview.
533 /// See [`ListItemExt::set_activatable()`][crate::prelude::ListItemExt::set_activatable()] for details on how to use
534 /// this signal.
535 ///
536 ///
537 /// <details><summary><h4>Widget</h4></summary>
538 ///
539 ///
540 /// #### `destroy`
541 /// Signals that all holders of a reference to the widget should release
542 /// the reference that they hold.
543 ///
544 /// May result in finalization of the widget if all references are released.
545 ///
546 /// This signal is not suitable for saving widget state.
547 ///
548 ///
549 ///
550 ///
551 /// #### `direction-changed`
552 /// Emitted when the text direction of a widget changes.
553 ///
554 ///
555 ///
556 ///
557 /// #### `hide`
558 /// Emitted when @widget is hidden.
559 ///
560 ///
561 ///
562 ///
563 /// #### `keynav-failed`
564 /// Emitted if keyboard navigation fails.
565 ///
566 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
567 ///
568 ///
569 ///
570 ///
571 /// #### `map`
572 /// Emitted when @widget is going to be mapped.
573 ///
574 /// A widget is mapped when the widget is visible (which is controlled with
575 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
576 /// are also visible.
577 ///
578 /// The `::map` signal can be used to determine whether a widget will be drawn,
579 /// for instance it can resume an animation that was stopped during the
580 /// emission of [`unmap`][struct@crate::Widget#unmap].
581 ///
582 ///
583 ///
584 ///
585 /// #### `mnemonic-activate`
586 /// Emitted when a widget is activated via a mnemonic.
587 ///
588 /// The default handler for this signal activates @widget if @group_cycling
589 /// is false, or just makes @widget grab focus if @group_cycling is true.
590 ///
591 ///
592 ///
593 ///
594 /// #### `move-focus`
595 /// Emitted when the focus is moved.
596 ///
597 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
598 ///
599 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
600 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
601 ///
602 /// Action
603 ///
604 ///
605 /// #### `query-tooltip`
606 /// Emitted when the widget’s tooltip is about to be shown.
607 ///
608 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
609 /// is true and the hover timeout has expired with the cursor hovering
610 /// above @widget; or emitted when @widget got focus in keyboard mode.
611 ///
612 /// Using the given coordinates, the signal handler should determine
613 /// whether a tooltip should be shown for @widget. If this is the case
614 /// true should be returned, false otherwise. Note that if @keyboard_mode
615 /// is true, the values of @x and @y are undefined and should not be used.
616 ///
617 /// The signal handler is free to manipulate @tooltip with the therefore
618 /// destined function calls.
619 ///
620 ///
621 ///
622 ///
623 /// #### `realize`
624 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
625 ///
626 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
627 /// or the widget has been mapped (that is, it is going to be drawn).
628 ///
629 ///
630 ///
631 ///
632 /// #### `show`
633 /// Emitted when @widget is shown.
634 ///
635 ///
636 ///
637 ///
638 /// #### `state-flags-changed`
639 /// Emitted when the widget state changes.
640 ///
641 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
642 ///
643 ///
644 ///
645 ///
646 /// #### `unmap`
647 /// Emitted when @widget is going to be unmapped.
648 ///
649 /// A widget is unmapped when either it or any of its parents up to the
650 /// toplevel widget have been set as hidden.
651 ///
652 /// As `::unmap` indicates that a widget will not be shown any longer,
653 /// it can be used to, for example, stop an animation on the widget.
654 ///
655 ///
656 ///
657 ///
658 /// #### `unrealize`
659 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
660 ///
661 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
662 /// or the widget has been unmapped (that is, it is going to be hidden).
663 ///
664 ///
665 /// </details>
666 ///
667 /// # Implements
668 ///
669 /// [`ListBaseExt`][trait@crate::prelude::ListBaseExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`ScrollableExt`][trait@crate::prelude::ScrollableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
670 #[doc(alias = "GtkListView")]
671 pub struct ListView(Object<ffi::GtkListView, ffi::GtkListViewClass>) @extends ListBase, Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable, Scrollable;
672
673 match fn {
674 type_ => || ffi::gtk_list_view_get_type(),
675 }
676}
677
678impl ListView {
679 /// Creates a new [`ListView`][crate::ListView] that uses the given @factory for
680 /// mapping items to widgets.
681 ///
682 /// The function takes ownership of the
683 /// arguments, so you can write code like
684 /// **⚠️ The following code is in c ⚠️**
685 ///
686 /// ```c
687 /// list_view = gtk_list_view_new (create_model (),
688 /// gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));
689 /// ```
690 /// ## `model`
691 /// the model to use
692 /// ## `factory`
693 /// The factory to populate items with
694 ///
695 /// # Returns
696 ///
697 /// a new [`ListView`][crate::ListView] using the given @model and @factory
698 #[doc(alias = "gtk_list_view_new")]
699 pub fn new(
700 model: Option<impl IsA<SelectionModel>>,
701 factory: Option<impl IsA<ListItemFactory>>,
702 ) -> ListView {
703 assert_initialized_main_thread!();
704 unsafe {
705 Widget::from_glib_none(ffi::gtk_list_view_new(
706 model.map(|p| p.upcast()).into_glib_ptr(),
707 factory.map(|p| p.upcast()).into_glib_ptr(),
708 ))
709 .unsafe_cast()
710 }
711 }
712
713 // rustdoc-stripper-ignore-next
714 /// Creates a new builder-pattern struct instance to construct [`ListView`] objects.
715 ///
716 /// This method returns an instance of [`ListViewBuilder`](crate::builders::ListViewBuilder) which can be used to create [`ListView`] objects.
717 pub fn builder() -> ListViewBuilder {
718 ListViewBuilder::new()
719 }
720
721 /// Returns whether rows can be selected by dragging with the mouse.
722 ///
723 /// # Returns
724 ///
725 /// true if rubberband selection is enabled
726 #[doc(alias = "gtk_list_view_get_enable_rubberband")]
727 #[doc(alias = "get_enable_rubberband")]
728 #[doc(alias = "enable-rubberband")]
729 pub fn enables_rubberband(&self) -> bool {
730 unsafe {
731 from_glib(ffi::gtk_list_view_get_enable_rubberband(
732 self.to_glib_none().0,
733 ))
734 }
735 }
736
737 /// Gets the factory that's currently used to populate list items.
738 ///
739 /// # Returns
740 ///
741 /// The factory in use
742 #[doc(alias = "gtk_list_view_get_factory")]
743 #[doc(alias = "get_factory")]
744 pub fn factory(&self) -> Option<ListItemFactory> {
745 unsafe { from_glib_none(ffi::gtk_list_view_get_factory(self.to_glib_none().0)) }
746 }
747
748 /// Gets the factory that's currently used to populate section headers.
749 ///
750 /// # Returns
751 ///
752 /// The factory in use
753 #[cfg(feature = "v4_12")]
754 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
755 #[doc(alias = "gtk_list_view_get_header_factory")]
756 #[doc(alias = "get_header_factory")]
757 #[doc(alias = "header-factory")]
758 pub fn header_factory(&self) -> Option<ListItemFactory> {
759 unsafe { from_glib_none(ffi::gtk_list_view_get_header_factory(self.to_glib_none().0)) }
760 }
761
762 /// Gets the model that's currently used to read the items displayed.
763 ///
764 /// # Returns
765 ///
766 /// The model in use
767 #[doc(alias = "gtk_list_view_get_model")]
768 #[doc(alias = "get_model")]
769 pub fn model(&self) -> Option<SelectionModel> {
770 unsafe { from_glib_none(ffi::gtk_list_view_get_model(self.to_glib_none().0)) }
771 }
772
773 /// Returns whether the listview should show separators
774 /// between rows.
775 ///
776 /// # Returns
777 ///
778 /// true if the listview shows separators
779 #[doc(alias = "gtk_list_view_get_show_separators")]
780 #[doc(alias = "get_show_separators")]
781 #[doc(alias = "show-separators")]
782 pub fn shows_separators(&self) -> bool {
783 unsafe {
784 from_glib(ffi::gtk_list_view_get_show_separators(
785 self.to_glib_none().0,
786 ))
787 }
788 }
789
790 /// Returns whether rows will be activated on single click and
791 /// selected on hover.
792 ///
793 /// # Returns
794 ///
795 /// true if rows are activated on single click
796 #[doc(alias = "gtk_list_view_get_single_click_activate")]
797 #[doc(alias = "get_single_click_activate")]
798 #[doc(alias = "single-click-activate")]
799 pub fn is_single_click_activate(&self) -> bool {
800 unsafe {
801 from_glib(ffi::gtk_list_view_get_single_click_activate(
802 self.to_glib_none().0,
803 ))
804 }
805 }
806
807 /// Gets the behavior set for the <kbd>Tab</kbd> key.
808 ///
809 /// # Returns
810 ///
811 /// The behavior of the <kbd>Tab</kbd> key
812 #[cfg(feature = "v4_12")]
813 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
814 #[doc(alias = "gtk_list_view_get_tab_behavior")]
815 #[doc(alias = "get_tab_behavior")]
816 #[doc(alias = "tab-behavior")]
817 pub fn tab_behavior(&self) -> ListTabBehavior {
818 unsafe { from_glib(ffi::gtk_list_view_get_tab_behavior(self.to_glib_none().0)) }
819 }
820
821 /// Scrolls to the item at the given position and performs the actions
822 /// specified in @flags.
823 ///
824 /// This function works no matter if the listview is shown or focused.
825 /// If it isn't, then the changes will take effect once that happens.
826 /// ## `pos`
827 /// position of the item. Must be less than the number of
828 /// items in the view.
829 /// ## `flags`
830 /// actions to perform
831 /// ## `scroll`
832 /// details of how to perform
833 /// the scroll operation or [`None`] to scroll into view
834 #[cfg(feature = "v4_12")]
835 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
836 #[doc(alias = "gtk_list_view_scroll_to")]
837 pub fn scroll_to(&self, pos: u32, flags: ListScrollFlags, scroll: Option<ScrollInfo>) {
838 unsafe {
839 ffi::gtk_list_view_scroll_to(
840 self.to_glib_none().0,
841 pos,
842 flags.into_glib(),
843 scroll.into_glib_ptr(),
844 );
845 }
846 }
847
848 /// Sets whether selections can be changed by dragging with the mouse.
849 /// ## `enable_rubberband`
850 /// whether to enable rubberband selection
851 #[doc(alias = "gtk_list_view_set_enable_rubberband")]
852 #[doc(alias = "enable-rubberband")]
853 pub fn set_enable_rubberband(&self, enable_rubberband: bool) {
854 unsafe {
855 ffi::gtk_list_view_set_enable_rubberband(
856 self.to_glib_none().0,
857 enable_rubberband.into_glib(),
858 );
859 }
860 }
861
862 /// Sets the [`ListItemFactory`][crate::ListItemFactory] to use for populating list items.
863 /// ## `factory`
864 /// the factory to use
865 #[doc(alias = "gtk_list_view_set_factory")]
866 #[doc(alias = "factory")]
867 pub fn set_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
868 unsafe {
869 ffi::gtk_list_view_set_factory(
870 self.to_glib_none().0,
871 factory.map(|p| p.as_ref()).to_glib_none().0,
872 );
873 }
874 }
875
876 /// Sets the [`ListItemFactory`][crate::ListItemFactory] to use for populating the
877 /// [`ListHeader`][crate::ListHeader] objects used in section headers.
878 ///
879 /// If this factory is set to `NULL`, the list will not show
880 /// section headers.
881 /// ## `factory`
882 /// the factory to use
883 #[cfg(feature = "v4_12")]
884 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
885 #[doc(alias = "gtk_list_view_set_header_factory")]
886 #[doc(alias = "header-factory")]
887 pub fn set_header_factory(&self, factory: Option<&impl IsA<ListItemFactory>>) {
888 unsafe {
889 ffi::gtk_list_view_set_header_factory(
890 self.to_glib_none().0,
891 factory.map(|p| p.as_ref()).to_glib_none().0,
892 );
893 }
894 }
895
896 /// Sets the model to use.
897 ///
898 /// This must be a [`SelectionModel`][crate::SelectionModel] to use.
899 /// ## `model`
900 /// the model to use
901 #[doc(alias = "gtk_list_view_set_model")]
902 #[doc(alias = "model")]
903 pub fn set_model(&self, model: Option<&impl IsA<SelectionModel>>) {
904 unsafe {
905 ffi::gtk_list_view_set_model(
906 self.to_glib_none().0,
907 model.map(|p| p.as_ref()).to_glib_none().0,
908 );
909 }
910 }
911
912 /// Sets whether the listview should show separators
913 /// between rows.
914 /// ## `show_separators`
915 /// whether to show separators
916 #[doc(alias = "gtk_list_view_set_show_separators")]
917 #[doc(alias = "show-separators")]
918 pub fn set_show_separators(&self, show_separators: bool) {
919 unsafe {
920 ffi::gtk_list_view_set_show_separators(
921 self.to_glib_none().0,
922 show_separators.into_glib(),
923 );
924 }
925 }
926
927 /// Sets whether rows should be activated on single click and
928 /// selected on hover.
929 /// ## `single_click_activate`
930 /// whether to activate items on single click
931 #[doc(alias = "gtk_list_view_set_single_click_activate")]
932 #[doc(alias = "single-click-activate")]
933 pub fn set_single_click_activate(&self, single_click_activate: bool) {
934 unsafe {
935 ffi::gtk_list_view_set_single_click_activate(
936 self.to_glib_none().0,
937 single_click_activate.into_glib(),
938 );
939 }
940 }
941
942 /// Sets the <kbd>Tab</kbd> key behavior.
943 ///
944 /// This influences how the <kbd>Tab</kbd> and
945 /// <kbd>Shift</kbd>+<kbd>Tab</kbd> keys move the
946 /// focus in the listview.
947 /// ## `tab_behavior`
948 /// The desired tab behavior
949 #[cfg(feature = "v4_12")]
950 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
951 #[doc(alias = "gtk_list_view_set_tab_behavior")]
952 #[doc(alias = "tab-behavior")]
953 pub fn set_tab_behavior(&self, tab_behavior: ListTabBehavior) {
954 unsafe {
955 ffi::gtk_list_view_set_tab_behavior(self.to_glib_none().0, tab_behavior.into_glib());
956 }
957 }
958
959 /// Emitted when a row has been activated by the user.
960 ///
961 /// Activation usually happens via the list.activate-item action of
962 /// the [`ListView`][crate::ListView].
963 ///
964 /// This allows for a convenient way to handle activation in a listview.
965 /// See [`ListItemExt::set_activatable()`][crate::prelude::ListItemExt::set_activatable()] for details on how to use
966 /// this signal.
967 /// ## `position`
968 /// position of item to activate
969 #[doc(alias = "activate")]
970 pub fn connect_activate<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
971 unsafe extern "C" fn activate_trampoline<F: Fn(&ListView, u32) + 'static>(
972 this: *mut ffi::GtkListView,
973 position: std::ffi::c_uint,
974 f: glib::ffi::gpointer,
975 ) {
976 unsafe {
977 let f: &F = &*(f as *const F);
978 f(&from_glib_borrow(this), position)
979 }
980 }
981 unsafe {
982 let f: Box_<F> = Box_::new(f);
983 connect_raw(
984 self.as_ptr() as *mut _,
985 c"activate".as_ptr() as *const _,
986 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
987 activate_trampoline::<F> as *const (),
988 )),
989 Box_::into_raw(f),
990 )
991 }
992 }
993
994 #[doc(alias = "enable-rubberband")]
995 pub fn connect_enable_rubberband_notify<F: Fn(&Self) + 'static>(
996 &self,
997 f: F,
998 ) -> SignalHandlerId {
999 unsafe extern "C" fn notify_enable_rubberband_trampoline<F: Fn(&ListView) + 'static>(
1000 this: *mut ffi::GtkListView,
1001 _param_spec: glib::ffi::gpointer,
1002 f: glib::ffi::gpointer,
1003 ) {
1004 unsafe {
1005 let f: &F = &*(f as *const F);
1006 f(&from_glib_borrow(this))
1007 }
1008 }
1009 unsafe {
1010 let f: Box_<F> = Box_::new(f);
1011 connect_raw(
1012 self.as_ptr() as *mut _,
1013 c"notify::enable-rubberband".as_ptr() as *const _,
1014 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1015 notify_enable_rubberband_trampoline::<F> as *const (),
1016 )),
1017 Box_::into_raw(f),
1018 )
1019 }
1020 }
1021
1022 #[doc(alias = "factory")]
1023 pub fn connect_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1024 unsafe extern "C" fn notify_factory_trampoline<F: Fn(&ListView) + 'static>(
1025 this: *mut ffi::GtkListView,
1026 _param_spec: glib::ffi::gpointer,
1027 f: glib::ffi::gpointer,
1028 ) {
1029 unsafe {
1030 let f: &F = &*(f as *const F);
1031 f(&from_glib_borrow(this))
1032 }
1033 }
1034 unsafe {
1035 let f: Box_<F> = Box_::new(f);
1036 connect_raw(
1037 self.as_ptr() as *mut _,
1038 c"notify::factory".as_ptr() as *const _,
1039 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1040 notify_factory_trampoline::<F> as *const (),
1041 )),
1042 Box_::into_raw(f),
1043 )
1044 }
1045 }
1046
1047 #[cfg(feature = "v4_12")]
1048 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1049 #[doc(alias = "header-factory")]
1050 pub fn connect_header_factory_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1051 unsafe extern "C" fn notify_header_factory_trampoline<F: Fn(&ListView) + 'static>(
1052 this: *mut ffi::GtkListView,
1053 _param_spec: glib::ffi::gpointer,
1054 f: glib::ffi::gpointer,
1055 ) {
1056 unsafe {
1057 let f: &F = &*(f as *const F);
1058 f(&from_glib_borrow(this))
1059 }
1060 }
1061 unsafe {
1062 let f: Box_<F> = Box_::new(f);
1063 connect_raw(
1064 self.as_ptr() as *mut _,
1065 c"notify::header-factory".as_ptr() as *const _,
1066 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1067 notify_header_factory_trampoline::<F> as *const (),
1068 )),
1069 Box_::into_raw(f),
1070 )
1071 }
1072 }
1073
1074 #[doc(alias = "model")]
1075 pub fn connect_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1076 unsafe extern "C" fn notify_model_trampoline<F: Fn(&ListView) + 'static>(
1077 this: *mut ffi::GtkListView,
1078 _param_spec: glib::ffi::gpointer,
1079 f: glib::ffi::gpointer,
1080 ) {
1081 unsafe {
1082 let f: &F = &*(f as *const F);
1083 f(&from_glib_borrow(this))
1084 }
1085 }
1086 unsafe {
1087 let f: Box_<F> = Box_::new(f);
1088 connect_raw(
1089 self.as_ptr() as *mut _,
1090 c"notify::model".as_ptr() as *const _,
1091 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1092 notify_model_trampoline::<F> as *const (),
1093 )),
1094 Box_::into_raw(f),
1095 )
1096 }
1097 }
1098
1099 #[doc(alias = "show-separators")]
1100 pub fn connect_show_separators_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1101 unsafe extern "C" fn notify_show_separators_trampoline<F: Fn(&ListView) + 'static>(
1102 this: *mut ffi::GtkListView,
1103 _param_spec: glib::ffi::gpointer,
1104 f: glib::ffi::gpointer,
1105 ) {
1106 unsafe {
1107 let f: &F = &*(f as *const F);
1108 f(&from_glib_borrow(this))
1109 }
1110 }
1111 unsafe {
1112 let f: Box_<F> = Box_::new(f);
1113 connect_raw(
1114 self.as_ptr() as *mut _,
1115 c"notify::show-separators".as_ptr() as *const _,
1116 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1117 notify_show_separators_trampoline::<F> as *const (),
1118 )),
1119 Box_::into_raw(f),
1120 )
1121 }
1122 }
1123
1124 #[doc(alias = "single-click-activate")]
1125 pub fn connect_single_click_activate_notify<F: Fn(&Self) + 'static>(
1126 &self,
1127 f: F,
1128 ) -> SignalHandlerId {
1129 unsafe extern "C" fn notify_single_click_activate_trampoline<F: Fn(&ListView) + 'static>(
1130 this: *mut ffi::GtkListView,
1131 _param_spec: glib::ffi::gpointer,
1132 f: glib::ffi::gpointer,
1133 ) {
1134 unsafe {
1135 let f: &F = &*(f as *const F);
1136 f(&from_glib_borrow(this))
1137 }
1138 }
1139 unsafe {
1140 let f: Box_<F> = Box_::new(f);
1141 connect_raw(
1142 self.as_ptr() as *mut _,
1143 c"notify::single-click-activate".as_ptr() as *const _,
1144 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1145 notify_single_click_activate_trampoline::<F> as *const (),
1146 )),
1147 Box_::into_raw(f),
1148 )
1149 }
1150 }
1151
1152 #[cfg(feature = "v4_12")]
1153 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1154 #[doc(alias = "tab-behavior")]
1155 pub fn connect_tab_behavior_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1156 unsafe extern "C" fn notify_tab_behavior_trampoline<F: Fn(&ListView) + 'static>(
1157 this: *mut ffi::GtkListView,
1158 _param_spec: glib::ffi::gpointer,
1159 f: glib::ffi::gpointer,
1160 ) {
1161 unsafe {
1162 let f: &F = &*(f as *const F);
1163 f(&from_glib_borrow(this))
1164 }
1165 }
1166 unsafe {
1167 let f: Box_<F> = Box_::new(f);
1168 connect_raw(
1169 self.as_ptr() as *mut _,
1170 c"notify::tab-behavior".as_ptr() as *const _,
1171 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1172 notify_tab_behavior_trampoline::<F> as *const (),
1173 )),
1174 Box_::into_raw(f),
1175 )
1176 }
1177 }
1178}
1179
1180impl Default for ListView {
1181 fn default() -> Self {
1182 glib::object::Object::new::<Self>()
1183 }
1184}
1185
1186// rustdoc-stripper-ignore-next
1187/// A [builder-pattern] type to construct [`ListView`] objects.
1188///
1189/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1190#[must_use = "The builder must be built to be used"]
1191pub struct ListViewBuilder {
1192 builder: glib::object::ObjectBuilder<'static, ListView>,
1193}
1194
1195impl ListViewBuilder {
1196 fn new() -> Self {
1197 Self {
1198 builder: glib::object::Object::builder(),
1199 }
1200 }
1201
1202 /// Allow rubberband selection.
1203 pub fn enable_rubberband(self, enable_rubberband: bool) -> Self {
1204 Self {
1205 builder: self
1206 .builder
1207 .property("enable-rubberband", enable_rubberband),
1208 }
1209 }
1210
1211 /// Factory for populating list items.
1212 ///
1213 /// The factory must be for configuring [`ListItem`][crate::ListItem] objects.
1214 pub fn factory(self, factory: &impl IsA<ListItemFactory>) -> Self {
1215 Self {
1216 builder: self.builder.property("factory", factory.clone().upcast()),
1217 }
1218 }
1219
1220 /// Factory for creating header widgets.
1221 ///
1222 /// The factory must be for configuring [`ListHeader`][crate::ListHeader] objects.
1223 #[cfg(feature = "v4_12")]
1224 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1225 pub fn header_factory(self, header_factory: &impl IsA<ListItemFactory>) -> Self {
1226 Self {
1227 builder: self
1228 .builder
1229 .property("header-factory", header_factory.clone().upcast()),
1230 }
1231 }
1232
1233 /// Model for the items displayed.
1234 pub fn model(self, model: &impl IsA<SelectionModel>) -> Self {
1235 Self {
1236 builder: self.builder.property("model", model.clone().upcast()),
1237 }
1238 }
1239
1240 /// Show separators between rows.
1241 pub fn show_separators(self, show_separators: bool) -> Self {
1242 Self {
1243 builder: self.builder.property("show-separators", show_separators),
1244 }
1245 }
1246
1247 /// Activate rows on single click and select them on hover.
1248 pub fn single_click_activate(self, single_click_activate: bool) -> Self {
1249 Self {
1250 builder: self
1251 .builder
1252 .property("single-click-activate", single_click_activate),
1253 }
1254 }
1255
1256 /// Behavior of the <kbd>Tab</kbd> key
1257 #[cfg(feature = "v4_12")]
1258 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1259 pub fn tab_behavior(self, tab_behavior: ListTabBehavior) -> Self {
1260 Self {
1261 builder: self.builder.property("tab-behavior", tab_behavior),
1262 }
1263 }
1264
1265 /// The orientation of the list. See GtkOrientable:orientation
1266 /// for details.
1267 pub fn orientation(self, orientation: Orientation) -> Self {
1268 Self {
1269 builder: self.builder.property("orientation", orientation),
1270 }
1271 }
1272
1273 /// Whether the widget or any of its descendents can accept
1274 /// the input focus.
1275 ///
1276 /// This property is meant to be set by widget implementations,
1277 /// typically in their instance init function.
1278 pub fn can_focus(self, can_focus: bool) -> Self {
1279 Self {
1280 builder: self.builder.property("can-focus", can_focus),
1281 }
1282 }
1283
1284 /// Whether the widget can receive pointer events.
1285 pub fn can_target(self, can_target: bool) -> Self {
1286 Self {
1287 builder: self.builder.property("can-target", can_target),
1288 }
1289 }
1290
1291 /// A list of css classes applied to this widget.
1292 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1293 Self {
1294 builder: self.builder.property("css-classes", css_classes.into()),
1295 }
1296 }
1297
1298 /// The name of this widget in the CSS tree.
1299 ///
1300 /// This property is meant to be set by widget implementations,
1301 /// typically in their instance init function.
1302 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1303 Self {
1304 builder: self.builder.property("css-name", css_name.into()),
1305 }
1306 }
1307
1308 /// The cursor used by @widget.
1309 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1310 Self {
1311 builder: self.builder.property("cursor", cursor.clone()),
1312 }
1313 }
1314
1315 /// Whether the widget should grab focus when it is clicked with the mouse.
1316 ///
1317 /// This property is only relevant for widgets that can take focus.
1318 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1319 Self {
1320 builder: self.builder.property("focus-on-click", focus_on_click),
1321 }
1322 }
1323
1324 /// Whether this widget itself will accept the input focus.
1325 pub fn focusable(self, focusable: bool) -> Self {
1326 Self {
1327 builder: self.builder.property("focusable", focusable),
1328 }
1329 }
1330
1331 /// How to distribute horizontal space if widget gets extra space.
1332 pub fn halign(self, halign: Align) -> Self {
1333 Self {
1334 builder: self.builder.property("halign", halign),
1335 }
1336 }
1337
1338 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1339 /// signal on @widget.
1340 ///
1341 /// A true value indicates that @widget can have a tooltip, in this case
1342 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1343 /// determine whether it will provide a tooltip or not.
1344 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1345 Self {
1346 builder: self.builder.property("has-tooltip", has_tooltip),
1347 }
1348 }
1349
1350 /// Overrides for height request of the widget.
1351 ///
1352 /// If this is -1, the natural request will be used.
1353 pub fn height_request(self, height_request: i32) -> Self {
1354 Self {
1355 builder: self.builder.property("height-request", height_request),
1356 }
1357 }
1358
1359 /// Whether to expand horizontally.
1360 pub fn hexpand(self, hexpand: bool) -> Self {
1361 Self {
1362 builder: self.builder.property("hexpand", hexpand),
1363 }
1364 }
1365
1366 /// Whether to use the `hexpand` property.
1367 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1368 Self {
1369 builder: self.builder.property("hexpand-set", hexpand_set),
1370 }
1371 }
1372
1373 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1374 /// the preferred size of the widget, and allocate its children.
1375 ///
1376 /// This property is meant to be set by widget implementations,
1377 /// typically in their instance init function.
1378 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1379 Self {
1380 builder: self
1381 .builder
1382 .property("layout-manager", layout_manager.clone().upcast()),
1383 }
1384 }
1385
1386 /// Makes this widget act like a modal dialog, with respect to
1387 /// event delivery.
1388 ///
1389 /// Global event controllers will not handle events with targets
1390 /// inside the widget, unless they are set up to ignore propagation
1391 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1392 #[cfg(feature = "v4_18")]
1393 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1394 pub fn limit_events(self, limit_events: bool) -> Self {
1395 Self {
1396 builder: self.builder.property("limit-events", limit_events),
1397 }
1398 }
1399
1400 /// Margin on bottom side of widget.
1401 ///
1402 /// This property adds margin outside of the widget's normal size
1403 /// request, the margin will be added in addition to the size from
1404 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1405 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1406 Self {
1407 builder: self.builder.property("margin-bottom", margin_bottom),
1408 }
1409 }
1410
1411 /// Margin on end of widget, horizontally.
1412 ///
1413 /// This property supports left-to-right and right-to-left text
1414 /// directions.
1415 ///
1416 /// This property adds margin outside of the widget's normal size
1417 /// request, the margin will be added in addition to the size from
1418 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1419 pub fn margin_end(self, margin_end: i32) -> Self {
1420 Self {
1421 builder: self.builder.property("margin-end", margin_end),
1422 }
1423 }
1424
1425 /// Margin on start of widget, horizontally.
1426 ///
1427 /// This property supports left-to-right and right-to-left text
1428 /// directions.
1429 ///
1430 /// This property adds margin outside of the widget's normal size
1431 /// request, the margin will be added in addition to the size from
1432 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1433 pub fn margin_start(self, margin_start: i32) -> Self {
1434 Self {
1435 builder: self.builder.property("margin-start", margin_start),
1436 }
1437 }
1438
1439 /// Margin on top side of widget.
1440 ///
1441 /// This property adds margin outside of the widget's normal size
1442 /// request, the margin will be added in addition to the size from
1443 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1444 pub fn margin_top(self, margin_top: i32) -> Self {
1445 Self {
1446 builder: self.builder.property("margin-top", margin_top),
1447 }
1448 }
1449
1450 /// The name of the widget.
1451 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1452 Self {
1453 builder: self.builder.property("name", name.into()),
1454 }
1455 }
1456
1457 /// The requested opacity of the widget.
1458 pub fn opacity(self, opacity: f64) -> Self {
1459 Self {
1460 builder: self.builder.property("opacity", opacity),
1461 }
1462 }
1463
1464 /// How content outside the widget's content area is treated.
1465 ///
1466 /// This property is meant to be set by widget implementations,
1467 /// typically in their instance init function.
1468 pub fn overflow(self, overflow: Overflow) -> Self {
1469 Self {
1470 builder: self.builder.property("overflow", overflow),
1471 }
1472 }
1473
1474 /// Whether the widget will receive the default action when it is focused.
1475 pub fn receives_default(self, receives_default: bool) -> Self {
1476 Self {
1477 builder: self.builder.property("receives-default", receives_default),
1478 }
1479 }
1480
1481 /// Whether the widget responds to input.
1482 pub fn sensitive(self, sensitive: bool) -> Self {
1483 Self {
1484 builder: self.builder.property("sensitive", sensitive),
1485 }
1486 }
1487
1488 /// Sets the text of tooltip to be the given string, which is marked up
1489 /// with Pango markup.
1490 ///
1491 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1492 ///
1493 /// This is a convenience property which will take care of getting the
1494 /// tooltip shown if the given string is not `NULL`:
1495 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1496 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1497 /// the default signal handler.
1498 ///
1499 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1500 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1501 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1502 Self {
1503 builder: self
1504 .builder
1505 .property("tooltip-markup", tooltip_markup.into()),
1506 }
1507 }
1508
1509 /// Sets the text of tooltip to be the given string.
1510 ///
1511 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1512 ///
1513 /// This is a convenience property which will take care of getting the
1514 /// tooltip shown if the given string is not `NULL`:
1515 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1516 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1517 /// the default signal handler.
1518 ///
1519 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1520 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1521 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1522 Self {
1523 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1524 }
1525 }
1526
1527 /// How to distribute vertical space if widget gets extra space.
1528 pub fn valign(self, valign: Align) -> Self {
1529 Self {
1530 builder: self.builder.property("valign", valign),
1531 }
1532 }
1533
1534 /// Whether to expand vertically.
1535 pub fn vexpand(self, vexpand: bool) -> Self {
1536 Self {
1537 builder: self.builder.property("vexpand", vexpand),
1538 }
1539 }
1540
1541 /// Whether to use the `vexpand` property.
1542 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1543 Self {
1544 builder: self.builder.property("vexpand-set", vexpand_set),
1545 }
1546 }
1547
1548 /// Whether the widget is visible.
1549 pub fn visible(self, visible: bool) -> Self {
1550 Self {
1551 builder: self.builder.property("visible", visible),
1552 }
1553 }
1554
1555 /// Overrides for width request of the widget.
1556 ///
1557 /// If this is -1, the natural request will be used.
1558 pub fn width_request(self, width_request: i32) -> Self {
1559 Self {
1560 builder: self.builder.property("width-request", width_request),
1561 }
1562 }
1563
1564 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1565 ///
1566 /// The accessible role cannot be changed once set.
1567 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1568 Self {
1569 builder: self.builder.property("accessible-role", accessible_role),
1570 }
1571 }
1572
1573 /// Horizontal [`Adjustment`][crate::Adjustment] of the scrollable widget.
1574 ///
1575 /// This adjustment is shared between the scrollable widget and its parent.
1576 pub fn hadjustment(self, hadjustment: &impl IsA<Adjustment>) -> Self {
1577 Self {
1578 builder: self
1579 .builder
1580 .property("hadjustment", hadjustment.clone().upcast()),
1581 }
1582 }
1583
1584 /// Determines when horizontal scrolling should start.
1585 pub fn hscroll_policy(self, hscroll_policy: ScrollablePolicy) -> Self {
1586 Self {
1587 builder: self.builder.property("hscroll-policy", hscroll_policy),
1588 }
1589 }
1590
1591 /// Vertical [`Adjustment`][crate::Adjustment] of the scrollable widget.
1592 ///
1593 /// This adjustment is shared between the scrollable widget and its parent.
1594 pub fn vadjustment(self, vadjustment: &impl IsA<Adjustment>) -> Self {
1595 Self {
1596 builder: self
1597 .builder
1598 .property("vadjustment", vadjustment.clone().upcast()),
1599 }
1600 }
1601
1602 /// Determines when vertical scrolling should start.
1603 pub fn vscroll_policy(self, vscroll_policy: ScrollablePolicy) -> Self {
1604 Self {
1605 builder: self.builder.property("vscroll-policy", vscroll_policy),
1606 }
1607 }
1608
1609 // rustdoc-stripper-ignore-next
1610 /// Build the [`ListView`].
1611 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1612 pub fn build(self) -> ListView {
1613 assert_initialized_main_thread!();
1614 self.builder.build()
1615 }
1616}