Re: Constructor Properties in GObject
- From: Tristan Van Berkom <tvb gnome org>
- To: matthew barnes net
- Cc: gtk-list gnome org
- Subject: Re: Constructor Properties in GObject
- Date: Wed, 14 Sep 2005 10:39:42 -0400
Matthew F. Barnes wrote:
I have a GObject question that I hope someone can help me with.  I
imagine this has been asked before, but a quick search of the
mailing-list archives didn't turn up any answers.
Regarding a GObject's constructor properties, is there a mechanism in
GObject or a generally accepted idiom for *requiring* certain properties
to be supplied at object construction?
There is no built-in support for that in GObject.
It is general practice is to write a function like:
   my_object_new (Required *param1, Required *param2)
   {
       MyObject *obj;
       g_return_val_if_fail (param1 != NULL, NULL);
       /* ... */
       obj = g_object_new (MY_TYPE_OBJECT,
                           "p1", param1,
                           "p2", param2, NULL);
       /* ... */
       return obj;
   }
But that aproach doesnt bar public access to
g_object_new () ofcourse.
Cheers,
                            -Tristan
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]