Re: user_data for callbacks

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

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

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


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] [2]


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