GNOME Bugzilla – Bug 551589
GtkEntryCompletion does not always obeys the return value of match_func
Last modified: 2018-02-10 03:28:24 UTC
In epiphany, I wanted to limit the number of matches drawn, since the completion can't be told to call match_func ONLY until N matches are found, I wrapped my match_func with a count, so after N return values that were 'TRUE' i will return FALSE before anything happens, like this: static gboolean match_func_wrapper (GtkEntryCompletion *completion, const char *key, GtkTreeIter *iter, gpointer data) { gboolean ret = FALSE; EphyLocationEntryPrivate *priv = ((EphyLocationEntry *) data)->priv; if (priv->matches_count > MAX_MATCHES) return FALSE; ret = priv->match_func(completion, key, iter, data); if (ret) priv->matches_count++; return ret; } Yes yes, matches_count begins as 0 and etc etc, this is just the real life snippet i wanted to show, I'm attaching a python testcase that shows the bug. The bug: after adding this "early return", the completion popup held only 1 result no matter there were more matches. Only in the second loop of match_func it would show all the MAX_MATCHES matches. Like this: User types: 'e': | e | ------------------- |http://e.com | ----------------- User deletes 'e', types 'e' again: | e | ------------------- |http://e.com | |http://e2.com | |http://e3.com | |http://e4.com | |http://e5.com | ----------------- See attached python test. Try writing 't' (that is supposed to show all the matches up to the set limit) and you'll see just 1 match, now delete and try again and you'll see N-1 matches, the last return True is being ignored.
Created attachment 118396 [details] Test showing the bug
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.