docs: Clarify types for BuilderListItemFactory

The docs for GtkBuilderListItemFactory previously stated that the
template must extend GtkListItem. However, this is not always true.
GtkListView has headers which must extend GtkListHeader, and
GtkColumnView has its own types.

Clarified this in the GtkBuilderListItemFactory docs, and specified the
expected types in the GtkColumnView, GtkListView, and GtkGridView docs.
This commit is contained in:
James Westman 2024-05-04 12:49:40 -05:00
parent f579b171a9
commit b7e4bbaf74
5 changed files with 21 additions and 5 deletions

View File

@ -32,8 +32,12 @@
* `GtkBuilderListItemFactory` is a `GtkListItemFactory` that creates
* widgets by instantiating `GtkBuilder` UI templates.
*
* The templates must be extending `GtkListItem`, and typically use
* `GtkExpression`s to obtain data from the items in the model.
* The templates must extend the class that the parent widget expects.
* For example, a factory provided to [property@Gtk.ListView:factory] must have
* a template that extends [class@Gtk.ListItem].
*
* Templates typically use `GtkExpression`s to obtain data from the items
* in the model.
*
* Example:
* ```xml
@ -203,7 +207,7 @@ gtk_builder_list_item_factory_set_property (GObject *object,
case PROP_RESOURCE:
{
GError *error = NULL;
GBytes *bytes;
GBytes *bytes;
const char *resource;
resource = g_value_get_string (value);

View File

@ -861,6 +861,8 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
*
* The factory used for configuring rows.
*
* The factory must be for configuring [class@Gtk.ColumnViewRow] objects.
*
* Since: 4.12
*/
properties[PROP_ROW_FACTORY] =
@ -926,6 +928,8 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
*
* Factory for creating header widgets.
*
* The factory must be for configuring [class@Gtk.ListHeader] objects.
*
* Since: 4.12
*/
properties[PROP_HEADER_FACTORY] =

View File

@ -255,6 +255,8 @@ gtk_column_view_column_class_init (GtkColumnViewColumnClass *klass)
* GtkColumnViewColumn:factory: (attributes org.gtk.Property.get=gtk_column_view_column_get_factory org.gtk.Property.set=gtk_column_view_column_set_factory)
*
* Factory for populating list items.
*
* The factory must be for configuring [class@Gtk.ColumnViewCell] objects.
*/
properties[PROP_FACTORY] =
g_param_spec_object ("factory", NULL, NULL,
@ -761,7 +763,7 @@ gtk_column_view_column_remove_from_sorter (GtkColumnViewColumn *self)
{
if (self->view == NULL)
return;
gtk_column_view_sorter_remove_column (GTK_COLUMN_VIEW_SORTER (gtk_column_view_get_sorter (self->view)), self);
}

View File

@ -1109,6 +1109,8 @@ gtk_grid_view_class_init (GtkGridViewClass *klass)
* GtkGridView:factory: (attributes org.gtk.Property.get=gtk_grid_view_get_factory org.gtk.Property.set=gtk_grid_view_set_factory)
*
* Factory for populating list items.
*
* The factory must be for configuring [class@Gtk.ListItem] objects.
*/
properties[PROP_FACTORY] =
g_param_spec_object ("factory", NULL, NULL,

View File

@ -881,6 +881,8 @@ gtk_list_view_class_init (GtkListViewClass *klass)
* GtkListView:factory: (attributes org.gtk.Property.get=gtk_list_view_get_factory org.gtk.Property.set=gtk_list_view_set_factory)
*
* Factory for populating list items.
*
* The factory must be for configuring [class@Gtk.ListItem] objects.
*/
properties[PROP_FACTORY] =
g_param_spec_object ("factory", NULL, NULL,
@ -892,6 +894,8 @@ gtk_list_view_class_init (GtkListViewClass *klass)
*
* Factory for creating header widgets.
*
* The factory must be for configuring [class@Gtk.ListHeader] objects.
*
* Since: 4.12
*/
properties[PROP_HEADER_FACTORY] =
@ -1355,7 +1359,7 @@ gtk_list_view_get_tab_behavior (GtkListView *self)
* @pos: position of the item
* @flags: actions to perform
* @scroll: (nullable) (transfer full): details of how to perform
* the scroll operation or %NULL to scroll into view
* the scroll operation or %NULL to scroll into view
*
* Scrolls to the item at the given position and performs the actions
* specified in @flags.