GNOME Bugzilla – Bug 680953
[regression] set_item_width / text wrapping doesn't work in iconviews in GTK3
Last modified: 2013-09-18 10:40:26 UTC
Created attachment 220039 [details] sample python code I've have Pitivi running with pygi, GTK3, GStreamer 1.0... and I noticed that somehow the iconview totally ignores set_item_width. The branch for that is the "pygi" branch of https://github.com/nekohayo/pitivi/branches For your convenience, the effects.py file where this occurs is attached. <Company> the right thing to use would be set_fixed_width() on the cell renderer <Company> it should still be fixed, but ultimately we should deprecate it <nekohayo> fwiw this is what I had (that worked in gtk2): https://github.com/nekohayo/pitivi/blob/pygi/pitivi/effects.py#L445 (this is the gtk3 version running with gtkcompat for now). I'm not sure how you'd set that fixed width on the cell renderer in there <Company> it should just work in theory, assuming you enlarge - because shrinking isn't supported in GTK3 <nekohayo> hmm, even with this it doesn't work: self.iconview.set_text_column(COL_NAME_TEXT) iconview_cell = self.iconview.get_cells()[1] iconview_cell.props.wrap_width = 10 iconview_cell.set_fixed_size(10, -1) self.iconview.set_item_width(50) <Company> looks like it's broken then
Created attachment 220040 [details] screenshot in gtk2
Created attachment 220041 [details] screenshot in gtk3
Not sure I fully understand what the problem here is, but testiconview in the gtk tree clearly shows text wrapping to the item width working in an iconview. The first thing you should do is ditch the legacy set_text_column api, and add your own cell renderers instead. That is pretty much the first thing to do with any iconview issue.
Hi Matthias, there might be some sort of bug going on in the text wrapping/measurement algos though. It's a bit weird because it's not just a matter of having long-enough labels. For what it's worth, here's a screencast to demonstrate the problem: http://jeff.ecchi.ca/public/gtk-680953.webm
Additionally, I've been looking at http://python-gtk-3-tutorial.readthedocs.org/en/latest/iconview.html http://developer.gnome.org/gtk3/3.4/GtkIconView.html They both talk about using set_text_column, not cell renderers...
Ok, we've now used our own cellrenderer in pitivi, which solves our problem. However, should this bug stay open/be considered valid still?
This is because in adjust_wrap_width() a fixed size is set for the text cell ignoring the item width.
Created attachment 225418 [details] [review] Patch
*** Bug 646055 has been marked as a duplicate of this bug. ***
could this be related to Bug #570152 ?
Review of attachment 225418 [details] [review]: patch looks fine, according to Benjamin
Pushed https://git.gnome.org/browse/gtk+/commit/?id=247ebbd17c70d2fe82b48d857549ceeeaad500ff I hope that fixes it. Please reopen if not.
why you always doubled the item width, even if i set it manually? if i call gtk_icon_view_set_item_width (icon_view, 100), i assume that width of items will be 100 points, not 200 so please, apply the following patch to correct the wrong calculate of item width --- gtk+-3.8.4/gtk/gtkiconview.c.orig 2013-08-30 14:10:17.000000000 +0300 +++ gtk+-3.8.4/gtk/gtkiconview.c 2013-09-18 10:29:18.199311431 +0300 @@ -1424,7 +1424,7 @@ wrap_width = MAX (pixbuf_width * 2, 50); } - if (icon_view->priv->items && icon_view->priv->pixbuf_cell) + if (icon_view->priv->items && icon_view->priv->pixbuf_cell && icon_view->priv->item_width < 0) { /* Here we go with the same old guess, try the icon size and set double * the size of the first icon found in the list, naive but works much