changeset 10081:ff4be2d1401d

[gaim-migrate @ 11071] Merge the gevolution changes back to HEAD. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 06 Oct 2004 03:17:24 +0000
parents 8e6329b8dcc1
children 51e9c4f27a62
files plugins/gevolution/Makefile.am plugins/gevolution/add_buddy_dialog.c plugins/gevolution/assoc-buddy.c plugins/gevolution/gevo-util.c plugins/gevolution/gevolution.c plugins/gevolution/gevolution.h plugins/gevolution/new_person_dialog.c
diffstat 7 files changed, 178 insertions(+), 200 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/gevolution/Makefile.am	Sun Oct 03 22:59:26 2004 +0000
+++ b/plugins/gevolution/Makefile.am	Wed Oct 06 03:17:24 2004 +0000
@@ -14,7 +14,8 @@
 	gevolution.c \
 	gevolution.h \
 	gevo-util.c \
-	new_person_dialog.c
+	new_person_dialog.c \
+	eds-utils.c
 
 endif
 
--- a/plugins/gevolution/add_buddy_dialog.c	Sun Oct 03 22:59:26 2004 +0000
+++ b/plugins/gevolution/add_buddy_dialog.c	Wed Oct 06 03:17:24 2004 +0000
@@ -44,14 +44,17 @@
 {
 	gtk_widget_destroy(dialog->win);
 
-	g_list_foreach(dialog->contacts, (GFunc)g_object_unref, NULL);
-
 	if (dialog->contacts != NULL)
+	{
+		g_list_foreach(dialog->contacts, (GFunc)g_object_unref, NULL);
 		g_list_free(dialog->contacts);
+	}
 
 	if (dialog->book != NULL)
 		g_object_unref(dialog->book);
 
+	gevo_addrbooks_model_unref(dialog->addrbooks);
+
 	if (dialog->username != NULL)
 		g_free(dialog->username);
 
@@ -68,7 +71,7 @@
 	group_name =
 		gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(dialog->group_combo)->entry));
 
