aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--addressbook/backend/ebook/e-card.c28
-rw-r--r--addressbook/backend/ebook/e-card.h2
-rw-r--r--addressbook/contact-editor/Makefile.am8
-rw-r--r--addressbook/contact-editor/e-contact-editor.c104
-rw-r--r--addressbook/contact-editor/e-contact-editor.h5
-rw-r--r--addressbook/contact-editor/test-editor.c135
-rw-r--r--addressbook/gui/contact-editor/Makefile.am8
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c104
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.h5
-rw-r--r--addressbook/gui/contact-editor/test-editor.c135
-rw-r--r--addressbook/gui/minicard/e-minicard.c14
-rw-r--r--addressbook/gui/widgets/e-minicard.c14
13 files changed, 457 insertions, 118 deletions
diff --git a/ChangeLog b/ChangeLog
index d89210832f..1c2ca0b987 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2000-04-08 Christopher James Lahey <clahey@helixcode.com>
+ * addressbook/contact-editor/Makefile.am,
+ addressbook/contact-editor/e-contact-editor.c,
+ addressbook/contact-editor/e-contact-editor.h,
+ addressbook/contact-editor/test-editor.c: Made the contact editor
+ load from an ECard.
+
+ * addressbook/backend/ebook/e-card.c,
+ addressbook/backend/ebook/e-card.h,
+ addressbook/gui/minicard/e-minicard.c: Added support for the URL
+ field.
+
+2000-04-08 Christopher James Lahey <clahey@helixcode.com>
+
* addressbook/backend/ebook/e-card.c (e_card_get_vcard): Fixed a
small typo.
diff --git a/addressbook/backend/ebook/e-card.c b/addressbook/backend/ebook/e-card.c
index ea7e2ba373..227643fe8c 100644
--- a/addressbook/backend/ebook/e-card.c
+++ b/addressbook/backend/ebook/e-card.c
@@ -30,7 +30,8 @@ enum {
ARG_ADDRESS,
ARG_PHONE,
ARG_EMAIL,
- ARG_BIRTH_DATE
+ ARG_BIRTH_DATE,
+ ARG_URL
};
#if 0
@@ -56,6 +57,7 @@ static void parse_name(ECard *card, VObject *object);
static void parse_email(ECard *card, VObject *object);
static void parse_phone(ECard *card, VObject *object);
static void parse_address(ECard *card, VObject *object);
+static void parse_url(ECard *card, VObject *object);
static ECardPhoneFlags get_phone_flags (VObject *vobj);
static void set_phone_flags (VObject *vobj, ECardPhoneFlags flags);
@@ -74,7 +76,8 @@ struct {
{ VCBirthDateProp, parse_bday },
{ VCEmailAddressProp, parse_email },
{ VCTelephoneProp, parse_phone },
- { VCAdrProp, parse_address }
+ { VCAdrProp, parse_address },
+ { VCURLProp, parse_url }
};
/**
@@ -251,6 +254,9 @@ char
addPropValue(vobj, VCBirthDateProp, value);
g_free(value);
}
+
+ if ( card->url )
+ addPropValue(vobj, VCURLProp, card->url);
#if 0
@@ -447,6 +453,14 @@ parse_address(ECard *card, VObject *vobj)
}
static void
+parse_url(ECard *card, VObject *vobj)
+{
+ if ( card->url )
+ g_free(card->url);
+ assign_string(vobj, &(card->url));
+}
+
+static void
parse_attribute(ECard *card, VObject *vobj)
{
ParsePropertyFunc function = g_hash_table_lookup(E_CARD_CLASS(GTK_OBJECT(card)->klass)->attribute_jump_table, vObjectName(vobj));
@@ -490,6 +504,8 @@ e_card_class_init (ECardClass *klass)
GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_EMAIL);
gtk_object_add_arg_type ("ECard::birth_date",
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_BIRTH_DATE);
+ gtk_object_add_arg_type ("ECard::url",
+ GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_URL);
object_class->destroy = e_card_destroy;
@@ -609,6 +625,10 @@ e_card_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
g_free(card->bday);
card->bday = GTK_VALUE_POINTER(*arg);
break;
+ case ARG_URL:
+ if ( card->url )
+ g_free(card->url);
+ card->url = GTK_VALUE_STRING(*arg);
default:
return;
}
@@ -653,6 +673,9 @@ e_card_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_BIRTH_DATE:
GTK_VALUE_POINTER(*arg) = card->bday;
break;
+ case ARG_URL:
+ GTK_VALUE_STRING(*arg) = card->url;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
@@ -674,6 +697,7 @@ e_card_init (ECard *card)
card->email = NULL;
card->phone = NULL;
card->address = NULL;
+ card->url = NULL;
#if 0
c = g_new0 (ECard, 1);
diff --git a/addressbook/backend/ebook/e-card.h b/addressbook/backend/ebook/e-card.h
index a8e1324b20..1f230159fb 100644
--- a/addressbook/backend/ebook/e-card.h
+++ b/addressbook/backend/ebook/e-card.h
@@ -40,10 +40,8 @@ struct _ECard {
#endif
ECardList *phone; /* Phone numbers (ECardPhone *) */
ECardList *email; /* Email addresses (char *) */
-#if 0
char *url; /* The person's web page. */
-#endif
ECardDate *bday; /* The person's birthday. */
#if 0
diff --git a/addressbook/contact-editor/Makefile.am b/addressbook/contact-editor/Makefile.am
index 7c3d0de273..2fb74b736d 100644
--- a/addressbook/contact-editor/Makefile.am
+++ b/addressbook/contact-editor/Makefile.am
@@ -9,7 +9,8 @@ CPPFLAGS = \
-DDATADIR=\""$(datadir)"\"
INCLUDES = \
- $(GNOME_INCLUDEDIR)
+ $(GNOME_INCLUDEDIR) \
+ -I$(top_srcdir)/addressbook/backend/ebook
noinst_LIBRARIES = \
libecontacteditor.a
@@ -25,6 +26,11 @@ contact_editor_test_SOURCES = \
test-editor.c
contact_editor_test_LDADD = \
+ $(top_builddir)/addressbook/backend/ebook/libebook.la \
+ $(top_builddir)/libversit/libversit.la \
+ $(GNOMEGNORBA_LIBS) \
+ -lbonobo \
+ $(top_builddir)/e-util/libeutil.la \
libecontacteditor.a \
$(EXTRA_GNOME_LIBS)
diff --git a/addressbook/contact-editor/e-contact-editor.c b/addressbook/contact-editor/e-contact-editor.c
index 81a6980ef7..9277eef1fd 100644
--- a/addressbook/contact-editor/e-contact-editor.c
+++ b/addressbook/contact-editor/e-contact-editor.c
@@ -32,6 +32,7 @@ static GtkWidget *e_contact_editor_build_dialog(EContactEditor *editor, gchar *e
static void _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
static void _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
static void _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
+static void fill_in_info(EContactEditor *editor, ECard *card);
static GtkVBoxClass *parent_class = NULL;
@@ -179,7 +180,7 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
GladeXML *gui;
GtkAdjustment *adjustment;
- /* e_contact_editor->card = NULL;*/
+ e_contact_editor->card = NULL;
gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-editor.glade", NULL);
e_contact_editor->gui = gui;
gtk_widget_reparent(glade_xml_get_widget(gui, "notebook-contact-editor"),
@@ -247,7 +248,7 @@ e_contact_editor_destroy (GtkObject *object) {
}
GtkWidget*
-e_contact_editor_new (void *card)
+e_contact_editor_new (ECard *card)
{
GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_contact_editor_get_type ()));
gtk_object_set (GTK_OBJECT(widget),
@@ -265,10 +266,8 @@ e_contact_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
switch (arg_id){
case ARG_CARD:
- /* e_contact_editor->card = GTK_VALUE_POINTER (*arg);
- _update_card(e_contact_editor);
- gnome_canvas_item_request_update (item);*/
- break;
+ fill_in_info(e_contact_editor, E_CARD(GTK_VALUE_OBJECT (*arg)));
+ break;
}
}
@@ -281,11 +280,11 @@ e_contact_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
switch (arg_id) {
case ARG_CARD:
- /* GTK_VALUE_POINTER (*arg) = e_contact_editor->card; */
- break;
+ GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(NULL);
+ break;
default:
- arg->type = GTK_TYPE_INVALID;
- break;
+ arg->type = GTK_TYPE_INVALID;
+ break;
}
}
@@ -567,3 +566,88 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito
_arrow_pressed (widget, button, editor, editor->address_popup, &editor->address_list, &editor->address_info, "label-address1", "entry-address1", "Add new Address type");
}
+
+static void
+fill_in_info(EContactEditor *editor, ECard *card)
+{
+ if (card) {
+ char *fname;
+ ECardList *address_list;
+ ECardList *phone_list;
+ ECardList *email_list;
+ char *url;
+
+ ECardIterator *iterator;
+
+ gtk_object_get(GTK_OBJECT(card),
+ "full_name", &fname,
+ "address", &address_list,
+ "phone", &phone_list,
+ "email", &email_list,
+ "url", &url,
+ NULL);
+
+ if (fname) {
+ int position = 0;
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-fullname"));
+ gtk_editable_delete_text(editable, 0, -1);
+ gtk_editable_insert_text(editable, fname, strlen(fname), &position);
+ } else {
+ int position = 0;
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-fullname"));
+ gtk_editable_delete_text(editable, 0, -1);
+ gtk_editable_insert_text(editable, "", 0, &position);
+ }
+
+ if (address_list) {
+ const ECardDeliveryAddress *address;
+ GtkEditable *editable;
+ int position = 0;
+ iterator = e_card_list_get_iterator(address_list);
+ address = e_card_iterator_get(iterator);
+ editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address"));
+ gtk_editable_delete_text(editable, 0, -1);
+ gtk_editable_insert_text(editable, address->city, strlen(address->city), &position);
+ } else {
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address"));
+ gtk_editable_delete_text(editable, 0, -1);
+ }
+
+ if (address_list) {
+ const ECardPhone *phone;
+ GtkEditable *editable;
+ int position = 0;
+ iterator = e_card_list_get_iterator(phone_list);
+ phone = e_card_iterator_get(iterator);
+ editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-phone1"));
+ gtk_editable_delete_text(editable, 0, -1);
+ gtk_editable_insert_text(editable, phone->number, strlen(phone->number), &position);
+ } else {
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-phone1"));
+ gtk_editable_delete_text(editable, 0, -1);
+ }
+ if (email_list) {
+ const char *email;
+ GtkEditable *editable;
+ int position = 0;
+ iterator = e_card_list_get_iterator(email_list);
+ email = e_card_iterator_get(iterator);
+ editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-email1"));
+ gtk_editable_delete_text(editable, 0, -1);
+ gtk_editable_insert_text(editable, email, strlen(email), &position);
+ } else {
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-email1"));
+ gtk_editable_delete_text(editable, 0, -1);
+ }
+ if (url) {
+ int position = 0;
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web"));
+ gtk_editable_delete_text(editable, 0, -1);
+ gtk_editable_insert_text(editable, url, strlen(url), &position);
+ } else {
+ int position = 0;
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web"));
+ gtk_editable_delete_text(editable, 0, -1);
+ }
+ }
+}
diff --git a/addressbook/contact-editor/e-contact-editor.h b/addressbook/contact-editor/e-contact-editor.h
index 7b914967ee..1ae0fdf275 100644
--- a/addressbook/contact-editor/e-contact-editor.h
+++ b/addressbook/contact-editor/e-contact-editor.h
@@ -23,6 +23,7 @@
#include <gnome.h>
#include <glade/glade.h>
+#include "e-card.h"
#ifdef __cplusplus
extern "C" {
@@ -53,7 +54,7 @@ struct _EContactEditor
GtkVBox parent;
/* item specific fields */
- /* ECard *card; */
+ ECard *card;
GladeXML *gui;
GnomeUIInfo *email_info;
@@ -73,7 +74,7 @@ struct _EContactEditorClass
};
-GtkWidget *e_contact_editor_new(void *card);
+GtkWidget *e_contact_editor_new(ECard *card);
GtkType e_contact_editor_get_type (void);
#ifdef __cplusplus
diff --git a/addressbook/contact-editor/test-editor.c b/addressbook/contact-editor/test-editor.c
index 23eb6e60ea..5b48c1a92f 100644
--- a/addressbook/contact-editor/test-editor.c
+++ b/addressbook/contact-editor/test-editor.c
@@ -26,6 +26,55 @@
#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@helixcode.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);
+}
+
/* This is a horrible thing to do, but it is just a test. */
GtkWidget *editor;
@@ -59,43 +108,51 @@ static void about_callback( GtkWidget *widget, gpointer data )
int main( int argc, char *argv[] )
{
- GtkWidget *app;
-
- /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);*/
-
- gnome_init( "Contact Editor Test", VERSION, argc, argv);
-
- glade_gnome_init ();
-
- app = gnome_app_new("Contact Editor Test", NULL);
-
- editor = e_contact_editor_new(NULL);
-
- gnome_app_set_contents( GNOME_APP( app ), editor );
-
- /* Connect the signals */
- gtk_signal_connect( GTK_OBJECT( app ), "destroy",
- GTK_SIGNAL_FUNC( destroy_callback ),
- ( gpointer ) app );
-
- gtk_widget_show_all( app );
-
- app = gnome_app_new("Contact Editor Test", NULL);
-
- editor = e_contact_editor_new(NULL);
-
- gnome_app_set_contents( GNOME_APP( app ), editor );
-
- /* Connect the signals */
- gtk_signal_connect( GTK_OBJECT( app ), "destroy",
- GTK_SIGNAL_FUNC( destroy_callback ),
- ( gpointer ) app );
-
- gtk_widget_show_all( app );
-
- gtk_main();
-
- /* Not reached. */
- return 0;
+ char *cardstr;
+ GtkWidget *app;
+
+ /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
+ textdomain (PACKAGE);*/
+
+ gnome_init( "Contact Editor Test", VERSION, argc, argv);
+
+ glade_gnome_init ();
+
+ app = gnome_app_new("Contact Editor Test", NULL);
+
+ cardstr = NULL;
+ if (argc == 2)
+ cardstr = read_file (argv [1]);
+
+ if (cardstr == NULL)
+ cardstr = TEST_VCARD;
+
+ editor = e_contact_editor_new(e_card_new(cardstr));
+
+ gnome_app_set_contents( GNOME_APP( app ), editor );
+
+ /* Connect the signals */
+ gtk_signal_connect( GTK_OBJECT( app ), "destroy",
+ GTK_SIGNAL_FUNC( destroy_callback ),
+ ( gpointer ) app );
+
+ gtk_widget_show_all( app );
+
+ app = gnome_app_new("Contact Editor Test", NULL);
+
+ editor = e_contact_editor_new(e_card_new(cardstr));
+
+ gnome_app_set_contents( GNOME_APP( app ), editor );
+
+ /* Connect the signals */
+ gtk_signal_connect( GTK_OBJECT( app ), "destroy",
+ GTK_SIGNAL_FUNC( destroy_callback ),
+ ( gpointer ) app );
+
+ gtk_widget_show_all( app );
+
+ gtk_main();
+
+ /* Not reached. */
+ return 0;
}
diff --git a/addressbook/gui/contact-editor/Makefile.am b/addressbook/gui/contact-editor/Makefile.am
index 7c3d0de273..2fb74b736d 100644
--- a/addressbook/gui/contact-editor/Makefile.am
+++ b/addressbook/gui/contact-editor/Makefile.am
@@ -9,7 +9,8 @@ CPPFLAGS = \
-DDATADIR=\""$(datadir)"\"
INCLUDES = \
- $(GNOME_INCLUDEDIR)
+ $(GNOME_INCLUDEDIR) \
+ -I$(top_srcdir)/addressbook/backend/ebook
noinst_LIBRARIES = \
libecontacteditor.a
@@ -25,6 +26,11 @@ contact_editor_test_SOURCES = \
test-editor.c
contact_editor_test_LDADD = \
+ $(top_builddir)/addressbook/backend/ebook/libebook.la \
+ $(top_builddir)/libversit/libversit.la \
+ $(GNOMEGNORBA_LIBS) \
+ -lbonobo \
+ $(top_builddir)/e-util/libeutil.la \
libecontacteditor.a \
$(EXTRA_GNOME_LIBS)
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 81a6980ef7..9277eef1fd 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -32,6 +32,7 @@ static GtkWidget *e_contact_editor_build_dialog(EContactEditor *editor, gchar *e
static void _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
static void _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
static void _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
+static void fill_in_info(EContactEditor *editor, ECard *card);
static GtkVBoxClass *parent_class = NULL;
@@ -179,7 +180,7 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
GladeXML *gui;
GtkAdjustment *adjustment;
- /* e_contact_editor->card = NULL;*/
+ e_contact_editor->card = NULL;
gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-editor.glade", NULL);
e_contact_editor->gui = gui;
gtk_widget_reparent(glade_xml_get_widget(gui, "notebook-contact-editor"),
@@ -247,7 +248,7 @@ e_contact_editor_destroy (GtkObject *object) {
}
GtkWidget*
-e_contact_editor_new (void *card)
+e_contact_editor_new (ECard *card)
{
GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_contact_editor_get_type ()));
gtk_object_set (GTK_OBJECT(widget),
@@ -265,10 +266,8 @@ e_contact_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
switch (arg_id){
case ARG_CARD:
- /* e_contact_editor->card = GTK_VALUE_POINTER (*arg);
- _update_card(e_contact_editor);
- gnome_canvas_item_request_update (item);*/
- break;
+ fill_in_info(e_contact_editor, E_CARD(GTK_VALUE_OBJECT (*arg)));
+ break;
}
}
@@ -281,11 +280,11 @@ e_contact_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
switch (arg_id) {
case ARG_CARD:
- /* GTK_VALUE_POINTER (*arg) = e_contact_editor->card; */
- break;
+ GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(NULL);
+ break;
default:
- arg->type = GTK_TYPE_INVALID;
- break;
+ arg->type = GTK_TYPE_INVALID;
+ break;
}
}
@@ -567,3 +566,88 @@ _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEdito
_arrow_pressed (widget, button, editor, editor->address_popup, &editor->address_list, &editor->address_info, "label-address1", "entry-address1", "Add new Address type");
}
+
+static void
+fill_in_info(EContactEditor *editor, ECard *card)
+{
+ if (card) {
+ char *fname;
+ ECardList *address_list;
+ ECardList *phone_list;
+ ECardList *email_list;
+ char *url;
+
+ ECardIterator *iterator;
+
+ gtk_object_get(GTK_OBJECT(card),
+ "full_name", &fname,
+ "address", &address_list,
+ "phone", &phone_list,
+ "email", &email_list,
+ "url", &url,
+ NULL);
+
+ if (fname) {
+ int position = 0;
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-fullname"));
+ gtk_editable_delete_text(editable, 0, -1);
+ gtk_editable_insert_text(editable, fname, strlen(fname), &position);
+ } else {
+ int position = 0;
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-fullname"));
+ gtk_editable_delete_text(editable, 0, -1);
+ gtk_editable_insert_text(editable, "", 0, &position);
+ }
+
+ if (address_list) {
+ const ECardDeliveryAddress *address;
+ GtkEditable *editable;
+ int position = 0;
+ iterator = e_card_list_get_iterator(address_list);
+ address = e_card_iterator_get(iterator);
+ editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address"));
+ gtk_editable_delete_text(editable, 0, -1);
+ gtk_editable_insert_text(editable, address->city, strlen(address->city), &position);
+ } else {
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address"));
+ gtk_editable_delete_text(editable, 0, -1);
+ }
+
+ if (address_list) {
+ const ECardPhone *phone;
+ GtkEditable *editable;
+ int position = 0;
+ iterator = e_card_list_get_iterator(phone_list);
+ phone = e_card_iterator_get(iterator);
+ editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-phone1"));
+ gtk_editable_delete_text(editable, 0, -1);
+ gtk_editable_insert_text(editable, phone->number, strlen(phone->number), &position);
+ } else {
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-phone1"));
+ gtk_editable_delete_text(editable, 0, -1);
+ }
+ if (email_list) {
+ const char *email;
+ GtkEditable *editable;
+ int position = 0;
+ iterator = e_card_list_get_iterator(email_list);
+ email = e_card_iterator_get(iterator);
+ editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-email1"));
+ gtk_editable_delete_text(editable, 0, -1);
+ gtk_editable_insert_text(editable, email, strlen(email), &position);
+ } else {
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-email1"));
+ gtk_editable_delete_text(editable, 0, -1);
+ }
+ if (url) {
+ int position = 0;
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web"));
+ gtk_editable_delete_text(editable, 0, -1);
+ gtk_editable_insert_text(editable, url, strlen(url), &position);
+ } else {
+ int position = 0;
+ GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web"));
+ gtk_editable_delete_text(editable, 0, -1);
+ }
+ }
+}
diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h
index 7b914967ee..1ae0fdf275 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.h
+++ b/addressbook/gui/contact-editor/e-contact-editor.h
@@ -23,6 +23,7 @@
#include <gnome.h>
#include <glade/glade.h>
+#include "e-card.h"
#ifdef __cplusplus
extern "C" {
@@ -53,7 +54,7 @@ struct _EContactEditor
GtkVBox parent;
/* item specific fields */
- /* ECard *card; */
+ ECard *card;
GladeXML *gui;
GnomeUIInfo *email_info;
@@ -73,7 +74,7 @@ struct _EContactEditorClass
};
-GtkWidget *e_contact_editor_new(void *card);
+GtkWidget *e_contact_editor_new(ECard *card);
GtkType e_contact_editor_get_type (void);
#ifdef __cplusplus
diff --git a/addressbook/gui/contact-editor/test-editor.c b/addressbook/gui/contact-editor/test-editor.c
index 23eb6e60ea..5b48c1a92f 100644
--- a/addressbook/gui/contact-editor/test-editor.c
+++ b/addressbook/gui/contact-editor/test-editor.c
@@ -26,6 +26,55 @@
#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@helixcode.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);
+}
+
/* This is a horrible thing to do, but it is just a test. */
GtkWidget *editor;
@@ -59,43 +108,51 @@ static void about_callback( GtkWidget *widget, gpointer data )
int main( int argc, char *argv[] )
{
- GtkWidget *app;
-
- /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
- textdomain (PACKAGE);*/
-
- gnome_init( "Contact Editor Test", VERSION, argc, argv);
-
- glade_gnome_init ();
-
- app = gnome_app_new("Contact Editor Test", NULL);
-
- editor = e_contact_editor_new(NULL);
-
- gnome_app_set_contents( GNOME_APP( app ), editor );
-
- /* Connect the signals */
- gtk_signal_connect( GTK_OBJECT( app ), "destroy",
- GTK_SIGNAL_FUNC( destroy_callback ),
- ( gpointer ) app );
-
- gtk_widget_show_all( app );
-
- app = gnome_app_new("Contact Editor Test", NULL);
-
- editor = e_contact_editor_new(NULL);
-
- gnome_app_set_contents( GNOME_APP( app ), editor );
-
- /* Connect the signals */
- gtk_signal_connect( GTK_OBJECT( app ), "destroy",
- GTK_SIGNAL_FUNC( destroy_callback ),
- ( gpointer ) app );
-
- gtk_widget_show_all( app );
-
- gtk_main();
-
- /* Not reached. */
- return 0;
+ char *cardstr;
+ GtkWidget *app;
+
+ /* bindtextdomain (PACKAGE, GNOMELOCALEDIR);
+ textdomain (PACKAGE);*/
+
+ gnome_init( "Contact Editor Test", VERSION, argc, argv);
+
+ glade_gnome_init ();
+
+ app = gnome_app_new("Contact Editor Test", NULL);
+
+ cardstr = NULL;
+ if (argc == 2)
+ cardstr = read_file (argv [1]);
+
+ if (cardstr == NULL)
+ cardstr = TEST_VCARD;
+
+ editor = e_contact_editor_new(e_card_new(cardstr));
+
+ gnome_app_set_contents( GNOME_APP( app ), editor );
+
+ /* Connect the signals */
+ gtk_signal_connect( GTK_OBJECT( app ), "destroy",
+ GTK_SIGNAL_FUNC( destroy_callback ),
+ ( gpointer ) app );
+
+ gtk_widget_show_all( app );
+
+ app = gnome_app_new("Contact Editor Test", NULL);
+
+ editor = e_contact_editor_new(e_card_new(cardstr));
+
+ gnome_app_set_contents( GNOME_APP( app ), editor );
+
+ /* Connect the signals */
+ gtk_signal_connect( GTK_OBJECT( app ), "destroy",
+ GTK_SIGNAL_FUNC( destroy_callback ),
+ ( gpointer ) app );
+
+ gtk_widget_show_all( app );
+
+ gtk_main();
+
+ /* Not reached. */
+ return 0;
}
diff --git a/addressbook/gui/minicard/e-minicard.c b/addressbook/gui/minicard/e-minicard.c
index 02c7670df9..12041a0c5f 100644
--- a/addressbook/gui/minicard/e-minicard.c
+++ b/addressbook/gui/minicard/e-minicard.c
@@ -402,6 +402,7 @@ remodel( EMinicard *e_minicard )
{
if (e_minicard->card) {
char *fname;
+ char *url;
ECardList *address_list;
ECardList *phone_list;
ECardList *email_list;
@@ -417,11 +418,12 @@ remodel( EMinicard *e_minicard )
e_minicard->fields = NULL;
gtk_object_get(GTK_OBJECT(e_minicard->card),
- "full_name", &fname,
- "address", &address_list,
- "phone", &phone_list,
- "email", &email_list,
- NULL);
+ "full_name", &fname,
+ "address", &address_list,
+ "phone", &phone_list,
+ "email", &email_list,
+ "url", &url,
+ NULL);
if (fname) {
add_field(e_minicard, "Name:", fname);
@@ -465,6 +467,8 @@ remodel( EMinicard *e_minicard )
add_field(e_minicard, "Email:", (char *) e_card_iterator_get(iterator));
}
}
+ if (url)
+ add_field(e_minicard, "Web page:", url);
}
}
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index 02c7670df9..12041a0c5f 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -402,6 +402,7 @@ remodel( EMinicard *e_minicard )
{
if (e_minicard->card) {
char *fname;
+ char *url;
ECardList *address_list;
ECardList *phone_list;
ECardList *email_list;
@@ -417,11 +418,12 @@ remodel( EMinicard *e_minicard )
e_minicard->fields = NULL;
gtk_object_get(GTK_OBJECT(e_minicard->card),
- "full_name", &fname,
- "address", &address_list,
- "phone", &phone_list,
- "email", &email_list,
- NULL);
+ "full_name", &fname,
+ "address", &address_list,
+ "phone", &phone_list,
+ "email", &email_list,
+ "url", &url,
+ NULL);
if (fname) {
add_field(e_minicard, "Name:", fname);
@@ -465,6 +467,8 @@ remodel( EMinicard *e_minicard )
add_field(e_minicard, "Email:", (char *) e_card_iterator_get(iterator));
}
}
+ if (url)
+ add_field(e_minicard, "Web page:", url);
}
}