Index: libedataserverui/e-name-selector-entry.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/e-name-selector-entry.c,v
retrieving revision 1.28
diff -u -p -r1.28 e-name-selector-entry.c
--- libedataserverui/e-name-selector-entry.c	2 Jan 2006 09:33:21 -0000	1.28
+++ libedataserverui/e-name-selector-entry.c	3 Mar 2006 09:09:53 -0000
@@ -1696,8 +1696,40 @@ find_book_by_contact (GList *books, cons
 }
 
 static void
-editor_closed_cb (GtkObject *editor, gpointer data)
+editor_closed_cb (GtkObject *editor, ENameSelectorEntry *name_selector_entry)
 {
+	EContact *contact;
+	gchar *contact_uid;
+	EDestination *destination;
+	GList *books;
+	EBook *book;
+	gboolean result;
+	gint email_num;
+
+	destination = name_selector_entry->popup_destination;
+	contact = e_destination_get_contact (destination);
+	if (!contact)
+		return;
+	contact_uid = e_contact_get (contact, E_CONTACT_UID);
+	if (!contact_uid)
+		return;
+
+	if (name_selector_entry->contact_store) {
+		books = e_contact_store_get_books (name_selector_entry->contact_store);
+		book = find_book_by_contact (books, contact_uid);
+		g_list_free (books);
+	} else {
+		book = NULL;
+	}
+	if (!book)
+		return;
+
+	result = e_book_get_contact(book, contact_uid, &contact, NULL);
+	email_num = e_destination_get_email_num(destination);
+	e_destination_set_contact (destination, contact, email_num);
+
+	g_free (contact_uid);
+	g_object_unref (contact);
 	g_object_unref (editor);
 }
 
@@ -1769,7 +1801,7 @@ popup_activate_contact (ENameSelectorEnt
 
 		contact_list_editor = (*name_selector_entry->contact_list_editor_func) (book, contact, FALSE, TRUE);
 		g_signal_connect (contact_list_editor, "editor_closed",
-				  G_CALLBACK (editor_closed_cb), NULL);
+				  G_CALLBACK (editor_closed_cb), name_selector_entry);
 	} else {
 		GtkWidget *contact_editor;
 
@@ -1778,7 +1810,7 @@ popup_activate_contact (ENameSelectorEnt
 
 		contact_editor = (*name_selector_entry->contact_editor_func) (book, contact, FALSE, TRUE);
 		g_signal_connect (contact_editor, "editor_closed",
-				  G_CALLBACK (editor_closed_cb), NULL);
+				  G_CALLBACK (editor_closed_cb), name_selector_entry);
 	}
 }
 
