diff options
Diffstat (limited to 'addressbook/gui/component/select-names')
3 files changed, 48 insertions, 37 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 5f87144510..aa1bf7e2e3 100644 --- a/addressbook/gui/component/select-names/e-select-names-completion.c +++ b/addressbook/gui/component/select-names/e-select-names-completion.c @@ -97,11 +97,14 @@ match_nickname (ESelectNamesCompletion *comp, EDestination *dest, double *score) if (card->nickname && !g_strncasecmp (comp->priv->query_text, card->nickname, len)) { + gchar *name = e_card_name_to_string (card->name); + gchar *str; *score = len * 10; /* nickname gives 10 points per matching character */ - return g_strdup_printf ("(%s) %s %s", card->nickname, card->name->given, card->name->family); - + str = g_strdup_printf ("(%s) %s", card->nickname, name); + g_free (name); + return str; } return NULL; @@ -125,8 +128,12 @@ match_email (ESelectNamesCompletion *comp, EDestination *dest, double *score) const gchar *email = e_destination_get_email (dest); if (email && !g_strncasecmp (comp->priv->query_text, email, len)) { + gchar *name, *str; *score = len * 2; /* 2 points for each matching character */ - return g_strdup_printf ("<%s> %s %s", email, card->name->given, card->name->family); + name = e_card_name_to_string (card->name); + str = g_strdup_printf ("<%s> %s", email, name); + g_free (name); + return str; } return NULL; @@ -693,7 +700,9 @@ struct _SearchOverride { const gchar *text[4]; }; static SearchOverride override[] = { - { "easter egg", { "This is the sample", "Easter Egg text for", "Evolution.", NULL } }, + { "why?", { "\"I must create a system, or be enslaved by another man's.\"", + " -- Wiliam Blake, \"Jerusalem\"", + NULL } }, { NULL, { NULL } } }; static gboolean @@ -711,6 +720,7 @@ e_select_names_completion_begin (ECompletion *comp, const gchar *text, gint pos, ESelectNamesCompletion *selcomp = E_SELECT_NAMES_COMPLETION (comp); const gchar *str; gint index, j; + gchar *s, *t; g_return_if_fail (comp != NULL); g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp)); @@ -751,6 +761,18 @@ e_select_names_completion_begin (ECompletion *comp, const gchar *text, gint pos, g_free (selcomp->priv->pending_query_text); selcomp->priv->pending_query_text = g_strdup (str); + + /* Strip problematic characters out of query text. */ + s = t = selcomp->priv->pending_query_text; + while (*s) { + if (*s != ',' && *s != '"') { + if (s != t) + *t = *s; + ++t; + } + ++s; + } + *t = '\0'; e_select_names_completion_do_query (selcomp); } diff --git a/addressbook/gui/component/select-names/e-select-names-popup.c b/addressbook/gui/component/select-names/e-select-names-popup.c index 23898a3079..85c2489b1a 100644 --- a/addressbook/gui/component/select-names/e-select-names-popup.c +++ b/addressbook/gui/component/select-names/e-select-names-popup.c @@ -31,8 +31,6 @@ #include <addressbook/contact-editor/e-contact-quick-add.h> #include "e-select-names-popup.h" -static FILE *out = NULL; - typedef struct _PopupInfo PopupInfo; struct _PopupInfo { ESelectNamesModel *model; @@ -64,9 +62,6 @@ popup_info_free (PopupInfo *info) { if (info) { - if (out) - fprintf (out, "popup_info_free\n"); - if (info->model) gtk_object_unref (GTK_OBJECT (info->model)); @@ -103,8 +98,6 @@ change_email_num_cb (GtkWidget *w, gpointer user_data) return; n = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (w), "number")); - if (out) - fprintf (out, "replacing %d\n", n); if (n != e_destination_get_email_num (info->dest)) { dest = e_destination_new (); @@ -157,9 +150,6 @@ popup_menu_card (PopupInfo *info) EIterator *iterator; gchar *name_str; - if (out) - fprintf (out, "popup_menu_card\n"); - /* * Build up our GnomeUIInfo array. */ @@ -236,9 +226,6 @@ popup_menu_card (PopupInfo *info) } } - if (out) - fprintf (out, "leaving popup_menu_card\n"); - return pop; } @@ -246,8 +233,7 @@ static void quick_add_cb (GtkWidget *w, gpointer user_data) { PopupInfo *info = (PopupInfo *) user_data; - e_contact_quick_add (NULL, e_destination_get_string (info->dest), - NULL, NULL); + e_contact_quick_add_free_form (e_destination_get_string (info->dest), NULL, NULL); } static GtkWidget * @@ -301,15 +287,6 @@ e_select_names_popup (ESelectNamesModel *model, GdkEventButton *ev, gint pos) g_return_if_fail (ev); g_return_if_fail (0 <= pos); - if (out == NULL) { - out = fopen ("/tmp/evo-debug-select-names-popup", "w"); - if (out) - setvbuf (out, NULL, _IONBF, 0); - } - - if (out) - fprintf (out, "\n\ne_select_names_popup\n"); - e_select_names_model_text_pos (model, pos, &index, NULL, NULL); if (index < 0 || index >= e_select_names_model_count (model)) return; @@ -328,9 +305,6 @@ e_select_names_popup (ESelectNamesModel *model, GdkEventButton *ev, gint pos) GTK_SIGNAL_FUNC (popup_info_cleanup), info); - if (out) - fprintf (out, "doing popup\n"); - gnome_popup_menu_do_popup (popup, NULL, NULL, ev, info); } else { @@ -338,8 +312,4 @@ e_select_names_popup (ESelectNamesModel *model, GdkEventButton *ev, gint pos) popup_info_free (info); } - - if (out) - fprintf (out, "leaving e_select_names_popup\n\n"); - } diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.c b/addressbook/gui/component/select-names/e-select-names-text-model.c index d66112d2bc..0e4d5eeb32 100644 --- a/addressbook/gui/component/select-names/e-select-names-text-model.c +++ b/addressbook/gui/component/select-names/e-select-names-text-model.c @@ -125,7 +125,7 @@ dump_model (ESelectNamesTextModel *text_model) if (out == NULL) return; - + fprintf (out, "\n*** Model State: count=%d\n", e_select_names_model_count (model)); for (i=0; i<e_select_names_model_count (model); ++i) @@ -297,6 +297,7 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha for (i = 0; i < length && text[i]; ++i) { gint index, start_pos, text_len; + gboolean inside_quote = FALSE; if (out) fprintf (out, "processing [%c]\n", text[i]); @@ -306,8 +307,26 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha if (out) fprintf (out, "index=%d start_pos=%d text_len=%d\n", index, start_pos, text_len); + if (text[i] == ',' && index >= 0) { /* Is this a quoted or an unquoted comma we are dealing with? */ + const EDestination *dest = e_select_names_model_get_destination (source, index); + if (dest) { + const gchar *str = e_destination_get_string (dest); + gint j; + if (out) + fprintf (out, "str=%s pos=%d\n", str, pos); + for (j=0; j<pos-start_pos && str[j]; ++j) + if (str[j] == '"') { + inside_quote = !inside_quote; + if (out) + fprintf (out, "flip to %d at %d\n", start_pos+j, inside_quote); + } + } + if (out) + fprintf (out, inside_quote ? "inside quote\n" : "not inside quote\n"); + } + - if (text[i] == ',') { + if (text[i] == ',' && !inside_quote) { /* This is the case of hitting , first thing in an empty entry */ if (index == -1) { |