GNOME Bugzilla – Bug 410815
Icon view gets confused when scaling down the pixbuf column
Last modified: 2007-06-12 09:28:14 UTC
Steps to reproduce it: 1. Create a GtkIconView as usual defining the text and the pixbuf columns; 2. Set a model to GtkIconView; 3. After having everything in place, change the pixbuf column values with a very small pixbuf; 4. The GtkIconView will get confused about the item's height and will actually increase (!) the height of the how instead of decrease it. I hacked a litle bit the code and it seems the problem is happening in GtkCellRendererText in a Pango call. More specifically, for some reason pango_layout_get_pixel_extents() returns a weird height value when the pixbuf column is too small.
Please see bug 406269 for more examples of this problem.
Created attachment 86493 [details] Testcase for this bug
From some first looks it seems to me that the call to adjust_wrap_width() in gtk_icon_view_set_cell_data() is messing up the layouting process. gtk_icon_view_set_cell_data() is called multiple times for an item (also during the second pass of the layouting process), so adjust_wrap_width() is also run when not necessary. I've seen the wrap-width being changed during the second pass of the layouting process, which clearly also affects the height -- the result is a mislayouted icon view. As far as I can see GtkCellRendererText is behaving correctly. I am still working on a patch, it is somewhat more involved that I anticipated ;)
Hei Kristian, just to let you know: this bug is not reproducible in GTK+ 2.6.
(In reply to comment #4) > Hei Kristian, just to let you know: this bug is not reproducible in GTK+ 2.6. That doesn't surprise me much, since if I turn off the automatic word wrapping the bug is not visible ;) A good share of problems seem to have been introduced in the icon view since 2.6, also in other (but probably related) areas.
Created attachment 88615 [details] [review] patch? Okay, I fooled a bit around with this code: - Got rid of the call to adjust_wrap_width() in _set_cell_data(), since that is messing stuff up badly as mentioned in one of my earlier comments. - Instead gtk_icon_view_layout() does a single call to adjust_wrap_width(), using the data of the first item. (I do not know how well this works with differently sized pixbufs, does GtkIconView actually work well at all with that? :) ) - Modified adjust_wrap_width() to honor the fixed item width, if set. - update_text_cell() shouldn't be setting wrap-width on the new cell renderer, this will be done by adjust_wrap_width() in a subsequent run of gtk_icon_view_layout().
Lucas, I would love to know whether this patch improves things for you.
Hey Kris, it works nicely. I would only set the text cell's "yalign" property to 0.5 (in the horizontal case) so that the text gets vertically centered. Thanks!
Comment on attachment 86493 [details] Testcase for this bug Changed attachment to not be a patch.
> do not know how well this works with > differently sized pixbufs, does GtkIconView actually work well at all with > that? :) ) Would be good to add some small test for varying-size icons somewhere in tests/ I guess.
Is Fernando's testcase program enough?
(In reply to comment #11) > Is Fernando's testcase program enough? No, it does not test the icon view with several differently sized images at the same time. Matthias, could you review my patch from comment #6? It would be really nice to commit this ASAP since it does seem to improve things a bit, we can tackle the remaining issues at some later point.
Turns out the current icon view code is almost totally broken with differently sized icons anyway.
Fixed on trunk. Opened #446665 for tracking the "layout differently sized icons" bugs.