Re: Patches to gtkwidget and gtkwindow for property support



John Margaglione <jmargaglione yahoo com> writes:

> OK, I'm working in all the suggestions, and I'll have a UNIFIED diff
> ready soon :)
> 
> A few things, though:
> 
> > >   g_object_class_install_property (gobject_class,
> > >                                    PROP_EVENTS,
> > >                                    g_param_spec_int ("events",
> > >                                                    _("Events"),
> > >                                                    _("Widget events"),
> > >                                                    0,
> > >                                                    GDK_ALL_EVENTS_MASK,
> > >                                                    0,
> > >                                                    G_PARAM_READABLE | G_PARAM_WRITABLE));
> > 
> > here you changed the property type, that should not
> > happen. simply use g_param_spec_enum (,GTK_TYPE_GDK_EVENT_MASK,)
> > here.
> 
> What is being passed into the PROP_EVENTS param is not of type
> GTK_TYPE_GDK_EVENT_MASK, since it is actually an OR of several
> GTK_TYPE_GDK_EVENT_MASKs.  That is, once you start OR'ing these enums
> together, you no longer have an enum, since the OR'd value is not one of
> the listed enumerated types.  Plus, properties should use the same type
> as the normal get/set calls, which in this case pass gint values:
> gtk_widget_set_events (GtkWidget* widget, gint events).  That is why I
> changed it.  If you still feel that this is incorrect, I'll leave it be.

The GTK+ type system includes, as well as enumeration types,
"flags" types, similar to Pascal sets. The way this is represented
in C is as an enumeration of values that that can be or'ed
together. But this is not the mapping in every language, and
certainly not how it will be displayed in a GUI builder.

So, parameters need to preserve the correct type, and not
just say it is a generic int.

So, the type of paramspec you should be using here is
g_param_spec_flags(..., GDK_TYPE_GDK_EVENT_MASK,...). 

Regards,
                                        Owen

[
For function parameters, we are a little inconsistent - in
some places, we use the enumeration type, to preserve the
most information in the header file, in other places,
we use guint, because C++ is strict in such matters. 
gint is definitely incorrect. 

My opinion is we should always use the enum type, but the
issue has never been definitely decided.
]




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