mattn / go-gtk

Go binding for GTK
http://mattn.github.com/go-gtk
BSD 3-Clause "New" or "Revised" License
2.11k stars 247 forks source link

gtk.TREE_VIEW(view) is *gtk._Ctype_struct__GtkTreeView #411

Closed jinj closed 4 years ago

jinj commented 4 years ago

I tried to all C.gtk_tree_view_get_path_at_pos function from my go code as:

C.gtk_tree_view_get_path_at_pos(gtk.TREE_VIEW(treeview), C.int(btn.X), C.int(btn.Y), &path.GTreePat h, nil, nil, nil)

and got this error:

cannot use gtk.TREE_VIEW(treeview) (type gtk._Ctype_struct__GtkTreeView) as type _Ctype_struct__GtkTreeView in assignment

So gtk.TRE_VIEW() returns gtk.C.GtkTreeView, not C.GtkTreeView.

What is the correct way to call the function from Go code?

mattn commented 4 years ago

You can not use gtk.TREE_VIEW to pass C API.

mattn commented 4 years ago

You have to use C casting.