[glib] Make GListModelInterface::get_item usable from GObject Introspection bindings



commit bb26bc29e3f9d05dfdf54f3e737da2541878f604
Author: Sam Thursfield <ssssam gmail com>
Date:   Mon Sep 4 22:42:04 2017 +0100

    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

 gio/glistmodel.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/gio/glistmodel.c b/gio/glistmodel.c
index c2491be..2b943a8 100644
--- a/gio/glistmodel.c
+++ b/gio/glistmodel.c
@@ -96,6 +96,22 @@ G_DEFINE_INTERFACE (GListModel, g_list_model, G_TYPE_OBJECT)
  */
 
 /**
+ * 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:
  *
  * #GListModel is an opaque data structure and can only be accessed
@@ -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
  */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]