Re: Dynamic knowledge about g_objects



On Fri, 2003-11-28 at 07:37, David Marín Carreño wrote:
Hi all.

I'd like to program a new gtktreemodel implementation for AF
Architecture (http://fact.aspl.es).

I want to dynamically create this model data from the data returned by
any remote listing service. This listing services return, currently, a
list where each node are structures representing customers, users, etc.

We're going to implement all these current structures as g-object
"classes". All them will have a common abstract parent class called
"AfDalDataNode".

But, for my gtktreemodel implementation I need to know, having a generic
AfDalDataNode pointer, information about its attributes (number of
attributes and their types). 
My treemodel will not have information about each actual AfDalDataNode
subclasses: it must be generic.

Can I do this? How?

If you use GObject properties for these attributes, you can call
g_object_class_list_properties (); That will return an array of
GParamSpec* pointers, which describe all the properties installed in
that object's class. If your objects implement any GInterfaces which
install properties (A 2.3/2.4 feature), you should also use
g_object_interface_list_properties(); The return values of both these
functions should be freed with g_free();

http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html
http://developer.gnome.org/doc/API/2.0/gobject/gobject-GParamSpec.html
http://developer.gnome.org/doc/API/2.0/gobject/gobject-Standard-Parameter-and-Value-Types.html

Getting the value of the property can be done via
g_object_get/g_value_get_valist.

-- 
Peace,

    Jim Cape
    http://ignore-your.tv

    "It is literally true that, like Christianity, Socialism
     has conquered the world by defeating itself."
        -- Alexander Berkman, ABC of Anarchism

Attachment: signature.asc
Description: This is a digitally signed message part



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