g_object_data vs struct fields

Jani Monoses jani.monoses at gmail.com
Sat Jan 21 22:35:38 CET 2006


Hello

looking at panel plugins, clock for example, I see that
g_object_{set,get}_data() are used to store attributes of the plugin
in this case dialog. Other plugins do this too, some for other fields as 
well.

Why is this better than having a field in struct Clock as the dialog?
For the actions and separator plugins I thought it is done because there 
is no separate struct for the plugin, OTOH there is a quite large struct 
Clock.

It still is not clear to me what the exact difference of roles of the 
plugin object and the optional plugin specific struct should be.
They seem to be both able to be used for the same things with minor code 
alterations as they both seem to be passed (or passable) to all functions.

Could the XfcePanelPlugin have another field besides 'child'? I see it's 
a dummy class so I am not sure, but if it had an opaque pointer field 
for each plugin's private use it would be less confusing.

If I am missing something important here bear with me please ;)

thanks
Jani




More information about the Xfce4-dev mailing list