aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-05-05 20:55:01 +0800
committerChris Lahey <clahey@src.gnome.org>2000-05-05 20:55:01 +0800
commit73eafe0999fe4f83e6428886bf63c09a03ccdcf6 (patch)
tree97c3965711296957e44d6cd751ed36e6a4c13d70
parentf80ee8128bb94839d8a84cc620a209d37bbfa277 (diff)
downloadgsoc2013-evolution-73eafe0999fe4f83e6428886bf63c09a03ccdcf6.tar
gsoc2013-evolution-73eafe0999fe4f83e6428886bf63c09a03ccdcf6.tar.gz
gsoc2013-evolution-73eafe0999fe4f83e6428886bf63c09a03ccdcf6.tar.bz2
gsoc2013-evolution-73eafe0999fe4f83e6428886bf63c09a03ccdcf6.tar.lz
gsoc2013-evolution-73eafe0999fe4f83e6428886bf63c09a03ccdcf6.tar.xz
gsoc2013-evolution-73eafe0999fe4f83e6428886bf63c09a03ccdcf6.tar.zst
gsoc2013-evolution-73eafe0999fe4f83e6428886bf63c09a03ccdcf6.zip
Added e-card-simple.c and e-card-simple.h.
2000-05-05 Christopher James Lahey <clahey@helixcode.com> * backend/ebook/Makefile.am: Added e-card-simple.c and e-card-simple.h. * backend/ebook/e-card-simple.c, backend/ebook/e-card-simple.h: New card wrapper class to simplify things. * contact-editor/e-contact-editor.c, contact-editor/e-contact-editor.h: Changed e-contact-editor to use ECardSimple a bit. svn path=/trunk/; revision=2815
-rw-r--r--addressbook/ChangeLog12
-rw-r--r--addressbook/backend/ebook/Makefile.am2
-rw-r--r--addressbook/backend/ebook/e-card-simple.c713
-rw-r--r--addressbook/backend/ebook/e-card-simple.h115
-rw-r--r--addressbook/contact-editor/e-contact-editor.c301
-rw-r--r--addressbook/contact-editor/e-contact-editor.h55
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c301
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.h55
8 files changed, 972 insertions, 582 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 89d894ab71..5430229ea1 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,15 @@
+2000-05-05 Christopher James Lahey <clahey@helixcode.com>
+
+ * backend/ebook/Makefile.am: Added e-card-simple.c and
+ e-card-simple.h.
+
+ * backend/ebook/e-card-simple.c, backend/ebook/e-card-simple.h:
+ New card wrapper class to simplify things.
+
+ * contact-editor/e-contact-editor.c,
+ contact-editor/e-contact-editor.h: Changed e-contact-editor to use
+ ECardSimple a bit.
+
2000-05-03 Chris Toshok <toshok@helixcode.com>
* gui/component/addressbook.c (control_deactivate): #ifdef
diff --git a/addressbook/backend/ebook/Makefile.am b/addressbook/backend/ebook/Makefile.am
index 970618c53a..9b4634f49e 100644
--- a/addressbook/backend/ebook/Makefile.am
+++ b/addressbook/backend/ebook/Makefile.am
@@ -36,6 +36,7 @@ libebook_la_SOURCES = \
e-card-iterator.c \
e-card-list-iterator.c \
e-card-list.c \
+ e-card-simple.c \
e-card.c
libebookincludedir = $(includedir)/evolution/ebook
@@ -49,6 +50,7 @@ libebookinclude_HEADERS = \
e-card-iterator.h \
e-card-list-iterator.h \
e-card-list.h \
+ e-card-simple.h \
e-card.h
test_client_SOURCES = \
diff --git a/addressbook/backend/ebook/e-card-simple.c b/addressbook/backend/ebook/e-card-simple.c
new file mode 100644
index 0000000000..495fc71e80
--- /dev/null
+++ b/addressbook/backend/ebook/e-card-simple.c
@@ -0,0 +1,713 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Authors:
+ * Chris Lahey <clahey@helixcode.com>
+ * Arturo Espinosa (arturo@nuclecu.unam.mx)
+ * Nat Friedman (nat@helixcode.com)
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Copyright (C) 1999 The Free Software Foundation
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gtk/gtk.h>
+
+#include <libversit/vcc.h>
+#include "e-card-simple.h"
+
+/* Object argument IDs */
+enum {
+ ARG_0,
+ ARG_CARD,
+#if 0
+ ARG_FILE_AS,
+ ARG_FULL_NAME,
+ ARG_NAME,
+ ARG_ADDRESS,
+ ARG_ADDRESS_LABEL,
+ ARG_PHONE,
+ ARG_EMAIL,
+ ARG_BIRTH_DATE,
+ ARG_URL,
+ ARG_ORG,
+ ARG_ORG_UNIT,
+ ARG_OFFICE,
+ ARG_TITLE,
+ ARG_ROLE,
+ ARG_MANAGER,
+ ARG_ASSISTANT,
+ ARG_NICKNAME,
+ ARG_SPOUSE,
+ ARG_ANNIVERSARY,
+ ARG_FBURL,
+ ARG_NOTE,
+ ARG_ID
+#endif
+};
+
+static void e_card_simple_init (ECardSimple *simple);
+static void e_card_simple_class_init (ECardSimpleClass *klass);
+
+static void e_card_simple_destroy (GtkObject *object);
+static void e_card_simple_set_arg (GtkObject *object, GtkArg *arg, guint arg_id);
+static void e_card_simple_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
+
+static void fill_in_info(ECardSimple *simple);
+
+ECardPhoneFlags phone_correspondences[] = {
+ 0xFF, /* E_CARD_SIMPLE_PHONE_ID_ASSISTANT, */
+ E_CARD_PHONE_WORK | E_CARD_PHONE_VOICE, /* E_CARD_SIMPLE_PHONE_ID_BUSINESS, */
+ E_CARD_PHONE_WORK | E_CARD_PHONE_VOICE, /* E_CARD_SIMPLE_PHONE_ID_BUSINESS_2, */
+ E_CARD_PHONE_WORK | E_CARD_PHONE_FAX, /* E_CARD_SIMPLE_PHONE_ID_BUSINESS_FAX, */
+ 0xFF, /* E_CARD_SIMPLE_PHONE_ID_CALLBACK, */
+ E_CARD_PHONE_CAR | E_CARD_PHONE_VOICE, /* E_CARD_SIMPLE_PHONE_ID_CAR, */
+ 0xFF, /* E_CARD_SIMPLE_PHONE_ID_COMPANY, */
+ E_CARD_PHONE_HOME | E_CARD_PHONE_VOICE, /* E_CARD_SIMPLE_PHONE_ID_HOME, */
+ E_CARD_PHONE_HOME | E_CARD_PHONE_VOICE, /* E_CARD_SIMPLE_PHONE_ID_HOME_2, */
+ E_CARD_PHONE_HOME | E_CARD_PHONE_FAX, /* E_CARD_SIMPLE_PHONE_ID_HOME_FAX, */
+ E_CARD_PHONE_ISDN, /* E_CARD_SIMPLE_PHONE_ID_ISDN, */
+ E_CARD_PHONE_CELL | E_CARD_PHONE_VOICE, /* E_CARD_SIMPLE_PHONE_ID_MOBILE, */
+ E_CARD_PHONE_VOICE, /* E_CARD_SIMPLE_PHONE_ID_OTHER, */
+ 0xFF, /* E_CARD_SIMPLE_PHONE_ID_OTHER_FAX, */
+ E_CARD_PHONE_PAGER | E_CARD_PHONE_VOICE, /* E_CARD_SIMPLE_PHONE_ID_PAGER, */
+ E_CARD_PHONE_PREF, /* E_CARD_SIMPLE_PHONE_ID_PRIMARY, */
+ 0xFF, /* E_CARD_SIMPLE_PHONE_ID_RADIO, */
+ 0xFF, /* E_CARD_SIMPLE_PHONE_ID_TELEX, */
+ 0xFF, /* E_CARD_SIMPLE_PHONE_ID_TTYTTD, */
+};
+
+ECardAddressFlags addr_correspondences[] = {
+ E_CARD_ADDR_WORK, /* E_CARD_SIMPLE_ADDRESS_ID_BUSINESS, */
+ E_CARD_ADDR_HOME, /* E_CARD_SIMPLE_ADDRESS_ID_HOME, */
+ E_CARD_ADDR_POSTAL, /* E_CARD_SIMPLE_ADDRESS_ID_OTHER, */
+};
+
+/**
+ * e_card_simple_get_type:
+ * @void:
+ *
+ * Registers the &ECardSimple class if necessary, and returns the type ID
+ * associated to it.
+ *
+ * Return value: The type ID of the &ECardSimple class.
+ **/
+GtkType
+e_card_simple_get_type (void)
+{
+ static GtkType simple_type = 0;
+
+ if (!simple_type) {
+ GtkTypeInfo simple_info = {
+ "ECardSimple",
+ sizeof (ECardSimple),
+ sizeof (ECardSimpleClass),
+ (GtkClassInitFunc) e_card_simple_class_init,
+ (GtkObjectInitFunc) e_card_simple_init,
+ NULL, /* reserved_1 */
+ NULL, /* reserved_2 */
+ (GtkClassInitFunc) NULL
+ };
+
+ simple_type = gtk_type_unique (gtk_object_get_type (), &simple_info);
+ }
+
+ return simple_type;
+}
+
+/**
+ * e_card_simple_new:
+ * @VCard: a string in vCard format
+ *
+ * Returns: a new #ECardSimple that wraps the @VCard.
+ */
+ECardSimple *
+e_card_simple_new (ECard *card)
+{
+ ECardSimple *simple = E_CARD_SIMPLE(gtk_type_new(e_card_simple_get_type()));
+ gtk_object_set(GTK_OBJECT(simple),
+ "card", card,
+ NULL);
+ return simple;
+}
+
+ECardSimple *e_card_simple_duplicate(ECardSimple *simple)
+{
+ char *vcard = e_card_simple_get_vcard(simple);
+ ECard *card = e_card_new(vcard);
+ ECardSimple *new_simple = e_card_simple_new(card);
+ g_free (vcard);
+ return new_simple;
+}
+
+/**
+ * e_card_simple_get_id:
+ * @simple: an #ECardSimple
+ *
+ * Returns: a string representing the id of the simple, which is unique
+ * within its book.
+ */
+char *
+e_card_simple_get_id (ECardSimple *simple)
+{
+ if (simple->card)
+ return e_card_get_id(simple->card);
+ else
+ return "";
+}
+
+/**
+ * e_card_simple_get_id:
+ * @simple: an #ECardSimple
+ * @id: a id in string format
+ *
+ * Sets the identifier of a simple, which should be unique within its
+ * book.
+ */
+void
+e_card_simple_set_id (ECardSimple *simple, const char *id)
+{
+ if ( simple->card )
+ e_card_set_id(simple->card, id);
+}
+
+/**
+ * e_card_simple_get_vcard:
+ * @simple: an #ECardSimple
+ *
+ * Returns: a string in vcard format, which is wrapped by the @simple.
+ */
+char
+*e_card_simple_get_vcard (ECardSimple *simple)
+{
+ if (simple->card)
+ return e_card_get_vcard(simple->card);
+ else
+ return g_strdup("");
+}
+
+static void
+e_card_simple_class_init (ECardSimpleClass *klass)
+{
+ GtkObjectClass *object_class;
+
+ object_class = GTK_OBJECT_CLASS(klass);
+
+ gtk_object_add_arg_type ("ECardSimple::card",
+ GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_CARD);
+#if 0
+ gtk_object_add_arg_type ("ECardSimple::file_as",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_FILE_AS);
+ gtk_object_add_arg_type ("ECardSimple::full_name",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_FULL_NAME);
+ gtk_object_add_arg_type ("ECardSimple::name",
+ GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_NAME);
+ gtk_object_add_arg_type ("ECardSimple::address",
+ GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_ADDRESS);
+ gtk_object_add_arg_type ("ECardSimple::address_label",
+ GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_ADDRESS_LABEL);
+ gtk_object_add_arg_type ("ECardSimple::phone",
+ GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_PHONE);
+ gtk_object_add_arg_type ("ECardSimple::email",
+ GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_EMAIL);
+ gtk_object_add_arg_type ("ECardSimple::birth_date",
+ GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_BIRTH_DATE);
+ gtk_object_add_arg_type ("ECardSimple::url",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_URL);
+ gtk_object_add_arg_type ("ECardSimple::org",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ORG);
+ gtk_object_add_arg_type ("ECardSimple::org_unit",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ORG_UNIT);
+ gtk_object_add_arg_type ("ECardSimple::office",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_OFFICE);
+ gtk_object_add_arg_type ("ECardSimple::title",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TITLE);
+ gtk_object_add_arg_type ("ECardSimple::role",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ROLE);
+ gtk_object_add_arg_type ("ECardSimple::manager",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_MANAGER);
+ gtk_object_add_arg_type ("ECardSimple::assistant",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ASSISTANT);
+ gtk_object_add_arg_type ("ECardSimple::nickname",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_NICKNAME);
+ gtk_object_add_arg_type ("ECardSimple::spouse",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_SPOUSE);
+ gtk_object_add_arg_type ("ECardSimple::anniversary",
+ GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_ANNIVERSARY);
+ gtk_object_add_arg_type ("ECardSimple::fburl",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_FBURL);
+ gtk_object_add_arg_type ("ECardSimple::note",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_NOTE);
+ gtk_object_add_arg_type ("ECardSimple::id",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ID);
+#endif
+
+ object_class->destroy = e_card_simple_destroy;
+ object_class->get_arg = e_card_simple_get_arg;
+ object_class->set_arg = e_card_simple_set_arg;
+}
+
+/*
+ * ECardSimple lifecycle management and vcard loading/saving.
+ */
+
+static void
+e_card_simple_destroy (GtkObject *object)
+{
+}
+
+
+/* Set_arg handler for the simple */
+static void
+e_card_simple_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
+{
+ ECardSimple *simple;
+
+ simple = E_CARD_SIMPLE (object);
+
+ switch (arg_id) {
+ case ARG_CARD:
+ if (simple->card)
+ gtk_object_unref(GTK_OBJECT(simple->card));
+ if (GTK_VALUE_OBJECT(*arg))
+ simple->card = E_CARD(GTK_VALUE_OBJECT(*arg));
+ else
+ simple->card = NULL;
+ if(simple->card)
+ gtk_object_ref(GTK_OBJECT(simple->card));
+ fill_in_info(simple);
+ break;
+#if 0
+ case ARG_FILE_AS:
+ if (simple->file_as)
+ g_free(simple->file_as);
+ simple->file_as = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_FULL_NAME:
+ if ( simple->fname )
+ g_free(simple->fname);
+ simple->fname = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_NAME:
+ if ( simple->name )
+ e_card_simple_name_free(simple->name);
+ simple->name = GTK_VALUE_POINTER(*arg);
+ break;
+ case ARG_BIRTH_DATE:
+ if ( simple->bday )
+ g_free(simple->bday);
+ simple->bday = GTK_VALUE_POINTER(*arg);
+ break;
+ case ARG_URL:
+ if ( simple->url )
+ g_free(simple->url);
+ simple->url = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_ORG:
+ if (simple->org)
+ g_free(simple->org);
+ simple->org = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_ORG_UNIT:
+ if (simple->org_unit)
+ g_free(simple->org_unit);
+ simple->org_unit = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_OFFICE:
+ if (simple->office)
+ g_free(simple->office);
+ simple->office = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_TITLE:
+ if ( simple->title )
+ g_free(simple->title);
+ simple->title = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_ROLE:
+ if (simple->role)
+ g_free(simple->role);
+ simple->role = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_MANAGER:
+ if (simple->manager)
+ g_free(simple->manager);
+ simple->manager = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_ASSISTANT:
+ if (simple->assistant)
+ g_free(simple->assistant);
+ simple->assistant = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_NICKNAME:
+ if (simple->nickname)
+ g_free(simple->nickname);
+ simple->nickname = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_SPOUSE:
+ if (simple->spouse)
+ g_free(simple->spouse);
+ simple->spouse = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_ANNIVERSARY:
+ if ( simple->anniversary )
+ g_free(simple->anniversary);
+ simple->anniversary = GTK_VALUE_POINTER(*arg);
+ break;
+ case ARG_FBURL:
+ if (simple->fburl)
+ g_free(simple->fburl);
+ simple->fburl = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_NOTE:
+ if (simple->note)
+ g_free (simple->note);
+ simple->note = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+ case ARG_ID:
+ if (simple->id)
+ g_free(simple->id);
+ simple->id = g_strdup(GTK_VALUE_STRING(*arg));
+ break;
+#endif
+ default:
+ return;
+ }
+}
+
+/* Get_arg handler for the simple */
+static void
+e_card_simple_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
+{
+ ECardSimple *simple;
+
+ simple = E_CARD_SIMPLE (object);
+
+ switch (arg_id) {
+ case ARG_CARD:
+ e_card_simple_sync_card(simple);
+ if (simple->card)
+ GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(simple->card);
+ else
+ GTK_VALUE_OBJECT (*arg) = NULL;
+ break;
+#if 0
+ case ARG_FILE_AS:
+ GTK_VALUE_STRING (*arg);
+ break;
+ case ARG_FULL_NAME:
+ GTK_VALUE_STRING (*arg) = simple->fname;
+ break;
+ case ARG_NAME:
+ GTK_VALUE_POINTER(*arg) = simple->name;
+ break;
+ case ARG_ADDRESS:
+ if (!simple->address)
+ simple->address = e_card_simple_list_new((ECardSimpleListCopyFunc) e_card_simple_delivery_address_copy,
+ (ECardSimpleListFreeFunc) e_card_simple_delivery_address_free,
+ NULL);
+ GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(simple->address);
+ break;
+ case ARG_ADDRESS_LABEL:
+ if (!simple->address_label)
+ simple->address_label = e_card_simple_list_new((ECardSimpleListCopyFunc) e_card_simple_address_label_copy,
+ (ECardSimpleListFreeFunc) e_card_simple_address_label_free,
+ NULL);
+ GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(simple->address_label);
+ break;
+ case ARG_PHONE:
+ if (!simple->phone)
+ simple->phone = e_card_simple_list_new((ECardSimpleListCopyFunc) e_card_simple_phone_copy,
+ (ECardSimpleListFreeFunc) e_card_simple_phone_free,
+ NULL);
+ GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(simple->phone);
+ break;
+ case ARG_EMAIL:
+ if (!simple->email)
+ simple->email = e_card_simple_list_new((ECardSimpleListCopyFunc) g_strdup,
+ (ECardSimpleListFreeFunc) g_free,
+ NULL);
+ GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(simple->email);
+ break;
+ case ARG_BIRTH_DATE:
+ GTK_VALUE_POINTER(*arg) = simple->bday;
+ break;
+ case ARG_URL:
+ GTK_VALUE_STRING(*arg) = simple->url;
+ break;
+ case ARG_ORG:
+ GTK_VALUE_STRING(*arg) = simple->org;
+ break;
+ case ARG_ORG_UNIT:
+ GTK_VALUE_STRING(*arg) = simple->org_unit;
+ break;
+ case ARG_OFFICE:
+ GTK_VALUE_STRING(*arg) = simple->office;
+ break;
+ case ARG_TITLE:
+ GTK_VALUE_STRING(*arg) = simple->title;
+ break;
+ case ARG_ROLE:
+ GTK_VALUE_STRING(*arg) = simple->role;
+ break;
+ case ARG_MANAGER:
+ GTK_VALUE_STRING(*arg) = simple->manager;
+ break;
+ case ARG_ASSISTANT:
+ GTK_VALUE_STRING(*arg) = simple->assistant;
+ break;
+ case ARG_NICKNAME:
+ GTK_VALUE_STRING(*arg) = simple->nickname;
+ break;
+ case ARG_SPOUSE:
+ GTK_VALUE_STRING(*arg) = simple->spouse;
+ break;
+ case ARG_ANNIVERSARY:
+ GTK_VALUE_POINTER(*arg) = simple->anniversary;
+ break;
+ case ARG_FBURL:
+ GTK_VALUE_STRING(*arg) = simple->fburl;
+ break;
+ case ARG_NOTE:
+ GTK_VALUE_STRING(*arg) = simple->note;
+ break;
+ case ARG_ID:
+ GTK_VALUE_STRING(*arg) = simple->id;
+ break;
+#endif
+ default:
+ arg->type = GTK_TYPE_INVALID;
+ break;
+ }
+}
+
+
+/**
+ * e_card_simple_init:
+ */
+static void
+e_card_simple_init (ECardSimple *simple)
+{
+ int i;
+ simple->card = NULL;
+ for(i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++)
+ simple->phone[i] = NULL;
+ for(i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++)
+ simple->email[i] = NULL;
+ for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++)
+ simple->address[i] = NULL;
+}
+
+static void
+fill_in_info(ECardSimple *simple)
+{
+ ECard *card = simple->card;
+ if (card) {
+ ECardList *address_list;
+ ECardList *phone_list;
+ ECardList *email_list;
+ const ECardPhone *phone;
+ const char *email;
+ const ECardAddrLabel *address;
+
+ ECardIterator *iterator;
+
+ gtk_object_get(GTK_OBJECT(card),
+ "address_label", &address_list,
+ "phone", &phone_list,
+ "email", &email_list,
+ NULL);
+ for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
+ int i;
+ phone = e_card_iterator_get(iterator);
+ for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++) {
+ if (((phone->flags & phone_correspondences[i]) == phone_correspondences[i]) && (simple->phone[i] == NULL)) {
+ simple->phone[i] = e_card_phone_copy(phone);
+ break;
+ }
+ }
+ }
+ gtk_object_unref(GTK_OBJECT(iterator));
+
+ for (iterator = e_card_list_get_iterator(email_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
+ int i;
+ email = e_card_iterator_get(iterator);
+ for (i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i ++) {
+ if ((simple->email[i] == NULL)) {
+ simple->email[i] = g_strdup(email);
+ break;
+ }
+ }
+ }
+ gtk_object_unref(GTK_OBJECT(iterator));
+
+ for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
+ int i;
+ address = e_card_iterator_get(iterator);
+ for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) {
+ if (((address->flags & addr_correspondences[i]) == addr_correspondences[i]) && (simple->address[i] == NULL)) {
+ simple->address[i] = e_card_address_label_copy(address);
+ break;
+ }
+ }
+ }
+ gtk_object_unref(GTK_OBJECT(iterator));
+ }
+}
+
+void
+e_card_simple_sync_card(ECardSimple *simple)
+{
+ ECard *card = simple->card;
+ if (card) {
+ ECardList *address_list;
+ ECardList *phone_list;
+ ECardList *email_list;
+ const ECardPhone *phone;
+ const ECardAddrLabel *address;
+ const char *email;
+ int i;
+ int iterator_next = 1;
+
+ ECardIterator *iterator;
+
+ gtk_object_get(GTK_OBJECT(card),
+ "address_label", &address_list,
+ "phone", &phone_list,
+ "email", &email_list,
+ NULL);
+
+ for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); iterator_next ? e_card_iterator_next(iterator) : FALSE ) {
+ int i;
+ phone = e_card_iterator_get(iterator);
+ iterator_next = 1;
+ for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++) {
+ if ((phone->flags & phone_correspondences[i]) == phone_correspondences[i]) {
+ if (simple->phone[i]) {
+ if (simple->phone[i]->number && *simple->phone[i]->number) {
+ e_card_iterator_set(iterator, simple->phone[i]);
+ } else {
+ e_card_iterator_delete(iterator);
+ iterator_next = 0;
+ }
+ e_card_phone_free(simple->phone[i]);
+ simple->phone[i] = NULL;
+ break;
+ }
+ }
+ }
+ }
+ gtk_object_unref(GTK_OBJECT(iterator));
+ for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++) {
+ if (simple->phone[i]) {
+ simple->phone[i]->flags = phone_correspondences[i];
+ e_card_list_append(phone_list, simple->phone[i]);
+ e_card_phone_free(simple->phone[i]);
+ simple->phone[i] = NULL;
+ }
+ }
+
+ for (iterator = e_card_list_get_iterator(email_list); e_card_iterator_is_valid(iterator); iterator_next ? e_card_iterator_next(iterator) : FALSE ) {
+ int i;
+ email = e_card_iterator_get(iterator);
+ iterator_next = 1;
+ for (i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i ++) {
+ if (simple->email[i]) {
+ if (*simple->email[i]) {
+ e_card_iterator_set(iterator, simple->email[i]);
+ } else {
+ e_card_iterator_delete(iterator);
+ iterator_next = 0;
+ }
+ g_free(simple->email[i]);
+ simple->email[i] = NULL;
+ break;
+ }
+ }
+ }
+ gtk_object_unref(GTK_OBJECT(iterator));
+ for (i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i ++) {
+ if (simple->email[i]) {
+ e_card_list_append(email_list, simple->email[i]);
+ g_free(simple->email[i]);
+ simple->email[i] = NULL;
+ }
+ }
+
+ for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); iterator_next ? e_card_iterator_next(iterator) : FALSE ) {
+ int i;
+ address = e_card_iterator_get(iterator);
+ iterator_next = 1;
+ for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) {
+ if ((address->flags & addr_correspondences[i]) == addr_correspondences[i]) {
+ if (simple->address[i]) {
+ if (simple->address[i]->data && *simple->address[i]->data) {
+ e_card_iterator_set(iterator, simple->address[i]);
+ } else {
+ e_card_iterator_delete(iterator);
+ iterator_next = 0;
+ }
+ e_card_address_label_free(simple->address[i]);
+ simple->address[i] = NULL;
+ break;
+ }
+ }
+ }
+ }
+ gtk_object_unref(GTK_OBJECT(iterator));
+ for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) {
+ if (simple->address[i]) {
+ simple->address[i]->flags = addr_correspondences[i];
+ e_card_list_append(address_list, simple->address[i]);
+ e_card_address_label_free(simple->address[i]);
+ simple->address[i] = NULL;
+ }
+ }
+ }
+}
+
+ECardPhone *e_card_simple_get_phone (ECardSimple *simple,
+ ECardSimplePhoneId id)
+{
+ return simple->phone[id];
+}
+
+char *e_card_simple_get_email (ECardSimple *simple,
+ ECardSimpleEmailId id)
+{
+ return simple->email[id];
+}
+
+ECardAddrLabel *e_card_simple_get_address (ECardSimple *simple,
+ ECardSimpleAddressId id)
+{
+ return simple->address[id];
+}
+
+void e_card_simple_set_phone (ECardSimple *simple,
+ ECardSimplePhoneId id,
+ ECardPhone *phone)
+{
+ if (simple->phone[id])
+ e_card_phone_free(simple->phone[id]);
+ simple->phone[id] = e_card_phone_copy(phone);
+}
+
+void e_card_simple_set_email (ECardSimple *simple,
+ ECardSimpleEmailId id,
+ char *email)
+{
+ if (simple->email[id])
+ g_free(simple->email[id]);
+ simple->email[id] = g_strdup(email);
+}
+
+void e_card_simple_set_address (ECardSimple *simple,
+ ECardSimpleAddressId id,
+ ECardAddrLabel *address)
+{
+ if (simple->address[id])
+ e_card_address_label_free(simple->address[id]);
+ simple->address[id] = e_card_address_label_copy(address);
+}
diff --git a/addressbook/backend/ebook/e-card-simple.h b/addressbook/backend/ebook/e-card-simple.h
new file mode 100644
index 0000000000..e039b55340
--- /dev/null
+++ b/addressbook/backend/ebook/e-card-simple.h
@@ -0,0 +1,115 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Authors:
+ * Chris Lahey <clahey@helixcode.com>
+ * Arturo Espinosa
+ * Nat Friedman (nat@helixcode.com)
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Copyright (C) 1999 The Free Software Foundation
+ */
+
+#ifndef __E_CARD_SIMPLE_H__
+#define __E_CARD_SIMPLE_H__
+
+#include <time.h>
+#include <gtk/gtk.h>
+#include <stdio.h>
+#include <ebook/e-card.h>
+#include <ebook/e-card-types.h>
+#include <ebook/e-card-list.h>
+
+#define E_TYPE_CARD_SIMPLE (e_card_simple_get_type ())
+#define E_CARD_SIMPLE(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CARD_SIMPLE, ECardSimple))
+#define E_CARD_SIMPLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CARD_SIMPLE, ECardSimpleClass))
+#define E_IS_CARD_SIMPLE(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CARD_SIMPLE))
+#define E_IS_CARD_SIMPLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_CARD_SIMPLE))
+
+typedef enum _ECardSimplePhoneId ECardSimplePhoneId;
+typedef enum _ECardSimpleEmailId ECardSimpleEmailId;
+typedef enum _ECardSimpleAddressId ECardSimpleAddressId;
+
+enum _ECardSimplePhoneId {
+ E_CARD_SIMPLE_PHONE_ID_ASSISTANT,
+ E_CARD_SIMPLE_PHONE_ID_BUSINESS,
+ E_CARD_SIMPLE_PHONE_ID_BUSINESS_2,
+ E_CARD_SIMPLE_PHONE_ID_BUSINESS_FAX,
+ E_CARD_SIMPLE_PHONE_ID_CALLBACK,
+ E_CARD_SIMPLE_PHONE_ID_CAR,
+ E_CARD_SIMPLE_PHONE_ID_COMPANY,
+ E_CARD_SIMPLE_PHONE_ID_HOME,
+ E_CARD_SIMPLE_PHONE_ID_HOME_2,
+ E_CARD_SIMPLE_PHONE_ID_HOME_FAX,
+ E_CARD_SIMPLE_PHONE_ID_ISDN,
+ E_CARD_SIMPLE_PHONE_ID_MOBILE,
+ E_CARD_SIMPLE_PHONE_ID_OTHER,
+ E_CARD_SIMPLE_PHONE_ID_OTHER_FAX,
+ E_CARD_SIMPLE_PHONE_ID_PAGER,
+ E_CARD_SIMPLE_PHONE_ID_PRIMARY,
+ E_CARD_SIMPLE_PHONE_ID_RADIO,
+ E_CARD_SIMPLE_PHONE_ID_TELEX,
+ E_CARD_SIMPLE_PHONE_ID_TTYTTD,
+ E_CARD_SIMPLE_PHONE_ID_LAST
+};
+
+/* We need HOME and WORK email addresses here. */
+enum _ECardSimpleEmailId {
+ E_CARD_SIMPLE_EMAIL_ID_EMAIL,
+ E_CARD_SIMPLE_EMAIL_ID_EMAIL_2,
+ E_CARD_SIMPLE_EMAIL_ID_EMAIL_3,
+ E_CARD_SIMPLE_EMAIL_ID_LAST
+};
+
+/* Should this include (BILLING/SHIPPING)? */
+enum _ECardSimpleAddressId {
+ E_CARD_SIMPLE_ADDRESS_ID_BUSINESS,
+ E_CARD_SIMPLE_ADDRESS_ID_HOME,
+ E_CARD_SIMPLE_ADDRESS_ID_OTHER,
+ E_CARD_SIMPLE_ADDRESS_ID_LAST
+};
+
+typedef struct _ECardSimple ECardSimple;
+typedef struct _ECardSimpleClass ECardSimpleClass;
+
+struct _ECardSimple {
+ GtkObject object;
+ ECard *card;
+
+ ECardPhone *phone[E_CARD_SIMPLE_PHONE_ID_LAST];
+ char *email[E_CARD_SIMPLE_EMAIL_ID_LAST];
+ ECardAddrLabel *address[E_CARD_SIMPLE_ADDRESS_ID_LAST];
+};
+
+struct _ECardSimpleClass {
+ GtkObjectClass parent_class;
+};
+
+ECardSimple *e_card_simple_new (ECard *card);
+char *e_card_simple_get_id (ECardSimple *simple);
+void e_card_simple_set_id (ECardSimple *simple, const gchar *character);
+char *e_card_simple_get_vcard (ECardSimple *simple);
+
+ECardSimple *e_card_simple_duplicate (ECardSimple *simple);
+
+ECardPhone *e_card_simple_get_phone (ECardSimple *simple,
+ ECardSimplePhoneId id);
+char *e_card_simple_get_email (ECardSimple *simple,
+ ECardSimpleEmailId id);
+ECardAddrLabel *e_card_simple_get_address (ECardSimple *simple,
+ ECardSimpleAddressId id);
+void e_card_simple_set_phone (ECardSimple *simple,
+ ECardSimplePhoneId id,
+ ECardPhone *phone);
+void e_card_simple_set_email (ECardSimple *simple,
+ ECardSimpleEmailId id,
+ char *email);
+void e_card_simple_set_address (ECardSimple *simple,
+ ECardSimpleAddressId id,
+ ECardAddrLabel *address);
+
+void e_card_simple_sync_card (ECardSimple *simple);
+
+/* Standard Gtk function */
+GtkType e_card_simple_get_type (void);
+
+#endif /* ! __E_CARD_SIMPLE_H__ */
diff --git a/addressbook/contact-editor/e-contact-editor.c b/addressbook/contact-editor/e-contact-editor.c
index 3b81cd51b6..42e1759bea 100644
--- a/addressbook/contact-editor/e-contact-editor.c
+++ b/addressbook/contact-editor/e-contact-editor.c
@@ -56,35 +56,6 @@ enum {
DYNAMIC_LIST_ADDRESS
};
-ECardPhoneFlags phone_correspondences[] = {
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_ASSISTANT, */
- E_CARD_PHONE_WORK | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_BUSINESS, */
- E_CARD_PHONE_WORK | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_BUSINESS_2, */
- E_CARD_PHONE_WORK | E_CARD_PHONE_FAX, /* E_CONTACT_EDITOR_PHONE_ID_BUSINESS_FAX, */
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_CALLBACK, */
- E_CARD_PHONE_CAR | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_CAR, */
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_COMPANY, */
- E_CARD_PHONE_HOME | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_HOME, */
- E_CARD_PHONE_HOME | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_HOME_2, */
- E_CARD_PHONE_HOME | E_CARD_PHONE_FAX, /* E_CONTACT_EDITOR_PHONE_ID_HOME_FAX, */
- E_CARD_PHONE_ISDN, /* E_CONTACT_EDITOR_PHONE_ID_ISDN, */
- E_CARD_PHONE_CELL | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_MOBILE, */
- E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_OTHER, */
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_OTHER_FAX, */
- E_CARD_PHONE_PAGER | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_PAGER, */
- E_CARD_PHONE_PREF, /* E_CONTACT_EDITOR_PHONE_ID_PRIMARY, */
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_RADIO, */
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_TELEX, */
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_TTYTTD, */
-};
-
-ECardAddressFlags addr_correspondences[] = {
- E_CARD_ADDR_WORK, /* E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS, */
- E_CARD_ADDR_HOME, /* E_CONTACT_EDITOR_ADDRESS_ID_HOME, */
- E_CARD_ADDR_POSTAL, /* E_CONTACT_EDITOR_ADDRESS_ID_OTHER, */
- E_CONTACT_EDITOR_ADDRESS_ID_LAST
-};
-
GtkType
e_contact_editor_get_type (void)
{
@@ -204,6 +175,7 @@ phone_entry_changed (GtkWidget *widget, EContactEditor *editor)
int which;
gchar *string;
GtkEntry *entry = GTK_ENTRY(widget);
+ ECardPhone *phone;
if ( widget == glade_xml_get_widget(editor->gui, "entry-phone1") ) {
which = 1;
@@ -216,14 +188,16 @@ phone_entry_changed (GtkWidget *widget, EContactEditor *editor)
} else
return;
string = gtk_entry_get_text(entry);
- if (editor->phone[editor->phone_choice[which - 1]]) {
- if (editor->phone[editor->phone_choice[which - 1]]->number)
- g_free(editor->phone[editor->phone_choice[which - 1]]->number);
- editor->phone[editor->phone_choice[which - 1]]->number = NULL;
+ phone = e_card_simple_get_phone(editor->simple, editor->phone_choice[which - 1]);
+ if (phone) {
+ g_free(phone->number);
} else {
- editor->phone[editor->phone_choice[which - 1]] = e_card_phone_new();
+ phone = e_card_phone_new();
+ e_card_simple_set_phone(editor->simple, editor->phone_choice[which - 1], phone);
+ e_card_phone_free(phone);
+ phone = e_card_simple_get_phone(editor->simple, editor->phone_choice[which - 1]);
}
- editor->phone[editor->phone_choice[which - 1]]->number = g_strdup(string);
+ phone->number = g_strdup(string);
set_fields(editor);
}
@@ -233,14 +207,9 @@ email_entry_changed (GtkWidget *widget, EContactEditor *editor)
gchar *string;
GtkEntry *entry = GTK_ENTRY(widget);
- if (editor->email[editor->email_choice]) {
- g_free(editor->email[editor->email_choice]);
- editor->email[editor->email_choice] = NULL;
- }
-
string = gtk_entry_get_text(entry);
- editor->email[editor->email_choice] = g_strdup(string);
+ e_card_simple_set_email(editor->simple, editor->email_choice, string);
}
static void
@@ -248,18 +217,22 @@ address_text_changed (GtkWidget *widget, EContactEditor *editor)
{
gchar *string;
GtkEditable *editable = GTK_EDITABLE(widget);
+ ECardAddrLabel *address;
+
if (editor->address_choice == -1)
return;
-
- if (editor->address[editor->address_choice]) {
- g_free(editor->address[editor->address_choice]->data);
- editor->address[editor->address_choice]->data = NULL;
+ address = e_card_simple_get_address(editor->simple, editor->address_choice);
+ if (address) {
+ g_free(address->data);
} else {
- editor->address[editor->address_choice] = e_card_address_label_new();
+ address = e_card_address_label_new();
+ e_card_simple_set_address(editor->simple, editor->address_choice, address);
+ e_card_address_label_free(address);
+ address = e_card_simple_get_address(editor->simple, editor->address_choice);
}
string = gtk_editable_get_chars(editable, 0, -1);
- editor->address[editor->address_choice]->data = string;
+ address->data = string;
}
/* This function tells you whether name_to_style will make sense. */
@@ -490,7 +463,6 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
{
GladeXML *gui;
GtkAdjustment *adjustment;
- int i;
e_contact_editor->card = NULL;
gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-editor.glade", NULL);
@@ -524,22 +496,14 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
e_contact_editor->name = NULL;
e_contact_editor->company = g_strdup("");
- for (i = 0; i < E_CONTACT_EDITOR_PHONE_ID_LAST; i++) {
- e_contact_editor->phone[i] = NULL;
- }
- for (i = 0; i < E_CONTACT_EDITOR_EMAIL_ID_LAST; i++) {
- e_contact_editor->email[i] = NULL;
- }
- for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i++) {
- e_contact_editor->address[i] = NULL;
- }
-
e_contact_editor->email_choice = 0;
- e_contact_editor->phone_choice[0] = E_CONTACT_EDITOR_PHONE_ID_BUSINESS;
- e_contact_editor->phone_choice[1] = E_CONTACT_EDITOR_PHONE_ID_HOME;
- e_contact_editor->phone_choice[2] = E_CONTACT_EDITOR_PHONE_ID_BUSINESS_FAX;
- e_contact_editor->phone_choice[3] = E_CONTACT_EDITOR_PHONE_ID_MOBILE;
+ e_contact_editor->phone_choice[0] = E_CARD_SIMPLE_PHONE_ID_BUSINESS;
+ e_contact_editor->phone_choice[1] = E_CARD_SIMPLE_PHONE_ID_HOME;
+ e_contact_editor->phone_choice[2] = E_CARD_SIMPLE_PHONE_ID_BUSINESS_FAX;
+ e_contact_editor->phone_choice[3] = E_CARD_SIMPLE_PHONE_ID_MOBILE;
e_contact_editor->address_choice = 0;
+
+ e_contact_editor->simple = e_card_simple_new(NULL);
}
void
@@ -578,6 +542,9 @@ e_contact_editor_destroy (GtkObject *object) {
if (e_contact_editor->address_popup) {
gtk_widget_unref(e_contact_editor->address_popup);
}
+
+ if (e_contact_editor->simple)
+ gtk_object_unref(GTK_OBJECT(e_contact_editor->simple));
g_free (e_contact_editor->company);
@@ -597,16 +564,19 @@ e_contact_editor_new (ECard *card)
static void
e_contact_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
- EContactEditor *e_contact_editor;
+ EContactEditor *editor;
- e_contact_editor = E_CONTACT_EDITOR (o);
+ editor = E_CONTACT_EDITOR (o);
switch (arg_id){
case ARG_CARD:
- if (e_contact_editor->card)
- gtk_object_unref(GTK_OBJECT(e_contact_editor->card));
- e_contact_editor->card = e_card_duplicate(E_CARD(GTK_VALUE_OBJECT (*arg)));
- fill_in_info(e_contact_editor);
+ if (editor->card)
+ gtk_object_unref(GTK_OBJECT(editor->card));
+ editor->card = e_card_duplicate(E_CARD(GTK_VALUE_OBJECT (*arg)));
+ gtk_object_set(GTK_OBJECT(editor->simple),
+ "card", editor->card,
+ NULL);
+ fill_in_info(editor);
break;
}
}
@@ -620,6 +590,7 @@ e_contact_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
switch (arg_id) {
case ARG_CARD:
+ e_card_simple_sync_card(e_contact_editor->simple);
extract_info(e_contact_editor);
GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_contact_editor->card);
break;
@@ -930,44 +901,40 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito
}
static void
-set_field(GtkEntry *entry, char *string)
+set_field(GtkEntry *entry, const char *string)
{
char *oldstring = gtk_entry_get_text(entry);
+ if (!string)
+ string = "";
if (strcmp(string, oldstring))
gtk_entry_set_text(entry, string);
}
static void
+set_phone_field(GtkEntry *entry, const ECardPhone *phone)
+{
+ set_field(entry, phone ? phone->number : "");
+}
+
+static void
set_fields(EContactEditor *editor)
{
GtkEntry *entry;
entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-phone1"));
- if (editor->phone[editor->phone_choice[0]])
- set_field(entry, editor->phone[editor->phone_choice[0]]->number);
- else
- set_field(entry, "");
+ set_phone_field(entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[0]));
+
entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-phone2"));
- if (editor->phone[editor->phone_choice[1]])
- set_field(entry, editor->phone[editor->phone_choice[1]]->number);
- else
- set_field(entry, "");
+ set_phone_field(entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[1]));
+
entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-phone3"));
- if (editor->phone[editor->phone_choice[2]])
- set_field(entry, editor->phone[editor->phone_choice[2]]->number);
- else
- set_field(entry, "");
+ set_phone_field(entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[2]));
entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-phone4"));
- if (editor->phone[editor->phone_choice[3]])
- set_field(entry, editor->phone[editor->phone_choice[3]]->number);
- else
- set_field(entry, "");
+ set_phone_field(entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[3]));
+
entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-email1"));
- if (editor->email[editor->email_choice])
- set_field(entry, editor->email[editor->email_choice]);
- else
- set_field(entry, "");
+ set_field(entry, e_card_simple_get_email(editor->simple, editor->email_choice));
set_address_field(editor, -1);
}
@@ -977,6 +944,7 @@ set_address_field(EContactEditor *editor, int result)
{
GtkEditable *editable;
int position;
+ ECardAddrLabel *address;
if (result == -1)
result = editor->address_choice;
editor->address_choice = -1;
@@ -984,8 +952,9 @@ set_address_field(EContactEditor *editor, int result)
position = 0;
editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address"));
gtk_editable_delete_text(editable, 0, -1);
- if (editor->address[result] && editor->address[result]->data)
- gtk_editable_insert_text(editable, editor->address[result]->data, strlen(editor->address[result]->data), &position);
+ address = e_card_simple_get_address(editor->simple, result);
+ if (address && address->data)
+ gtk_editable_insert_text(editable, address->data, strlen(address->data), &position);
editor->address_choice = result;
}
@@ -997,9 +966,6 @@ fill_in_info(EContactEditor *editor)
char *file_as;
char *fname;
ECardName *name;
- ECardList *address_list;
- ECardList *phone_list;
- ECardList *email_list;
char *title;
char *org;
char *org_unit;
@@ -1013,22 +979,14 @@ fill_in_info(EContactEditor *editor)
const ECardDate *anniversary;
char *fburl;
char *note;
- const ECardPhone *phone;
- const char *email;
const ECardDate *bday;
- const ECardAddrLabel *address;
GtkEditable *editable;
int position = 0;
- ECardIterator *iterator;
-
gtk_object_get(GTK_OBJECT(card),
"file_as", &file_as,
"name", &name,
"full_name", &fname,
- "address_label", &address_list,
- "phone", &phone_list,
- "email", &email_list,
"url", &url,
"org", &org,
"org_unit", &org_unit,
@@ -1051,42 +1009,6 @@ fill_in_info(EContactEditor *editor)
if (fname)
gtk_editable_insert_text(editable, fname, strlen(fname), &position);
- for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
- int i;
- phone = e_card_iterator_get(iterator);
- for (i = 0; i < E_CONTACT_EDITOR_PHONE_ID_LAST; i ++) {
- if (((phone->flags & phone_correspondences[i]) == phone_correspondences[i]) && (editor->phone[i] == NULL)) {
- editor->phone[i] = e_card_phone_copy(phone);
- break;
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
-
- for (iterator = e_card_list_get_iterator(email_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
- int i;
- email = e_card_iterator_get(iterator);
- for (i = 0; i < E_CONTACT_EDITOR_EMAIL_ID_LAST; i ++) {
- if ((editor->email[i] == NULL)) {
- editor->email[i] = g_strdup(email);
- break;
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
-
- for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
- int i;
- address = e_card_iterator_get(iterator);
- for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i ++) {
- if (((address->flags & addr_correspondences[i]) == addr_correspondences[i]) && (editor->address[i] == NULL)) {
- editor->address[i] = e_card_address_label_copy(address);
- break;
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
-
position = 0;
editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web"));
gtk_editable_delete_text(editable, 0, -1);
@@ -1201,9 +1123,6 @@ extract_info(EContactEditor *editor)
if (card) {
char *file_as;
char *fname;
- ECardList *address_list;
- ECardList *phone_list;
- ECardList *email_list;
char *url;
char *org;
char *org_unit;
@@ -1217,26 +1136,13 @@ extract_info(EContactEditor *editor)
ECardDate *anniversary;
char *fburl;
char *note;
- const ECardPhone *phone;
- const ECardAddrLabel *address;
- const char *email;
ECardDate *bday;
GtkEditable *editable;
GnomeDateEdit *dateedit;
int position = 0;
struct tm time_struct;
time_t time_val;
- int i;
- int iterator_next = 1;
-
- ECardIterator *iterator;
- gtk_object_get(GTK_OBJECT(card),
- "address_label", &address_list,
- "phone", &phone_list,
- "email", &email_list,
- NULL);
-
position = 0;
editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-file-as"));
file_as = gtk_editable_get_chars(editable, 0, -1);
@@ -1263,93 +1169,6 @@ extract_info(EContactEditor *editor)
"name", editor->name,
NULL);
- for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); iterator_next ? e_card_iterator_next(iterator) : FALSE ) {
- int i;
- phone = e_card_iterator_get(iterator);
- iterator_next = 1;
- for (i = 0; i < E_CONTACT_EDITOR_PHONE_ID_LAST; i ++) {
- if ((phone->flags & phone_correspondences[i]) == phone_correspondences[i]) {
- if (editor->phone[i]) {
- if (editor->phone[i]->number && *editor->phone[i]->number) {
- e_card_iterator_set(iterator, editor->phone[i]);
- } else {
- e_card_iterator_delete(iterator);
- iterator_next = 0;
- }
- e_card_phone_free(editor->phone[i]);
- editor->phone[i] = NULL;
- break;
- }
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- for (i = 0; i < E_CONTACT_EDITOR_PHONE_ID_LAST; i ++) {
- if (editor->phone[i]) {
- editor->phone[i]->flags = phone_correspondences[i];
- e_card_list_append(phone_list, editor->phone[i]);
- e_card_phone_free(editor->phone[i]);
- editor->phone[i] = NULL;
- }
- }
-
- for (iterator = e_card_list_get_iterator(email_list); e_card_iterator_is_valid(iterator); iterator_next ? e_card_iterator_next(iterator) : FALSE ) {
- int i;
- email = e_card_iterator_get(iterator);
- iterator_next = 1;
- for (i = 0; i < E_CONTACT_EDITOR_EMAIL_ID_LAST; i ++) {
- if (editor->email[i]) {
- if (*editor->email[i]) {
- e_card_iterator_set(iterator, editor->email[i]);
- } else {
- e_card_iterator_delete(iterator);
- iterator_next = 0;
- }
- g_free(editor->email[i]);
- editor->email[i] = NULL;
- break;
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- for (i = 0; i < E_CONTACT_EDITOR_EMAIL_ID_LAST; i ++) {
- if (editor->email[i]) {
- e_card_list_append(email_list, editor->email[i]);
- g_free(editor->email[i]);
- editor->email[i] = NULL;
- }
- }
-
- for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); iterator_next ? e_card_iterator_next(iterator) : FALSE ) {
- int i;
- address = e_card_iterator_get(iterator);
- iterator_next = 1;
- for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i ++) {
- if ((address->flags & addr_correspondences[i]) == addr_correspondences[i]) {
- if (editor->address[i]) {
- if (editor->address[i]->data && *editor->address[i]->data) {
- e_card_iterator_set(iterator, editor->address[i]);
- } else {
- e_card_iterator_delete(iterator);
- iterator_next = 0;
- }
- e_card_address_label_free(editor->address[i]);
- editor->address[i] = NULL;
- break;
- }
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i ++) {
- if (editor->address[i]) {
- editor->address[i]->flags = addr_correspondences[i];
- e_card_list_append(address_list, editor->address[i]);
- e_card_address_label_free(editor->address[i]);
- editor->address[i] = NULL;
- }
- }
-
position = 0;
editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web"));
url = gtk_editable_get_chars(editable, 0, -1);
diff --git a/addressbook/contact-editor/e-contact-editor.h b/addressbook/contact-editor/e-contact-editor.h
index a0bad6e1f9..9bf8c0fdb2 100644
--- a/addressbook/contact-editor/e-contact-editor.h
+++ b/addressbook/contact-editor/e-contact-editor.h
@@ -24,6 +24,7 @@
#include <gnome.h>
#include <glade/glade.h>
#include <ebook/e-card.h>
+#include <ebook/e-card-simple.h>
#ifdef __cplusplus
extern "C" {
@@ -39,49 +40,6 @@ extern "C" {
* card ECard * RW The card currently being edited
*/
-typedef enum _EContactEditorPhoneId EContactEditorPhoneId;
-typedef enum _EContactEditorEmailId EContactEditorEmailId;
-typedef enum _EContactEditorAddressId EContactEditorAddressId;
-
-enum _EContactEditorPhoneId {
- E_CONTACT_EDITOR_PHONE_ID_ASSISTANT,
- E_CONTACT_EDITOR_PHONE_ID_BUSINESS,
- E_CONTACT_EDITOR_PHONE_ID_BUSINESS_2,
- E_CONTACT_EDITOR_PHONE_ID_BUSINESS_FAX,
- E_CONTACT_EDITOR_PHONE_ID_CALLBACK,
- E_CONTACT_EDITOR_PHONE_ID_CAR,
- E_CONTACT_EDITOR_PHONE_ID_COMPANY,
- E_CONTACT_EDITOR_PHONE_ID_HOME,
- E_CONTACT_EDITOR_PHONE_ID_HOME_2,
- E_CONTACT_EDITOR_PHONE_ID_HOME_FAX,
- E_CONTACT_EDITOR_PHONE_ID_ISDN,
- E_CONTACT_EDITOR_PHONE_ID_MOBILE,
- E_CONTACT_EDITOR_PHONE_ID_OTHER,
- E_CONTACT_EDITOR_PHONE_ID_OTHER_FAX,
- E_CONTACT_EDITOR_PHONE_ID_PAGER,
- E_CONTACT_EDITOR_PHONE_ID_PRIMARY,
- E_CONTACT_EDITOR_PHONE_ID_RADIO,
- E_CONTACT_EDITOR_PHONE_ID_TELEX,
- E_CONTACT_EDITOR_PHONE_ID_TTYTTD,
- E_CONTACT_EDITOR_PHONE_ID_LAST
-};
-
-/* We need HOME and WORK email addresses here. */
-enum _EContactEditorEmailId {
- E_CONTACT_EDITOR_EMAIL_ID_EMAIL,
- E_CONTACT_EDITOR_EMAIL_ID_EMAIL_2,
- E_CONTACT_EDITOR_EMAIL_ID_EMAIL_3,
- E_CONTACT_EDITOR_EMAIL_ID_LAST
-};
-
-/* Should this include (BILLING/SHIPPING)? */
-enum _EContactEditorAddressId {
- E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS,
- E_CONTACT_EDITOR_ADDRESS_ID_HOME,
- E_CONTACT_EDITOR_ADDRESS_ID_OTHER,
- E_CONTACT_EDITOR_ADDRESS_ID_LAST
-};
-
#define E_CONTACT_EDITOR_TYPE (e_contact_editor_get_type ())
#define E_CONTACT_EDITOR(obj) (GTK_CHECK_CAST ((obj), E_CONTACT_EDITOR_TYPE, EContactEditor))
#define E_CONTACT_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CONTACT_EDITOR_TYPE, EContactEditorClass))
@@ -98,6 +56,7 @@ struct _EContactEditor
/* item specific fields */
ECard *card;
+ ECardSimple *simple;
GladeXML *gui;
GnomeUIInfo *email_info;
@@ -110,16 +69,12 @@ struct _EContactEditor
GList *phone_list;
GList *address_list;
- ECardPhone *phone[E_CONTACT_EDITOR_PHONE_ID_LAST];
- char *email[E_CONTACT_EDITOR_EMAIL_ID_LAST];
- ECardAddrLabel *address[E_CONTACT_EDITOR_ADDRESS_ID_LAST];
-
ECardName *name;
char *company;
- EContactEditorEmailId email_choice;
- EContactEditorPhoneId phone_choice[4];
- EContactEditorAddressId address_choice;
+ ECardSimpleEmailId email_choice;
+ ECardSimplePhoneId phone_choice[4];
+ ECardSimpleAddressId address_choice;
};
struct _EContactEditorClass
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 3b81cd51b6..42e1759bea 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -56,35 +56,6 @@ enum {
DYNAMIC_LIST_ADDRESS
};
-ECardPhoneFlags phone_correspondences[] = {
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_ASSISTANT, */
- E_CARD_PHONE_WORK | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_BUSINESS, */
- E_CARD_PHONE_WORK | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_BUSINESS_2, */
- E_CARD_PHONE_WORK | E_CARD_PHONE_FAX, /* E_CONTACT_EDITOR_PHONE_ID_BUSINESS_FAX, */
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_CALLBACK, */
- E_CARD_PHONE_CAR | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_CAR, */
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_COMPANY, */
- E_CARD_PHONE_HOME | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_HOME, */
- E_CARD_PHONE_HOME | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_HOME_2, */
- E_CARD_PHONE_HOME | E_CARD_PHONE_FAX, /* E_CONTACT_EDITOR_PHONE_ID_HOME_FAX, */
- E_CARD_PHONE_ISDN, /* E_CONTACT_EDITOR_PHONE_ID_ISDN, */
- E_CARD_PHONE_CELL | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_MOBILE, */
- E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_OTHER, */
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_OTHER_FAX, */
- E_CARD_PHONE_PAGER | E_CARD_PHONE_VOICE, /* E_CONTACT_EDITOR_PHONE_ID_PAGER, */
- E_CARD_PHONE_PREF, /* E_CONTACT_EDITOR_PHONE_ID_PRIMARY, */
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_RADIO, */
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_TELEX, */
- 0xFF, /* E_CONTACT_EDITOR_PHONE_ID_TTYTTD, */
-};
-
-ECardAddressFlags addr_correspondences[] = {
- E_CARD_ADDR_WORK, /* E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS, */
- E_CARD_ADDR_HOME, /* E_CONTACT_EDITOR_ADDRESS_ID_HOME, */
- E_CARD_ADDR_POSTAL, /* E_CONTACT_EDITOR_ADDRESS_ID_OTHER, */
- E_CONTACT_EDITOR_ADDRESS_ID_LAST
-};
-
GtkType
e_contact_editor_get_type (void)
{
@@ -204,6 +175,7 @@ phone_entry_changed (GtkWidget *widget, EContactEditor *editor)
int which;
gchar *string;
GtkEntry *entry = GTK_ENTRY(widget);
+ ECardPhone *phone;
if ( widget == glade_xml_get_widget(editor->gui, "entry-phone1") ) {
which = 1;
@@ -216,14 +188,16 @@ phone_entry_changed (GtkWidget *widget, EContactEditor *editor)
} else
return;
string = gtk_entry_get_text(entry);
- if (editor->phone[editor->phone_choice[which - 1]]) {
- if (editor->phone[editor->phone_choice[which - 1]]->number)
- g_free(editor->phone[editor->phone_choice[which - 1]]->number);
- editor->phone[editor->phone_choice[which - 1]]->number = NULL;
+ phone = e_card_simple_get_phone(editor->simple, editor->phone_choice[which - 1]);
+ if (phone) {
+ g_free(phone->number);
} else {
- editor->phone[editor->phone_choice[which - 1]] = e_card_phone_new();
+ phone = e_card_phone_new();
+ e_card_simple_set_phone(editor->simple, editor->phone_choice[which - 1], phone);
+ e_card_phone_free(phone);
+ phone = e_card_simple_get_phone(editor->simple, editor->phone_choice[which - 1]);
}
- editor->phone[editor->phone_choice[which - 1]]->number = g_strdup(string);
+ phone->number = g_strdup(string);
set_fields(editor);
}
@@ -233,14 +207,9 @@ email_entry_changed (GtkWidget *widget, EContactEditor *editor)
gchar *string;
GtkEntry *entry = GTK_ENTRY(widget);
- if (editor->email[editor->email_choice]) {
- g_free(editor->email[editor->email_choice]);
- editor->email[editor->email_choice] = NULL;
- }
-
string = gtk_entry_get_text(entry);
- editor->email[editor->email_choice] = g_strdup(string);
+ e_card_simple_set_email(editor->simple, editor->email_choice, string);
}
static void
@@ -248,18 +217,22 @@ address_text_changed (GtkWidget *widget, EContactEditor *editor)
{
gchar *string;
GtkEditable *editable = GTK_EDITABLE(widget);
+ ECardAddrLabel *address;
+
if (editor->address_choice == -1)
return;
-
- if (editor->address[editor->address_choice]) {
- g_free(editor->address[editor->address_choice]->data);
- editor->address[editor->address_choice]->data = NULL;
+ address = e_card_simple_get_address(editor->simple, editor->address_choice);
+ if (address) {
+ g_free(address->data);
} else {
- editor->address[editor->address_choice] = e_card_address_label_new();
+ address = e_card_address_label_new();
+ e_card_simple_set_address(editor->simple, editor->address_choice, address);
+ e_card_address_label_free(address);
+ address = e_card_simple_get_address(editor->simple, editor->address_choice);
}
string = gtk_editable_get_chars(editable, 0, -1);
- editor->address[editor->address_choice]->data = string;
+ address->data = string;
}
/* This function tells you whether name_to_style will make sense. */
@@ -490,7 +463,6 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
{
GladeXML *gui;
GtkAdjustment *adjustment;
- int i;
e_contact_editor->card = NULL;
gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-editor.glade", NULL);
@@ -524,22 +496,14 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
e_contact_editor->name = NULL;
e_contact_editor->company = g_strdup("");
- for (i = 0; i < E_CONTACT_EDITOR_PHONE_ID_LAST; i++) {
- e_contact_editor->phone[i] = NULL;
- }
- for (i = 0; i < E_CONTACT_EDITOR_EMAIL_ID_LAST; i++) {
- e_contact_editor->email[i] = NULL;
- }
- for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i++) {
- e_contact_editor->address[i] = NULL;
- }
-
e_contact_editor->email_choice = 0;
- e_contact_editor->phone_choice[0] = E_CONTACT_EDITOR_PHONE_ID_BUSINESS;
- e_contact_editor->phone_choice[1] = E_CONTACT_EDITOR_PHONE_ID_HOME;
- e_contact_editor->phone_choice[2] = E_CONTACT_EDITOR_PHONE_ID_BUSINESS_FAX;
- e_contact_editor->phone_choice[3] = E_CONTACT_EDITOR_PHONE_ID_MOBILE;
+ e_contact_editor->phone_choice[0] = E_CARD_SIMPLE_PHONE_ID_BUSINESS;
+ e_contact_editor->phone_choice[1] = E_CARD_SIMPLE_PHONE_ID_HOME;
+ e_contact_editor->phone_choice[2] = E_CARD_SIMPLE_PHONE_ID_BUSINESS_FAX;
+ e_contact_editor->phone_choice[3] = E_CARD_SIMPLE_PHONE_ID_MOBILE;
e_contact_editor->address_choice = 0;
+
+ e_contact_editor->simple = e_card_simple_new(NULL);
}
void
@@ -578,6 +542,9 @@ e_contact_editor_destroy (GtkObject *object) {
if (e_contact_editor->address_popup) {
gtk_widget_unref(e_contact_editor->address_popup);
}
+
+ if (e_contact_editor->simple)
+ gtk_object_unref(GTK_OBJECT(e_contact_editor->simple));
g_free (e_contact_editor->company);
@@ -597,16 +564,19 @@ e_contact_editor_new (ECard *card)
static void
e_contact_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
- EContactEditor *e_contact_editor;
+ EContactEditor *editor;
- e_contact_editor = E_CONTACT_EDITOR (o);
+ editor = E_CONTACT_EDITOR (o);
switch (arg_id){
case ARG_CARD:
- if (e_contact_editor->card)
- gtk_object_unref(GTK_OBJECT(e_contact_editor->card));
- e_contact_editor->card = e_card_duplicate(E_CARD(GTK_VALUE_OBJECT (*arg)));
- fill_in_info(e_contact_editor);
+ if (editor->card)
+ gtk_object_unref(GTK_OBJECT(editor->card));
+ editor->card = e_card_duplicate(E_CARD(GTK_VALUE_OBJECT (*arg)));
+ gtk_object_set(GTK_OBJECT(editor->simple),
+ "card", editor->card,
+ NULL);
+ fill_in_info(editor);
break;
}
}
@@ -620,6 +590,7 @@ e_contact_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
switch (arg_id) {
case ARG_CARD:
+ e_card_simple_sync_card(e_contact_editor->simple);
extract_info(e_contact_editor);
GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_contact_editor->card);
break;
@@ -930,44 +901,40 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito
}
static void
-set_field(GtkEntry *entry, char *string)
+set_field(GtkEntry *entry, const char *string)
{
char *oldstring = gtk_entry_get_text(entry);
+ if (!string)
+ string = "";
if (strcmp(string, oldstring))
gtk_entry_set_text(entry, string);
}
static void
+set_phone_field(GtkEntry *entry, const ECardPhone *phone)
+{
+ set_field(entry, phone ? phone->number : "");
+}
+
+static void
set_fields(EContactEditor *editor)
{
GtkEntry *entry;
entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-phone1"));
- if (editor->phone[editor->phone_choice[0]])
- set_field(entry, editor->phone[editor->phone_choice[0]]->number);
- else
- set_field(entry, "");
+ set_phone_field(entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[0]));
+
entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-phone2"));
- if (editor->phone[editor->phone_choice[1]])
- set_field(entry, editor->phone[editor->phone_choice[1]]->number);
- else
- set_field(entry, "");
+ set_phone_field(entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[1]));
+
entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-phone3"));
- if (editor->phone[editor->phone_choice[2]])
- set_field(entry, editor->phone[editor->phone_choice[2]]->number);
- else
- set_field(entry, "");
+ set_phone_field(entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[2]));
entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-phone4"));
- if (editor->phone[editor->phone_choice[3]])
- set_field(entry, editor->phone[editor->phone_choice[3]]->number);
- else
- set_field(entry, "");
+ set_phone_field(entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[3]));
+
entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-email1"));
- if (editor->email[editor->email_choice])
- set_field(entry, editor->email[editor->email_choice]);
- else
- set_field(entry, "");
+ set_field(entry, e_card_simple_get_email(editor->simple, editor->email_choice));
set_address_field(editor, -1);
}
@@ -977,6 +944,7 @@ set_address_field(EContactEditor *editor, int result)
{
GtkEditable *editable;
int position;
+ ECardAddrLabel *address;
if (result == -1)
result = editor->address_choice;
editor->address_choice = -1;
@@ -984,8 +952,9 @@ set_address_field(EContactEditor *editor, int result)
position = 0;
editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address"));
gtk_editable_delete_text(editable, 0, -1);
- if (editor->address[result] && editor->address[result]->data)
- gtk_editable_insert_text(editable, editor->address[result]->data, strlen(editor->address[result]->data), &position);
+ address = e_card_simple_get_address(editor->simple, result);
+ if (address && address->data)
+ gtk_editable_insert_text(editable, address->data, strlen(address->data), &position);
editor->address_choice = result;
}
@@ -997,9 +966,6 @@ fill_in_info(EContactEditor *editor)
char *file_as;
char *fname;
ECardName *name;
- ECardList *address_list;
- ECardList *phone_list;
- ECardList *email_list;
char *title;
char *org;
char *org_unit;
@@ -1013,22 +979,14 @@ fill_in_info(EContactEditor *editor)
const ECardDate *anniversary;
char *fburl;
char *note;
- const ECardPhone *phone;
- const char *email;
const ECardDate *bday;
- const ECardAddrLabel *address;
GtkEditable *editable;
int position = 0;
- ECardIterator *iterator;
-
gtk_object_get(GTK_OBJECT(card),
"file_as", &file_as,
"name", &name,
"full_name", &fname,
- "address_label", &address_list,
- "phone", &phone_list,
- "email", &email_list,
"url", &url,
"org", &org,
"org_unit", &org_unit,
@@ -1051,42 +1009,6 @@ fill_in_info(EContactEditor *editor)
if (fname)
gtk_editable_insert_text(editable, fname, strlen(fname), &position);
- for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
- int i;
- phone = e_card_iterator_get(iterator);
- for (i = 0; i < E_CONTACT_EDITOR_PHONE_ID_LAST; i ++) {
- if (((phone->flags & phone_correspondences[i]) == phone_correspondences[i]) && (editor->phone[i] == NULL)) {
- editor->phone[i] = e_card_phone_copy(phone);
- break;
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
-
- for (iterator = e_card_list_get_iterator(email_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
- int i;
- email = e_card_iterator_get(iterator);
- for (i = 0; i < E_CONTACT_EDITOR_EMAIL_ID_LAST; i ++) {
- if ((editor->email[i] == NULL)) {
- editor->email[i] = g_strdup(email);
- break;
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
-
- for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) {
- int i;
- address = e_card_iterator_get(iterator);
- for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i ++) {
- if (((address->flags & addr_correspondences[i]) == addr_correspondences[i]) && (editor->address[i] == NULL)) {
- editor->address[i] = e_card_address_label_copy(address);
- break;
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
-
position = 0;
editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web"));
gtk_editable_delete_text(editable, 0, -1);
@@ -1201,9 +1123,6 @@ extract_info(EContactEditor *editor)
if (card) {
char *file_as;
char *fname;
- ECardList *address_list;
- ECardList *phone_list;
- ECardList *email_list;
char *url;
char *org;
char *org_unit;
@@ -1217,26 +1136,13 @@ extract_info(EContactEditor *editor)
ECardDate *anniversary;
char *fburl;
char *note;
- const ECardPhone *phone;
- const ECardAddrLabel *address;
- const char *email;
ECardDate *bday;
GtkEditable *editable;
GnomeDateEdit *dateedit;
int position = 0;
struct tm time_struct;
time_t time_val;
- int i;
- int iterator_next = 1;
-
- ECardIterator *iterator;
- gtk_object_get(GTK_OBJECT(card),
- "address_label", &address_list,
- "phone", &phone_list,
- "email", &email_list,
- NULL);
-
position = 0;
editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-file-as"));
file_as = gtk_editable_get_chars(editable, 0, -1);
@@ -1263,93 +1169,6 @@ extract_info(EContactEditor *editor)
"name", editor->name,
NULL);
- for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); iterator_next ? e_card_iterator_next(iterator) : FALSE ) {
- int i;
- phone = e_card_iterator_get(iterator);
- iterator_next = 1;
- for (i = 0; i < E_CONTACT_EDITOR_PHONE_ID_LAST; i ++) {
- if ((phone->flags & phone_correspondences[i]) == phone_correspondences[i]) {
- if (editor->phone[i]) {
- if (editor->phone[i]->number && *editor->phone[i]->number) {
- e_card_iterator_set(iterator, editor->phone[i]);
- } else {
- e_card_iterator_delete(iterator);
- iterator_next = 0;
- }
- e_card_phone_free(editor->phone[i]);
- editor->phone[i] = NULL;
- break;
- }
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- for (i = 0; i < E_CONTACT_EDITOR_PHONE_ID_LAST; i ++) {
- if (editor->phone[i]) {
- editor->phone[i]->flags = phone_correspondences[i];
- e_card_list_append(phone_list, editor->phone[i]);
- e_card_phone_free(editor->phone[i]);
- editor->phone[i] = NULL;
- }
- }
-
- for (iterator = e_card_list_get_iterator(email_list); e_card_iterator_is_valid(iterator); iterator_next ? e_card_iterator_next(iterator) : FALSE ) {
- int i;
- email = e_card_iterator_get(iterator);
- iterator_next = 1;
- for (i = 0; i < E_CONTACT_EDITOR_EMAIL_ID_LAST; i ++) {
- if (editor->email[i]) {
- if (*editor->email[i]) {
- e_card_iterator_set(iterator, editor->email[i]);
- } else {
- e_card_iterator_delete(iterator);
- iterator_next = 0;
- }
- g_free(editor->email[i]);
- editor->email[i] = NULL;
- break;
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- for (i = 0; i < E_CONTACT_EDITOR_EMAIL_ID_LAST; i ++) {
- if (editor->email[i]) {
- e_card_list_append(email_list, editor->email[i]);
- g_free(editor->email[i]);
- editor->email[i] = NULL;
- }
- }
-
- for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); iterator_next ? e_card_iterator_next(iterator) : FALSE ) {
- int i;
- address = e_card_iterator_get(iterator);
- iterator_next = 1;
- for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i ++) {
- if ((address->flags & addr_correspondences[i]) == addr_correspondences[i]) {
- if (editor->address[i]) {
- if (editor->address[i]->data && *editor->address[i]->data) {
- e_card_iterator_set(iterator, editor->address[i]);
- } else {
- e_card_iterator_delete(iterator);
- iterator_next = 0;
- }
- e_card_address_label_free(editor->address[i]);
- editor->address[i] = NULL;
- break;
- }
- }
- }
- }
- gtk_object_unref(GTK_OBJECT(iterator));
- for (i = 0; i < E_CONTACT_EDITOR_ADDRESS_ID_LAST; i ++) {
- if (editor->address[i]) {
- editor->address[i]->flags = addr_correspondences[i];
- e_card_list_append(address_list, editor->address[i]);
- e_card_address_label_free(editor->address[i]);
- editor->address[i] = NULL;
- }
- }
-
position = 0;
editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web"));
url = gtk_editable_get_chars(editable, 0, -1);
diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h
index a0bad6e1f9..9bf8c0fdb2 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.h
+++ b/addressbook/gui/contact-editor/e-contact-editor.h
@@ -24,6 +24,7 @@
#include <gnome.h>
#include <glade/glade.h>
#include <ebook/e-card.h>
+#include <ebook/e-card-simple.h>
#ifdef __cplusplus
extern "C" {
@@ -39,49 +40,6 @@ extern "C" {
* card ECard * RW The card currently being edited
*/
-typedef enum _EContactEditorPhoneId EContactEditorPhoneId;
-typedef enum _EContactEditorEmailId EContactEditorEmailId;
-typedef enum _EContactEditorAddressId EContactEditorAddressId;
-
-enum _EContactEditorPhoneId {
- E_CONTACT_EDITOR_PHONE_ID_ASSISTANT,
- E_CONTACT_EDITOR_PHONE_ID_BUSINESS,
- E_CONTACT_EDITOR_PHONE_ID_BUSINESS_2,
- E_CONTACT_EDITOR_PHONE_ID_BUSINESS_FAX,
- E_CONTACT_EDITOR_PHONE_ID_CALLBACK,
- E_CONTACT_EDITOR_PHONE_ID_CAR,
- E_CONTACT_EDITOR_PHONE_ID_COMPANY,
- E_CONTACT_EDITOR_PHONE_ID_HOME,
- E_CONTACT_EDITOR_PHONE_ID_HOME_2,
- E_CONTACT_EDITOR_PHONE_ID_HOME_FAX,
- E_CONTACT_EDITOR_PHONE_ID_ISDN,
- E_CONTACT_EDITOR_PHONE_ID_MOBILE,
- E_CONTACT_EDITOR_PHONE_ID_OTHER,
- E_CONTACT_EDITOR_PHONE_ID_OTHER_FAX,
- E_CONTACT_EDITOR_PHONE_ID_PAGER,
- E_CONTACT_EDITOR_PHONE_ID_PRIMARY,
- E_CONTACT_EDITOR_PHONE_ID_RADIO,
- E_CONTACT_EDITOR_PHONE_ID_TELEX,
- E_CONTACT_EDITOR_PHONE_ID_TTYTTD,
- E_CONTACT_EDITOR_PHONE_ID_LAST
-};
-
-/* We need HOME and WORK email addresses here. */
-enum _EContactEditorEmailId {
- E_CONTACT_EDITOR_EMAIL_ID_EMAIL,
- E_CONTACT_EDITOR_EMAIL_ID_EMAIL_2,
- E_CONTACT_EDITOR_EMAIL_ID_EMAIL_3,
- E_CONTACT_EDITOR_EMAIL_ID_LAST
-};
-
-/* Should this include (BILLING/SHIPPING)? */
-enum _EContactEditorAddressId {
- E_CONTACT_EDITOR_ADDRESS_ID_BUSINESS,
- E_CONTACT_EDITOR_ADDRESS_ID_HOME,
- E_CONTACT_EDITOR_ADDRESS_ID_OTHER,
- E_CONTACT_EDITOR_ADDRESS_ID_LAST
-};
-
#define E_CONTACT_EDITOR_TYPE (e_contact_editor_get_type ())
#define E_CONTACT_EDITOR(obj) (GTK_CHECK_CAST ((obj), E_CONTACT_EDITOR_TYPE, EContactEditor))
#define E_CONTACT_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CONTACT_EDITOR_TYPE, EContactEditorClass))
@@ -98,6 +56,7 @@ struct _EContactEditor
/* item specific fields */
ECard *card;
+ ECardSimple *simple;
GladeXML *gui;
GnomeUIInfo *email_info;
@@ -110,16 +69,12 @@ struct _EContactEditor
GList *phone_list;
GList *address_list;
- ECardPhone *phone[E_CONTACT_EDITOR_PHONE_ID_LAST];
- char *email[E_CONTACT_EDITOR_EMAIL_ID_LAST];
- ECardAddrLabel *address[E_CONTACT_EDITOR_ADDRESS_ID_LAST];
-
ECardName *name;
char *company;
- EContactEditorEmailId email_choice;
- EContactEditorPhoneId phone_choice[4];
- EContactEditorAddressId address_choice;
+ ECardSimpleEmailId email_choice;
+ ECardSimplePhoneId phone_choice[4];
+ ECardSimpleAddressId address_choice;
};
struct _EContactEditorClass