From e51bb13fc41584414bdb78cf2ea3d1c86d01133f Mon Sep 17 00:00:00 2001 From: Jon Trowbridge Date: Sat, 31 Mar 2001 06:52:11 +0000 Subject: Call e_select_names_model_clean after adding address. This should deal 2001-03-31 Jon Trowbridge * gui/component/select-names/e-select-names.c (real_add_address_cb): Call e_select_names_model_clean after adding address. This should deal with the bug reports related to stray commas. * gui/component/select-names/e-select-names-model.c (e_select_names_model_clean): Added. Remove all empty destinations. * backend/ebook/e-destination.c (e_destination_is_empty): Added. Check if an EDestination is in essentially a null state. svn path=/trunk/; revision=9067 --- .../component/select-names/e-select-names-model.c | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'addressbook/gui/component/select-names/e-select-names-model.c') diff --git a/addressbook/gui/component/select-names/e-select-names-model.c b/addressbook/gui/component/select-names/e-select-names-model.c index 5dd11496d2..59d7bc7c24 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ b/addressbook/gui/component/select-names/e-select-names-model.c @@ -432,10 +432,41 @@ e_select_names_model_delete (ESelectNamesModel *model, gint index) e_select_names_model_changed (model); } +void +e_select_names_model_clean (ESelectNamesModel *model) +{ + GList *iter, *next; + gboolean changed = FALSE; + + g_return_if_fail (model != NULL && E_IS_SELECT_NAMES_MODEL (model)); + + iter = model->priv->data; + + while (iter) { + EDestination *dest; + + next = g_list_next (iter); + dest = iter->data ? E_DESTINATION (iter->data) : NULL; + + if (dest == NULL || e_destination_is_empty (dest)) { + if (dest) + gtk_object_unref (GTK_OBJECT (dest)); + model->priv->data = g_list_remove_link (model->priv->data, iter); + g_list_free_1 (iter); + changed = TRUE; + } + + iter = next; + } + + if (changed) + e_select_names_model_changed (model); +} + void e_select_names_model_delete_all (ESelectNamesModel *model) { - g_return_if_fail (model != NULL); + g_return_if_fail (model != NULL && E_IS_SELECT_NAMES_MODEL (model)); g_list_foreach (model->priv->data, (GFunc) gtk_object_unref, NULL); g_list_free (model->priv->data); -- cgit v1.2.3