From b6d54c7762636036e6b9173ef8c40befd5ddd1d8 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Sun, 10 Mar 2002 01:47:02 +0000 Subject: since I've gone ahead and made the file backend (by way of 2002-03-09 Chris Toshok * gui/widgets/e-addressbook-view.c (jump_to_letter): since I've gone ahead and made the file backend (by way of pas-backend-card-sexp.c) use case insensitive searches for beginswith, there's no need to list upper and lower case here. * gui/component/addressbook.c (addressbook_search_option_items): reorder things to put "Any field contains" at the end, since it's the least efficient search. Also reorder the enum to the same ordering. Change "Name contains" to "Name begins with" and change "Email contains" to "Email is". (addressbook_search_activated): change FULL_NAME to beginswith, and change EMAIL to is to match the labels. * backend/pas/pas-backend-card-sexp.c (compare_name): new function, so we can compare both full and family names (so beginswith can operate on them both.) (endswith_helper): use e_utf8_strstrcase here, since all the backends backends use case insensitive searching. (func_endswith): same. svn path=/trunk/; revision=16004 --- addressbook/backend/pas/pas-backend-card-sexp.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'addressbook/backend') diff --git a/addressbook/backend/pas/pas-backend-card-sexp.c b/addressbook/backend/pas/pas-backend-card-sexp.c index 8b531d5ede..ea217fa052 100644 --- a/addressbook/backend/pas/pas-backend-card-sexp.c +++ b/addressbook/backend/pas/pas-backend-card-sexp.c @@ -70,6 +70,23 @@ compare_phone (ECardSimple *card, const char *str, return FALSE; } +static gboolean +compare_name (ECardSimple *card, const char *str, + char *(*compare)(const char*, const char*)) +{ + const char *name; + + name = e_card_simple_get_const (card, E_CARD_SIMPLE_FIELD_FULL_NAME); + if (name && compare (name, str)) + return TRUE; + + name = e_card_simple_get_const (card, E_CARD_SIMPLE_FIELD_FAMILY_NAME); + if (name && compare (name, str)) + return TRUE; + + return FALSE; +} + static gboolean compare_address (ECardSimple *card, const char *str, char *(*compare)(const char*, const char*)) @@ -157,7 +174,7 @@ static struct prop_info { /* query prop, ecard prop, type, list compare function */ NORMAL_PROP ( E_CARD_SIMPLE_FIELD_FILE_AS, "file_as", "file_as" ), - NORMAL_PROP ( E_CARD_SIMPLE_FIELD_FULL_NAME, "full_name", "full_name" ), + LIST_PROP ( "full_name", "full_name", compare_name), /* not really a list, but we need to compare both full and surname */ NORMAL_PROP ( E_CARD_SIMPLE_FIELD_URL, "url", "url" ), NORMAL_PROP ( E_CARD_SIMPLE_FIELD_MAILER, "mailer", "mailer"), NORMAL_PROP ( E_CARD_SIMPLE_FIELD_ORG, "org", "org"), @@ -280,7 +297,7 @@ static char * endswith_helper (const char *s1, const char *s2) { char *p; - if ((p = strstr(s1, s2)) + if ((p = (char*)e_utf8_strstrcase(s1, s2)) && (strlen(p) == strlen(s2))) return p; else @@ -299,7 +316,7 @@ static char * beginswith_helper (const char *s1, const char *s2) { char *p; - if ((p = strstr(s1, s2)) + if ((p = (char*)e_utf8_strstrcase(s1, s2)) && (p == s1)) return p; else -- cgit v1.2.3