GNOME Bugzilla – Bug 131920
gtkNotebook sends incorrect switch_page value
Last modified: 2008-06-08 21:43:10 UTC
Create a notebook with multiple tabs (>2). Attach a handler for the switch_page signal. Remove the leftmost tab using gtk_notebook_remove_page(). The signal handler will be invoked, however, the value sent in for page_num will be 1, rather than 0, even though the leftmost tab (index 0) is still the new active tab. When any other tab is removed, the correct index of the new active tab is passed in to the switch_page signal handler.
Standalone compilable test case would be useful.
Created attachment 25581 [details] Standalone compilable test case - press button to delete the ntbk page; outputs index of page deleted as well as new page index reported to the switch_page sig handler
Mass changing gtk+ bugs with target milestone of 2.4.2 to target 2.4.4, as Matthias said he was trying to do himself on IRC and was asking for help with. If you see this message, it means I was successful at fixing the borken-ness in bugzilla :) Sorry for the spam; just query on this message and delete all emails you get with this message, since there will probably be a lot.
Created attachment 80785 [details] [review] Fixes switch_page signal and tab behaviour I've made a patch against SVN /trunk/gtk/gtknotebook.c 17095 I just unliked the current page GList element as soon as it is no longer used and before any signal is send. I've also taken the liberty to patch the behaviour of tabs when one is removed. The logical behaviour would be to STEP_NEXT for all tabs except the last tab and the rightmost tab.
Patch 80785 applies cleanly. Reviewing it would take little time. (Working on http://mail.gnome.org/archives/gtk-devel-list/2007-March/msg00148.html)
Could a maintainer please review this patch? A year is an unfair amount of time to wait.
The patch works, so committed in r20339: 2008-06-08 Björn Lindqvist <bjourne@gmail.com> Bug 131920 – gtkNotebook sends incorrect switch_page value * gtk/gtknotebook.c (gtk_notebook_real_remove): Make switch-page signal send correct page index when page index 0 is active and removed. (#131920, Samuel Fogh) And here is the test case that verifies that the bug vanishes: num_in_cb = ['other'] def switch_page_cb(notebook, page, page_num): num_in_cb[0] = page_num book = gtk.Notebook() for x in range(5): page = gtk.Label('page-%d' % x) page.show() book.append_page(page, gtk.Label('page-%d' % x)) book.connect('switch-page', switch_page_cb) book.remove_page(0) assert num_in_cb[0] == 0