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 562701 - GtkEntryCompletion popup sizes its rows wrong when they span for more than one line
GtkEntryCompletion popup sizes its rows wrong when they span for more than on...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.14.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 541782
 
 
Reported: 2008-11-29 18:18 UTC by Diego Escalante Urrelo (not reading bugmail)
Modified: 2009-01-15 09:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
video of the bug (104.65 KB, video/ogg)
2008-11-29 18:22 UTC, Diego Escalante Urrelo (not reading bugmail)
  Details
Python testcase (339 bytes, text/x-python)
2008-11-29 18:23 UTC, Diego Escalante Urrelo (not reading bugmail)
  Details
[PATCH] Don't assume actions and results have equal height (2.09 KB, patch)
2009-01-13 21:26 UTC, Diego Escalante Urrelo (not reading bugmail)
committed Details | Review

Description Diego Escalante Urrelo (not reading bugmail) 2008-11-29 18:18:36 UTC
See the attached python example. You'll see that the only line in the model is:
'A single entry with two lines (separated with \\n)\nline2'

This should be shown as:
'A single entry with two lines (separated with \n)
line2'

Instead, it's shown as if the row was 1 line tall, when a second draw is triggered, it's correctly sized.
See screenshot, example.
Comment 1 Diego Escalante Urrelo (not reading bugmail) 2008-11-29 18:22:26 UTC
Created attachment 123652 [details]
video of the bug
Comment 2 Diego Escalante Urrelo (not reading bugmail) 2008-11-29 18:23:26 UTC
Created attachment 123653 [details]
Python testcase
Comment 3 Alexander “weej” Jones 2008-11-30 03:24:30 UTC
Have been seeing bugs like this in Empathy/Gossip contact list and the update manager's package list in Ubuntu. I wonder if they are related. Good work on the test case dieguitoooo!
Comment 4 Diego Escalante Urrelo (not reading bugmail) 2009-01-13 21:24:08 UTC
Ok I found gtk_cell_renderer_text_set_fixed_height_from_font() :-). Good thing is that it fixes this problem (which turns out is not precisely a problem).
I'll explain what I understood from the code:

 - the completion popup is sized taking into account the number of items and the height of each item
 - the height of the item is reported by the cell renderer, it will get it wrong the first time if it's more than one line tall
 - specifying the height "in text lines" with the mentioned function will allow the renderer to precisely know its size, hence working flawlessly

However I found that when you specify this, and have a lot of actions, the current formula produces negative numbers, after some thought I discovered that it's because it assumes actions and results to be the same height, which is not always true, like in my case.
My proposal is to fix the formula to this:

   if (y > monitor.height / 2)
-    items = MIN (matches, (monitor.y + y) / height - actions);
+    items = MIN (matches, (((monitor.y + y) - (actions * action_height)) / height) - 1);
   else
-    items = MIN (matches, (monitor.height - y) / height - 1  - actions);
+    items = MIN (matches, (((monitor.height - y) - (actions * action_height)) / height) - 1);

Which reads "from the available screen space we have, let's take the space needed by actions, now from what's left lets find out how many results we can fit. and now, let's leave one empty "row" so it looks nice".

Patch is really simple, attaching.
Comment 5 Diego Escalante Urrelo (not reading bugmail) 2009-01-13 21:26:50 UTC
Created attachment 126376 [details] [review]
[PATCH] Don't assume actions and results have equal height


This causes negative (invalid) size requisitions when results are more than one
line tall.

Fixes Bug 562701 – GtkEntryCompletion popup sizes its rows wrong when they span for
more than one line
---
 gtk/gtkentrycompletion.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
Comment 6 Christian Persch 2009-01-13 22:31:59 UTC
This looks reasonable to me. Can we please get this considered for 2.16 ?

+ g_debug("height: %d; items: %d", height, items);

Remove this :)
Comment 7 Matthias Clasen 2009-01-14 21:20:50 UTC
Makes sense to me.

Please commit with the debug spew removed.
Comment 8 Diego Escalante Urrelo (not reading bugmail) 2009-01-15 09:51:22 UTC
Committed to trunk.