aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog19
-rw-r--r--addressbook/gui/component/addressbook.c65
-rw-r--r--addressbook/gui/component/select-names/e-select-names-bonobo.c1
-rw-r--r--addressbook/gui/component/select-names/e-select-names-completion.c71
4 files changed, 82 insertions, 74 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index b2d7c8bc11..2cb8dc355a 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,22 @@
+2001-08-16 Jon Trowbridge <trow@ximian.com>
+
+ * gui/component/select-names/e-select-names-completion.c
+ (match_nickname): Boost scoring on an exact nickname match.
+ Manually addressify match.
+ (match_name): Manually addressify matches.
+ (book_query_score): Remove automatic addressification.
+
+ * gui/component/addressbook.c (addressbook_query_changed): Minor
+ tweak to avoid a crash if we have a negative subid with id
+ ESB_CATEGORY. This should never happen.
+ (addressbook_menu_activated): Reset the entry/option when we
+ select "Clear".
+ Some changes to reflect renaming in ESearchBar.
+
+ * gui/component/select-names/e-select-names-bonobo.c
+ (entry_set_property_fn): Cardify after importing destinations.
+ This might fix a problem that Damon is having.
+
2001-08-15 Chris Toshok <toshok@ximian.com>
* gui/component/addressbook-config.glade: set title of initial
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index c0acf414ad..e73a01164b 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -616,16 +616,6 @@ static ESearchBarItem addressbook_search_menu_items[] = {
{ NULL, -1, NULL },
};
-static void
-addressbook_menu_activated (ESearchBar *esb, int id, AddressbookView *view)
-{
- switch (id) {
- case E_FILTERBAR_RESET_ID:
- e_addressbook_view_show_all(view->view);
- break;
- }
-}
-
enum {
ESB_ANY,
ESB_FULL_NAME,
@@ -643,11 +633,33 @@ static ESearchBarItem addressbook_search_option_items[] = {
{ NULL, -1, NULL }
};
-static ECategoriesMasterList *category_list = NULL;
+static void
+addressbook_menu_activated (ESearchBar *esb, int id, AddressbookView *view)
+{
+ switch (id) {
+ case E_FILTERBAR_RESET_ID:
+ /* e_addressbook_view_show_all(view->view); */
+
+ /* Fix option menu if we are using "Category is" */
+ if (e_search_bar_get_item_id (esb) == ESB_CATEGORY) {
+
+ e_search_bar_set_subitem_id (esb, G_MAXINT);
+
+ } else {
+
+ e_search_bar_set_text (esb, "");
+
+ }
+
+ break;
+ }
+}
static ECategoriesMasterList *
get_master_list (void)
{
+ static ECategoriesMasterList *category_list = NULL;
+
if (category_list == NULL)
category_list = e_categories_master_list_wombat_new ();
return category_list;
@@ -659,11 +671,11 @@ addressbook_query_changed (ESearchBar *esb, AddressbookView *view)
ECategoriesMasterList *master_list;
char *search_word, *search_query;
const char *category_name;
- int search_type, subopt;
+ int search_type, subid;
gtk_object_get(GTK_OBJECT(esb),
"text", &search_word,
- "option_choice", &search_type,
+ "item_id", &search_type,
NULL);
if (search_type == ESB_ADVANCED) {
@@ -685,17 +697,15 @@ addressbook_query_changed (ESearchBar *esb, AddressbookView *view)
search_word);
break;
case ESB_CATEGORY:
- subopt = e_search_bar_get_suboption_choice (esb);
- g_message ("subopt: %d", subopt);
- if (subopt >= 0) {
- if (subopt == G_MAXINT) {
- /* match everything */
- search_query = g_strdup ("(contains \"full_name\" \"\")");
- } else {
- master_list = get_master_list ();
- category_name = e_categories_master_list_nth (master_list, subopt);
- search_query = g_strdup_printf ("(contains \"category\" \"%s\")", category_name);
- }
+ subid = e_search_bar_get_subitem_id (esb);
+
+ if (subid < 0 || subid == G_MAXINT) {
+ /* match everything */
+ search_query = g_strdup ("(contains \"full_name\" \"\")");
+ } else {
+ master_list = get_master_list ();
+ category_name = e_categories_master_list_nth (master_list, subid);
+ search_query = g_strdup_printf ("(contains \"category\" \"%s\")", category_name);
}
break;
default:
@@ -705,9 +715,10 @@ addressbook_query_changed (ESearchBar *esb, AddressbookView *view)
} else
search_query = g_strdup ("(contains \"full_name\" \"\")");
- gtk_object_set (GTK_OBJECT(view->view),
- "query", search_query,
- NULL);
+ if (search_query)
+ gtk_object_set (GTK_OBJECT(view->view),
+ "query", search_query,
+ NULL);
g_free (search_query);
g_free (search_word);
diff --git a/addressbook/gui/component/select-names/e-select-names-bonobo.c b/addressbook/gui/component/select-names/e-select-names-bonobo.c
index 90b3e477fb..3130d1c9c9 100644
--- a/addressbook/gui/component/select-names/e-select-names-bonobo.c
+++ b/addressbook/gui/component/select-names/e-select-names-bonobo.c
@@ -149,6 +149,7 @@ entry_set_property_fn (BonoboPropertyBag *bag,
g_assert (model != NULL);
e_select_names_model_import_destinationv (model, BONOBO_ARG_GET_STRING (arg));
+ e_select_names_model_cardify_all (model, NULL, 0);
break;
}
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 8222ae86ad..d91c9e5274 100644
--- a/addressbook/gui/component/select-names/e-select-names-completion.c
+++ b/addressbook/gui/component/select-names/e-select-names-completion.c
@@ -120,33 +120,6 @@ make_match (EDestination *dest, const gchar *menu_form, double score)
return match;
}
-static void
-emailify_match (ECompletionMatch *match)
-{
- EDestination *dest = E_DESTINATION (match->user_data);
- ECard *card = e_destination_get_card (dest);
- const gchar *email = e_destination_get_email (dest);
- const gchar *menu_txt = e_completion_match_get_menu_text (match);
-
- if (card && email && !e_card_evolution_list (card)) {
-
- if (email
- && menu_txt
- && *menu_txt
- && *menu_txt != '<'
- && strstr (menu_txt, email) == NULL
- && menu_txt[strlen(menu_txt)-1] != '>') {
- gchar *tmp = g_strdup_printf ("%s <%s>", menu_txt, email);
- gchar *tmp2 = g_strdup (e_completion_match_get_match_text (match));
- e_completion_match_set_text (match, tmp2, tmp);
- g_free (tmp);
- g_free (tmp2);
- }
-
- match->sort_minor = e_destination_get_email_num (dest);
- }
-}
-
/*
* Nickname query
*/
@@ -169,14 +142,16 @@ match_nickname (ESelectNamesCompletion *comp, EDestination *dest)
if (card->nickname
&& !g_utf8_strncasecmp (comp->priv->query_text, card->nickname, len)) {
ECompletionMatch *match = g_new0 (ECompletionMatch, 1);
- gchar *name = e_card_name_to_string (card->name);
gchar *str;
score = len * 10; /* nickname gives 10 points per matching character */
- str = g_strdup_printf ("(%s) %s", card->nickname, name);
+
+ 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));
match = make_match (dest, str, score);
- g_free (name);
g_free (str);
}
@@ -198,27 +173,25 @@ match_email (ESelectNamesCompletion *comp, EDestination *dest)
{
ECompletionMatch *match;
gint len = strlen (comp->priv->query_text);
- ECard *card = e_destination_get_card (dest);
+ const gchar *name = e_destination_get_name (dest);
const gchar *email = e_destination_get_email (dest);
double score;
if (email
&& !g_utf8_strncasecmp (comp->priv->query_text, email, len)
&& !e_destination_is_evolution_list (dest)) {
-
- gchar *name, *str;
+
+ gchar *str;
score = len * 2; /* 2 points for each matching character */
- name = e_card_name_to_string (card->name);
if (name && *name)
- str = g_strdup_printf ("<%s> %s", email, name);
+ str = g_strdup_printf ("<%s> %s", name, email);
else
str = g_strdup (email);
match = make_match (dest, str, score);
- g_free (name);
g_free (str);
return match;
@@ -303,6 +276,7 @@ match_name (ESelectNamesCompletion *comp, EDestination *dest)
ECompletionMatch *final_match = NULL;
gchar *menu_text = NULL;
ECard *card;
+ const gchar *email;
gchar *cpy, **strv;
gint len, i, match_len = 0;
gint match = 0, first_match = 0;
@@ -314,6 +288,8 @@ match_name (ESelectNamesCompletion *comp, EDestination *dest)
if (card->name == NULL)
return NULL;
+ email = e_destination_get_email (dest);
+
cpy = g_strdup (comp->priv->query_text);
strv = g_strsplit (cpy, " ", 0);
@@ -382,7 +358,7 @@ match_name (ESelectNamesCompletion *comp, EDestination *dest)
} else if (first_match == MATCHED_GIVEN_NAME) {
if (have_family)
- menu_text = g_strdup_printf ("%s %s", card->name->given, card->name->family);
+ menu_text = g_strdup_printf ("%s %s <%s>", card->name->given, card->name->family, email);
else
menu_text = g_strdup_printf (card->name->given);
@@ -390,30 +366,34 @@ match_name (ESelectNamesCompletion *comp, EDestination *dest)
if (have_family) {
- menu_text = g_strdup_printf ("%s, %s%s%s",
+ menu_text = g_strdup_printf ("%s, %s%s%s <%s>",
card->name->family,
have_given ? card->name->given : "",
have_given ? " " : "",
- card->name->additional);
+ card->name->additional,
+ email);
} else {
- menu_text = g_strdup_printf ("%s%s%s",
+ menu_text = g_strdup_printf ("%s%s%s <%s>",
have_given ? card->name->given : "",
have_given ? " " : "",
- card->name->additional);
+ card->name->additional,
+ email);
}
} else if (first_match == MATCHED_FAMILY_NAME) {
if (have_given)
- menu_text = g_strdup_printf ("%s, %s %s",
+ menu_text = g_strdup_printf ("%s, %s%s%s <%s>",
card->name->family,
card->name->given,
- have_additional ? card->name->additional : "");
+ have_additional ? " " : "",
+ have_additional ? card->name->additional : "",
+ email);
else
- menu_text = g_strdup_printf (card->name->family);
+ menu_text = g_strdup_printf ("%s <%s>", card->name->family, email);
}
if (menu_text) {
@@ -536,9 +516,6 @@ book_query_score (ESelectNamesCompletion *comp, EDestination *dest)
}
}
- if (best_match)
- emailify_match (best_match);
-
return best_match;
}