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 53130 - Incorrect changed events for GtkEntry, GtkSpinButton
Incorrect changed events for GtkEntry, GtkSpinButton
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
1.2.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2001-04-12 05:00 UTC by jgotts
Modified: 2011-02-04 16:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (untested - is there a good way to test signal emission ?) (1.32 KB, patch)
2002-02-20 09:37 UTC, Matthias Clasen
none Details | Review
fixed fix (1.67 KB, patch)
2002-02-21 09:01 UTC, Matthias Clasen
none Details | Review

Description jgotts 2001-04-12 05:00:29 UTC
GtkEntry triggers "changed" events for clicking in a blank entry or before
the first character and pressing the backspace button.  Of course the text
(or lack thereof) hasn't actually changed.  In this case, backspace is like
the back arrow key and should not emit this particular event.  This problem
also occurs for GtkSpinButtons, of course.

GtkSpinButtons trigger "changed" events for pressing the space bar, which
can't by definition change the value.  I think GtkSpinButton was improved
recently to disallow anything but -?[0-9]*\.?[0-9]*, but typing other
characters still triggers "changed" events even though the value didn't
change.
Comment 1 Owen Taylor 2001-04-18 14:10:12 UTC
In general, "changed" signals should be thought of as 
"something might have changed" rather than as "something
changed". However, I can see where this might be annoying
behavior while maintaining, e.g., the sensitivity of a
"Apply" button in a dialog, so fixing it up to the extent
possible is probably a good idea.

I don't see it as very feasible to fix up GtkSpinButton, but fixing
up GtkEntry should be more or less easy. (Emit CHANGED
out of real_insert_text(), real_delete_text(), instead
of out of insert_text, delete_text)
Comment 2 Matthias Clasen 2002-02-20 09:37:16 UTC
Created attachment 6789 [details] [review]
patch (untested - is there a good way to test signal emission ?)
Comment 3 Owen Taylor 2002-02-20 22:15:49 UTC
Connect to the example in testgtk and print stuff to stderr?

Bug 64998 is a closely related bug, though considerably harder to
fix. (That one, you'd probably have to set a "in multiple
change" flag and suppress ::change signals until it is cleared;
might be best fixed along with 69616?)

Actually, the in-change flag could solve this one as well...

 insert_/delete_text() 

would do:

 start_change()
 [ push the stuff inside ]
 end_change()

real_insert/delete_text would set a "stuff actually changed"
flag. Then end_change would emit ::changed() if the 
"stuff actually changed" flag was set.
Comment 4 Matthias Clasen 2002-02-21 09:00:30 UTC
"print to stderr" rang the bell; I just refactored my testcase for
54444 to print out entry::changed. This uncovered that my patch
doesn't completely fix the described problems with entry::changed.
It still gets emitted when backspace is pressed at position 0.

The next patch fixes this and works ok as far as cursory testing
can prove.
Comment 5 Matthias Clasen 2002-02-21 09:01:08 UTC
Created attachment 6801 [details] [review]
fixed fix
Comment 6 Matthias Clasen 2002-02-21 09:06:39 UTC
Regarding the spinbutton problems, connecting to spinbutton::value_changed or adjustment::value_changed 
instead of spinbutton::changed might be a solution, although that
has the slight problem that if the value is typed in the entry of
the spinbutton, ::value_changed will apparently not be emitted 
until the spinbutton looses focus.
Comment 7 Owen Taylor 2002-02-23 21:57:39 UTC
Sat Feb 23 16:52:38 2002  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkentry.c: Patch from Matthias Clasen to remove some
	excessive ::changed signals for GtkEntry. (#53130)