-	gevo_new_person_dialog_show(NULL, dialog->account, NULL,
+	gevo_new_person_dialog_show(dialog->book, NULL, dialog->account, NULL,
 								(*group_name ? group_name : NULL),
 								NULL, FALSE);
 
@@ -106,7 +109,7 @@
 
 	if (username == NULL || *username == '\0')
 	{
-		gevo_new_person_dialog_show(NULL, dialog->account, NULL,
+		gevo_new_person_dialog_show(dialog->book, NULL, dialog->account, NULL,
 									(*group_name ? group_name : NULL),
 									NULL, FALSE);
 	}
@@ -119,65 +122,6 @@
 }
 
 static void
-populate_address_books(GevoAddBuddyDialog *dialog)
-{
-	GtkWidget *item;
-	GtkWidget *menu;
-#if notyet
-	ESourceList *addressbooks;
-	GSList *groups, *g;
-#endif
-
-	menu =
-		gtk_option_menu_get_menu(GTK_OPTION_MENU(dialog->addressbooks_menu));
-
-	item = gtk_menu_item_new_with_label(_("Local Addressbook"));
-	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-	gtk_widget_show(item);
-
-#if notyet
-	if (!e_book_get_addressbooks(&addressbooks, NULL))
-	{
-		gaim_debug_error("evolution",
-						 "Unable to fetch list of address books.\n");
-
-		item = gtk_menu_item_new_with_label(_("None"));
-		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-		gtk_widget_show(item);
-
-		return;
-	}
-
-	groups = e_source_list_peek_groups(addressbooks);
-
-	if (groups == NULL)
-	{
-		item = gtk_menu_item_new_with_label(_("None"));
-		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-		gtk_widget_show(item);
-
-		return;
-	}
-
-	for (g = groups; g != NULL; g = g->next)
-	{
-		GSList *sources, *s;
-
-		sources = e_source_group_peek_sources(g->data);
-
-		for (s = sources; s != NULL; s = s->next)
-		{
-			ESource *source = E_SOURCE(s->data);
-
-			item = gtk_menu_item_new_with_label(e_source_peek_name(source));
-			gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-			gtk_widget_show(item);
-		}
-	}
-#endif
-}
-
-static void
 add_columns(GevoAddBuddyDialog *dialog)
 {
 	GtkCellRenderer *renderer;
@@ -288,14 +232,29 @@
 }
 
 static void
-populate_treeview(GevoAddBuddyDialog *dialog)
+populate_treeview(GevoAddBuddyDialog *dialog, const gchar *uri)
 {
 	EBookQuery *query;
 	EBook *book;
 	gboolean status;
 	GList *cards, *c;
 
-	if (!gevo_load_addressbook(&book, NULL))
+	if (dialog->book != NULL)
+	{
+		g_object_unref(dialog->book);
+		dialog->book = NULL;
+	}
+
+	if (dialog->contacts != NULL)
+	{
+		g_list_foreach(dialog->contacts, (GFunc)g_object_unref, NULL);
+		g_list_free(dialog->contacts);
+		dialog->contacts = NULL;
+	}
+
+	gtk_list_store_clear(dialog->model);
+
+	if (!gevo_load_addressbook(uri, &book, NULL))
 	{
 		gaim_debug_error("evolution",
 						 "Error retrieving default addressbook\n");
@@ -369,6 +328,22 @@
 }
 
 static void
+addrbook_change_cb(GtkComboBox *combo, GevoAddBuddyDialog *dialog)
+{
+	GtkTreeIter iter;
+	const char *esource_uri;
+
+	if (!gtk_combo_box_get_active_iter(combo, &iter))
+		return;
+
+	gtk_tree_model_get(GTK_TREE_MODEL(dialog->addrbooks), &iter,
+					   ADDRBOOK_COLUMN_URI, &esource_uri,
+					   -1);
+
+	populate_treeview(dialog, esource_uri);
+}
+
+static void
 selected_cb(GtkTreeSelection *sel, GevoAddBuddyDialog *dialog)
 {
 	gtk_widget_set_sensitive(dialog->select_button, TRUE);
@@ -449,9 +424,9 @@
 	GtkWidget *vbox;
 	GtkWidget *hbox;
 	GtkWidget *bbox;
-	GtkWidget *menu;
 	GtkWidget *sep;
 	GtkTreeSelection *selection;
+	GtkCellRenderer *cell;
 
 	dialog = g_new0(GevoAddBuddyDialog, 1);
 
@@ -495,17 +470,20 @@
 	gtk_widget_show(label);
 
 	/* Addressbooks */
-	dialog->addressbooks_menu = gtk_option_menu_new();
-	menu = gtk_menu_new();
-	gtk_option_menu_set_menu(GTK_OPTION_MENU(dialog->addressbooks_menu), menu);
-
-	populate_address_books(dialog);
+	dialog->addrbooks = gevo_addrbooks_model_new();
 
-	gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->addressbooks_menu), 0);
-
-	gtk_box_pack_start(GTK_BOX(hbox), dialog->addressbooks_menu,
-					   FALSE, FALSE, 0);
-	gtk_widget_show(dialog->addressbooks_menu);
+	dialog->addrbooks_combo = gtk_combo_box_new_with_model(
+			dialog->addrbooks);
+	cell = gtk_cell_renderer_text_new();
+	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dialog->addrbooks_combo),
+							   cell, TRUE);
+	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dialog->addrbooks_combo),
+								   cell,
+								   "text", ADDRBOOK_COLUMN_NAME,
+								   NULL);
+	gtk_box_pack_start(GTK_BOX(hbox), dialog->addrbooks_combo, FALSE,
+					   FALSE, 0);
+	gtk_widget_show(dialog->addrbooks_combo);
 
 	/* Search field */
 	dialog->search_field = gtk_entry_new();
@@ -554,7 +532,14 @@
 
 	add_columns(dialog);
 
-	populate_treeview(dialog);
+	/*
+	 * Catch addressbook selection and populate treeview with the first
+	 * addressbook
+	 */
+	gevo_addrbooks_model_populate(dialog->addrbooks);
+	g_signal_connect(G_OBJECT(dialog->addrbooks_combo), "changed",
+							  G_CALLBACK(addrbook_change_cb), dialog);
+	gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->addrbooks_combo), 0);
 
 	/* Group box */
 	hbox = gtk_hbox_new(FALSE, 6);
