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 680953 - [regression] set_item_width / text wrapping doesn't work in iconviews in GTK3
[regression] set_item_width / text wrapping doesn't work in iconviews in GTK3
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkIconView
3.4.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 646055 (view as bug list)
Depends on:
Blocks: 541424 679758 682886
 
 
Reported: 2012-08-01 08:09 UTC by Jean-François Fortin Tam
Modified: 2013-09-18 10:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sample python code (32.83 KB, text/x-python)
2012-08-01 08:09 UTC, Jean-François Fortin Tam
  Details
screenshot in gtk2 (132.12 KB, image/png)
2012-08-01 08:12 UTC, Jean-François Fortin Tam
  Details
screenshot in gtk3 (92.45 KB, image/png)
2012-08-01 08:12 UTC, Jean-François Fortin Tam
  Details
Patch (1.12 KB, patch)
2012-09-30 11:11 UTC, Carlos Garcia Campos
accepted-commit_now Details | Review

Description Jean-François Fortin Tam 2012-08-01 08:09:07 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
Comment 1 Jean-François Fortin Tam 2012-08-01 08:12:02 UTC
Created attachment 220040 [details]
screenshot in gtk2
Comment 2 Jean-François Fortin Tam 2012-08-01 08:12:22 UTC
Created attachment 220041 [details]
screenshot in gtk3
Comment 3 Matthias Clasen 2012-08-04 20:17:23 UTC
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.
Comment 4 Jean-François Fortin Tam 2012-08-10 19:25:50 UTC
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
Comment 5 Jean-François Fortin Tam 2012-08-10 21:03:36 UTC
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...
Comment 6 Jean-François Fortin Tam 2012-08-28 06:40:06 UTC
Ok, we've now used our own cellrenderer in pitivi, which solves our problem. However, should this bug stay open/be considered valid still?
Comment 7 Carlos Garcia Campos 2012-09-30 11:03:15 UTC
This is because in adjust_wrap_width() a fixed size is set for the text cell ignoring the item width.
Comment 8 Carlos Garcia Campos 2012-09-30 11:11:41 UTC
Created attachment 225418 [details] [review]
Patch
Comment 9 Carlos Garcia Campos 2012-10-05 16:07:23 UTC
*** Bug 646055 has been marked as a duplicate of this bug. ***
Comment 10 logari81 2013-04-30 07:49:14 UTC
could this be related to Bug #570152 ?
Comment 11 Matthias Clasen 2013-08-26 15:59:29 UTC
Review of attachment 225418 [details] [review]:

patch looks fine, according to  Benjamin
Comment 12 Benjamin Otte (Company) 2013-08-26 16:34:40 UTC
Pushed https://git.gnome.org/browse/gtk+/commit/?id=247ebbd17c70d2fe82b48d857549ceeeaad500ff

I hope that fixes it. Please reopen if not.
Comment 13 Victor Ananjevsky 2013-09-18 10:40:26 UTC
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