group-added and group-removed signals added

Differential Revision: https://phabricator.freedesktop.org/D619
This commit is contained in:
Fabian Orccon 2016-02-16 12:49:57 +00:00 committed by Thibault Saunier
parent 0ea76cf905
commit 6a97b50b4b
3 changed files with 51 additions and 0 deletions

View file

@ -554,16 +554,26 @@ _child_removed (GESContainer * group, GESTimelineElement * child)
static GList *
_ungroup (GESContainer * group, gboolean recursive)
{
GPtrArray *children_array;
GESTimeline *timeline;
GList *children, *tmp, *ret = NULL;
/* We choose 16 just as an arbitrary value */
children_array = g_ptr_array_sized_new (16);
timeline = GES_TIMELINE_ELEMENT_TIMELINE (group);
children = ges_container_get_children (group, FALSE);
for (tmp = children; tmp; tmp = tmp->next) {
GESTimelineElement *child = tmp->data;
gst_object_ref (child);
ges_container_remove (group, child);
g_ptr_array_add (children_array, child);
ret = g_list_append (ret, child);
}
ges_timeline_emit_group_removed (timeline, (GESGroup *) group,
children_array);
g_ptr_array_free (children_array, TRUE);
g_list_free_full (children, gst_object_unref);
/* No need to remove from the timeline here, this will be done in _child_removed */

View file

@ -238,6 +238,8 @@ enum
TRACK_REMOVED,
LAYER_ADDED,
LAYER_REMOVED,
GROUP_ADDED,
GROUP_REMOVED,
SNAPING_STARTED,
SNAPING_ENDED,
SELECT_TRACKS_FOR_OBJECT,
@ -564,6 +566,32 @@ ges_timeline_class_init (GESTimelineClass * klass)
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, layer_removed),
NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GES_TYPE_LAYER);
/**
* GESTimeline::group-added
* @timeline: the #GESTimeline
* @group: the #GESGroup
*
* Will be emitted after a group has been added to to the timeline.
*/
ges_timeline_signals[GROUP_ADDED] =
g_signal_new ("group-added", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, group_added), NULL,
NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GES_TYPE_GROUP);
/**
* GESTimeline::group-removed
* @timeline: the #GESTimeline
* @group: the #GESGroup
* @children: (element-type GES.Container) (transfer container): a list of #GESContainer
*
* Will be emitted after a group has been removed from the timeline.
*/
ges_timeline_signals[GROUP_REMOVED] =
g_signal_new ("group-removed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESTimelineClass, group_removed),
NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2, GES_TYPE_GROUP,
G_TYPE_PTR_ARRAY);
/**
* GESTimeline::track-elements-snapping:
* @timeline: the #GESTimeline
@ -2125,6 +2153,16 @@ timeline_add_group (GESTimeline * timeline, GESGroup * group)
gst_object_ref_sink (group));
ges_timeline_element_set_timeline (GES_TIMELINE_ELEMENT (group), timeline);
g_signal_emit (timeline, ges_timeline_signals[GROUP_ADDED], 0, group);
}
void
ges_timeline_emit_group_removed (GESTimeline * timeline, GESGroup * group,
GPtrArray * array)
{
g_signal_emit (timeline, ges_timeline_signals[GROUP_REMOVED], 0, group,
array);
}
void

View file

@ -92,6 +92,8 @@ struct _GESTimelineClass {
void (*track_removed) (GESTimeline *timeline, GESTrack * track);
void (*layer_added) (GESTimeline *timeline, GESLayer *layer);
void (*layer_removed) (GESTimeline *timeline, GESLayer *layer);
void (*group_added) (GESTimeline *timeline, GESGroup *group);
void (*group_removed) (GESTimeline *timeline, GESGroup *group, GPtrArray *children);
/* Padding for API extension */
gpointer _ges_reserved[GES_PADDING];
@ -129,6 +131,7 @@ GstClockTime ges_timeline_get_snapping_distance (GESTimeline * timeline);
void ges_timeline_set_snapping_distance (GESTimeline * timeline, GstClockTime snapping_distance);
GESTimelineElement * ges_timeline_get_element (GESTimeline * timeline, const gchar *name);
gboolean ges_timeline_is_empty (GESTimeline * timeline);
void ges_timeline_emit_group_removed (GESTimeline * timeline, GESGroup * group, GPtrArray * array);
G_END_DECLS