Пример #1
0
static void
contacts_edit_delete_cb (GtkWidget *button, ContactsData *data)
{
	GtkWidget *dialog, *main_window;
	GList *widgets;
	
	main_window = data->ui->main_window;
	dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
					 0, GTK_MESSAGE_QUESTION,
					 GTK_BUTTONS_YES_NO,
					 _("Are you sure you want to delete "\
					 "this contact?"));
	
	widgets = contacts_set_widgets_desensitive (main_window);
	switch (gtk_dialog_run (GTK_DIALOG (dialog))) {
		case GTK_RESPONSE_YES:
			e_book_remove_contact (data->book,
				e_contact_get_const (
					data->contact, E_CONTACT_UID), NULL);
			contacts_set_widgets_sensitive (widgets);
			contacts_edit_pane_hide (data);
			break;
		default:
			contacts_set_widgets_sensitive (widgets);
			break;
	}
	gtk_widget_destroy (dialog);
}
gint
main (gint argc,
      gchar **argv)
{
#if 0  /* ACCOUNT_MGMT */
	GError *err = NULL;
	EBook *book = NULL;

	printf ("loading addressbook\n");
	book = e_book_new_system_addressbook (NULL);
	if (!book) {
		printf ("failed to create local addressbook\n");
		exit (0);
	}

	if (!e_book_open (book, FALSE, NULL)) {
		printf ("failed to open local addressbook\n");
		exit (0);
	}

	printf ("removing nonexistant contact\n");
	if (!e_book_remove_contact (book, "kk", &err)) {
		printf ("error %d removing contact: %s\n", err->code, err->message);
		g_clear_error (&err);
	}
#endif /* ACCOUNT_MGMT */

	return 0;
}
Пример #3
0
static gint
delete_record (GnomePilotConduitSyncAbs *conduit,
	       EAddrLocalRecord *local,
	       EAddrConduitContext *ctxt)
{
	GError *error = NULL;
	int retval = 0;

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

	LOG (g_message ( "delete_record: delete %s\n", print_local (local) ));

	e_pilot_map_remove_by_uid (ctxt->map, e_contact_get_const (local->contact, E_CONTACT_UID));
	if (!e_book_remove_contact (ctxt->ebook, e_contact_get_const (local->contact, E_CONTACT_UID), &error) && error->code != E_BOOK_ERROR_CONTACT_NOT_FOUND) {
		WARN ("delete_record: failed to delete card in ebook\n");
		g_error_free (error);

		retval = -1;
	}

	return retval;
}