From 24d771f7b18094cd961f82064542dc96432d4377 Mon Sep 17 00:00:00 2001 From: Devashish Sharma Date: Thu, 25 May 2006 07:44:48 +0000 Subject: contacts added to a contact-list cant be added again. svn path=/trunk/; revision=32025 --- .../contact-list-editor/e-contact-list-editor.c | 41 +++++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) (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 eeb9454908..21dd8da9e7 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -23,6 +23,7 @@ #include "e-contact-list-editor.h" #include #include +#include #include @@ -667,6 +668,27 @@ e_contact_list_editor_create_table(gchar *name, return table; } +static gboolean +contact_already_exists (EContactListModel *model, const char *email) +{ + int row_count; + int row; + char *list_email; + row_count = e_table_model_row_count (E_TABLE_MODEL (model)); + for (row = 0; row < row_count; row ++) { + list_email = (char *) e_destination_get_email(e_contact_list_model_get_destination (model, row)); + if (strcmp (list_email, email) == 0) { + if (e_error_run (NULL, "addressbook:ask-list-add-exists", + email) != GTK_RESPONSE_YES) + return TRUE; + else + return FALSE; + break; + } + } + return FALSE; +} + static void add_to_model (EContactListEditor *editor, GList *destinations) { @@ -674,7 +696,13 @@ add_to_model (EContactListEditor *editor, GList *destinations) for (l = destinations; l; l = g_list_next (l)) { EDestination *destination = l->data; - e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL(editor->model), destination); + if (e_destination_get_email (destination)) { + if (! contact_already_exists (E_CONTACT_LIST_MODEL (editor->model) + , e_destination_get_email (destination))) { + e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL (editor->model), + destination); + } + } } } @@ -973,12 +1001,15 @@ table_drag_data_received_cb (ETable *table, int row, int col, EContact *contact = c->data; if (!e_contact_get (contact, E_CONTACT_IS_LIST)) { - if (e_contact_get (contact, E_CONTACT_EMAIL)) { - e_contact_list_model_add_contact (E_CONTACT_LIST_MODEL (editor->model), - contact, + if (e_contact_get (contact, E_CONTACT_EMAIL_1)) { + if (! contact_already_exists (E_CONTACT_LIST_MODEL (editor->model) + , e_contact_get (contact, E_CONTACT_EMAIL_1))) { + e_contact_list_model_add_contact (E_CONTACT_LIST_MODEL (editor->model), + contact, 0 /* Hard-wired for default e-mail */); - changed = TRUE; + changed = TRUE; + } } else g_warning ("Contact with no email-ids listed can't be added to a Contact-List"); -- cgit v1.2.3