From dd47def4e313fac342bd941b77bf19afbc1dbc76 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 19 Feb 2015 18:19:44 +0100 Subject: [PATCH] container: implement children property handling --- .arcconfig | 3 ++ ges/ges-container.c | 86 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 .arcconfig diff --git a/.arcconfig b/.arcconfig new file mode 100644 index 0000000000..fc70fd3df8 --- /dev/null +++ b/.arcconfig @@ -0,0 +1,3 @@ +{ + "phabricator.uri" : "http://phabricator.freedesktop.org/" +} diff --git a/ges/ges-container.c b/ges/ges-container.c index c401059189..7b26f89e72 100644 --- a/ges/ges-container.c +++ b/ges/ges-container.c @@ -185,6 +185,86 @@ _set_duration (GESTimelineElement * element, GstClockTime duration) return TRUE; } +static void +_ges_container_add_child_properties (GESContainer * container, + GESTimelineElement * child) +{ + guint n_props, i; + + GParamSpec **child_props = + ges_timeline_element_list_children_properties (child, + &n_props); + + for (i = 0; i < n_props; i++) { + GObject *prop_child; + + if (ges_timeline_element_lookup_child (child, child_props[i]->name, + &prop_child, NULL)) { + ges_timeline_element_add_child_property (GES_TIMELINE_ELEMENT (container), + child_props[i], prop_child); + + } + + g_param_spec_unref (child_props[i]); + } + + g_free (child_props); +} + +static void +_ges_container_remove_child_properties (GESContainer * container, + GESTimelineElement * child) +{ + guint n_props, i; + + GParamSpec **child_props = + ges_timeline_element_list_children_properties (child, + &n_props); + + for (i = 0; i < n_props; i++) { + GObject *prop_child; + + if (ges_timeline_element_lookup_child (child, child_props[i]->name, + &prop_child, NULL)) { + ges_timeline_element_remove_child_property (GES_TIMELINE_ELEMENT + (container), child_props[i]); + + } + + g_param_spec_unref (child_props[i]); + } + + g_free (child_props); +} + +static GParamSpec ** +_list_children_properties (GESTimelineElement * self, guint * n_properties) +{ + GList *tmp; + + for (tmp = GES_CONTAINER_CHILDREN (self); tmp; tmp = tmp->next) + _ges_container_add_child_properties (GES_CONTAINER (self), tmp->data); + + return + GES_TIMELINE_ELEMENT_CLASS + (ges_container_parent_class)->list_children_properties (self, + n_properties); +} + +static gboolean +_lookup_child (GESTimelineElement * self, const gchar * prop_name, + GObject ** child, GParamSpec ** pspec) +{ + GList *tmp; + + for (tmp = GES_CONTAINER_CHILDREN (self); tmp; tmp = tmp->next) + _ges_container_add_child_properties (GES_CONTAINER (self), tmp->data); + + return + GES_TIMELINE_ELEMENT_CLASS (ges_container_parent_class)->lookup_child + (self, prop_name, child, pspec); +} + /****************************************** * * * GObject virtual methods implementation * @@ -281,6 +361,8 @@ ges_container_class_init (GESContainerClass * klass) element_class->set_start = _set_start; element_class->set_duration = _set_duration; element_class->set_inpoint = _set_inpoint; + element_class->list_children_properties = _list_children_properties; + element_class->lookup_child = _lookup_child; /* No default implementations */ klass->remove_child = NULL; @@ -558,6 +640,8 @@ ges_container_add (GESContainer * container, GESTimelineElement * child) return FALSE; } + _ges_container_add_child_properties (container, child); + g_signal_emit (container, ges_container_signals[CHILD_ADDED_SIGNAL], 0, child); @@ -602,6 +686,8 @@ ges_container_remove (GESContainer * container, GESTimelineElement * child) /* Let it live removing from our mappings */ g_hash_table_remove (priv->mappings, child); + _ges_container_remove_child_properties (container, child); + g_signal_emit (container, ges_container_signals[CHILD_REMOVED_SIGNAL], 0, child); gst_object_unref (child);