GNOME Bugzilla – Bug 580385
Implement minimum, maximum constraints for GObject properties that support it
Last modified: 2018-05-22 13:20:31 UTC
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): 1. 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. 2. 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.
*** Bug 614587 has been marked as a duplicate of this bug. ***
*** Bug 575387 has been marked as a duplicate of this bug. ***
Created attachment 344320 [details] [review] Add support for minimum/maximum constraints for properties The values can be passed withing the property definition block, exactly how the 'default' value is handled. "public int foo { get; set; default = 0; minimum = -128; maximum = 512; }"
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/32.