Re: gobject introspection




But the real reason why I'm posting here is to ask how the different
language bindings handle unions (in particular GdkEvent). The
introspection prototype currently doesn't handle unions at all, apart
from the fact that fields are supposed to have struct offset
information, so unions could be modeled by describing the overlapping
fields. CORBA does seem to have a concept of discriminated union,
which would probably cover the GdkEvent case, but trying to describe
arbitrary anonymous unions in the middle of structs sounds like adding a lot of complexity. It would be very tempting to just require
accessors to make those kinds of C-specific things bindable.

So, how do language bindings handle GdkEvent currently ?
In Python there is only one GdkEvent class, which looks differently depending on the
actual event.

So for example event.type is a member which is always accessible while event.button is only accessible for GdkEventButton.

You can also create new events and assign members of them, that looks very similar to the C API:

 event = gtk.gdk.Event(gtk.gdk.BUTTON_PRESS)
 event.button = ...

Ideally, subclassing would be used, a main gdk.Event class and a subclass for each type in the union.

Currently the events are not handled by the code generator. In a future version of PyGTK they might be.

Johan Dahlin




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