]> git.0d.be Git - empathy.git/commitdiff
[EmpathyContactSelectorDialog] normalise case in match function
authorDanielle Madeley <danielle.madeley@collabora.co.uk>
Fri, 18 Dec 2009 06:53:51 +0000 (17:53 +1100)
committerDanielle Madeley <danielle.madeley@collabora.co.uk>
Fri, 18 Dec 2009 23:48:56 +0000 (10:48 +1100)
libempathy-gtk/empathy-contact-selector-dialog.c

index d0246e86b031f627d3523d0c88cf40c9079c54b4..2793567f12cad62d67ec7caed984acab10ad7219 100644 (file)
@@ -167,32 +167,38 @@ contact_selector_dialog_match_func (GtkEntryCompletion *completion,
     gpointer user_data)
 {
   GtkTreeModel *model;
-  gchar *id;
-  gchar *name;
+  gchar *str, *lower;
+  gboolean v = FALSE;
 
   model = gtk_entry_completion_get_model (completion);
   if (!model || !iter)
     return FALSE;
 
-  gtk_tree_model_get (model, iter, COMPLETION_COL_NAME, &name, -1);
-  if (strstr (name, key))
+  gtk_tree_model_get (model, iter, COMPLETION_COL_NAME, &str, -1);
+  lower = g_utf8_strdown (str, -1);
+  if (strstr (lower, key))
     {
-      DEBUG ("Key %s is matching name **%s**", key, name);
-      g_free (name);
-      return TRUE;
+      DEBUG ("Key %s is matching name **%s**", key, str);
+      v = TRUE;
+      goto out;
     }
-  g_free (name);
+  g_free (str);
+  g_free (lower);
 
-  gtk_tree_model_get (model, iter, COMPLETION_COL_ID, &id, -1);
-  if (strstr (id, key))
+  gtk_tree_model_get (model, iter, COMPLETION_COL_ID, &str, -1);
+  lower = g_utf8_strdown (str, -1);
+  if (strstr (lower, key))
     {
-      DEBUG ("Key %s is matching ID **%s**", key, id);
-      g_free (id);
-      return TRUE;
+      DEBUG ("Key %s is matching ID **%s**", key, str);
+      v = TRUE;
+      goto out;
     }
-  g_free (id);
 
-  return FALSE;
+out:
+  g_free (str);
+  g_free (lower);
+
+  return v;
 }
 
 static void