After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 734660 - Always emit value-changed when the adjustment is changed
Always emit value-changed when the adjustment is changed
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkSpinButton
3.13.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-08-12 11:49 UTC by Debarshi Ray
Modified: 2014-08-14 04:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GtkSpinButton: Always emit value-changed when the adjustment is changed (6.23 KB, patch)
2014-08-12 11:50 UTC, Debarshi Ray
none Details | Review
GtkSpinButton: Always emit value-changed when the adjustment is changed (8.04 KB, patch)
2014-08-12 12:15 UTC, Debarshi Ray
none Details | Review
GtkSpinButton: Always emit value-changed when the adjustment is changed (6.96 KB, patch)
2014-08-12 15:34 UTC, Debarshi Ray
none Details | Review
GtkSpinButton: Always emit value-changed when the adjustment is changed (6.97 KB, patch)
2014-08-12 15:52 UTC, Debarshi Ray
committed Details | Review
GtkSpinButton: Prevent public API from unsetting the adjustment (1.78 KB, patch)
2014-08-12 15:52 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2014-08-12 11:49:57 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);
Comment 1 Debarshi Ray 2014-08-12 11:50:29 UTC
Created attachment 283176 [details] [review]
GtkSpinButton: Always emit value-changed when the adjustment is changed
Comment 2 Debarshi Ray 2014-08-12 12:04:03 UTC
(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.
Comment 3 Debarshi Ray 2014-08-12 12:15:34 UTC
Created attachment 283180 [details] [review]
GtkSpinButton: Always emit value-changed when the adjustment is changed

Sorry about that.
Comment 4 Benjamin Otte (Company) 2014-08-12 13:44:07 UTC
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!
Comment 5 Debarshi Ray 2014-08-12 15:34:44 UTC
Created attachment 283213 [details] [review]
GtkSpinButton: Always emit value-changed when the adjustment is changed
Comment 6 Debarshi Ray 2014-08-12 15:52:26 UTC
Created attachment 283214 [details] [review]
GtkSpinButton: Always emit value-changed when the adjustment is changed
Comment 7 Debarshi Ray 2014-08-12 15:52:51 UTC
Created attachment 283215 [details] [review]
GtkSpinButton: Prevent public API from unsetting the adjustment
Comment 8 Matthias Clasen 2014-08-14 04:04:45 UTC
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