After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 410815 - Icon view gets confused when scaling down the pixbuf column
Icon view gets confused when scaling down the pixbuf column
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkIconView
2.10.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2007-02-22 14:35 UTC by Lucas Rocha
Modified: 2007-06-12 09:28 UTC
See Also:
GNOME target: ---
GNOME version: 2.17/2.18


Attachments
Testcase for this bug (5.25 KB, text/plain)
2007-04-17 12:22 UTC, Fernando Herrera
  Details
patch? (2.84 KB, patch)
2007-05-22 14:58 UTC, Kristian Rietveld
committed Details | Review

Description Lucas Rocha 2007-02-22 14:35:28 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.
Comment 1 Jose M. daLuz 2007-03-02 03:50:56 UTC
Please see bug 406269 for more examples of this problem.
Comment 2 Fernando Herrera 2007-04-17 12:22:31 UTC
Created attachment 86493 [details]
Testcase for this bug
Comment 3 Kristian Rietveld 2007-04-25 07:52:51 UTC
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 ;)
Comment 4 Lucas Rocha 2007-04-25 10:16:56 UTC
Hei Kristian, just to let you know: this bug is not reproducible in GTK+ 2.6.
Comment 5 Kristian Rietveld 2007-04-25 10:20:48 UTC
(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.
Comment 6 Kristian Rietveld 2007-05-22 14:58:44 UTC
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().
Comment 7 Kristian Rietveld 2007-05-22 15:01:27 UTC
Lucas, I would love to know whether this patch improves things for you.
Comment 8 Lucas Rocha 2007-05-25 13:16:27 UTC
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 9 Philip Withnall 2007-05-26 19:59:23 UTC
Comment on attachment 86493 [details]
Testcase for this bug

Changed attachment to not be a patch.
Comment 10 Matthias Clasen 2007-05-30 12:09:45 UTC
> 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.
Comment 11 Lucas Rocha 2007-06-08 12:42:11 UTC
Is Fernando's testcase program enough?
Comment 12 Kristian Rietveld 2007-06-11 13:43:51 UTC
(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.

Comment 13 Matthias Clasen 2007-06-11 15:51:12 UTC
Turns out the current icon view code is almost totally  broken with differently sized icons anyway.
Comment 14 Kristian Rietveld 2007-06-12 09:28:14 UTC
Fixed on trunk.  Opened #446665 for tracking the "layout differently sized icons" bugs.