GNOME Bugzilla – Bug 121629
Wrapper for gnome-vfs async API
Last modified: 2004-12-22 21:47:04 UTC
attached goes a patch adding gnome_vfs_async support to gnome-python. The actual code goes in vfs-async-handle.c, also attached [1]. Short description (please ask for clarification if needed, comments are welcome): All new functionality lives under gnome.vfs.async, have a look to the attached example to see usage of the wrapper. Most gnome_vfs_async_* stuff is wrapped, exceptions being: - set_file_info: Requires major gnome.vfs.FileInfo surgery. - [open|create]_as_stream: Requires GIOChannel wrappers not yet written AFAICS. - async_xfer, find_directory, file_control: I'm lazy, but the current gnome-python wrappers don't include the sync versions either. It shouldn't be difficult in case someone desperately needs it, just ask for it. The api for the wrappers is straightforward, it follows the order of the C api except for the callback parameter, which gets promoted to being the last required arg, and the handle, which disappears. I.e.: C: open(handle, uri, open_mode, priority, callback, data) becomes Python: open(uri, callback [, open_mode, priority, data])
Created attachment 19785 [details] [review] Trivial part of the patch
Created attachment 19786 [details] Interesting part of the patch.
Created attachment 19787 [details] example of usage
In pygvfs_async_create, I changed default permission from 0666 to 0644, for obvious reasons I hope :) I also reformatted the code a bit, in pygtk we don't use spaces around () in function calls. Other than that, code was comitted as is to HEAD. Also the example program. Thanks!
I changed the API slightly. I added bytes_requested to read/write callbacks, which was missing. I don't see any reason to omit such parameter, and it can be useful sometimes. Also updated examples/vfs/async.py updated, since that's the only form of documentation we have so far.. :)