From 6a97b50b4bfafbe8c52cafb72b8687c4b7e65ebe Mon Sep 17 00:00:00 2001 From: Fabian Orccon Date: Tue, 16 Feb 2016 12:49:57 +0000 Subject: [PATCH] group-added and group-removed signals added Differential Revision: https://phabricator.freedesktop.org/D619 --- ges/ges-group.c | 10 ++++++++++ ges/ges-timeline.c | 38 ++++++++++++++++++++++++++++++++++++++ ges/ges-timeline.h | 3 +++ 3 files changed, 51 insertions(+) diff --git a/ges/ges-group.c b/ges/ges-group.c index 296cfa754e..fa060a9de7 100644 --- a/ges/ges-group.c +++ b/ges/ges-group.c @@ -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 */ diff --git a/ges/ges-timeline.c b/ges/ges-timeline.c index 3fc83ffbcf..ad48951123 100644 --- a/ges/ges-timeline.c +++ b/ges/ges-timeline.c @@ -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 diff --git a/ges/ges-timeline.h b/ges/ges-timeline.h index fde723109f..3b2a16f863 100644 --- a/ges/ges-timeline.h +++ b/ges/ges-timeline.h @@ -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