From 96204ac1d26885e15ac79d07a0f40d4eae91de76 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Wed, 10 Jul 2013 21:24:28 +0200 Subject: [PATCH] container: Add a 'recursive' argument to the get_children method API: - ges_container_get_children (GESContainer *container); + ges_container_get_children (GESContainer *container, gboolean recurse); --- ges/ges-clip.c | 4 ++-- ges/ges-container.c | 30 +++++++++++++++++++++++++++--- ges/ges-container.h | 2 +- ges/ges-group.c | 2 +- ges/ges-timeline.c | 2 +- 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/ges/ges-clip.c b/ges/ges-clip.c index 3d5ec814c8..de40280bd9 100644 --- a/ges/ges-clip.c +++ b/ges/ges-clip.c @@ -383,7 +383,7 @@ _ungroup (GESContainer * container, gboolean recursive) } /* We need a copy of the current list of tracks */ - children = ges_container_get_children (container); + children = ges_container_get_children (container, FALSE); for (tmp = children; tmp; tmp = tmp->next) { track_element = GES_TRACK_ELEMENT (tmp->data); track_type = ges_track_element_get_track_type (track_element); @@ -546,7 +546,7 @@ _group (GList * containers) supported_formats = GES_CLIP (ret)->priv->supportedformats; for (tmpclip = containers->next; tmpclip; tmpclip = tmpclip->next) { GESClip *cclip = tmpclip->data; - GList *children = ges_container_get_children (GES_CONTAINER (cclip)); + GList *children = ges_container_get_children (GES_CONTAINER (cclip), FALSE); for (tmpelement = children; tmpelement; tmpelement = tmpelement->next) { GESTimelineElement *celement = GES_TIMELINE_ELEMENT (tmpelement->data); diff --git a/ges/ges-container.c b/ges/ges-container.c index 13b178bff8..7f0e956f4a 100644 --- a/ges/ges-container.c +++ b/ges/ges-container.c @@ -564,9 +564,27 @@ ges_container_remove (GESContainer * container, GESTimelineElement * child) return TRUE; } +static void +_get_children_recursively (GESContainer * container, GList ** children) +{ + GList *tmp; + + *children = + g_list_concat (*children, g_list_copy_deep (container->children, + (GCopyFunc) gst_object_ref, NULL)); + + for (tmp = container->children; tmp; tmp = tmp->next) { + GESTimelineElement *element = tmp->data; + + if (GES_IS_CONTAINER (element)) + _get_children_recursively (tmp->data, children); + } +} + /** * ges_container_get_children: * @container: a #GESContainer + * @recursive: Whether to recursively get children in @container * * Get the list of #GESTimelineElement contained in @container * The user is responsible for unreffing the contained objects @@ -576,12 +594,18 @@ ges_container_remove (GESContainer * container, GESTimelineElement * child) * timeline element contained in @container. */ GList * -ges_container_get_children (GESContainer * container) +ges_container_get_children (GESContainer * container, gboolean recursive) { + GList *children = NULL; + g_return_val_if_fail (GES_IS_CONTAINER (container), NULL); - return g_list_copy_deep (container->children, (GCopyFunc) gst_object_ref, - NULL); + if (!recursive) + return g_list_copy_deep (container->children, (GCopyFunc) gst_object_ref, + NULL); + + _get_children_recursively (container, &children); + return children; } /** diff --git a/ges/ges-container.h b/ges/ges-container.h index 26542facf2..f44d795754 100644 --- a/ges/ges-container.h +++ b/ges/ges-container.h @@ -137,7 +137,7 @@ struct _GESContainerClass GType ges_container_get_type (void); /* Children handling */ -GList* ges_container_get_children (GESContainer *container); +GList* ges_container_get_children (GESContainer *container, gboolean recursive); gboolean ges_container_add (GESContainer *container, GESTimelineElement *child); gboolean ges_container_remove (GESContainer *container, GESTimelineElement *child); GList * ges_container_ungroup (GESContainer * container, gboolean recursive); diff --git a/ges/ges-group.c b/ges/ges-group.c index 1f1775c02f..4410f668c0 100644 --- a/ges/ges-group.c +++ b/ges/ges-group.c @@ -450,7 +450,7 @@ _ungroup (GESContainer * group, gboolean recursive) { GList *children, *tmp, *ret = NULL; - children = ges_container_get_children (group); + children = ges_container_get_children (group, FALSE); for (tmp = children; tmp; tmp = tmp->next) { GESTimelineElement *child = tmp->data; diff --git a/ges/ges-timeline.c b/ges/ges-timeline.c index f89acd58f7..7dd9530917 100644 --- a/ges/ges-timeline.c +++ b/ges/ges-timeline.c @@ -2014,7 +2014,7 @@ layer_object_removed_cb (GESLayer * layer, GESClip * clip, /* Go over the clip's track element and figure out which one belongs to * the list of tracks we control */ - trackelements = ges_container_get_children (GES_CONTAINER (clip)); + trackelements = ges_container_get_children (GES_CONTAINER (clip), FALSE); for (tmp = trackelements; tmp; tmp = tmp->next) { GESTrackElement *track_element = (GESTrackElement *) tmp->data; GESTrack *track = ges_track_element_get_track (track_element);