X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-address-book.c;h=53626b403bb9c537a3790187e2f03036078ac8b9;hb=87596c5aa5517ac7ba37e50664a969fcaaea72f9;hp=eccf77fd2a7555d404cc3ade718626d5c465a53e;hpb=6d6bda6e1b5178fa4894245c2b5dc573d9a15f8c;p=modest diff --git a/src/maemo/modest-address-book.c b/src/maemo/modest-address-book.c index eccf77f..53626b4 100644 --- a/src/maemo/modest-address-book.c +++ b/src/maemo/modest-address-book.c @@ -37,6 +37,7 @@ #include #include #include "modest-hildon-includes.h" +#include "modest-platform.h" #include #include #include @@ -163,20 +164,19 @@ modest_address_book_select_addresses (ModestRecptEditor *recpt_editor) toplevel = gtk_widget_get_toplevel (GTK_WIDGET (recpt_editor)); - contact_model = osso_abook_contact_model_new (); - if (!open_addressbook_sync ()) { + if (!open_addressbook ()) { if (contact_model) { g_object_unref (contact_model); contact_model = NULL; } return; } + contact_model = osso_abook_contact_model_new (); contact_view = osso_abook_contact_selector_new_basic (contact_model); osso_abook_contact_selector_set_minimum_selection (OSSO_ABOOK_CONTACT_SELECTOR (contact_view), 1); contact_dialog = osso_abook_select_dialog_new (OSSO_ABOOK_TREE_VIEW (contact_view)); - osso_abook_select_dialog_set_new_contact (OSSO_ABOOK_SELECT_DIALOG (contact_dialog), TRUE); gtk_window_set_title (GTK_WINDOW (contact_dialog), _("mcen_ti_select_recipients")); gtk_widget_show (contact_dialog); @@ -326,7 +326,7 @@ commit_contact(EContact * contact) if (!contact || !book) return; -#ifdef MODEST_HILDON_VERSION_0 +#ifdef MODEST_HAVE_OLD_ABOOK osso_abook_contact_commit(contact, FALSE, book); #else osso_abook_contact_commit(contact, FALSE, book, NULL); @@ -450,13 +450,24 @@ run_add_email_addr_to_contact_dlg(const gchar * contact_name) result = gtk_dialog_run(GTK_DIALOG(add_email_addr_to_contact_dlg)); if (result == GTK_RESPONSE_ACCEPT) { + const gchar *invalid_char_offset = NULL; new_email_addr = g_strdup(gtk_entry_get_text(GTK_ENTRY(email_entry))); new_email_addr = g_strstrip(new_email_addr); - if (!modest_text_utils_validate_email_address (new_email_addr)) { + if (!modest_text_utils_validate_email_address (new_email_addr, &invalid_char_offset)) { gtk_widget_grab_focus(email_entry); + if ((invalid_char_offset != NULL)&&(*invalid_char_offset != '\0')) { + gchar *char_in_string = g_strdup_printf ("%c", *invalid_char_offset); + gchar *message = g_strdup_printf( + dgettext("hildon-common-strings", "ckdg_ib_illegal_characters_entered"), + char_in_string); + hildon_banner_show_information ( + add_email_addr_to_contact_dlg, NULL, message ); + g_free (message); + } else { + hildon_banner_show_information (add_email_addr_to_contact_dlg, NULL, _("mcen_ib_invalid_email")); + run_dialog = TRUE; + } gtk_editable_select_region((GtkEditable *) email_entry, 0, -1); - hildon_banner_show_information (add_email_addr_to_contact_dlg, NULL, _("mcen_ib_invalid_email")); - run_dialog = TRUE; g_free(new_email_addr); new_email_addr = NULL; } @@ -503,6 +514,10 @@ select_email_addrs_for_contact(GList * email_addr_list) _("mcen_bd_dialog_cancel"), GTK_RESPONSE_REJECT, NULL); gtk_dialog_set_has_separator(GTK_DIALOG(select_email_addr_dlg), FALSE); + /* Make the window approximately big enough, because it doesn't resize to be big enough + * for the window title text: */ + gtk_window_set_default_size (GTK_WINDOW (select_email_addr_dlg), 400, -1); + scrolledwindow = gtk_scrolled_window_new(NULL, NULL); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(select_email_addr_dlg)->vbox), scrolledwindow, TRUE, TRUE, 0); @@ -588,6 +603,7 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor) gchar *address; 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; @@ -600,8 +616,17 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor) gtk_text_buffer_get_iter_at_offset (buffer, &end_iter, end_pos); gtk_text_buffer_select_range (buffer, &start_iter, &end_iter); - if (!modest_text_utils_validate_recipient (address)) { - if (strstr (address, "@") == NULL) { + if (!modest_text_utils_validate_recipient (address, &invalid_char_position)) { + if ((invalid_char_position != NULL) && (*invalid_char_position != '\0')) { + gchar *char_in_string = g_strdup_printf("%c", *invalid_char_position); + gchar *message = g_strdup_printf( + dgettext("hildon-common-strings", "ckdg_ib_illegal_characters_entered"), + char_in_string); + g_free (char_in_string); + hildon_banner_show_information (NULL, NULL, message ); + g_free (message); + result = FALSE; + } else if (strstr (address, "@") == NULL) { /* here goes searching in addressbook */ gchar *contact_id = NULL; GSList *resolved_addresses = NULL; @@ -627,7 +652,7 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor) } else { /* this address is not valid, select it and return control to user showing banner */ - hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_mail")); + hildon_banner_show_information (NULL, NULL, _("mcen_ib_invalid_email")); result = FALSE; } } @@ -729,7 +754,7 @@ resolve_address (const gchar *address, GSList **resolved_addresses, gchar **cont if (resolved_contacts == NULL) { /* no matching contacts for the search string */ - hildon_banner_show_information (NULL, NULL, _("mcen_nc_no_matching_contacts")); + modest_platform_run_information_dialog (NULL, _("mcen_nc_no_matching_contacts")); return FALSE; }