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 776333 - Fix annotation on g_file_copy_async()
Fix annotation on g_file_copy_async()
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-12-21 01:45 UTC by Patrick Griffis (tingping)
Modified: 2017-06-02 17:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] Fix g_file_copy_async() annotation (1.60 KB, patch)
2016-12-21 01:45 UTC, Patrick Griffis (tingping)
none Details | Review
Fix g_file_copy_async() annotation (1.61 KB, patch)
2017-04-28 10:52 UTC, Patrick Griffis (tingping)
committed Details | Review

Description Patrick Griffis (tingping) 2016-12-21 01:45:39 UTC
Created attachment 342292 [details] [review]
[PATCH] Fix g_file_copy_async() annotation

Don't skip annotations for g_file_copy_async() so it can be used from bindings.
Comment 1 Emmanuele Bassi (:ebassi) 2017-04-28 10:49:51 UTC
Review of attachment 342292 [details] [review]:

::: gio/gfile.c
@@ +3408,3 @@
  *     information, or %NULL if progress information is not needed
+ * @progress_callback_data: (closure progress_callback) (nullable): user data to pass to @progress_callback
+ * @callback (scope async): a #GAsyncReadyCallback to call when the request is satisfied

Missing ':' between argument and annotation.

@@ +3409,3 @@
+ * @progress_callback_data: (closure progress_callback) (nullable): user data to pass to @progress_callback
+ * @callback (scope async): a #GAsyncReadyCallback to call when the request is satisfied
+ * @user_data (closure callback): the data to pass to callback function

Missing ':' between argument and annotation.
Comment 2 Emmanuele Bassi (:ebassi) 2017-04-28 10:50:46 UTC
AFAIR, the reason why we didn't bind this is because the GDestroyNotify would be called twice — once for the progress callback and once for the callback — and the bindings didn't cope with that.
Comment 3 Patrick Griffis (tingping) 2017-04-28 10:52:44 UTC
Created attachment 350629 [details] [review]
Fix g_file_copy_async() annotation

Add missing :
Comment 4 Patrick Griffis (tingping) 2017-04-28 10:53:58 UTC
(In reply to Emmanuele Bassi (:ebassi) from comment #2)
> AFAIR, the reason why we didn't bind this is because the GDestroyNotify
> would be called twice — once for the progress callback and once for the
> callback — and the bindings didn't cope with that.

For what its worth I use it successfully from pygobject: https://github.com/TingPing/transmission-remote-gnome/blob/d3c509a9793e457054994eb791520f95b31c801c/trg/preferences_dialog.py#L206
Comment 5 Emmanuele Bassi (:ebassi) 2017-04-28 11:41:14 UTC
(In reply to Patrick Griffis (tingping) from comment #4)
> (In reply to Emmanuele Bassi (:ebassi) from comment #2)
> > AFAIR, the reason why we didn't bind this is because the GDestroyNotify
> > would be called twice — once for the progress callback and once for the
> > callback — and the bindings didn't cope with that.
> 
> For what its worth I use it successfully from pygobject:
> https://github.com/TingPing/transmission-remote-gnome/blob/
> d3c509a9793e457054994eb791520f95b31c801c/trg/preferences_dialog.py#L206

You're not using the callbacks, which is what I'm worried about.

That's basically the equivalent of using GTask<g_file_copy>.
Comment 6 Patrick Griffis (tingping) 2017-04-28 12:42:39 UTC
I did a test with the progress callback at the time and while the api was a bit odd (it required a tuple for the userdata?) it seemed to function. Eitherway I don't think the annotations are wrong and if implementations cannot handle it that is on them.

> That's basically the equivalent of using GTask<g_file_copy>.

Well its not like GTask is easy to use from python so this function is much nicer =)
Comment 7 Patrick Griffis (tingping) 2017-05-22 08:09:08 UTC
Just as an update I tested this in GJS and it works perfectly:


    let file = Gio.File.new_for_path('test.txt');
    let dest = Gio.File.new_for_path('test2.txt');
    file.copy_async(dest, Gio.FileCopyFlags.NONE, GLib.PRIORITY_DEFAULT, null,
        (current, total) => {
            print(`${current}/${total}`);
        }, (obj, res) => {
            print(obj.copy_finish(res));
    });

I really see no harm in merging this.
Comment 8 Emmanuele Bassi (:ebassi) 2017-06-02 16:27:59 UTC
Review of attachment 350629 [details] [review]:

If this works with GJS then sounds good to me.
Comment 9 Patrick Griffis (tingping) 2017-06-02 17:45:09 UTC
Attachment 350629 [details] pushed as 7c5cd29 - Fix g_file_copy_async() annotation