--- a/plugins/gevolution/assoc-buddy.c	Sun Oct 03 22:59:26 2004 +0000
+++ b/plugins/gevolution/assoc-buddy.c	Wed Oct 06 03:17:24 2004 +0000
@@ -31,6 +31,7 @@
 
 #include <stdlib.h>
 #include <bonobo/bonobo-main.h>
+#include <gtk/gtk.h>
 
 enum
 {
@@ -44,12 +45,14 @@
 {
 	gtk_widget_destroy(dialog->win);
 
-	g_list_foreach(dialog->contacts, (GFunc)g_free, NULL);
-
 	if (dialog->contacts != NULL)
+	{
+		g_list_foreach(dialog->contacts, (GFunc)g_object_unref, NULL);
 		g_list_free(dialog->contacts);
+	}
 
 	g_object_unref(dialog->book);
+	gevo_addrbooks_model_unref(dialog->addrbooks);
 
 	g_free(dialog);
 
@@ -57,65 +60,6 @@
 }
 
 static void
-populate_address_books(GevoAssociateBuddyDialog *dialog)
-{
-	GtkWidget *item;
-	GtkWidget *menu;
-#if notyet
-	ESourceList *addressbooks;
-	GSList *groups, *g;
-#endif
-
-	menu =
-		gtk_option_menu_get_menu(GTK_OPTION_MENU(dialog->addressbooks_menu));
-
-	item = gtk_menu_item_new_with_label(_("Local Addressbook"));
-	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-	gtk_widget_show(item);
-
-#if notyet
-	if (!e_book_get_addressbooks(&addressbooks, NULL))
-	{
-		gaim_debug_error("evolution",
-						 "Unable to fetch list of address books.\n");
-
-		item = gtk_menu_item_new_with_label(_("None"));
-		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-		gtk_widget_show(item);
-
-		return;
-	}
-
-	groups = e_source_list_peek_groups(addressbooks);
-
-	if (groups == NULL)
-	{
-		item = gtk_menu_item_new_with_label(_("None"));
-		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-		gtk_widget_show(item);
-
-		return;
-	}
-
-	for (g = groups; g != NULL; g = g->next)
-	{
-		GSList *sources, *s;
-
-		sources = e_source_group_peek_sources(g->data);
-
-		for (s = sources; s != NULL; s = s->next)
-		{
-			ESource *source = E_SOURCE(s->data);
-
-			item = gtk_menu_item_new_with_label(e_source_peek_name(source));
-			gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-			gtk_widget_show(item);
-		}
-	}
-#endif
-}
-
-static void
 search_changed_cb(GtkEntry *entry, GevoAssociateBuddyDialog *dialog)
 {
 	const char *text = gtk_entry_get_text(entry);
@@ -184,18 +128,33 @@
 }
 
 static void
-populate_treeview(GevoAssociateBuddyDialog *dialog)
+populate_treeview(GevoAssociateBuddyDialog *dialog, const gchar *uri)
 {
+	EBook *book;
 	EBookQuery *query;
-	EBook *book;
 	const char *prpl_id;
 	gboolean status;
 	GList *cards, *c;
 
-	if (!gevo_load_addressbook(&book, NULL))
+	if (dialog->book != NULL)
+	{
+		g_object_unref(dialog->book);
+		dialog->book = NULL;
+	}
+
+	if (dialog->contacts != NULL)
+	{
+		g_list_foreach(dialog->contacts, (GFunc) g_object_unref, NULL);
+		g_list_free(dialog->contacts);
+		dialog->contacts = NULL;
+	}
+
+	gtk_list_store_clear(dialog->model);
+
+	if (!gevo_load_addressbook(uri, &book, NULL))
 	{
 		gaim_debug_error("evolution",
-						 "Error retrieving default addressbook\n");
+						 "Error retrieving addressbook\n");
 
 		return;
 	}
@@ -275,9 +234,25 @@
 }
 
 static void
