After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 793820 - Implement paste functionality within GESTimeline class
Implement paste functionality within GESTimeline class
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-editing-services
unspecified
Other Linux
: Normal enhancement
: 1.13.90
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-02-25 22:12 UTC by Harish Fulara
Modified: 2018-03-02 12:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Added paste functionality to GESTimeline class (4.84 KB, patch)
2018-02-25 22:57 UTC, Harish Fulara
none Details | Review
Added paste functionality to GESTimeline class (4.40 KB, patch)
2018-02-26 10:59 UTC, Harish Fulara
none Details | Review
Added paste functionality to GESTimeline class (4.13 KB, patch)
2018-02-26 15:40 UTC, Harish Fulara
none Details | Review
Added paste functionality to GESTimeline class (4.25 KB, patch)
2018-02-26 21:27 UTC, Harish Fulara
none Details | Review
Added paste functionality to GESTimeline class (4.23 KB, patch)
2018-02-26 23:41 UTC, Harish Fulara
committed Details | Review

Description Harish Fulara 2018-02-25 22:12:54 UTC
Implement paste functionality within GESTimeline class so that GESTimelineElement is pasted onto the timeline rather than it being pasting itself onto the timeline. Implement the function - 'GESTimelineElement * ges_timeline_paste (GESTimeline * timeline, GESTimelineElement * element, GstClockTime paste_position, gint layer_priority);' - inside GESTimeline class.
Comment 1 Harish Fulara 2018-02-25 22:57:21 UTC
Created attachment 368906 [details] [review]
Added paste functionality to GESTimeline class
Comment 2 Thibault Saunier 2018-02-25 23:49:05 UTC
Review of attachment 368906 [details] [review]:

Looks almost all right :-)

::: ges/ges-timeline-element.h
@@ -138,2 +138,4 @@
   GESTimeline *timeline;
   gchar *name;
+  /* For copy-paste operation */
+  GESTimelineElement *copied_from;

This break the ABI (it would require to add `gpointer _ges_reserved[GES_PADDING_LARGE -1];` in the same structure), but you should rather had an internal method to get it as I do not think that should be API

::: ges/ges-timeline.h
@@ -159,2 +159,4 @@
 GST_EXPORT
 gboolean ges_timeline_is_empty (GESTimeline * timeline);
+GST_EXPORT
+GESTimelineElement * ges_timeline_paste (GESTimeline * timeline,

I would call it `ges_timeline_paste_elemt`.
Comment 3 Harish Fulara 2018-02-26 10:59:22 UTC
Created attachment 368927 [details] [review]
Added paste functionality to GESTimeline class
Comment 4 Harish Fulara 2018-02-26 11:00:30 UTC
(In reply to Thibault Saunier from comment #2)
> Review of attachment 368906 [details] [review] [review]:
> 
> Looks almost all right :-)
> 
> ::: ges/ges-timeline-element.h
> @@ -138,2 +138,4 @@
>    GESTimeline *timeline;
>    gchar *name;
> +  /* For copy-paste operation */
> +  GESTimelineElement *copied_from;
> 
> This break the ABI (it would require to add `gpointer
> _ges_reserved[GES_PADDING_LARGE -1];` in the same structure), but you should
> rather had an internal method to get it as I do not think that should be API
>
> Made the appropriate changes.
> 
> ::: ges/ges-timeline.h
> @@ -159,2 +159,4 @@
>  GST_EXPORT
>  gboolean ges_timeline_is_empty (GESTimeline * timeline);
> +GST_EXPORT
> +GESTimelineElement * ges_timeline_paste (GESTimeline * timeline,
> 
> I would call it `ges_timeline_paste_elemt`.
> Renamed function to 'ges_timeline_paste_element'
Comment 5 Thibault Saunier 2018-02-26 14:34:51 UTC
Review of attachment 368927 [details] [review]:

::: ges/ges-timeline-element.h
@@ -196,2 +196,3 @@
                                             GObject **child, GParamSpec **pspec);
   GESTrackType (*get_track_types)          (GESTimelineElement * self);
+  GESTimelineElement * (*get_copied_from) (GESTimelineElement * self);

This is not what I meant :-) - You should add in ges/ges-internal.h:

> G_GNUC_INTERNAL GESTimelineElement* ges_timeline_element_get_copied_from (GESTimelineElement *self);

and implement that in ges-timeline-element.c
Comment 6 Harish Fulara 2018-02-26 15:40:48 UTC
Created attachment 368951 [details] [review]
Added paste functionality to GESTimeline class
Comment 7 Thibault Saunier 2018-02-26 15:56:55 UTC
Review of attachment 368951 [details] [review]:

::: ges/ges-timeline.c
@@ +3782,3 @@
+  res = element_class->paste (element, copied_from, paste_position);
+
+  g_clear_object (&copied_from);

You do not own the reference here, GESTimelineElement does, you will need to add a way to clean that ref, I guess we can state that ges_timeline_element_get_copied_from gives it reference and sets it back to NULL (ie. in that method result priv->copied_from to NULL).
Comment 8 Harish Fulara 2018-02-26 21:27:41 UTC
Created attachment 368980 [details] [review]
Added paste functionality to GESTimeline class
Comment 9 Thibault Saunier 2018-02-26 22:03:58 UTC
Review of attachment 368980 [details] [review]:

It is almost good and I am being a bit annoying but let's get it **right** ;)

::: ges/ges-timeline-element.c
@@ +1863,3 @@
+ges_timeline_element_get_copied_from (GESTimelineElement * self)
+{
+  GESTimelineElement * copied_from_ref = gst_object_ref(self->priv->copied_from);

I am pretty much sure it is not `gst-indent` complient, could you check that please?

You could have done:

```
copied_from = self->priv->copied_from;
self->priv->copied_from = NULL;
return copied_from;
```
Comment 10 Alex Băluț 2018-02-26 22:56:59 UTC
Review of attachment 368980 [details] [review]:

::: ges/ges-timeline.c
@@ +3743,3 @@
+ * Paste @element inside the timeline. @element must have been
+ * created using ges_timeline_element_copy with recurse=TRUE set,
+ * @paste_position: The position in the timeline the element should

How "it will fail"? Describe instead exactly what happens.

It's too bad you can't paste an object you created yourself.. which are not copied.

@@ +3745,3 @@
+ * otherwise it will fail.
+ *
+ * be pasted to, meaning it will become the start of @element

Is this better? "The @element copy which has been pasted"

@@ +3761,3 @@
+
+  if (!copied_from) {
+ * Returns: (transfer none): Paste @element copying the element

*has not been copied recursively

@@ +3767,3 @@
+
+  if (!element_class->paste) {
+ges_timeline_paste_element (GESTimeline * timeline, GESTimelineElement * element,

Should we print element or element_class?

::: ges/ges-timeline.h
@@ +161,3 @@
+GST_EXPORT
+GESTimelineElement * ges_timeline_paste_element (GESTimeline * timeline,
+  GESTimelineElement * element, GstClockTime paste_position, gint layer_priority);

Why "paste_position" and not "position"?
Comment 11 Harish Fulara 2018-02-26 23:00:38 UTC
(In reply to Thibault Saunier from comment #9)
> Review of attachment 368980 [details] [review] [review]:
> 
> It is almost good and I am being a bit annoying but let's get it **right** ;)
> 
> ::: ges/ges-timeline-element.c
> @@ +1863,3 @@
> +ges_timeline_element_get_copied_from (GESTimelineElement * self)
> +{
> +  GESTimelineElement * copied_from_ref =
> gst_object_ref(self->priv->copied_from);
> 
> I am pretty much sure it is not `gst-indent` complient, could you check that
> please?
> 
> You could have done:
> 
> ```
> copied_from = self->priv->copied_from;
> self->priv->copied_from = NULL;
> return copied_from;
> ```

Yea, it is not gst-indent compliant.
Comment 12 Thibault Saunier 2018-02-26 23:01:49 UTC
Review of attachment 368980 [details] [review]:

::: ges/ges-timeline.c
@@ +3743,3 @@
+ * Paste @element inside the timeline. @element must have been
+ * created using ges_timeline_element_copy with recurse=TRUE set,
+ * otherwise it will fail.

Well, to paste you need to copy... that's just the way it works, and it obviously makes sense.

@@ +3767,3 @@
+
+  if (!element_class->paste) {
+    GST_ERROR_OBJECT (element, "No paste vmethod implemented");

It is fine this way.
Comment 13 Harish Fulara 2018-02-26 23:41:05 UTC
Created attachment 368983 [details] [review]
Added paste functionality to GESTimeline class
Comment 14 Thibault Saunier 2018-03-02 12:32:13 UTC
Attachment 368983 [details] pushed as e944739 - Added paste functionality to GESTimeline class
Comment 15 Thibault Saunier 2018-03-02 12:33:01 UTC
Do you need it to be backported to 1.12 for Pitivi 1.0?
Comment 16 Harish Fulara 2018-03-02 12:39:00 UTC
I am not sure. @aleb can comment better on that :)