GNOME Bugzilla – Bug 562701
GtkEntryCompletion popup sizes its rows wrong when they span for more than one line
Last modified: 2009-01-15 09:51:22 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.
Created attachment 123652 [details] video of the bug
Created attachment 123653 [details] Python testcase
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!
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.
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(-)
This looks reasonable to me. Can we please get this considered for 2.16 ? + g_debug("height: %d; items: %d", height, items); Remove this :)
Makes sense to me. Please commit with the debug spew removed.
Committed to trunk.