marker-list: add prev position to ::marker-moved
authorHenry Wilkes <hwilkes@igalia.com>
Wed, 16 Oct 2019 15:40:27 +0000 (16:40 +0100)
committerHenry Wilkes <hwilkes@igalia.com>
Wed, 16 Oct 2019 16:58:15 +0000 (17:58 +0100)
Additionally give the previous marker position in the
GESMarkerList::marker-moved signal, since a user may want to know
where a move was from.

Also, fixed the documentation for GESMarkerList::marker-added

https://gitlab.freedesktop.org/gstreamer/gst-editing-services/issues/78

ges/ges-marker-list.c
tests/check/ges/markerlist.c

index d0dde9cc26b21ba8c132c6cbd258b4009263e159..4d8272ce495c9de6f52e00e26680fca8c963203f 100644 (file)
@@ -162,9 +162,10 @@ ges_marker_list_class_init (GESMarkerListClass * klass)
 
   object_class->finalize = ges_marker_list_finalize;
 
-  /**
+/**
   * GESMarkerList::marker-added:
   * @marker-list: the #GESMarkerList
+  * @position: the position of the added marker
   * @marker: the #GESMarker that was added.
   *
   * Will be emitted after the marker was added to the marker-list.
@@ -191,7 +192,9 @@ ges_marker_list_class_init (GESMarkerListClass * klass)
 /**
   * GESMarkerList::marker-moved:
   * @marker-list: the #GESMarkerList
-  * @marker: the #GESMarker that was added.
+  * @previous-position: the previous position of the marker
+  * @new-position: the new position of the marker
+  * @marker: the #GESMarker that was moved.
   *
   * Will be emitted after the marker was moved to.
   * Since: 1.18
@@ -199,7 +202,7 @@ ges_marker_list_class_init (GESMarkerListClass * klass)
   ges_marker_list_signals[MARKER_MOVED] =
       g_signal_new ("marker-moved", G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_generic,
-      G_TYPE_NONE, 2, G_TYPE_UINT64, GES_TYPE_MARKER);
+      G_TYPE_NONE, 3, G_TYPE_UINT64, G_TYPE_UINT64, GES_TYPE_MARKER);
 }
 
 static gint
@@ -358,6 +361,7 @@ ges_marker_list_move (GESMarkerList * self, GESMarker * marker,
 {
   GSequenceIter *iter;
   gboolean ret = FALSE;
+  GstClockTime previous_position;
 
   g_return_val_if_fail (GES_IS_MARKER_LIST (self), FALSE);
 
@@ -367,10 +371,11 @@ ges_marker_list_move (GESMarkerList * self, GESMarker * marker,
     goto done;
   }
 
+  previous_position = marker->position;
   marker->position = position;
 
-  g_signal_emit (self, ges_marker_list_signals[MARKER_MOVED], 0, position,
-      marker);
+  g_signal_emit (self, ges_marker_list_signals[MARKER_MOVED], 0,
+      previous_position, position, marker);
 
   g_sequence_sort_changed (iter, cmp_marker, NULL);
 
index 588490da93dcbeb2313655603d1a4d9d62998bc8..b41b00f71c1dbec046f32583f25bb2945ffb6d58 100644 (file)
@@ -150,9 +150,10 @@ GST_END_TEST;
 
 
 static void
-marker_moved_cb (GESMarkerList * mlist, GstClockTime position,
-    GESMarker * marker, gboolean * called)
+marker_moved_cb (GESMarkerList * mlist, GstClockTime prev_position,
+    GstClockTime position, GESMarker * marker, gboolean * called)
 {
+  fail_unless_equals_int (prev_position, 10);
   fail_unless_equals_int (position, 42);
 
   ASSERT_OBJECT_REFCOUNT (marker, "local ref + signal", 2);