[Xfce4-commits] <postler:master> Complete based on any part of a name
Christian Dywan
noreply at xfce.org
Tue Dec 7 21:46:01 CET 2010
Updating branch refs/heads/master
to c4f83e0c73b95f61c71fd024ac4acc17829da034 (commit)
from e2c9750489385b2577726d8755f27e09ac7dca89 (commit)
commit c4f83e0c73b95f61c71fd024ac4acc17829da034
Author: Christian Dywan <christian at twotoasts.de>
Date: Tue Dec 7 21:46:31 2010 +0100
Complete based on any part of a name
postler/postler-composer.vala | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/postler/postler-composer.vala b/postler/postler-composer.vala
index 87b12f1..6226dc1 100644
--- a/postler/postler-composer.vala
+++ b/postler/postler-composer.vala
@@ -338,19 +338,27 @@ public class Postler.Composer : Gtk.Window {
var completion = new Gtk.EntryCompletion ();
completion.model = new Gtk.ListStore (1, typeof (string));
completion.text_column = 0;
+ completion.set_match_func ((completion, key, iter) => {
+ var model = entry.get_completion ().model as Gtk.ListStore;
+ string? contact;
+ model.get (iter, 0, out contact);
+ if (contact == null)
+ return false;
+ string? normalized = contact.normalize (-1, NormalizeMode.ALL);
+ if (normalized != null) {
+ string? casefolded = normalized.casefold (-1);
+ if (casefolded != null)
+ return key in casefolded;
+ }
+ return false;
+ });
completion.inline_completion = true;
completion.inline_selection = true;
entry.set_completion (completion);
entry.changed.connect ((editable) => {
- long input_length = entry.text.length;
- if (input_length < 3)
+ if (entry.text.length < 3)
return;
var model = entry.get_completion ().model as Gtk.ListStore;
- long model_length = model.iter_n_children (null);
- if (model_length > 0 && input_length < 4)
- model.clear ();
- if (model_length > 0 || input_length > 3)
- return;
model.clear ();
string[] contacts = dexter.search_contacts (entry.text);
foreach (string contact in contacts) {
More information about the Xfce4-commits
mailing list