From 7a4ec897bc471ea7403bce12ff0035c6f1d9c25d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 9 Jun 2022 17:03:09 +0200 Subject: [PATCH] listmodel: Recommend implementing properties "item-type" and "n-items" should ideally be implemented by listmodels, so document that. --- gio/glistmodel.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gio/glistmodel.c b/gio/glistmodel.c index 94f183ecc..3f9b85e91 100644 --- a/gio/glistmodel.c +++ b/gio/glistmodel.c @@ -84,6 +84,21 @@ G_DEFINE_INTERFACE (GListModel, g_list_model, G_TYPE_OBJECT) * implementation, but typically it will be from the thread that owns * the [thread-default main context][g-main-context-push-thread-default] * in effect at the time that the model was created. + * + * Over time, it has established itself as good practice for listmodel + * implementations to provide properties `item-type` and `n-items` to + * ease working with them. While it is not required, it is recommended + * that implementations provide these two properties. They should return + * the values of g_list_model_get_item_type() and g_list_model_get_n_items() + * respectively and be defined as such: + * |[ + * properties[PROP_ITEM_TYPE] = + * g_param_spec_gtype ("item-type", "", "", G_TYPE_OBJECT, + * G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + * properties[PROP_N_ITEMS] = + * g_param_spec_uint ("n-items", "", "", 0, G_MAXUINT, 0, + * G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + * ]| */ /**