aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-09-27 03:40:02 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-09-27 03:40:02 +0800
commit31f1562d1435fd8b99f9b7f5b19bc93b3210bab4 (patch)
tree56f9c3f410cc7b24637c57b777553c19fa0b951e /addressbook/gui
parent56b24983e2413d5863442af43f10150808a8a56f (diff)
downloadgsoc2013-evolution-31f1562d1435fd8b99f9b7f5b19bc93b3210bab4.tar
gsoc2013-evolution-31f1562d1435fd8b99f9b7f5b19bc93b3210bab4.tar.gz
gsoc2013-evolution-31f1562d1435fd8b99f9b7f5b19bc93b3210bab4.tar.bz2
gsoc2013-evolution-31f1562d1435fd8b99f9b7f5b19bc93b3210bab4.tar.lz
gsoc2013-evolution-31f1562d1435fd8b99f9b7f5b19bc93b3210bab4.tar.xz
gsoc2013-evolution-31f1562d1435fd8b99f9b7f5b19bc93b3210bab4.tar.zst
gsoc2013-evolution-31f1562d1435fd8b99f9b7f5b19bc93b3210bab4.zip
Properly handle names when the individual elements (given, addition,
2001-09-26 Jon Trowbridge <trow@ximian.com> * backend/ebook/e-card-compare.c (e_card_compare_name_to_string): Properly handle names when the individual elements (given, addition, family) contain whitespace. (Bug #10502) * backend/ebook/e-destination.c (e_destination_set_name): Reset textrep when we change the name. (e_destination_set_email): Reset textrep when we change the email. (e_destination_get_textrep): Make sure that the textrep version of the address is properly quoted if it contains unsafe characters. (All related to bug #10796) * gui/component/select-names/e-select-names-completion.c (match_nickname): Fix nickname matching. (bug #9698) (make_match): Use e_completion_match_new when building our match, rather than ad hoc manipulation of the struct. svn path=/trunk/; revision=13158
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/component/select-names/e-select-names-completion.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/addressbook/gui/component/select-names/e-select-names-completion.c b/addressbook/gui/component/select-names/e-select-names-completion.c
index 49a3ecf4b2..1e9027e8fc 100644
--- a/addressbook/gui/component/select-names/e-select-names-completion.c
+++ b/addressbook/gui/component/select-names/e-select-names-completion.c
@@ -102,14 +102,13 @@ our_match_destroy (ECompletionMatch *match)
static ECompletionMatch *
make_match (EDestination *dest, const gchar *menu_form, double score)
{
- ECompletionMatch *match = g_new0 (ECompletionMatch, 1);
+ ECompletionMatch *match;
ECard *card = e_destination_get_card (dest);
- e_completion_match_construct (match);
+ match = e_completion_match_new (e_destination_get_name (dest), menu_form, score);
e_completion_match_set_text (match, e_destination_get_name (dest), menu_form);
match->sort_major = card ? floor (e_card_get_use_score (card)) : 0;
- match->score = score;
match->sort_minor = e_destination_get_email_num (dest);
match->user_data = dest;
@@ -127,8 +126,9 @@ make_match (EDestination *dest, const gchar *menu_form, double score)
static gchar *
sexp_nickname (ESelectNamesCompletion *comp)
{
- return g_strdup_printf ("(beginswith \"nickname\" \"%s\")", comp->priv->query_text);
+ gchar *query = g_strdup_printf ("(beginswith \"nickname\" \"%s\")", comp->priv->query_text);
+ return query;
}
static ECompletionMatch *
@@ -139,19 +139,25 @@ match_nickname (ESelectNamesCompletion *comp, EDestination *dest)
ECard *card = e_destination_get_card (dest);
double score;
- len = strlen (comp->priv->query_text);
+ if (card->nickname == NULL)
+ return NULL;
- if (card->nickname
- && !g_utf8_strncasecmp (comp->priv->query_text, card->nickname, len)) {
- ECompletionMatch *match;
+ len = MIN (strlen (card->nickname), strlen (comp->priv->query_text));
+
+ if (card->nickname && !g_utf8_strncasecmp (comp->priv->query_text, card->nickname, len)) {
+ const gchar *name;
gchar *str;
-
- score = len * 10; /* nickname gives 10 points per matching character */
+
+ score = len * 2; /* nickname gives 2 points per matching character */
if (len == strlen (card->nickname)) /* boost score on an exact match */
score *= 10;
- str = g_strdup_printf ("(%s) %s <%s>", card->nickname, e_destination_get_name (dest), e_destination_get_email (dest));
+ name = e_destination_get_name (dest);
+ if (name && *name)
+ str = g_strdup_printf ("'%s' %s <%s>", card->nickname, name, e_destination_get_email (dest));
+ else
+ str = g_strdup_printf ("'%s' <%s>", card->nickname, e_destination_get_email (dest));
match = make_match (dest, str, score);
g_free (str);
@@ -565,8 +571,9 @@ book_query_score (ESelectNamesCompletion *comp, EDestination *dest)
ECompletionMatch *this_match = NULL;
if (book_queries[i].primary || !comp->priv->primary_only) {
- if (book_queries[i].tester && e_destination_get_card (dest))
+ if (book_queries[i].tester && e_destination_get_card (dest)) {
this_match = book_queries[i].tester (comp, dest);
+ }
if (this_match) {
if (best_match == NULL || this_match->score > best_match->score) {
@@ -1236,3 +1243,4 @@ e_select_names_completion_set_match_contact_lists (ESelectNamesCompletion *comp,
g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp));
comp->priv->match_contact_lists = x;
}
+