2001-09-02 Christopher James Lahey <clahey@ximian.com> * backend/ebook/e-book.c (e_book_add_card, e_book_commit_card), backend/pas/pas-backend-file.c (do_create), backend/pas/pas-backend-ldap.c (create_card_handler, remove_card_handler, modify_card_handler, pas_backend_ldap_process_get_vcard, poll_ldap): Use e_card_get_vcard_assume_utf8 instead of e_card_get_vcard here since all internal communications and database storage are assumed to be utf8. * backend/ebook/e-card-simple.c, backend/ebook/e-card-simple.h (e_card_simple_duplicate): Simplified this function considerably. (e_card_simple_get_vcard_assume_utf8): Added this function. * backend/ebook/e-card.c, backend/ebook/e-card.h (e_card_new, e_card_load_cards_from_file, e_card_load_cards_from_string): Made these functions pay attention to charset attributes. (e_card_new_with_default_charset, e_card_load_cards_from_file_with_default_charset, e_card_load_cards_from_string_with_default_charset): New functions that let you change the default charset from UTF-8. (e_card_get_vcard): Made this write out charset attributes when necessary. (e_card_get_vcard_assume_utf8): New function that writes out a card without writing out charset attributes. * backend/ebook/evolution-vcard-importer.c (book_open_cb), backend/ebook/load-gnomecard-addressbook.c (book_open_cb), backend/ebook/test-card.c (main), gui/component/addressbook-component.c (destination_folder_handle_drop), gui/contact-editor/test-editor.c (main), gui/contact-list-editor/e-contact-list-editor.c (table_drag_data_received_cb), gui/widgets/e-addressbook-view.c (selection_received), gui/widgets/e-minicard-control.c (pstream_load): Changed the default charset to be used here to ISO-8859-1. * backend/ebook/load-gnomecard-addressbook.c (add_card_cb), backend/ebook/load-pine-addressbook.c (add_card_cb), backend/ebook/test-client-list.c (get_cursor_cb), backend/ebook/test-client.c (get_cursor_cb, get_card_cb): Use e_card_get_vcard_assume_utf8 to print out testing strings. * gui/component/select-names/e-select-names-model.c, gui/component/select-names/e-select-names-model.h (e_select_names_model_contains): Changed this to be const EDestination *dest to fix a warning. * gui/contact-editor/e-contact-editor.c (e_contact_editor_init): Translate window title here. svn path=/trunk/; revision=12558
146 lines
3.3 KiB
C
146 lines
3.3 KiB
C
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
|
/*
|
|
* test-editor.c
|
|
* Copyright (C) 2000 Ximian, Inc.
|
|
* Author: Chris Lahey <clahey@ximian.com>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdlib.h>
|
|
#include <gtk/gtkmain.h>
|
|
#include <libgnomeui/gnome-app.h>
|
|
#include <libgnomeui/gnome-init.h>
|
|
#include <glade/glade.h>
|
|
#include "e-contact-editor.h"
|
|
|
|
#define TEST_VCARD \
|
|
"BEGIN:VCARD
|
|
" \
|
|
"FN:Nat
|
|
" \
|
|
"N:Friedman;Nat;D;Mr.
|
|
" \
|
|
"BDAY:1977-08-06
|
|
" \
|
|
"TEL;WORK:617 679 1984
|
|
" \
|
|
"TEL;CELL:123 456 7890
|
|
" \
|
|
"EMAIL;INTERNET:nat@nat.org
|
|
" \
|
|
"EMAIL;INTERNET:nat@ximian.com
|
|
" \
|
|
"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234;
|
|
" \
|
|
"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA
|
|
" \
|
|
"END:VCARD
|
|
" \
|
|
"
|
|
"
|
|
|
|
static char *
|
|
read_file (char *name)
|
|
{
|
|
int len;
|
|
char buff[65536];
|
|
char line[1024];
|
|
FILE *f;
|
|
|
|
f = fopen (name, "r");
|
|
if (f == NULL)
|
|
g_error ("Unable to open %s!\n", name);
|
|
|
|
len = 0;
|
|
while (fgets (line, sizeof (line), f) != NULL) {
|
|
strcpy (buff + len, line);
|
|
len += strlen (line);
|
|
}
|
|
|
|
fclose (f);
|
|
|
|
return g_strdup (buff);
|
|
}
|
|
|
|
/* Callback used when a contact editor is closed */
|
|
static void
|
|
editor_closed_cb (EContactEditor *ce, gpointer data)
|
|
{
|
|
static int count = 2;
|
|
|
|
count--;
|
|
gtk_object_unref (GTK_OBJECT (ce));
|
|
|
|
if (count == 0)
|
|
exit (0);
|
|
}
|
|
|
|
#if 0
|
|
static void about_callback( GtkWidget *widget, gpointer data )
|
|
{
|
|
|
|
const gchar *authors[] =
|
|
{
|
|
"Christopher James Lahey <clahey@umich.edu>",
|
|
NULL
|
|
};
|
|
|
|
GtkWidget *about =
|
|
gnome_about_new ( _( "Contact Editor Test" ), VERSION,
|
|
_( "Copyright (C) 2000, Ximian, Inc." ),
|
|
authors,
|
|
_( "This should test the contact editor canvas item" ),
|
|
NULL);
|
|
gtk_widget_show (about);
|
|
}
|
|
#endif
|
|
|
|
int main( int argc, char *argv[] )
|
|
{
|
|
char *cardstr;
|
|
EContactEditor *ce;
|
|
|
|
/* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
|
|
textdomain (PACKAGE);*/
|
|
|
|
gnome_init( "Contact Editor Test", VERSION, argc, argv);
|
|
|
|
glade_gnome_init ();
|
|
|
|
cardstr = NULL;
|
|
if (argc == 2)
|
|
cardstr = read_file (argv [1]);
|
|
|
|
if (cardstr == NULL)
|
|
cardstr = TEST_VCARD;
|
|
|
|
ce = e_contact_editor_new (e_card_new_with_default_charset (cardstr, "ISO-8859-1"), TRUE, NULL, FALSE);
|
|
gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
|
|
GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
|
|
|
|
ce = e_contact_editor_new (e_card_new_with_default_charset (cardstr, "ISO-8859-1"), TRUE, NULL, FALSE);
|
|
gtk_signal_connect (GTK_OBJECT (ce), "editor_closed",
|
|
GTK_SIGNAL_FUNC (editor_closed_cb), NULL);
|
|
|
|
gtk_main();
|
|
|
|
/* Not reached. */
|
|
return 0;
|
|
}
|