GNOME Bugzilla – Bug 106336
GtkToolbar draws with offset of border_width
Last modified: 2004-12-22 21:47:04 UTC
GtkToolbar is currently calling paint_box with offsets for border_width, which is wrong, and makes the toolbar look very ugly. Attached is a patch to make GtkToolbar draw correctly and fix this bug.
Created attachment 14391 [details] [review] Patch to fix GtkToolbar paint_box bug
What it does currently looks perfectly correct to me. Why do you think it is incorrect?
It causes too many bevels to be drawn and doesn't behave correctly in most cases, and looks horrid. If you remove the border_width offsets, it looks 1000x better, border_width is still taken into account for the widget, so the spacing is correct, rather than having the buttons be the full height of the bevel area. It is also now consistently drawn as the bonobo toolbar is, and so everything matches nicely and the desktop is consistent as it should be. Shadow types other than SHADOW_OUT still work and look better as well (especially with the Handlebox patch I've submitted in bug 106335 applied also). Please commit these patches. I will also have a patch for MenuBar submitted soon as well, as it has similar issues, most noticeable when embedding a menubar in a handlebox.
*** Bug 106335 has been marked as a duplicate of this bug. ***
--- gtk+-2.2.0.orig/gtk/gtktoolbar.c Sat Feb 15 10:32:03 2003 +++ gtk+-2.2.0/gtk/gtktoolbar.c Mon Feb 17 13:43:36 2003 @@ -557,10 +557,10 @@ GTK_WIDGET_STATE (widget), shadow_type, &event->area, widget, "toolbar", widget->allocation.x + border_width, widget->allocation.y + border_width, - widget->allocation.width - border_width, - widget->allocation.height - border_width); widget->allocation.x + border_width, widget->allocation.y + border_width, + widget->allocation.width - border_width * 2, + widget->allocation.height - border_width * 2); for (children = toolbar->children; children; children = children->next) { ----------------- Owen: This may be a better patch to your liking, GtkMenuBar needs the same fix to it's call to gtk_paint_box (). The problem is that you are only subtracting what you're adding, so the toolbar is still drawing over top of the handlebox on the bottom/right edges. The extra pixel hangoffs occur from the border_width and is the number of pixels that this is set to. If this patch is to be applied, rather than the first one, can we also change the default shadow_type to be GTK_SHADOW_NONE so that it at least doesn't look like crap by default, since the handlebox defaults to GTK_SHADOW_OUT? Pick which one patch you would rather commit to fix this bug, and I'll make a patch for GtkMenuBar also, and update the libbonoboui patch I made, to do the exact same thing. However, the best solution with this second patch is to make the default shadow be SHADOW_NONE. Thanks.
Created attachment 15303 [details] Screenshot showing the faulty toolbar border
In response to Owen's question: "What it does currently looks perfectly correct to me. Why do you think it is incorrect?" Have a look at the attached screenshot of Abiword for GTK2. I think it's obvious that the toolbar does indeed have too many bevels.
it's irrelevant to me that abiword has too many bevels. That simply isn't GTK+'s problem, and we can't go changing the the behavior of GTK+ in the middle of a stable release.
(I think Rodney's Dawes last patch is correct, and I'll likely apply that for 2.2.2, but I'm not changing the bevelling.)
Can I commit the last patch and another that fixes the same thing in GtkMenuBar so that everything is consistent and the offset math bugs are fixed? Thanks.
Hello? Is that an approval to commit the toolbar patch?
Two questions: - GtkMenuBar has the same bug? Where? gtk_paint_box (widget->style, widget->window, GTK_WIDGET_STATE (widget), get_shadow_type (GTK_MENU_BAR (widget)), area, widget, "menubar", border, border, widget->allocation.width - border * 2, widget->allocation.height - border * 2); - Who sets the border_width on a toolbar? While I'll fix the bug, I can't imagine it will change the appearance of any applications.
OK, after some discussion with Soeren, we reverse-engineered that BonoboDockItem sets the border-width because in GTK+-1.2 that worked to make GTK+ not overlap toolbar buttons over the toolbar bevel. Thu Jun 5 19:24:33 2003 Owen Taylor <otaylor@redhat.com> * gtk/gtktoolbar.c (gtk_toolbar_expose): Subtract off twice the border width from the width/height, not 1x the border width. (#106336, Rodney Dawes)