Re: Defining custom GEnum subclasses



Actually I put in a patch to dynamically register GEnum types for
enums in the gir while don't have a GType. Turns out that this wasn't
needed. I implemented it for GStreamer, but is a gstreamer bug which
prevented the gi scanner from getting the right GType.

But I found that it was possible to dynamically call g_register_enum()
with a dynamically allocated struct, and use that to construct a
PyGEnum class.

It would be possible to expose this with a Python api. If we wanted to.

On Fri, Jun 10, 2011 at 9:09 PM, John Palmieri <johnp redhat com> wrote:
>
>
> ----- Original Message -----
>> Hi,
>>
>> I'm wondering if it is possible to define a new GEnum type.
>>
>> GObject.type_register() only registers subtypes of GObject
>> and whatever else I tried resulted in some error about a missing
>> '__enum_values__' attribute (which I don't know how to define).
>>
>> Of course this is expected, as I suppose that the underlying
>> GObject system must be notified for the value list somehow.
>>
>> I need the custom GEnum, to use it for defining custom properties.
>>
>>
>> The reason why I DO NEED a custom GEnum instead of an integer
>> for defining my properties, is that I want to expose and use
>> my custom widgets from the Glade designer, and I want to
>> be able to select the property by its values (with a combo box),
>> instead of just specifying an integer
>>
>> Thanks in advance,
>> Costas
>>
>
> Looking at the code in gobject/pygenum.c, it doesn't look like you can actually construct a GEnumClass in Python since it requires a subclass of GEnumClass that aleady defines the size and limits of the enum.  It is all pretty bound to C and there doesn't look like GEnums can ever be constructed dynamically.
>
> --
> John (J5) Palmieri
> Software Engineer
> Red Hat, Inc.
> _______________________________________________
> python-hackers-list mailing list
> python-hackers-list gnome org
> http://mail.gnome.org/mailman/listinfo/python-hackers-list
>


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