diff options
Diffstat (limited to 'addressbook/gui/component/select-names')
3 files changed, 39 insertions, 1 deletions
diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c index 0bec7da416..3212242fbd 100644 --- a/addressbook/gui/component/select-names/e-select-names-manager.c +++ b/addressbook/gui/component/select-names/e-select-names-manager.c @@ -472,7 +472,7 @@ e_select_names_clicked(ESelectNames *dialog, gint button, ESelectNamesManager *m for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) { ESelectNamesManagerSection *section = (void *) e_iterator_get(iterator); ESelectNamesModel *source = e_select_names_get_source(dialog, section->id); - e_select_names_model_overwrite_copy (section->model, source); + e_select_names_model_merge (section->model, source); gtk_object_unref (GTK_OBJECT (source)); } 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) { @@ -652,6 +668,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) { gint rp = 0, i, len = 0; diff --git a/addressbook/gui/component/select-names/e-select-names-model.h b/addressbook/gui/component/select-names/e-select-names-model.h index 9f89e91093..9fca3897db 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.h +++ b/addressbook/gui/component/select-names/e-select-names-model.h @@ -61,12 +61,15 @@ void e_select_names_model_import_destinationv (ESelectNamesModel ECard *e_select_names_model_get_card (ESelectNamesModel *model, gint index); const gchar *e_select_names_model_get_string (ESelectNamesModel *model, gint index); +gboolean e_select_names_model_contains (ESelectNamesModel *model, EDestination *dest); + void e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest); void e_select_names_model_append (ESelectNamesModel *model, EDestination *dest); void e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest); void e_select_names_model_delete (ESelectNamesModel *model, gint index); void e_select_names_model_delete_all (ESelectNamesModel *model); void e_select_names_model_overwrite_copy (ESelectNamesModel *dest, ESelectNamesModel *src); +void e_select_names_model_merge (ESelectNamesModel *dest, ESelectNamesModel *src); void e_select_names_model_clean (ESelectNamesModel *model); |