From c442d00f9325bd84f28ed5965a7b2fc512b9b3b7 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 15 Oct 2009 19:40:28 +0200 Subject: Bug #449520 - Adding a contact to a contact list fails when using a comma --- .../contact-list-editor/e-contact-list-editor.c | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'addressbook/gui/contact-list-editor/e-contact-list-editor.c') diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index 73b5dcd7cf..79fef05f45 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -603,10 +603,35 @@ contact_list_editor_email_entry_key_press_event_cb (GtkWidget *widget, GdkEventKey *event) { EContactListEditor *editor; + gboolean can_comma = FALSE; editor = contact_list_editor_extract (widget); - if (event->keyval == GDK_comma || event->keyval == GDK_Return) { + if (event->keyval == GDK_comma) { + GtkEntry *entry; + gint cpos = -1; + + entry = GTK_ENTRY (WIDGET (EMAIL_ENTRY)); + g_object_get (G_OBJECT (entry), "cursor-position", &cpos, NULL); + + /* not the first letter */ + if (cpos > 0) { + const gchar *text; + gint quotes = 0, i; + + text = gtk_entry_get_text (entry); + + for (i = 0; text && text [i] && i < cpos; i++) { + if (text [i] == '\"') + quotes++; + } + + /* even count of quotes */ + can_comma = (quotes & 1) == 0; + } + } + + if (can_comma || event->keyval == GDK_Return) { g_signal_emit_by_name (widget, "activate", 0); contact_list_editor_add_email (editor); -- cgit v1.2.3