示例#1
0
void
dates_calendar_combo_changed_cb (GtkComboBox *widget, DatesData *d)
{
    ECal *c;
    ECalComponent *comp = d->comp;
    GtkTreeIter iter;
	
    if (!gtk_combo_box_get_active_iter (widget, &iter)) return;
    gtk_tree_model_get (gtk_combo_box_get_model (widget),
			&iter, COL_CALPTR, &c, -1);
	
    if (c != d->cal) {
	/* Move event between calendars */
	const char *uid = NULL;
		
	g_object_ref (comp);
	if (!d->waiting)
	    d->waiting = PENDING_CAL_CHANGE;
	e_cal_component_get_uid (comp, &uid);
	e_cal_remove_object (d->cal, uid, NULL);
		
	/* TODO: Error checking */
	e_cal_create_object (c,
			     e_cal_component_get_icalcomponent (comp),
			     (char **)&uid, NULL);
	g_object_unref (comp);
	d->uri_uid = g_strconcat (e_cal_get_uri (c), uid, NULL);
	d->widgets = contacts_set_widgets_desensitive (d->details_dialog);
	g_idle_add (dates_select_event_idle_cb, d);
    }
}
示例#2
0
void
dates_details_cancel_cb (GtkWidget *source, DatesData *d)
{
    if (d->event_type == NEW_EVENT) {
	if (d->waiting == NONE) {
	    const char *uid = NULL;
	    d->event_type = NORMAL;
	    e_cal_component_get_uid (d->comp, &uid);
	    e_cal_remove_object (d->cal, uid, NULL);
	} else {
	    d->widgets = contacts_set_widgets_desensitive (
		d->details_dialog);
	    d->waiting = PENDING_DELETE;
	    return;
	}
    }

	dates_platform_details_dlg (d, FALSE);
}
示例#3
0
static gint
delete_record (GnomePilotConduitSyncAbs *conduit,
	       EMemoLocalRecord *local,
	       EMemoConduitContext *ctxt)
{
	const char *uid;

	g_return_val_if_fail (local != NULL, -1);
	g_return_val_if_fail (local->comp != NULL, -1);

	e_cal_component_get_uid (local->comp, &uid);

	LOG (g_message ( "delete_record: deleting %s", uid ));

	e_pilot_map_remove_by_uid (ctxt->map, uid);
	/* FIXME Error handling */
	e_cal_remove_object (ctxt->client, uid, NULL);

        return 0;
}
示例#4
0
gboolean
evo_cal_source_remove_object(ECal *ecal, ECalComponent *obj)
{
    char *uid = NULL;
    GError *error = NULL;
    gboolean ret = FALSE;

    uid = evo_cal_component_get_uid(obj);
    if (uid) {
        if (e_cal_remove_object(ecal, uid, &error)) {
            ret = TRUE;
        } else {
            g_warning("failed to remove %s: %s", uid, error ? error->message : "None");
            g_clear_error(&error);
        }
    }
    g_free(uid);

    return ret;
}
示例#5
0
gboolean
dates_select_event_idle_cb (gpointer data)
{
    DatesData *d = data;
    gboolean selected =
	dates_view_set_selected_event (d->view, d->uri_uid, NULL);
	
    if (selected) {
	const char *uid = NULL;
	g_free (d->uri_uid);
	d->uri_uid = NULL;
	
	if (d->widgets) {
	    contacts_set_widgets_sensitive (d->widgets);
	    g_list_free (d->widgets);
	    d->widgets = NULL;
	}
	switch (d->waiting) {
	    case NONE :
	    case PENDING_CREATE :
		break;
	    case PENDING_DELETE :
		e_cal_component_get_uid (d->comp, &uid);
		e_cal_remove_object (d->cal, uid, NULL);
	    dates_platform_details_dlg (d, FALSE);
		break;
	    case PENDING_CHANGE :
		dates_save_changes (d);
		gtk_widget_hide (d->details_dialog);
		break;
	    case PENDING_CAL_CHANGE :
		break;
	    default:
		g_warning ("Unknown pending state");
	}
	d->waiting = NONE;
    }
	
    return !selected;
}
示例#6
0
static gchar *
test_object_removal (ECal *client)
{

	gchar *uid;
	ECalComponent *comp;
	icalcomponent *icalcomp;
	gboolean compare = 1;
	GError *error = NULL;

	comp = e_cal_component_new ();
	e_cal_component_commit_sequence (comp);
	icalcomp = e_cal_component_get_icalcomponent (comp);
	if (!e_cal_create_object (client, icalcomp, &uid, &error)) {
		cl_printf (client, "Test object removal - Object creation:  %s\n", error->message);
		g_object_unref (comp);
		g_object_unref (icalcomp);
		return "Test Object Removal failed\n";
	}

	if (!e_cal_remove_object (client, uid, &error)) {
		cl_printf (client, "Test object removal - Could not remove the object\n");
		g_free (uid);
		g_object_unref (comp);
		g_object_unref (icalcomp);
		return "Test Object Removal failed\n";

	}

	compare =  e_cal_get_object (client, uid, NULL, &icalcomp, &error);

	g_free (uid);
	g_object_unref (comp);
	g_object_unref (icalcomp);

	mu_assert ("Test object removal - Failed\n", compare);
	return NULL;
}
示例#7
0
void
dates_delete_cb (GtkWidget *source, DatesData *d)
{
    ECalComponentText summary;
    GtkWidget *widget;
    const char *orig_value;
    char *value;
#ifdef WITH_HILDON
    gchar *tmp;
#endif

    e_cal_component_get_summary (d->comp, &summary);
    widget = d->details_dialog;
    if (GTK_WIDGET_VISIBLE (widget))
	orig_value = gtk_entry_get_text (GTK_ENTRY (d->details_summary_entry));
    else if (summary.value)
	orig_value = summary.value;
    else if (summary.altrep)
	orig_value = summary.altrep;
    else {
	g_warning ("Deleting event with no summary");
	orig_value = _("Unknown event");
    }

    value = str_truncate (orig_value, 50);

#ifdef WITH_HILDON
    tmp = g_strdup_printf(_("Are you sure you want to delete event '%s'?"), value);
    widget = hildon_note_new_confirmation_add_buttons(
        GTK_WINDOW (d->main_window),
        tmp,
        _("Keep event"), GTK_RESPONSE_NO,
        _("Delete event"), GTK_RESPONSE_YES,
        NULL);
    g_free(tmp);
#else
    widget = gtk_message_dialog_new (
	GTK_WINDOW (d->main_window),
	GTK_DIALOG_MODAL,
	GTK_MESSAGE_QUESTION,
	GTK_BUTTONS_NONE,
	_("Are you sure you want to delete event '%s'?"),
	value);
    gtk_dialog_add_buttons (GTK_DIALOG (widget),
			    _("Keep event"), GTK_RESPONSE_NO,
			    _("Delete event"), GTK_RESPONSE_YES,
			    NULL);
#endif
    if (gtk_dialog_run (GTK_DIALOG (widget)) == GTK_RESPONSE_YES) {
	/* Reset event type, in case this was a new event */
	d->event_type = NORMAL;
		
	if (d->waiting == NONE) {
	    const char *uid = NULL;
	    e_cal_component_get_uid (d->comp, &uid);
	    e_cal_remove_object (d->cal, uid, NULL);

	    /* Hide the details dialog, in case we deleted
	     * from there.
	     */
	    dates_platform_details_dlg (d, FALSE);
	} else {
	    d->widgets = contacts_set_widgets_desensitive (
		d->details_dialog);
	    d->waiting = PENDING_DELETE;
	}
    }
	
    gtk_widget_destroy (widget);
    g_free (value);
}