timeline: Add a method to easily check if a timeline is empty

API:
    + ges_timeline_is_empty
This commit is contained in:
Thibault Saunier 2014-12-01 00:38:07 +01:00
parent 78913931b2
commit 97c56da95b
3 changed files with 31 additions and 0 deletions

View file

@ -376,6 +376,7 @@ ges_timeline_set_auto_transition
ges_timeline_get_snapping_distance
ges_timeline_set_snapping_distance
ges_timeline_get_element
ges_timeline_is_empty
<SUBSECTION Standard>
GESTimelinePrivate
GESTimelineClass

View file

@ -3187,3 +3187,32 @@ ges_timeline_get_element (GESTimeline * timeline, const gchar * name)
return NULL;
}
/**
* ges_timeline_is_empty:
* @timeline: a #GESTimeline
*
* Check whether a #GESTimelineElement is empty or not
*
* Returns: %TRUE if the timeline is empty %FALSE otherwize
*/
gboolean
ges_timeline_is_empty (GESTimeline * timeline)
{
GHashTableIter iter;
gpointer key, value;
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
if (g_hash_table_size (timeline->priv->all_elements) == 0)
return TRUE;
g_hash_table_iter_init (&iter, timeline->priv->all_elements);
while (g_hash_table_iter_next (&iter, &key, &value)) {
if (GES_IS_SOURCE (value) &&
ges_track_element_is_active (GES_TRACK_ELEMENT (value)))
return FALSE;
}
return TRUE;
}

View file

@ -126,6 +126,7 @@ void ges_timeline_set_auto_transition (GESTimeline * timeline, gboolean auto_tra
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);
G_END_DECLS