honour mail address attributes when setting up Home and Work addresses

2007-08-21  Jens Granseuer  <jensgr@gmx.net>

	* gnome-about-me.c: honour mail address attributes when setting
	up Home and Work addresses

svn path=/trunk/; revision=8026
This commit is contained in:
Jens Granseuer 2007-08-21 10:36:05 +00:00 committed by Rodrigo Moya
parent 23b792113a
commit 7aa4e96a78
2 changed files with 38 additions and 3 deletions

View file

@ -1,3 +1,8 @@
2007-08-21 Jens Granseuer <jensgr@gmx.net>
* gnome-about-me.c: honour mail address attributes when setting
up Home and Work addresses
2007-07-31 Jens Granseuer <jensgr@gmx.net>
* gnome-about-me.c: (about_me_image_clicked_cb): use

View file

@ -70,7 +70,7 @@ typedef struct {
static GnomeAboutMe *me = NULL;
struct WidToCid{
struct WidToCid {
gchar *wid;
guint cid;
};
@ -84,6 +84,8 @@ enum {
ADDRESS_COUNTRY
};
#define EMAIL_HOME 0
#define EMAIL_WORK 1
#define ADDRESS_HOME 21
#define ADDRESS_WORK 27
@ -132,6 +134,8 @@ struct WidToCid ids[] = {
{ NULL, 0 }
};
#define ATTRIBUTE_HOME "HOME"
#define ATTRIBUTE_WORK "WORK"
static void about_me_set_address_field (EContactAddress *, guint, gchar *);
@ -199,7 +203,7 @@ about_me_commit (GnomeAboutMe *me)
}
e_contact_set (me->contact, E_CONTACT_FILE_AS, fileas);
e_contact_set (me->contact, E_CONTACT_NICKNAME, "nickname");
e_contact_set (me->contact, E_CONTACT_NICKNAME, me->login);
e_contact_set (me->contact, E_CONTACT_FULL_NAME, me->username);
e_contact_name_free (name);
@ -376,6 +380,30 @@ about_me_set_address_field (EContactAddress *addr, guint cid, gchar *str)
}
}
static void
about_me_setup_email (EContact *contact)
{
GList *attrs, *a;
gboolean has_home = FALSE, has_work = FALSE;
guint cid;
attrs = e_contact_get_attributes (contact, E_CONTACT_EMAIL);
for (a = attrs, cid = E_CONTACT_EMAIL_1; a; a = a->next, ++cid) {
if (!has_home &&
e_vcard_attribute_has_type ((EVCardAttribute *)a->data, ATTRIBUTE_HOME)) {
has_home = TRUE;
ids[EMAIL_HOME].cid = cid;
} else if (!has_work &&
e_vcard_attribute_has_type ((EVCardAttribute *)a->data, ATTRIBUTE_WORK)) {
has_work = TRUE;
ids[EMAIL_WORK].cid = cid;
}
g_free (a->data);
}
g_list_free (attrs);
}
/**
* about_me_load_string_field:
*
@ -828,6 +856,8 @@ about_me_setup_dialog (void)
g_clear_error (&error);
}
}
} else {
about_me_setup_email (me->contact);
}
/************************************************/