/* Fills the audio alarm data with the values from the widgets */ static void aalarm_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm) { char *url; icalattach *attach; if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->aalarm_sound))) return; url = gtk_file_chooser_get_uri ( GTK_FILE_CHOOSER (dialog->aalarm_file_chooser)); attach = icalattach_new_from_url (url ? url : ""); g_free (url); e_cal_component_alarm_set_attach (alarm, attach); icalattach_unref (attach); }
/* Fills the procedure alarm data with the values from the widgets */ static void palarm_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm) { gchar *program; icalattach *attach; gchar *str; ECalComponentText description; icalcomponent *icalcomp; icalproperty *icalprop; program = e_dialog_editable_get (dialog->palarm_program); attach = icalattach_new_from_url (program ? program : ""); g_free (program); e_cal_component_alarm_set_attach (alarm, attach); icalattach_unref (attach); str = e_dialog_editable_get (dialog->palarm_args); 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); } }
static void add_attach (icalcomponent *icalcomp, const gchar *uri) { gsize buf_size; gchar *buf; icalproperty *prop; icalattach *attach; g_return_if_fail (icalcomp != NULL); g_return_if_fail (uri != NULL); buf_size = 2 * strlen (uri); buf = g_malloc0 (buf_size); icalvalue_encode_ical_string (uri, buf, buf_size); attach = icalattach_new_from_url (uri); prop = icalproperty_new_attach (attach); icalcomponent_add_property (icalcomp, prop); icalattach_unref (attach); g_free (buf); }