Implement minimum, maximum constraints for GObject properties that support it
Submitted by Mark Lee
Link to original bug (#580385)
Description
I'm attempting to convert some GObjects written in C into Vala for the Awn project, and in several instances, the minimum/maximum constraints for GObject properties are used with non-default values (Type.MIN/Type.MAX). For example, a panel background pattern can have a alpha (float) value between 0 and 1.
For the sake of completeness, there are two possible ways of implementing this (as far as I can tell):
- Implement the same way as the default value. This would require that "min(imum)" and "max(imum)" become keywords, which would probably screw up a lot of code, but would be consistent with the other property attributes.
- Implement as code attributes. For example:
... [CCode (minimum_value = 0.0f, maximum_value = 1.0f)] public float pattern_alpha { get; construct; default = 1.0f; } ...
I'm not entirely comfortable with the idea of having to add a code attribute for every single property with non-default constraints, though.
Version: 0.7.x