summaryrefslogtreecommitdiff
path: root/gtk/gtktextchild.c
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2020-04-25 15:42:24 +0200
committerTimm Bäder <mail@baedert.org>2020-05-05 08:20:09 +0200
commit289b157e3251581cff91c7bca5f5ed34ff309260 (patch)
tree3be24498de205fd12c4ddc308da3934270fa5359 /gtk/gtktextchild.c
parent85237c8665aa74213b9a70e261c0431da230f3cc (diff)
downloadgtk+-289b157e3251581cff91c7bca5f5ed34ff309260.tar.gz
textchild: Return an array from get_widgets
Yay, one GList less.
Diffstat (limited to 'gtk/gtktextchild.c')
-rw-r--r--gtk/gtktextchild.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/gtk/gtktextchild.c b/gtk/gtktextchild.c
index 0a2e6163dd..fb2b0f14c8 100644
--- a/gtk/gtktextchild.c
+++ b/gtk/gtktextchild.c
@@ -437,21 +437,31 @@ gtk_text_child_anchor_finalize (GObject *obj)
*
* Returns: (element-type GtkWidget) (transfer container): list of widgets anchored at @anchor
**/
-GList*
-gtk_text_child_anchor_get_widgets (GtkTextChildAnchor *anchor)
+GtkWidget **
+gtk_text_child_anchor_get_widgets (GtkTextChildAnchor *anchor,
+ guint *out_len)
{
GtkTextLineSegment *seg = anchor->segment;
- GList *list = NULL;
+ GPtrArray *arr;
GSList *iter;
CHECK_IN_BUFFER_RETURN (anchor, NULL);
-
+
+ g_return_val_if_fail (out_len != NULL, NULL);
g_return_val_if_fail (seg->type == &gtk_text_child_type, NULL);
iter = seg->body.child.widgets;
+
+ if (!iter)
+ {
+ *out_len = 0;
+ return NULL;
+ }
+
+ arr = g_ptr_array_new ();
while (iter != NULL)
{
- list = g_list_prepend (list, iter->data);
+ g_ptr_array_add (arr, iter->data);
iter = iter->next;
}
@@ -459,7 +469,8 @@ gtk_text_child_anchor_get_widgets (GtkTextChildAnchor *anchor)
/* Order is not relevant, so we don't need to reverse the list
* again.
*/
- return list;
+ *out_len = arr->len;
+ return (GtkWidget **)g_ptr_array_free (arr, FALSE);
}
/**