+addrbook_change_cb(GtkComboBox *combo, GevoAssociateBuddyDialog *dialog)
+{
+	GtkTreeIter iter;
+	const char *esource_uri;
+
+	if (!gtk_combo_box_get_active_iter(combo, &iter))
+		return;
+
+	gtk_tree_model_get(GTK_TREE_MODEL(dialog->addrbooks), &iter,
+					   ADDRBOOK_COLUMN_URI, &esource_uri,
+					   -1);
+
+	populate_treeview(dialog, esource_uri);
+}
+
+static void
 new_person_cb(GtkWidget *w, GevoAssociateBuddyDialog *dialog)
 {
-	gevo_new_person_dialog_show(NULL, dialog->buddy->account,
+	gevo_new_person_dialog_show(dialog->book, NULL, dialog->buddy->account,
 								dialog->buddy->name, NULL, dialog->buddy,
 								TRUE);
 
@@ -315,14 +290,12 @@
 		return; /* XXX */
 
 	list = e_contact_get(contact, protocol_field);
-
 	list = g_list_append(list, g_strdup(dialog->buddy->name));
 
 	e_contact_set(contact, protocol_field, list);
+
 	if (!e_book_commit_contact(dialog->book, contact, NULL))
-	{
 		gaim_debug_error("evolution", "Error adding contact to book\n");
-	}
 
 	/* Free the list. */
 	g_list_foreach(list, (GFunc)g_free, NULL);
@@ -341,10 +314,10 @@
 	GtkWidget *vbox;
 	GtkWidget *hbox;
 	GtkWidget *bbox;
-	GtkWidget *menu;
 	GtkWidget *sep;
 	GtkWidget *disclosure;
 	GtkTreeSelection *selection;
+	GtkCellRenderer *cell;
 
 	g_return_val_if_fail(buddy != NULL, NULL);
 
@@ -383,17 +356,19 @@
 	gtk_widget_show(label);
 
 	/* Addressbooks */
-	dialog->addressbooks_menu = gtk_option_menu_new();
-	menu = gtk_menu_new();
-	gtk_option_menu_set_menu(GTK_OPTION_MENU(dialog->addressbooks_menu), menu);
-
-	populate_address_books(dialog);
+	dialog->addrbooks = gevo_addrbooks_model_new();
 
-	gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->addressbooks_menu), 0);
+	dialog->addrbooks_combo = gtk_combo_box_new_with_model(dialog->addrbooks);
+	cell = gtk_cell_renderer_text_new();
+	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dialog->addrbooks_combo),
+							   cell, TRUE);
+	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dialog->addrbooks_combo),
+								   cell,
+								   "text", ADDRBOOK_COLUMN_NAME,
+								   NULL);
+	gtk_box_pack_start(GTK_BOX(hbox), dialog->addrbooks_combo, FALSE, FALSE, 0);
+	gtk_widget_show(dialog->addrbooks_combo);
 
-	gtk_box_pack_start(GTK_BOX(hbox), dialog->addressbooks_menu,
-					   FALSE, FALSE, 0);
-	gtk_widget_show(dialog->addressbooks_menu);
 
 	/* Search field */
 	dialog->search_field = gtk_entry_new();
@@ -426,8 +401,8 @@
 									   G_TYPE_STRING, G_TYPE_POINTER);
 
 	/* Now for the treeview */
-	dialog->treeview =
-		gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model));
+	dialog->treeview = gtk_tree_view_new_with_model(
+			GTK_TREE_MODEL(dialog->model));
 	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(dialog->treeview), TRUE);
 	gtk_container_add(GTK_CONTAINER(sw), dialog->treeview);
 	gtk_widget_show(dialog->treeview);
@@ -441,7 +416,14 @@
 
 	add_columns(dialog);
 
