gtk4/auto/list_item_factory.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::ffi;
6
7glib::wrapper! {
8 /// A [`ListItemFactory`][crate::ListItemFactory] creates widgets for the items taken from a `GListModel`.
9 ///
10 /// This is one of the core concepts of handling list widgets such
11 /// as [`ListView`][crate::ListView] or [`GridView`][crate::GridView].
12 ///
13 /// The [`ListItemFactory`][crate::ListItemFactory] is tasked with creating widgets for items
14 /// taken from the model when the views need them and updating them as
15 /// the items displayed by the view change.
16 ///
17 /// A view is usually only able to display anything after both a factory
18 /// and a model have been set on the view. So it is important that you do
19 /// not skip this step when setting up your first view.
20 ///
21 /// Because views do not display the whole list at once but only a few
22 /// items, they only need to maintain a few widgets at a time. They will
23 /// instruct the [`ListItemFactory`][crate::ListItemFactory] to create these widgets and bind them
24 /// to the items that are currently displayed.
25 ///
26 /// As the list model changes or the user scrolls to the list, the items will
27 /// change and the view will instruct the factory to bind the widgets to those
28 /// new items.
29 ///
30 /// The actual widgets used for displaying those widgets is provided by you.
31 ///
32 /// When the factory needs widgets created, it will create a [`ListItem`][crate::ListItem]
33 /// and hand it to your code to set up a widget for. This list item will provide
34 /// various properties with information about what item to display and provide
35 /// you with some opportunities to configure its behavior. See the
36 /// [`ListItem`][crate::ListItem] documentation for further details.
37 ///
38 /// Various implementations of [`ListItemFactory`][crate::ListItemFactory] exist to allow you different
39 /// ways to provide those widgets. The most common implementations are
40 /// [`BuilderListItemFactory`][crate::BuilderListItemFactory] which takes a [`Builder`][crate::Builder] .ui file
41 /// and then creates widgets and manages everything automatically from the
42 /// information in that file and [`SignalListItemFactory`][crate::SignalListItemFactory] which allows
43 /// you to connect to signals with your own code and retain full control over
44 /// how the widgets are setup and managed.
45 ///
46 /// A [`ListItemFactory`][crate::ListItemFactory] is supposed to be final - that means its behavior should
47 /// not change and the first widget created from it should behave the same way as
48 /// the last widget created from it.
49 /// If you intend to do changes to the behavior, it is recommended that you create
50 /// a new [`ListItemFactory`][crate::ListItemFactory] which will allow the views to recreate its widgets.
51 ///
52 /// Once you have chosen your factory and created it, you need to set it
53 /// on the view widget you want to use it with, such as via
54 /// [`ListView::set_factory()`][crate::ListView::set_factory()]. Reusing factories across different
55 /// views is allowed, but very uncommon.
56 ///
57 /// # Implements
58 ///
59 /// [`trait@glib::ObjectExt`]
60 #[doc(alias = "GtkListItemFactory")]
61 pub struct ListItemFactory(Object<ffi::GtkListItemFactory, ffi::GtkListItemFactoryClass>);
62
63 match fn {
64 type_ => || ffi::gtk_list_item_factory_get_type(),
65 }
66}
67
68impl ListItemFactory {
69 pub const NONE: Option<&'static ListItemFactory> = None;
70}