Ejemplo n.º 1
0
/* fill_widgets handler for the alarm page */
static void
alarm_to_dialog (Dialog *dialog)
{
	GtkTreeModel *model;
	GtkTreeIter iter;
	gboolean valid;
	gboolean repeat;
	ECalComponentAlarmAction action;
	gchar *email;
	gint i;

	/* Clean the page */
	clear_widgets (dialog);

	/* Alarm types */
	model = gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->action_combo));
	valid = gtk_tree_model_get_iter_first (model, &iter);
	for (i = 0; valid && action_map[i] != -1; i++) {
		gtk_list_store_set (
			GTK_LIST_STORE (model), &iter,
			1, !e_client_check_capability (E_CLIENT (dialog->cal_client), action_map_cap[i]),
			-1);

		valid = gtk_tree_model_iter_next (model, &iter);
	}

	/* Set a default address if possible */
	if (!e_client_check_capability (E_CLIENT (dialog->cal_client), CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)
	    && !e_cal_component_alarm_has_attendees (dialog->alarm)
	    && e_client_get_backend_property_sync (E_CLIENT (dialog->cal_client), CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS, &email, NULL, NULL)) {
		ECalComponentAttendee *a;
		GSList attendee_list;

		a = g_new0 (ECalComponentAttendee, 1);
		a->value = email;
		a->cutype = ICAL_CUTYPE_INDIVIDUAL;
		a->status = ICAL_PARTSTAT_NEEDSACTION;
		a->role = ICAL_ROLE_REQPARTICIPANT;
		attendee_list.data = a;
		attendee_list.next = NULL;
		e_cal_component_alarm_set_attendee_list (dialog->alarm, &attendee_list);
		g_free (email);
		g_free (a);
	}

	/* If we can repeat */
	repeat = !e_client_check_capability (E_CLIENT (dialog->cal_client), CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT);
	gtk_widget_set_sensitive (dialog->repeat_toggle, repeat);

	/* if we are editing a exiting alarm */
	e_cal_component_alarm_get_action (dialog->alarm, &action);

	if (action)
		populate_widgets_from_alarm (dialog);
}
Ejemplo n.º 2
0
/* fill_widgets handler for the alarm page */
static void
alarm_to_dialog (Dialog *dialog)
{
    GtkWidget *menu;
    GList *l;
    gboolean repeat;
    ECalComponentAlarmAction action;
    char *email;
    int i;

    /* Clean the page */
    clear_widgets (dialog);

    /* Alarm types */
    menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (dialog->action));
    for (i = 0, l = GTK_MENU_SHELL (menu)->children; action_map[i] != -1; i++, l = l->next) {
        if (e_cal_get_static_capability (dialog->ecal, action_map_cap[i]))
            gtk_widget_set_sensitive (l->data, FALSE);
        else
            gtk_widget_set_sensitive (l->data, TRUE);
    }

    /* Set a default address if possible */
    if (!e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS)
            && !e_cal_component_alarm_has_attendees (dialog->alarm)
            && e_cal_get_alarm_email_address (dialog->ecal, &email, NULL)) {
        ECalComponentAttendee *a;
        GSList attendee_list;

        a = g_new0 (ECalComponentAttendee, 1);
        a->value = email;
        attendee_list.data = a;
        attendee_list.next = NULL;
        e_cal_component_alarm_set_attendee_list (dialog->alarm, &attendee_list);
        g_free (email);
        g_free (a);
    }

    /* If we can repeat */
    repeat = !e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT);
    gtk_widget_set_sensitive (dialog->repeat_toggle, repeat);

    /* if we are editing a exiting alarm */
    e_cal_component_alarm_get_action (dialog->alarm, &action);

    if (action)
        populate_widgets_from_alarm (dialog);
}