From 19ec5dbb3b419740b0a9e84ba4c6667cb48c5631 Mon Sep 17 00:00:00 2001 From: Jon Trowbridge Date: Thu, 30 Aug 2001 04:57:18 +0000 Subject: Use e_select_names_model_merge to combine the selected names with any 2001-08-29 Jon Trowbridge * gui/component/select-names/e-select-names-manager.c (e_select_names_clicked): Use e_select_names_model_merge to combine the selected names with any existing ones. This causes you to not lose addresses typed directly into the entry while the SelectNames dialog is up. (Bug #8058) * gui/component/select-names/e-select-names-model.c (e_select_names_model_merge): Merge the contents of one ESelectNamesModel into another, avoiding duplicates. * backend/ebook/e-destination.c (e_destination_equal): Added. Determines if two destinations appear to refer to the same recipient. * backend/ebook/e-card.c (e_card_list_send): Added cast to g_free args to silence compiler warnings. svn path=/trunk/; revision=12526 --- .../component/select-names/e-select-names-model.c | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (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 6e0482ade3..66d7e96bb4 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ b/addressbook/gui/component/select-names/e-select-names-model.c @@ -465,6 +465,22 @@ disconnect_destination (ESelectNamesModel *model, EDestination *dest) gtk_signal_disconnect_by_func (GTK_OBJECT (dest), destination_changed_proxy, model); } +gboolean +e_select_names_model_contains (ESelectNamesModel *model, EDestination *dest) +{ + GList *iter; + + g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), FALSE); + g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE); + + for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { + if (iter->data != NULL && e_destination_equal (dest, E_DESTINATION (iter->data))) + return TRUE; + } + + return FALSE; +} + void e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest) { @@ -651,6 +667,25 @@ e_select_names_model_overwrite_copy (ESelectNamesModel *dest, ESelectNamesModel } } +void +e_select_names_model_merge (ESelectNamesModel *dest, ESelectNamesModel *src) +{ + gint i, len; + + g_return_if_fail (E_IS_SELECT_NAMES_MODEL (dest)); + g_return_if_fail (E_IS_SELECT_NAMES_MODEL (src)); + + if (src == dest) + return; + + len = e_select_names_model_count (src); + for (i = 0; i < len; ++i) { + const EDestination *d = e_select_names_model_get_destination (src, i); + if (d && !e_select_names_model_contains (dest, d)) + e_select_names_model_append (dest, e_destination_copy (d)); + } +} + void e_select_names_model_name_pos (ESelectNamesModel *model, gint index, gint *pos, gint *length) { -- cgit v1.2.3