-	populate_treeview(dialog);
+	/*
+	 * Catch addressbook selection and populate treeview with the first
+	 * addressbook
+	 */
+	gevo_addrbooks_model_populate( dialog->addrbooks );
+	g_signal_connect(G_OBJECT(dialog->addrbooks_combo), "changed",
+					 G_CALLBACK(addrbook_change_cb), dialog);
+	gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->addrbooks_combo), 0);
 
 	/* Add the disclosure */
 	disclosure = gaim_disclosure_new(_("Show user details"),
--- a/plugins/gevolution/gevo-util.c	Sun Oct 03 22:59:26 2004 +0000
+++ b/plugins/gevolution/gevo-util.c	Wed Oct 06 03:17:24 2004 +0000
@@ -55,15 +55,13 @@
 GList *
 gevo_get_groups(void)
 {
-	GList *tmp = NULL;
-	char *tmp2;
+	GList *list = NULL;
 	GaimGroup *g;
 	GaimBlistNode *gnode;
 
 	if (gaim_get_blist()->root == NULL)
 	{
-		tmp2 = g_strdup(_("Buddies"));
-		tmp  = g_list_append(tmp, tmp2);
+		list  = g_list_append(list, _("Buddies"));
 	}
 	else
 	{
@@ -73,14 +71,13 @@
 		{
 			if (GAIM_BLIST_NODE_IS_GROUP(gnode))
 			{
-				g    = (GaimGroup *)gnode;
-				tmp2 = g->name;
-				tmp  = g_list_append(tmp, tmp2);
+				g = (GaimGroup *)gnode;
+				list = g_list_append(list, g->name);
 			}
 		}
 	}
 
-	return tmp;
+	return list;
 }
 
 EContactField
@@ -126,21 +123,18 @@
 }
 
 gboolean
-gevo_load_addressbook(EBook **book, GError **error)
+gevo_load_addressbook(const gchar* uri, EBook **book, GError **error)
 {
 	gboolean result = FALSE;
 
 	g_return_val_if_fail(book != NULL, FALSE);
 
-#if EBOOK_CHECK_VERSION(0, 0, 94)
-	*book = e_book_new_system_addressbook(NULL);
+	if (uri == NULL)
+		*book = e_book_new_system_addressbook(NULL);
+	else
+		*book = e_book_new_from_uri(uri, error);
 
 	result = e_book_open(*book, FALSE, NULL);
-#else
-	*book = e_book_new();
-
-	result = e_book_load_local_addressbook(*book, error);
-#endif
 
 	if (!result && *book != NULL)
 	{
--- a/plugins/gevolution/gevolution.c	Sun Oct 03 22:59:26 2004 +0000
+++ b/plugins/gevolution/gevolution.c	Wed Oct 06 03:17:24 2004 +0000
@@ -232,7 +232,7 @@
 
 	timer = 0;
 
-	if (!gevo_load_addressbook(&book, NULL))
+	if (!gevo_load_addressbook(NULL, &book, NULL))
 		return FALSE;
 
 	query = e_book_query_any_field_contains("");
--- a/plugins/gevolution/gevolution.h	Sun Oct 03 22:59:26 2004 +0000
+++ b/plugins/gevolution/gevolution.h	Wed Oct 06 03:17:24 2004 +0000
@@ -33,9 +33,20 @@
 
 #include <libebook/e-book.h>
 
-#if !EBOOK_CHECK_VERSION(0, 0, 95)
-# include <libebook/e-book-async.h>
-#endif
+enum
+{
+	ADDRBOOK_COLUMN_NAME,
+	ADDRBOOK_COLUMN_URI,
+	NUM_ADDRBOOK_COLUMNS
+};
+
+typedef struct
+{
+	GtkListStore *sources;
+	EBook *active_book;
+	GList *contacts;
+
+} GevoAddrbooksSelector;
 
 typedef struct
 {
@@ -46,13 +57,14 @@
 
 	GtkWidget *win;
 	GtkWidget *treeview;
-	GtkWidget *addressbooks_menu;
+	GtkWidget *addrbooks_combo;
 	GtkWidget *search_field;
 	GtkWidget *group_combo;
 	GtkWidget *select_button;
 	GtkWidget *account_optmenu;
 	GtkListStore *model;
 
+	GtkTreeModel *addrbooks;
 	GList *contacts;
 
 } GevoAddBuddyDialog;
@@ -64,6 +76,7 @@
 	GaimAccount *account;
 	GaimBuddy *buddy;
 
+	EBook *book;
 	EContact *contact;
 
 	GtkWidget *win;
@@ -87,12 +100,13 @@
 
 	GtkWidget *win;
 	GtkWidget *treeview;
-	GtkWidget *addressbooks_menu;
+	GtkWidget *addrbooks_combo;
 	GtkWidget *search_field;
 	GtkWidget *assoc_button;
 	GtkWidget *imhtml;
 	GtkListStore *model;
 
+	GtkTreeModel *addrbooks;
 	GList *contacts;
 
 } GevoAssociateBuddyDialog;
@@ -104,9 +118,10 @@
 									  const char *name, GaimAccount *account,
 									  const char *screenname);
 
