Re: Overriding property defaults
- From: Owen Taylor <otaylor redhat com>
- To: timj gtk org
- Cc: gtk-devel-list gtk org
- Subject: Re: Overriding property defaults
- Date: 27 Mar 2001 12:11:44 -0500
Hey Tim,
Did you have any thoughts on this?
- Whether we should be worrying about this problem
- Whether the approach is good
I'm going through the open GObject bugs, and trying to decide
whether to punt this one (#51748) from the 2.0 milestone.
The minimum to be able to do this without breaking source
compatibility is adding _copy and _set_default functions to
GParamSpecTypeInfo.
Regards,
Owen
Owen Taylor <otaylor redhat com> writes:
> While reviewing at a patch to clean up GtkButtonBox, I noticed a
> problem with the way properties work currently.
>
> The problem is that GtkButtonBox inherits GtkButtons' spacing
> parameter, but wants to change the default value. It is currently
> impossible for a derived class to modify the default value for a
> property.
>
> I think this is a fairly common requirement. (Somewhat less common,
> but also legitimate, would be wanting to use more restrictive
> validation for a property.)
>
> The essence of my proposal would be:
>
> GParamSpec *spec = g_object_class_copy_parent_property (object_class, "spacing");
>
> g_param_spec_int_set_default (G_PARAM_SPEC_INT (spec), BUTTON_BOX_SPACING);
>
> g_object_class_install_property (object_class, 0, spec);
>
> That is:
>
> - We add a way of copying paramspecs, and a convenience function
> in GObject to copy the parameter spec of a property you are overriding.
>
> - We add a way of setting default values; another possibility would be
> to have a virtual function in GParamSpec taking a GValue, so you could
> do:
>
> g_param_spec_set_default (spec, BUTTON_BOX_SPACING);
>
> - We allow properties to be installed with a parameter ID of 0, meaning
> "ignore this property when looking for the getter/setter".
>
> This requires some changes to the way the internals of GParam works,
> in particular GParamSpecPool. And for efficiency/simplicity one might
> want to move the ParamID directly into the GParamSpec instance as a
> private member.
>
> But I think, in general, it is a fairly small change and a quite
> important feature we are currently lacking.
>
> Regards,
> Owen
>
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]