Re: GParamSpec



Chema Celorio <chema ximian com> writes:

> On 19 Jun 2001 23:07:19 -0400, Owen Taylor wrote:
> > Each parameter has three strings associated with it:
> > 
> >   gchar         *name;
> >   gchar         *nick;
> >   gchar         *blurb;
> > 
> >  name: the name of the property "Type"
> >  nick: The programmatic name of the property "type"
> >  blurb: tooltip "
> 
> 
> Yes, but name gives me "type" not Type, and for enum values name has
> "GTK_WINDOW_TOPLEVEL" and nick has "toplevel", i still need "Toplevel".

As Tim said, I got name and nick backwards:

  /* Construct */
  g_object_class_install_property (gobject_class,
                                   PROP_TYPE,
                                   g_param_spec_enum ("type",
						      _("Window Type"),
						      _("The type of the window"),
						      GTK_TYPE_WINDOW_TYPE,
						      GTK_WINDOW_TOPLEVEL,
						      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));


For enum values, name and nick mean different things. 

 name - name in C
 nick - short name for use when a namespace isn't needed, as in language bindings
        or gtkrc files.

The reuse of these terms for GParamSpec is confusing. Enum values have no
descriptions or translated names.

> > > - Another thing that i bumped into last night (and this was the first
> > > time I started using the ParamSpec) is that i could not get the default
> > > value for an Enum spec.
> > 
> > Why not?
> > 
> > struct _GParamSpecEnum
> > {
> >   GParamSpec    parent_instance;
> >   
> >   GEnumClass   *enum_class;
> >   glong         default_value;
> > };
> > 
> 
> I'm sorry, my mistake. 
> Hmm why is it a glong ? (just curious)

I believe the C standard doesn't restrict what integral type will be picked
for a particular enumeration, so Tim may have just been being cautious,
in case someone did:

typedef enum {
  Value1,
  Value2 = G_MAXLONG
} MyEnum;

Regards,
                                              Owen




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