-void gevo_new_person_dialog_show(EContact *contact, GaimAccount *account,
-								 const char *username, const char *group,
-								 GaimBuddy *buddy, gboolean person_only);
+void gevo_new_person_dialog_show(EBook *book, EContact *contact,
+								 GaimAccount *account, const char *username,
+								 const char *group, GaimBuddy *buddy,
+								 gboolean person_only);
 
 void gevo_add_buddy(GaimAccount *account, const char *group_name,
 					const char *screenname, const char *alias);
@@ -114,8 +129,13 @@
 
 EContactField gevo_prpl_get_field(GaimAccount *account, GaimBuddy *buddy);
 gboolean gevo_prpl_is_supported(GaimAccount *account, GaimBuddy *buddy);
-gboolean gevo_load_addressbook(EBook **book, GError **error);
+gboolean gevo_load_addressbook(const gchar *uri, EBook **book, GError **error);
 
 GevoAssociateBuddyDialog *gevo_associate_buddy_dialog_new(GaimBuddy *buddy);
 
+
+GtkTreeModel *gevo_addrbooks_model_new(void);
+void gevo_addrbooks_model_unref(GtkTreeModel *model);
+void gevo_addrbooks_model_populate(GtkTreeModel *model);
+
 #endif /* _GEVOLUTION_H_ */
--- a/plugins/gevolution/new_person_dialog.c	Sun Oct 03 22:59:26 2004 +0000
+++ b/plugins/gevolution/new_person_dialog.c	Wed Oct 06 03:17:24 2004 +0000
@@ -54,6 +54,7 @@
 {
 	gtk_widget_destroy(dialog->win);
 
+	g_object_unref(dialog->book);
 	g_free(dialog);
 
 	return 0;
@@ -84,7 +85,6 @@
 add_cb(GtkWidget *w, GevoNewPersonDialog *dialog)
 {
 	EContact *contact = NULL;
-	EBook *book;
 	const char *screenname;
 	const char *firstname;
 	const char *lastname;
@@ -106,14 +106,6 @@
 
 	if (*firstname || *lastname)
 	{
-		if (!gevo_load_addressbook(&book, NULL))
-		{
-			gaim_debug_error("evolution",
-							 "Error retrieving default addressbook\n");
-
-			return;
-		}
-
 		if (dialog->contact == NULL)
 		{
 			char *file_as;
@@ -175,7 +167,7 @@
 
 		if (new_contact)
 		{
-			if (!e_book_add_contact(book, contact, NULL))
+			if (!e_book_add_contact(dialog->book, contact, NULL))
 			{
 				gaim_debug_error("evolution", "Error adding contact to book\n");
 
@@ -186,7 +178,7 @@
 		}
 		else
 		{
-			if (!e_book_commit_contact(book, contact, NULL))
+			if (!e_book_commit_contact(dialog->book, contact, NULL))
 			{
 				gaim_debug_error("evolution", "Error adding contact to book\n");
 
@@ -226,9 +218,10 @@
 }
 
 void
-gevo_new_person_dialog_show(EContact *contact, GaimAccount *account,
-							const char *username, const char *group,
-							GaimBuddy *buddy, gboolean person_only)
+gevo_new_person_dialog_show(EBook *book, EContact *contact,
+							GaimAccount *account, const char *username,
+							const char *group, GaimBuddy *buddy,
+							gboolean person_only)
 {
 	GevoNewPersonDialog *dialog;
 	GtkWidget *vbox, *vbox2;
@@ -240,6 +233,7 @@
 	GtkSizeGroup *sg, *sg2;
 	const char *str;
 
+	g_return_if_fail(book);
 	g_return_if_fail(!person_only || (person_only && buddy));
 
 	dialog = g_new0(GevoNewPersonDialog, 1);
@@ -247,6 +241,8 @@
 	dialog->account = account;
 	dialog->person_only = person_only;
 	dialog->buddy = buddy;
+	dialog->book = book;
+	g_object_ref(book);
 
 	dialog->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 	gtk_window_set_role(GTK_WINDOW(dialog->win), "new_person");