aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/contact-editor
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-04-09 11:04:47 +0800
committerChris Lahey <clahey@src.gnome.org>2000-04-09 11:04:47 +0800
commit75513364f1db91b894cacb8853d9486e74b45caf (patch)
treee658f21e6fd1407de3a6b041b41988b2d9b9d447 /addressbook/contact-editor
parent2baf1a70830fc9a0a4cd9ef210c92c147490aeb3 (diff)
downloadgsoc2013-evolution-75513364f1db91b894cacb8853d9486e74b45caf.tar
gsoc2013-evolution-75513364f1db91b894cacb8853d9486e74b45caf.tar.gz
gsoc2013-evolution-75513364f1db91b894cacb8853d9486e74b45caf.tar.bz2
gsoc2013-evolution-75513364f1db91b894cacb8853d9486e74b45caf.tar.lz
gsoc2013-evolution-75513364f1db91b894cacb8853d9486e74b45caf.tar.xz
gsoc2013-evolution-75513364f1db91b894cacb8853d9486e74b45caf.tar.zst
gsoc2013-evolution-75513364f1db91b894cacb8853d9486e74b45caf.zip
Made the contact editor load from an ECard.
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. svn path=/trunk/; revision=2349
Diffstat (limited to 'addressbook/contact-editor')
-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
4 files changed, 200 insertions, 52 deletions
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;
}