void contact_list_editor_email_entry_updated_cb (GtkWidget *widget, EDestination *destination) { EContactListEditor *editor; ENameSelectorEntry *entry; EContactListModel *model; EDestinationStore *store; gchar *email; editor = contact_list_editor_extract (widget); entry = E_NAME_SELECTOR_ENTRY (widget); model = E_CONTACT_LIST_MODEL (editor->priv->model); email = g_strdup (e_destination_get_address (destination)); store = e_name_selector_entry_peek_destination_store (entry); e_destination_store_remove_destination (store, destination); gtk_entry_set_text (GTK_ENTRY (WIDGET (EMAIL_ENTRY)), ""); if (email && *email) { e_contact_list_model_add_email (model, email); contact_list_editor_scroll_to_end (editor); editor->priv->changed = TRUE; } g_free (email); contact_list_editor_update (editor); }
void contact_list_editor_select_button_clicked_cb (GtkWidget *widget) { EContactListEditor *editor; EContactListModel *model; ENameSelectorDialog *dialog; EDestinationStore *store; GList *list, *iter; editor = contact_list_editor_extract (widget); model = E_CONTACT_LIST_MODEL (editor->priv->model); dialog = e_name_selector_peek_dialog (editor->priv->name_selector); gtk_window_set_title (GTK_WINDOW (dialog), _("Contact List Members")); /* We need to empty out the destination store, since we copy its * contents every time. This sucks, we should really be wired * directly to the EDestinationStore that the name selector uses * in true MVC fashion. */ e_name_selector_model_peek_section ( e_name_selector_peek_model (editor->priv->name_selector), "Members", NULL, &store); list = e_destination_store_list_destinations (store); for (iter = list; iter != NULL; iter = iter->next) e_destination_store_remove_destination (store, iter->data); g_list_free (list); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_hide (GTK_WIDGET (dialog)); list = e_destination_store_list_destinations (store); for (iter = list; iter != NULL; iter = iter->next) { EDestination *destination = iter->data; const gchar *email = e_destination_get_email (destination); if (email == NULL) continue; if (!contact_list_editor_contact_exists (model, email)) e_contact_list_model_add_destination ( model, destination); } g_list_free (list); editor->priv->changed = TRUE; contact_list_editor_update (editor); }
static void contact_list_model_dispose (GObject *object) { EContactListModelPrivate *priv = E_CONTACT_LIST_MODEL (object)->priv; if (priv->uids_table) { g_hash_table_destroy (priv->uids_table); priv->uids_table = NULL; } if (priv->emails_table) { g_hash_table_destroy (priv->emails_table); priv->emails_table = NULL; } G_OBJECT_CLASS (e_contact_list_model_parent_class)->dispose (object); }
static void contact_list_editor_add_email (EContactListEditor *editor) { EContactListEditorPrivate *priv = editor->priv; EContactListModel *model; GtkEntry *entry; const gchar *text; entry = GTK_ENTRY (WIDGET (EMAIL_ENTRY)); model = E_CONTACT_LIST_MODEL (priv->model); text = gtk_entry_get_text (entry); if (text != NULL && *text != '\0') { e_contact_list_model_add_email (model, text); contact_list_editor_scroll_to_end (editor); priv->changed = TRUE; } gtk_entry_set_text (entry, ""); contact_list_editor_update (editor); }
void contact_list_editor_drag_data_received_cb (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint info, guint time) { EContactListEditor *editor; EContactListModel *model; gchar *target_type; gboolean changed = FALSE; gboolean handled = FALSE; GList *list, *iter; editor = contact_list_editor_extract (widget); model = E_CONTACT_LIST_MODEL (editor->priv->model); target_type = gdk_atom_name (selection_data->target); if (strcmp (target_type, VCARD_TYPE) != 0) goto exit; list = eab_contact_list_from_string ((gchar *) selection_data->data); if (list != NULL) handled = TRUE; for (iter = list; iter != NULL; iter = iter->next) { EContact *contact = iter->data; const gchar *email; if (e_contact_get (contact, E_CONTACT_IS_LIST)) continue; email = e_contact_get (contact, E_CONTACT_EMAIL_1); if (email == NULL) { g_warning ( "Contact with no email-ids listed " "can't be added to a Contact-List"); continue; } if (!contact_list_editor_contact_exists (model, email)) { /* Hard-wired for default e-mail */ e_contact_list_model_add_contact (model, contact, 0); changed = TRUE; } } g_list_foreach (list, (GFunc) g_object_unref, NULL); g_list_free (list); contact_list_editor_scroll_to_end (editor); if (changed) { editor->priv->changed = TRUE; contact_list_editor_update (editor); } exit: gtk_drag_finish (context, handled, FALSE, time); }