GNOME Bugzilla – Bug 61743
HScale/VScale label display always one step behind
Last modified: 2011-02-04 16:09:32 UTC
The display of a scale widget's label seems to always be one step behind the position of the slider itself. It's not until you let go of the mouse button that the label jumps to position. This is most easily seen if you create a rather wide or tall scale widget and set the number of digits to display to 0. Here's a simple Python example that demonstrates the problem: import gtk window = gtk.Window() window.connect("destroy", gtk.mainquit) adj = gtk.Adjustment(10, 0, 20, 1, 1, 1) s = gtk.HScale(adj) s.set_digits(0) window.add(s) window.show_all() gtk.mainloop()
We'd really appreciate test cases in C :-). Test cases in Python aren't conducive to debugging in a debugger, and not everyone working on GTK+ will have the python bindings, python 2.2, automake-1.5, etc.
Created attachment 5860 [details] C example demonstrating broken number display in HScale
I attached a C example that demonstrates the problem. It's my first Gtk program written in C. If you'd like a tutorial on debugging Gtk via gdb (works just fine for C code called from Python as well), let me know. ;-)
*** Bug 66772 has been marked as a duplicate of this bug. ***
Created attachment 6736 [details] [review] created a patch to fix it
I think in gtkhscale and gtkvscale expose function (gtk_hscale_expose) the expose event for the parent class (parent_class->expose_event) can be called at the start of the method insted of at the end.
I believe this patch is correct. The parent class expose handler needs to run so that the geometry gets calculated before the vscale/hscale handler runs.
*** Bug 72245 has been marked as a duplicate of this bug. ***
*** Bug 72220 has been marked as a duplicate of this bug. ***
Applied with: - Comment about the strange side effect - Chain up first outside of the 'if (scale->draw_value)' conditional. - Fixes to conform GTK+ indentation style. Tue Feb 26 19:32:42 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtk[hv]vscale.c (gtk_[hv]scale_expose): Chain up before drawing the scale values so that the number is drawn in the right place instead of one step back. (#61743, patch from Satyajit Kanungo)