I’m trying to set the default value for a SpinButton from a .ui file, but the value always is set to lower, not to value as I would expect. Demonstration:
This is an unfortunate side effect of how values are set. Gtk.Builder sets spin_button.value, then adjustment.lower, then adjustment.value, then adjustment.upper – that is, in the same order you wrote them. But this means that when value gets set (both on the spin button and on the adjustment), the upper bound is still 0.0, so the value is clamped to 0.0 as well.
It starts working if you reorder the properties so that either value is assigned textually after the upper.
In my humble opinion, this should be considered an issue in Gtk.Builder. It should (somehow) know to use Gtk.Adjustment.configure() instead of setting the properties via g_object_setv(). Gtk.Adjustment.configure() already verifies the invariants, sets properties in the right order, and emits the signals optimally.
But overall, GtkBuilder already has special support for many well-known types (mostly for parsing and setting properties of those types). So it could go “aha, I see this is a GTK_TYPE_ADJUSTMENT, let me call gtk_adjustment_configure () instead of g_object_setv ()”. Alternatively, GtkAdjustment could do it on its side, making these all into construct properties and overriding constructor vfunc (but this would cause GLib to take a slower path when constructing it ).
The exceptions usually concern values, or custom syntax; they do not to change how values are set. Adding a new exception means having a different behaviour that needs to be maintained and debugged.
And the same considerations for setting properties in GtkAdjustment applies to both GtkBuilder and the generic GObject API.
If we want to add an exception for GtkAdjustment, I’d rather add some custom syntax for setting up an adjustment, and possibly turn every property read-only to force people to use gtk_adjustment_configure().