GNOME Bugzilla – Bug 354353
entry fires changed signal twice, once empty
Last modified: 2006-09-04 22:32:50 UTC
Hi, When I set an entry2 in the changed signal for another entry1, the entry2 itself fire the signal twice, once with the field empty, and once with the real value. The following python code demonstrates it. Same logig in Haskell has same results, so I don't think it's a bug in the bindings: ===================================================== import pygtk import gtk def e1(w): text = entry1.get_text() print "entry1: %s"%text entry2.set_text(text) def e2(w): text = entry2.get_text() print "entry2: %s"%text button.set_label(text) window = gtk.Window() button = gtk.Button() entry1 = gtk.Entry() entry2 = gtk.Entry() vbox = gtk.VBox() vbox.add(entry1) vbox.add(entry2) vbox.add(button) window.add(vbox) button.set_label("Test it") entry1.connect("changed", e1) entry2.connect("changed", e2) button.connect("clicked", lambda: entry1.set_text("test")) window.show_all() gtk.main() ===================================================== Output when user changes entry one from "s" to "ss": entry1: ss entry2: entry2: ss Happens like that for every key press in entry1, unless entry2 was empty before, In this case entry1: s entry2: s Like it should be. By looking at the code at http://cvs.gnome.org/viewcvs/gtk%2B/gtk/gtkentry.c?rev=1.323&view=markup I see that setting the text first deletes the text and then inputs it, so that's probably the cause. My suggestions would be to either try to no raise a signal when deleting, or by bypassing these two functions somehow. But I'm not gtk developer, there might be better solutions... I'd appreciate if this could be fixed. Thanks!
Allright, looks like I'm not good in searching the bugzilla... *** This bug has been marked as a duplicate of 64998 ***