From 229ec5f435ca59fd913ee694ef74ec090f8adce0 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Sat, 23 Mar 2013 03:26:33 -0300 Subject: [PATCH] container: Replace ignore_notify by a GESChildrenControlMode flag --- ges/ges-clip.c | 5 +++-- ges/ges-container.c | 38 +++++++++++++++++++------------------- ges/ges-container.h | 12 ++++++++++++ ges/ges-internal.h | 2 -- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/ges/ges-clip.c b/ges/ges-clip.c index 5e43068ba3..7b3a0214db 100644 --- a/ges/ges-clip.c +++ b/ges/ges-clip.c @@ -144,11 +144,12 @@ _add_child (GESContainer * container, GESTimelineElement * element) /* We set the timing value of the child to ours, we avoid infinite loop * making sure the container ignore notifies from the child */ - _ges_container_set_ignore_notifies (container, TRUE); + _ges_container_set_children_control_mode (container, + GES_CHILDREN_IGNORE_NOTIFIES); _set_start0 (element, GES_TIMELINE_ELEMENT_START (container)); _set_inpoint0 (element, GES_TIMELINE_ELEMENT_INPOINT (container)); _set_duration0 (element, GES_TIMELINE_ELEMENT_DURATION (container)); - _ges_container_set_ignore_notifies (container, FALSE); + _ges_container_set_children_control_mode (container, GES_CHILDREN_UPDATE); return TRUE; } diff --git a/ges/ges-container.c b/ges/ges-container.c index ac4a35fa89..c088602d99 100644 --- a/ges/ges-container.c +++ b/ges/ges-container.c @@ -76,7 +76,7 @@ struct _GESContainerPrivate /* Set to TRUE when the container is doing updates of track object * properties so we don't end up in infinite property update loops */ - gboolean ignore_notifies; + GESChildrenControlMode children_control_mode; GHashTable *mappings; guint nb_effects; GESTimelineElement *initiated_move; @@ -157,7 +157,7 @@ _set_start (GESTimelineElement * element, GstClockTime start) GST_DEBUG_OBJECT (element, "Setting children start, (initiated_move: %" GST_PTR_FORMAT ")", container->priv->initiated_move); - container->priv->ignore_notifies = TRUE; + container->priv->children_control_mode = GES_CHILDREN_IGNORE_NOTIFIES; for (tmp = container->children; tmp; tmp = g_list_next (tmp)) { GESTimelineElement *child = (GESTimelineElement *) tmp->data; @@ -183,7 +183,7 @@ _set_start (GESTimelineElement * element, GstClockTime start) map->start_offset = start - _START (child); } } - container->priv->ignore_notifies = FALSE; + priv->children_control_mode = GES_CHILDREN_UPDATE; return TRUE; } @@ -194,7 +194,7 @@ _set_inpoint (GESTimelineElement * element, GstClockTime inpoint) GList *tmp; GESContainer *container = GES_CONTAINER (element); - container->priv->ignore_notifies = TRUE; + container->priv->children_control_mode = GES_CHILDREN_IGNORE_NOTIFIES; for (tmp = container->children; tmp; tmp = g_list_next (tmp)) { GESTimelineElement *child = (GESTimelineElement *) tmp->data; ChildMapping *map = g_hash_table_lookup (container->priv->mappings, child); @@ -206,7 +206,7 @@ _set_inpoint (GESTimelineElement * element, GstClockTime inpoint) _set_inpoint0 (child, inpoint); } - container->priv->ignore_notifies = FALSE; + container->priv->children_control_mode = GES_CHILDREN_UPDATE; return TRUE; } @@ -220,7 +220,7 @@ _set_duration (GESTimelineElement * element, GstClockTime duration) GESContainer *container = GES_CONTAINER (element); GESContainerPrivate *priv = container->priv; - priv->ignore_notifies = TRUE; + priv->children_control_mode = GES_CHILDREN_IGNORE_NOTIFIES; for (tmp = container->children; tmp; tmp = g_list_next (tmp)) { GESTimelineElement *child = (GESTimelineElement *) tmp->data; ChildMapping *map = g_hash_table_lookup (priv->mappings, child); @@ -236,7 +236,7 @@ _set_duration (GESTimelineElement * element, GstClockTime duration) NULL, GES_EDGE_END, _START (child) + duration, TRUE) == FALSE) _set_duration0 (GES_TIMELINE_ELEMENT (child), duration); } - priv->ignore_notifies = FALSE; + priv->children_control_mode = GES_CHILDREN_UPDATE; return TRUE; } @@ -267,7 +267,7 @@ _set_priority (GESTimelineElement * element, guint32 priority) GES_CONTAINER_GET_CLASS (element)->get_priorty_range (container, &min_prio, &max_prio); - priv->ignore_notifies = TRUE; /* */ + priv->children_control_mode = GES_CHILDREN_IGNORE_NOTIFIES; for (tmp = container->children; tmp; tmp = g_list_next (tmp)) { GESTimelineElement *child = (GESTimelineElement *) tmp->data; ChildMapping *map = g_hash_table_lookup (priv->mappings, child); @@ -282,7 +282,7 @@ _set_priority (GESTimelineElement * element, guint32 priority) } _set_priority0 (child, real_tck_prio); } - priv->ignore_notifies = FALSE; + priv->children_control_mode = GES_CHILDREN_UPDATE; update_height (container); @@ -423,7 +423,7 @@ _child_start_changed_cb (GESTimelineElement * child, GESContainerPrivate *priv = container->priv; GESTimelineElement *element = GES_TIMELINE_ELEMENT (container); - if (priv->ignore_notifies) + if (priv->children_control_mode == GES_CHILDREN_IGNORE_NOTIFIES) return; map = g_hash_table_lookup (priv->mappings, child); @@ -447,7 +447,7 @@ _child_inpoint_changed_cb (GESTimelineElement * child, GESContainerPrivate *priv = container->priv; GESTimelineElement *element = GES_TIMELINE_ELEMENT (container); - if (priv->ignore_notifies) + if (priv->children_control_mode == GES_CHILDREN_IGNORE_NOTIFIES) return; map = g_hash_table_lookup (priv->mappings, child); @@ -468,7 +468,7 @@ _child_duration_changed_cb (GESTimelineElement * child, GESContainerPrivate *priv = container->priv; GESTimelineElement *element = GES_TIMELINE_ELEMENT (container); - if (priv->ignore_notifies) + if (priv->children_control_mode == GES_CHILDREN_IGNORE_NOTIFIES) return; map = g_hash_table_lookup (priv->mappings, child); @@ -491,7 +491,7 @@ _child_priority_changed_cb (GESTimelineElement * child, GST_DEBUG_OBJECT (container, "TimelineElement %p priority changed to %i", child, _PRIORITY (child)); - if (priv->ignore_notifies) + if (priv->children_control_mode == GES_CHILDREN_IGNORE_NOTIFIES) return; update_height (container); @@ -527,10 +527,10 @@ _ges_container_sort_children_by_end (GESContainer * container) } void -_ges_container_set_ignore_notifies (GESContainer * container, - gboolean ignore_notifies) +_ges_container_set_children_control_mode (GESContainer * container, + GESChildrenControlMode children_control_mode) { - container->priv->ignore_notifies = ignore_notifies; + container->priv->children_control_mode = children_control_mode; } /********************************************** @@ -565,15 +565,15 @@ ges_container_add (GESContainer * container, GESTimelineElement * child) GST_DEBUG_OBJECT (container, "adding timeline element %" GST_PTR_FORMAT, child); - priv->ignore_notifies = TRUE; + priv->children_control_mode = GES_CHILDREN_IGNORE_NOTIFIES; if (class->add_child) { if (class->add_child (container, child) == FALSE) { - priv->ignore_notifies = FALSE; + priv->children_control_mode = GES_CHILDREN_UPDATE; GST_WARNING_OBJECT (container, "Erreur adding child %p", child); return FALSE; } } - priv->ignore_notifies = FALSE; + priv->children_control_mode = GES_CHILDREN_UPDATE; mapping = g_slice_new0 (ChildMapping); mapping->child = gst_object_ref (child); diff --git a/ges/ges-container.h b/ges/ges-container.h index bfd5760e72..1f6a5718d7 100644 --- a/ges/ges-container.h +++ b/ges/ges-container.h @@ -38,6 +38,14 @@ G_BEGIN_DECLS typedef struct _GESContainerPrivate GESContainerPrivate; +/* To be used by sublcasses only */ +typedef enum +{ + GES_CHILDREN_UPDATE, + GES_CHILDREN_IGNORE_NOTIFIES, + GES_CHILDREN_UPDATE_OFFSETS, +} GESChildrenControlMode; + /** * GES_CONTAINER_HEIGHT: * @obj: a #GESContainer @@ -123,5 +131,9 @@ gboolean ges_container_remove (GESContainer *container, GESTimelineElement * GList * ges_container_ungroup (GESContainer * container, gboolean recursive); GESContainer *ges_container_group (GList *containers); +/* To be used by subclasses only */ +void _ges_container_set_children_control_mode (GESContainer * container, + GESChildrenControlMode children_control_mode); + G_END_DECLS #endif /* _GES_CONTAINER */ diff --git a/ges/ges-internal.h b/ges/ges-internal.h index 2dd2cdbd5a..246471b611 100644 --- a/ges/ges-internal.h +++ b/ges/ges-internal.h @@ -233,8 +233,6 @@ G_GNUC_INTERNAL gint element_end_compare (GESTimelineElement * ****************************************************/ G_GNUC_INTERNAL void _ges_container_sort_children (GESContainer *container); G_GNUC_INTERNAL void _ges_container_sort_children_by_end (GESContainer *container); -G_GNUC_INTERNAL void _ges_container_set_ignore_notifies (GESContainer *container, - gboolean ignore_notifies); /**************************************************** * GESClip *