Fix wrong address book contact in message list's From column and potentially
authorwwp <wwp@free.fr>
Mon, 28 Apr 2014 15:53:03 +0000 (17:53 +0200)
committerwwp <wwp@free.fr>
Mon, 28 Apr 2014 15:53:03 +0000 (17:53 +0200)
at other places. The AB completion engine won't use submatching by default,
it will only use it when completion is requested by a human operator
(compose window, few other GUI location). Updated the doc accordingly.

manual/advanced.xml
src/addr_compl.c

index 1776d14fe7ae78cd475aa051160874b9c0061c10..8a17cdc754fcf0365f8679e9254bf4e38c2b92e4 100644 (file)
        <term><literal>address_search_wildcard</literal></term>
        <listitem>
          <para>
-       TAB-address completion in the Compose window will match any part of the
+       TAB-address completion in the Compose window and other GUI places will match any part of the
        string (1) or just the start of the string (0).
          </para>
        </listitem>
index 407e6267fe12ff6fe5d2e142e30cf5d4606918c9..104ce6661f8e73d5eb96230aa713ae6d7d1cae3f 100644 (file)
@@ -179,11 +179,20 @@ static gint addr_completion_func(const gchar *needle, const gchar *haystack,
 static void init_all(void)
 {
        g_completion = g_completion_new(completion_func);
-       if (prefs_common.address_search_wildcard)
-               g_completion_set_compare(g_completion, addr_completion_func);
        cm_return_if_fail(g_completion != NULL);
 }
 
+/**
+ * set the compare function (default is strncmp)
+ */
+static void set_match_any_part(const gboolean any_part)
+{
+       if (any_part && prefs_common.address_search_wildcard)
+               g_completion_set_compare(g_completion, addr_completion_func);
+       else
+               g_completion_set_compare(g_completion, strncmp);
+}
+
 static void free_all_addresses(void)
 {
        GList *walk;
@@ -1179,6 +1188,7 @@ static void completion_window_apply_selection(GtkTreeView *list_view,
 void address_completion_start(GtkWidget *mainwindow)
 {
        start_address_completion(NULL);
+       set_match_any_part(TRUE);
 
        /* register focus change hook */
        g_signal_connect(G_OBJECT(mainwindow), "set_focus",