aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorDevashish Sharma <dsharma@src.gnome.org>2006-05-25 15:44:48 +0800
committerDevashish Sharma <dsharma@src.gnome.org>2006-05-25 15:44:48 +0800
commit24d771f7b18094cd961f82064542dc96432d4377 (patch)
tree033c00ffbc9bdb55fb8a55d09dcdf1a330f21f52 /addressbook/gui
parentc345604989402eab7e4c72bcf9e249792c0810bb (diff)
downloadgsoc2013-evolution-24d771f7b18094cd961f82064542dc96432d4377.tar
gsoc2013-evolution-24d771f7b18094cd961f82064542dc96432d4377.tar.gz
gsoc2013-evolution-24d771f7b18094cd961f82064542dc96432d4377.tar.bz2
gsoc2013-evolution-24d771f7b18094cd961f82064542dc96432d4377.tar.lz
gsoc2013-evolution-24d771f7b18094cd961f82064542dc96432d4377.tar.xz
gsoc2013-evolution-24d771f7b18094cd961f82064542dc96432d4377.tar.zst
gsoc2013-evolution-24d771f7b18094cd961f82064542dc96432d4377.zip
contacts added to a contact-list cant be added again.
svn path=/trunk/; revision=32025
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c41
1 files changed, 36 insertions, 5 deletions
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 <e-util/e-icon-factory.h>
#include <e-util/e-util-private.h>
+#include <e-util/e-error.h>
#include <string.h>
@@ -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");