On Sat, 2003-08-23 at 05:45, Mikoyan wrote:
On Fri, 2003-08-22 at 19:05, Russell Shaw wrote:Hi,
The advantages over just whatever->member or whatever_get_member (); is
ease of creating language bindings, ease of apps like Glade mapping the
Glade UI to your object's properties, consistency with the rest of
GObjects, easy custom initialization of (construct-time) properties,
getting notification of changes, and not having to export, or even
write, accessor functions (as it can all be contained in
something_(get|set)_property):
// Application code that uses MyObject...
static void
myobject_notify_property_name_cb (GObject *obj,
GParamSpec *pspec,
gpointer user_data)
{
gpointer some_val = my_object_get_property_name (MY_OBJECT (obj));
/* do something with "some_val", like save state, create a new
* object, validate the value against something else, or
* whatever. */
}
static void
create_object (gpointer initial_val)
{
GObject *myobj, *something_else;
myobj = g_object_new (MY_TYPE_OBJECT, "property-name", initial_val,
NULL);
g_signal_connect (myobj, "notify::property-name",
G_CALLBACK (myobject_notify_property_name_cb),
NULL);
// and other junk... :-)
}
As an example, GtkCellRenderer & it's subclasses don't have any
(get|set)_<whatever> functions, it's all done with (a lot of) GObject
properties.
Oh yeah, and you can set a bunch of properties with one function call
:-).
/me blushes at refs to the gtcpsocket subclassing tutorial ;-)
--
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