Re: user_data for callbacks



On 09/25/2012 07:24 PM, Daniel Drake wrote:
Hi,

Just checking the introspection of g_volume_mount():

/**
  * g_volume_mount:
  * @volume: a #GVolume.
  * @flags: flags affecting the operation
  * @mount_operation: (allow-none): a #GMountOperation or %NULL to
avoid user interaction.
  * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
  * @callback: (allow-none): a #GAsyncReadyCallback, or %NULL.
  * @user_data: user data that gets passed to @callback
  *
  * Mounts a volume. This is an asynchronous operation, and is
  * finished by calling g_volume_mount_finish() with the @volume
  * and #GAsyncResult returned in the @callback.
  *
  * Virtual: mount_fn
  **/

The user_data parameter above doesn't have a (closure) annotation, but
looking at the gir file, it doesn't seem necessary: the callback
parameter has closure=4 already set.

Python wants me to pass 5 arguments, i.e.
volume.mount(flags, mount_op, cancellable, callback, user_data)

I was expecting the user_data parameter to be optional, as it is with
e.g. mybutton.connect('clicked', clicked_cb)

Similarly, I am forced to provide a user_data parameter in my callback
function to receive the value that was passed, otherwise python throws
an exception about the callback receiving the wrong number of
arguments.

Is this the intended behaviour, or is there a bug somewhere?

Thanks
Daniel

Hmm, this sounds similar to:

"Using gtk_container_foreach or gtk_container_forall [1] does expect the
callback data to be passed in Python, it does work in a subclassed
container due to Carlos fix in the GtkCallback annotations [2]."

[1] http://developer.gnome.org/gtk3/3.4/GtkContainer.html#gtk-container-foreach [2] http://git.gnome.org/browse/gtk+/commit/?id=db569cbee7e3842d802c5f1d53e28d0dde98ffeb

Regards,
   Simon


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]