On 12/07/12 19:18, Matthew Pirocchi wrote:
> The vapi binding for Gtk.ClipboardGetFunc looks like this:
>
> [CCode (cheader_filename = "gtk/gtk.h", has_target = false)]
> public delegate void ClipboardGetFunc (Gtk.Clipboard clipboard,
> Gtk.SelectionData selection_data, uint info, void* user_data_or_owner);
>
> The function has a user_data parameter, but the CCode attribute sets
> has_target to false. Presumably, this is because the user_data parameter
> doesn't have to be user data, it can also be an owner (see
> Gtk.Clipboard.set_with_data and Gtk.Clipboard.set_with_owner).
It looks to me like the set_with_data binding broken, and you'll have to
use set_with_owner, with an Object subclass encapsulating the data, and
the callback being a static method.
class ClipboardHelper : Object
{
public static void get_func (Clipboard clipboard,
SelectionData selection_data, uint info,
void* owner) {
ClipboardHelper self = (ClipboardHelper) owner;
// ...
}
}
>
> How then can I pass user data to a Gtk.ClipboardGetFunc? I can't use a
> closure, because has_target is false. I also can't create a class to hold
> the user data:
>
> public class ClipboardHelper : Object {
> public void get_func(Gtk.Clipboard clipboard, Gtk.SelectionData
> selection_data, uint info, void* user_data_or_owner) {
> }
> }
>
> If I try this, I get the following error:
> error: Argument 2: Cannot convert from `ClipboardHelper.get_func' to
> `Gtk.ClipboardGetFunc'
> Presumably, this is because of the implicit first parameter to
> ClipboardHelper.get_func.
>
> Am I missing something here?
>
> - Matthew
>
>
>
>
> _______________________________________________
> vala-list mailing list
> [email protected]
> https://mail.gnome.org/mailman/listinfo/vala-list
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list