In compose window, allow address completion to match any part of address, not just...
authorAndrej Kacian <ticho@claws-mail.org>
Thu, 12 Dec 2013 17:18:23 +0000 (18:18 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Thu, 12 Dec 2013 17:18:23 +0000 (18:18 +0100)
src/addr_compl.c

index d7467aa..ed73557 100644 (file)
@@ -164,12 +164,22 @@ static gchar *completion_func(gpointer data)
        return ((completion_entry *)data)->string;
 } 
 
+static gint addr_completion_func(const gchar *needle, const gchar *haystack,
+               gsize n)
+{
+       if (needle == NULL || haystack == NULL)
+               return 1;
+
+       return (strcasestr(haystack, needle) != NULL ? 0 : 1);
+}
+
 /**
  * Initialize all completion index data.
  */
 static void init_all(void)
 {
        g_completion = g_completion_new(completion_func);
+       g_completion_set_compare(g_completion, addr_completion_func);
        cm_return_if_fail(g_completion != NULL);
 }