summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu.duponchelle@epitech.eu>2013-07-10 21:24:28 +0200
committerThibault Saunier <thibault.saunier@collabora.com>2013-07-10 23:25:12 -0400
commit96204ac1d26885e15ac79d07a0f40d4eae91de76 (patch)
tree21ce94af58c42cbc8c7a66223ea04813e8262293
parentff21ea7f9221e600ff1ebb4eed66a1bf1285a8c4 (diff)
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);
-rw-r--r--ges/ges-clip.c4
-rw-r--r--ges/ges-container.c30
-rw-r--r--ges/ges-container.h2
-rw-r--r--ges/ges-group.c2
-rw-r--r--ges/ges-timeline.c2
5 files changed, 32 insertions, 8 deletions
diff --git a/ges/ges-clip.c b/ges/ges-clip.c
index 3d5ec81..de40280 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 13b178b..7f0e956 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 26542fa..f44d795 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 1f1775c..4410f66 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 f89acd5..7dd9530 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);