Make GListModelInterface::get_item usable from GObject Introspection bindings

Language bindings have so far been unable to implement the GListModel
interface because the ::get_item virtual function returns a
non-bindable type (gpointer). The `gpointer` type gets translated into
`void` by G-I meaning that get_item() implementations can't return any
items.

We can set the return type of the get_item() vfunc explicitly to
GObject, which fixes the issue.

This patch also removes the existing (type GObject) annotation on
g_list_model_get_item(), which is necessary because if its return type
matches that of the get_item() vfunc, G-I connects the two and
propagates the 'skip' annotation from one to the other resulting in the
get_item() vfunc being hidden. There's no API break here because the
'skip' annotation makes g_list_model_get_item() invisible to G-I users
anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=787271
This commit is contained in:
Sam Thursfield 2017-09-04 22:42:04 +01:00 committed by Philip Withnall
parent 1a5cebec39
commit bb26bc29e3

View File

@ -95,6 +95,22 @@ G_DEFINE_INTERFACE (GListModel, g_list_model, G_TYPE_OBJECT)
* Since: 2.44
*/
/**
* GListModelInterface::get_item:
* @list: a #GListModel
* @position: the position of the item to fetch
*
* Get the item at @position. If @position is greater than the number of
* items in @list, %NULL is returned.
*
* %NULL is never returned for an index that is smaller than the length
* of the list. See g_list_model_get_n_items().
*
* Returns: (type GObject) (transfer full) (nullable): the object at @position.
*
* Since: 2.44
*/
/**
* GListModel:
*
@ -186,7 +202,7 @@ g_list_model_get_n_items (GListModel *list)
* %NULL is never returned for an index that is smaller than the length
* of the list. See g_list_model_get_n_items().
*
* Returns: (transfer full) (nullable) (type GObject): the item at @position.
* Returns: (transfer full) (nullable): the item at @position.
*
* Since: 2.44
*/