static void check_custom_email (Dialog *dialog) { gchar *str; GtkTextBuffer *text_buffer; GtkTextIter text_iter_start, text_iter_end; ENameSelectorModel *name_selector_model; EDestinationStore *destination_store; GList *destinations; gboolean sens; name_selector_model = e_name_selector_peek_model (dialog->name_selector); e_name_selector_model_peek_section (name_selector_model, section_name, NULL, &destination_store); destinations = e_destination_store_list_destinations (destination_store); text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->malarm_description)); gtk_text_buffer_get_start_iter (text_buffer, &text_iter_start); gtk_text_buffer_get_end_iter (text_buffer, &text_iter_end); str = gtk_text_buffer_get_text (text_buffer, &text_iter_start, &text_iter_end, FALSE); sens = (destinations != NULL) && (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->malarm_message)) ? str && *str : TRUE); gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog->toplevel), GTK_RESPONSE_OK, sens); g_list_free (destinations); }
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); }
/* Fills the widgets from mail alarm data */ static void alarm_to_malarm_widgets (Dialog *dialog, ECalComponentAlarm *alarm) { ENameSelectorModel *name_selector_model; EDestinationStore *destination_store; ECalComponentText description; GtkTextBuffer *text_buffer; GSList *attendee_list, *l; gint len; /* Attendees */ name_selector_model = e_name_selector_peek_model (dialog->name_selector); e_name_selector_model_peek_section (name_selector_model, section_name, NULL, &destination_store); e_cal_component_alarm_get_attendee_list (alarm, &attendee_list); len = g_slist_length (attendee_list); if (len > 0) { for (l = attendee_list; l; l = g_slist_next (l)) { ECalComponentAttendee *a = l->data; EDestination *dest; dest = e_destination_new (); if (a->cn != NULL && *a->cn) e_destination_set_name (dest, a->cn); if (a->value != NULL && *a->value) { if (!strncasecmp (a->value, "MAILTO:", 7)) e_destination_set_email (dest, a->value + 7); else e_destination_set_email (dest, a->value); } e_destination_store_append_destination (destination_store, dest); g_object_unref (G_OBJECT (dest)); } e_cal_component_free_attendee_list (attendee_list); } /* Description */ e_cal_component_alarm_get_description (alarm, &description); if (description.value) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->malarm_message), TRUE); text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->malarm_description)); gtk_text_buffer_set_text (text_buffer, description.value, -1); } }
/* Fills the mail alarm data with the values from the widgets */ static void malarm_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm) { gchar *str; ECalComponentText description; GSList *attendee_list = NULL; GtkTextBuffer *text_buffer; GtkTextIter text_iter_start, text_iter_end; ENameSelectorModel *name_selector_model; EDestinationStore *destination_store; GList *destinations; icalcomponent *icalcomp; icalproperty *icalprop; GList *l; /* Attendees */ name_selector_model = e_name_selector_peek_model (dialog->name_selector); e_name_selector_model_peek_section (name_selector_model, section_name, NULL, &destination_store); destinations = e_destination_store_list_destinations (destination_store); for (l = destinations; l; l = g_list_next (l)) { EDestination *dest; ECalComponentAttendee *a; dest = l->data; a = g_new0 (ECalComponentAttendee, 1); a->value = e_destination_get_email (dest); a->cn = e_destination_get_name (dest); a->cutype = ICAL_CUTYPE_INDIVIDUAL; a->status = ICAL_PARTSTAT_NEEDSACTION; a->role = ICAL_ROLE_REQPARTICIPANT; attendee_list = g_slist_append (attendee_list, a); } e_cal_component_alarm_set_attendee_list (alarm, attendee_list); e_cal_component_free_attendee_list (attendee_list); g_list_free (destinations); if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->malarm_message))) return; /* Description */ text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->malarm_description)); gtk_text_buffer_get_start_iter (text_buffer, &text_iter_start); gtk_text_buffer_get_end_iter (text_buffer, &text_iter_end); str = gtk_text_buffer_get_text (text_buffer, &text_iter_start, &text_iter_end, FALSE); description.value = str; description.altrep = NULL; e_cal_component_alarm_set_description (alarm, &description); g_free (str); /* remove the X-EVOLUTION-NEEDS-DESCRIPTION property, so that * we don't re-set the alarm's description */ icalcomp = e_cal_component_alarm_get_icalcomponent (alarm); icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY); while (icalprop) { const gchar *x_name; x_name = icalproperty_get_x_name (icalprop); if (!strcmp (x_name, "X-EVOLUTION-NEEDS-DESCRIPTION")) { icalcomponent_remove_property (icalcomp, icalprop); break; } icalprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY); } }