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 570152 - gtk_icon_view_set_item_width acts unexpectedly in gtk+-2.15 (different than in 2.14)
gtk_icon_view_set_item_width acts unexpectedly in gtk+-2.15 (different than i...
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkIconView
2.15.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2009-02-01 22:53 UTC by logari81
Modified: 2018-02-10 03:36 UTC
See Also:
GNOME target: ---
GNOME version: 2.25/2.26


Attachments
testcase (961 bytes, text/x-csrc)
2009-02-01 22:54 UTC, logari81
Details
appearance with gtk+-2.14 (6.50 KB, image/png)
2009-02-01 22:55 UTC, logari81
Details
appearance with gtk+-2.15 (13.48 KB, image/png)
2009-02-01 22:56 UTC, logari81
Details

Description logari81 2009-02-01 22:53:30 UTC
Please describe the problem:
Because setting item width to -1 doesn't always achieve to arrange cells in an icon view correctly, I used to scan all the rows of my model to find the widest item and then set the item width of the icon view explicitly to this width.

This technique worked well until gtk+2-14. With gtk+2-15 I noticed that every column in my model got exactly the double width of the widest item in it.

Steps to reproduce:
1. Compile and run attached testcase.c
2. Run the TestCase executable in gtk+-2.14
3. Run the TestCase executable in gtk+-2.15


Actual results:
In gtk+-2.14 I see 3 columns of icons like in the attachment test214.png, whether with gtk+-2.15 I see one column of items with much unallocated space left and right of the pixbuf cell like in the attachment test215.png.

Expected results:
See the same behavior in gtk+-2.15 like in gtk+-2.14

Does this happen every time?
yes

Other information:
After debugging the problem in gtkiconview.c, I realized the new behavior is apparently due to the changes of the following ChangeLog entry:


2008-09-24  Denis Washington  <denisw@svn.gnome.org>

	* gtk/gtkiconview.c: draw focus as a rectangle around the
	complete item, not just the text. (Bug #38254)


Extra space of ITEM_PADDING=6 is allocated around the cell for the new frame around the cell. The problem I see here is that, on the one hand the user doesn't receive any information about this space allocation, for example in get_item_width. On the other hand he has to take this space in consideration when he uses set_item_width.

In my test example I generate a pattern of 16 squares with a dimension 150x150 and I expect to have the right to set the item_width of the iconview equal to 150. Unfortunately the icon width of 150 plus the frame of 2*ITEM_PADDING=12 yield to a required width of 162. If I try to set a width under 162 the iconview widget registers two columns (colspan=2) for my item resulting to the picture test215.png

Possible solution:

Use space from columns_spacing to draw the frame around the icon:
- leave ITEM_PADDING out of consideration in calculation of colspan
- use min(ITEM_PADDING,columns_spacing) instead of ITEM_PADDING to avoid overlapping
Comment 1 logari81 2009-02-01 22:54:22 UTC
Created attachment 127730 [details]
testcase
Comment 2 logari81 2009-02-01 22:55:47 UTC
Created attachment 127731 [details]
appearance with gtk+-2.14
Comment 3 logari81 2009-02-01 22:56:22 UTC
Created attachment 127732 [details]
appearance with gtk+-2.15
Comment 4 Matthias Clasen 2009-02-02 15:29:59 UTC
Denis, can you take a look at this ? 
(You committed the patch that leads to this behaviour change).
Comment 5 Denis Washington 2009-02-02 17:02:44 UTC
I will look into this when I find the time, which will probably be some time this week.
Comment 6 Gabriel Burt 2010-09-13 19:12:03 UTC
I believe the bug is located here: http://git.gnome.org/browse/gtk+/tree/gtk/gtkiconview.c#n2736 where we have

colspan = 1 + (item->width - 1) / (item_width + icon_view->priv->column_spacing);

item->width = colspan * item_width + (colspan - 1) * icon_view->priv->column_spacing;

The problem is colspan (looks to me like it) gets set to 2 in most cases, so then the item->width gets set to 2*item_width.  I hacked around this bug in PDF Mod by setting ItemWidth to -1 and instead setting the size by renderer.SetFixedSize (w, h), and then changing toggling icon_view.Orientation to trigger a invalide_sizes/queue_layout so that I could shrink things (otherwise would only grow, not shrink).
Comment 7 Denis Washington 2011-08-23 07:03:49 UTC
From running the test case, it seems that this is fixed in GTK+ 3.0, but the problem still persists in 2.24. If there will be another 2.x point release, I could look into it (I must admit that I forgot about the bug two years ago).
Comment 8 Matthias Clasen 2018-02-10 03:36:04 UTC
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and
still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue
for it.