Signals in Vala are implemented using GLib's signals, which is an example of the observer pattern. To use signals in Vala the class needs to inherit from Object
and it doesn't look like libui
is using GLib's GObject. So it won't be possible to use signals in this binding. Although it is possible to use signals in a Vala binding. For example the gtksourceview VAPI binds the redo
and undo
signals of SourceBuffer
.
The pattern used in uiWindowOnClosing
is to pass a C function pointer to use as the callback. On the Vala side these are called delegates. libui
hasn't added a typedef for the function point, so Vala needs to generate that. This is indicated by using [CCode (has_typedef = false)]
in the VAPI.
The other problem here is the void pointer for the user data - void *data
. This is probably best bound using simple generics.
A rough cut at a binding would be:
[CCode (cname = "uiWindow")]
public class Window {
[CCode (has_typedef = false, simple_generics = true)]
public delegate int Callback<T> (T data);
[CCode (cname = "uiWindowOnClosing", simple_generics = true)]
public void on_closing<K> (Callback callback, K data);
}
This is untested, but should give you a better idea of the underlying concepts.