Re: [Vala] Gtk.TreeView: void* in vapi

Thanks for your reply! I will test it and then file a bug.

Am Mittwoch, den 30.09.2009, 06:12 +0200 schrieb Jan Hudec:
On Tue, Sep 29, 2009 at 09:16:24 +0200, JM wrote:
I need some help with the binding for TreeViewRowSeparatorFunc.
Something is wrong here.
If I use

  this.set_row_separator_func(separator_func, null, destrnot);

I think there are two parameters too many.

It looks like a problem in the .vapi -- since C signature is

    void gtk_tree_view_set_row_separator_func(
            GtkTreeView *tree_view,
            GtkTreeViewRowSeparatorFunc func,
            gpointer data,
            GDestroyNotify destroy);

The corresponding Vala signature should be:

    class TreeView { ...
        void set_row_separator_func(owned Gtk.TreeViewRowSeparatorFunc func);
    ... }

But it's not. File a bug. Thanks.

By the way, the binding for get_row_separator_func won't work either and
should probably just be removed, because it seems unfixable (it returns just
the function pointer, which is not enough to reconstruct a closure).

in my TreeView widget together with
  public static void destrnot() {
    return; //just for testing
  private bool separator_func(Gtk.TreeModel model, Gtk.TreeIter iter) {
   print("in TreeViewRowSeparatorFunc\n");
   return false; //just for testing

I get the following ccode:

  gtk_tree_view_set_row_separator_func (
     (GtkTreeView*) self,

The vapi file says:

  public void set_search_position_func (Gtk.TreeViewSearchPositionFunc
void* data, 
GLib.DestroyNotify destroy);

I'm not sure how vala handles void* but obviously in the ccode there is
one too many 'self'. 

No, the self is fine. The problem is not in void *, which is handled just
fine. The problem is, that a non-static delegate argument consists of the
function pointer, the taget (user data) pointer and, if modified with
'owned', the destroy notify pointer.

Remember that the separator_func is an /instance/ method? So the instance
must be passed in somehow -- that's why the 'self' is there. And since vala
is supposed to take care of memory management for you, it will also pass
correct unref function if the delegate is owned.

Can anybody give me a hint how to correct the vapi? 

See above.

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