GNOME Bugzilla – Bug 734660
Always emit value-changed when the adjustment is changed
Last modified: 2014-08-14 04:04:55 UTC
Changing adjustment via the property setter would not emit value-changed, however changing it via gtk_spin_button_configure would. This inconsistency had the following side-effects: - Setting an adjustment with a different value would not update the value shown by the spin button. - Creating a spin button like this (common in GtkBuilder XML) will not show the initial value: g_object_new (GTK_TYPE_SPIN_BUTTON, "adjustment", adj, NULL);
Created attachment 283176 [details] [review] GtkSpinButton: Always emit value-changed when the adjustment is changed
(In reply to comment #1) > Created an attachment (id=283176) [details] [review] > GtkSpinButton: Always emit value-changed when the adjustment is changed Oops, wait a minute. This might not compile.
Created attachment 283180 [details] [review] GtkSpinButton: Always emit value-changed when the adjustment is changed Sorry about that.
I don't like this patch because it makes things confusing: Setting an adjustment is now a way of configuring a spinbutton with a new adjustment. And configuring a spinbutton does not set the adjustment anymore but instead it calls an internal setter. That kind of confusing. Also, from the way it looks, setting a NULL adjustment is not valid, so making gtk_spin_button_set_adjustment() (or gtk_spin_button_set_adjustment_internal()) accept NULL seems wrong. I'd probably do this: (1) split out an _unset_adjustment() from _set_adjustment_internal() (2) call _unset_adjustment() from _finalize() (3) call _set_adjustment() from _init(). There's no need to care about avoiding signals at that point. (4) Also call _set_adjustment() from set_property(). Setting a property should be identical to calling the setter. (5) fold _set_adjustment_internal() into _configure() and remove all the NULL checks. And probably: (6) figure out what to do when set_adjustment() is called with NULL. Probably adjustment_new(0, 0, 0, 0, 0, 0). (7) Remove all the other places (init, set_property) where we construct adjustments and just call set_adjustment() with NULL. Also: tests, tests, tests!
Created attachment 283213 [details] [review] GtkSpinButton: Always emit value-changed when the adjustment is changed
Created attachment 283214 [details] [review] GtkSpinButton: Always emit value-changed when the adjustment is changed
Created attachment 283215 [details] [review] GtkSpinButton: Prevent public API from unsetting the adjustment
Attachment 283214 [details] pushed as 1e304e6 - GtkSpinButton: Always emit value-changed when the adjustment is changed Attachment 283215 [details] pushed as 137abd6 - GtkSpinButton: Prevent public API from unsetting the adjustment