* src/modest-text-utils.[ch]:
[modest] / src / maemo / modest-address-book.c
index cd0de4b..ac1996e 100644 (file)
@@ -130,6 +130,7 @@ modest_address_book_add_address (const gchar *address)
 {
        OssoABookAccount *account = NULL;
        GtkWidget *dialog = NULL;
+       gchar *email_address = NULL;
 
        contact_model = osso_abook_contact_model_new ();
        if (!open_addressbook ()) {
@@ -139,8 +140,11 @@ modest_address_book_add_address (const gchar *address)
                }
                return;
        }
+
+       email_address = modest_text_utils_get_email_address (address);
        
-       account = osso_abook_account_get (EVC_EMAIL, NULL, address);
+       account = osso_abook_account_get (EVC_EMAIL, NULL, email_address);
+       g_free (email_address);
        if (account)
        {
                dialog = osso_abook_add_to_contacts_dialog_new (contact_model, account);
@@ -624,6 +628,16 @@ add_to_address_book (const gchar* address)
        return TRUE;
 }
 
+static gboolean
+show_check_names_banner (gpointer data)
+{
+       GtkWidget **banner = (GtkWidget **) data;
+
+       *banner = hildon_banner_show_animation (NULL, NULL, _("mail_ib_checking_names"));
+       g_object_ref (G_OBJECT (*banner));
+
+       return FALSE;
+}
 
 gboolean
 modest_address_book_check_names (ModestRecptEditor *recpt_editor, gboolean update_addressbook)
@@ -636,20 +650,22 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor, gboolean updat
        gint offset_delta = 0;
        gint last_length;
        GtkTextIter start_iter, end_iter;
-       GtkWidget *banner;
+       GtkWidget *banner = NULL;
+       guint show_banner_timeout;
 
        g_return_val_if_fail (MODEST_IS_RECPT_EDITOR (recpt_editor), FALSE);
 
-       banner = hildon_banner_show_animation (NULL, NULL, _("mail_ib_checking_names"));
-       g_object_ref (G_OBJECT (banner));
-
+       show_banner_timeout = g_timeout_add (2000, show_check_names_banner, &banner);
        recipients = modest_recpt_editor_get_recipients (recpt_editor);
        last_length = g_utf8_strlen (recipients, -1);
        modest_text_utils_get_addresses_indexes (recipients, &start_indexes, &end_indexes);
 
        if (start_indexes == NULL) {
-               gtk_widget_destroy (banner);
-               g_object_unref (G_OBJECT(banner));
+               g_source_remove (show_banner_timeout);
+               if (banner != NULL) {
+                       gtk_widget_destroy (banner);
+                       g_object_unref (G_OBJECT(banner));
+               }
                return TRUE;
        }
 
@@ -662,7 +678,7 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor, gboolean updat
                gchar *start_ptr, *end_ptr;
                gint start_pos, end_pos;
                const gchar *invalid_char_position = NULL;
-               
+
                start_pos = (*((gint*) current_start->data)) + offset_delta;
                end_pos = (*((gint*) current_end->data)) + offset_delta;
               
@@ -733,8 +749,11 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor, gboolean updat
                gtk_text_buffer_place_cursor (buffer, &end_iter);
        }
 
-       gtk_widget_destroy (banner);
-       g_object_unref (G_OBJECT (banner));
+       g_source_remove (show_banner_timeout);
+       if (banner != NULL) {
+               gtk_widget_destroy (banner);
+               g_object_unref (G_OBJECT (banner));
+       }
        modest_recpt_editor_grab_focus (recpt_editor);
 
        g_slist_foreach (start_indexes, (GFunc) g_free, NULL);