g_object_ref (selector);
for (node = address_list; node != NULL; node = g_slist_next (node)) {
- if (!modest_address_book_has_address ((const gchar *) node->data)) {
- hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector),
- (const gchar *) node->data);
- contacts_to_add = TRUE;
+ const gchar *recipient = (const gchar *) node->data;
+ if (modest_text_utils_validate_recipient (recipient, NULL)) {
+ if (!modest_address_book_has_address (recipient)) {
+ hildon_touch_selector_append_text ((HildonTouchSelector *) selector,
+ recipient);
+ contacts_to_add = TRUE;
+ }
}
}
}
+void
+modest_msg_edit_window_add_to_contacts (ModestMsgEditWindow *self)
+{
+ GSList *recipients = NULL;
+ ModestMsgEditWindowPrivate *priv;
+ gchar *joined, *after_remove, *to, *cc, *bcc;
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
+
+ /* First of all check names */
+ if (!modest_msg_edit_window_check_names (self, FALSE))
+ return;
+
+ /* Don't add the from obviously */
+ to = g_strdup (modest_recpt_editor_get_recipients ((ModestRecptEditor *) priv->to_field));
+ cc = g_strdup (modest_recpt_editor_get_recipients ((ModestRecptEditor *) priv->cc_field));
+ bcc = g_strdup (modest_recpt_editor_get_recipients ((ModestRecptEditor *) priv->bcc_field));
+
+ joined = modest_text_utils_join_addresses (NULL, to, cc, bcc);
+ g_free (to);
+ g_free (cc);
+ g_free (bcc);
+
+ after_remove = modest_text_utils_remove_duplicate_addresses (joined);
+ g_free (joined);
+
+ recipients = modest_text_utils_split_addresses_list (after_remove);
+ g_free (after_remove);
+
+ if (recipients) {
+ /* Offer the user to add recipients to the address book */
+ modest_address_book_add_address_list_with_selector (recipients, (GtkWindow *) self);
+ g_slist_foreach (recipients, (GFunc) g_free, NULL); g_slist_free (recipients);
+ }
+}
+
static void
modest_msg_edit_window_add_attachment_clicked (GtkButton *button,
ModestMsgEditWindow *window)
modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_editor_checknames"), NULL,
MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_check_names),
NULL);
+ modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_viewer_addtocontacts"), NULL,
+ MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_add_to_contacts),
+ MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_add_to_contacts));
modest_window_add_to_menu (MODEST_WINDOW (self), _("mcen_me_inbox_undo"), "<Ctrl>z",
MODEST_WINDOW_MENU_CALLBACK (modest_ui_actions_on_undo),
MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_undo));
- priv->cc_button = modest_toolkit_factory_create_check_menu (modest_runtime_get_toolkit_factory (),
- _("mcen_me_editor_showcc"));
- modest_togglable_set_active (priv->cc_button,
- FALSE);
- modest_window_add_item_to_menu (MODEST_WINDOW (self), priv->cc_button,
- NULL);
+ priv->cc_button = hildon_check_button_new (0);
+ gtk_button_set_label (GTK_BUTTON (priv->cc_button), _("mcen_me_editor_showcc"));
+ hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->cc_button),
+ FALSE);
+ modest_window_add_item_to_menu (MODEST_WINDOW (self), priv->cc_button, NULL);
g_signal_connect (G_OBJECT (priv->cc_button), "toggled",
G_CALLBACK (on_cc_button_toggled), (gpointer) self);