diff options
author | Devashish Sharma <dsharma@src.gnome.org> | 2006-07-19 18:40:43 +0800 |
---|---|---|
committer | Devashish Sharma <dsharma@src.gnome.org> | 2006-07-19 18:40:43 +0800 |
commit | 8dc17e7cbc05c91e99251d2b1d8ec8dbf9cb2dcf (patch) | |
tree | cb6f4fa21ca98bf85c86d7514e82fa97e2d38163 /addressbook | |
parent | 980cf81e06337ff344fad8393770a2025441748a (diff) | |
download | gsoc2013-evolution-8dc17e7cbc05c91e99251d2b1d8ec8dbf9cb2dcf.tar.gz gsoc2013-evolution-8dc17e7cbc05c91e99251d2b1d8ec8dbf9cb2dcf.tar.zst gsoc2013-evolution-8dc17e7cbc05c91e99251d2b1d8ec8dbf9cb2dcf.zip |
Fix for Bug 343816
svn path=/trunk/; revision=32346
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 8 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard.c | 110 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-contact-display.c | 80 |
3 files changed, 182 insertions, 16 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 6d1eb078fc..ec12831d52 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,11 @@ +2006-07-19 Devashish Sharma <sdevashish@novell.com> + + * addressbook/gui/widgets/e-minicard.c : + * addressbook/gui/widgets/eab-contact-display.c : In the minicard view + and preview pane, show the type(home, work) of email instead of showing + email1,email2. + Fixes Bug 343816. + 2006-07-18 Ross Burton <ross@openedhand.com> * addressbook/gui/contact-editor/e-contact-editor.c: diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index a5dc42285a..9f9fb88f43 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -92,6 +92,17 @@ enum { LAST_SIGNAL }; +static struct { + gchar *name; + gchar *pretty_name; +} +common_location [] = +{ + { "WORK", N_ ("Work Email") }, + { "HOME", N_ ("Home Email") }, + { "OTHER", N_ ("Other Email") } +}; + static guint e_minicard_signals [LAST_SIGNAL] = {0, }; GType @@ -806,6 +817,70 @@ add_field (EMinicard *e_minicard, EContactField field, gdouble left_width) g_free(string); } + +static const char * +get_email_location (EVCardAttribute *attr) +{ + gint i; + + for (i = 0; i < G_N_ELEMENTS (common_location); i++) { + if (e_vcard_attribute_has_type (attr, common_location [i].name)) + return common_location [i].pretty_name; + } + + return NULL; +} + +static void +add_email_field (EMinicard *e_minicard, GList *email_list, gdouble left_width, int limit) +{ + GnomeCanvasItem *new_item; + GnomeCanvasGroup *group; + EMinicardField *minicard_field; + char *name; + char *string; + GList *l, *le; + int count =0; + GList *emails = e_contact_get (e_minicard->contact, E_CONTACT_EMAIL); + group = GNOME_CANVAS_GROUP( e_minicard ); + + for (l=email_list, le=emails; l!=NULL && count < limit && le!=NULL; l = l->next, le=le->next) { + + name = get_email_location ((EVCardAttribute *) l->data); + string = e_text_to_html (le->data, 0); + + new_item = e_minicard_label_new(group); + + gnome_canvas_item_set( new_item, + "width", e_minicard->width - 4.0, + "fieldname", name, + "field", string, + "max_field_name_length", left_width, + "editable", FALSE /* e_minicard->editable */, + NULL ); + + +#ifdef notyet + g_object_set(E_MINICARD_LABEL(new_item)->field, + "allow_newlines", e_card_simple_get_allow_newlines (e_minicard->contact, field), + NULL); +#endif + g_object_set_data(G_OBJECT (E_MINICARD_LABEL(new_item)->field), + "EMinicard:field", + GINT_TO_POINTER(E_CONTACT_EMAIL)); + + minicard_field = g_new(EMinicardField, 1); + minicard_field->field = E_CONTACT_EMAIL; + minicard_field->label = new_item; + + e_minicard->fields = g_list_append( e_minicard->fields, minicard_field); + e_canvas_item_move_absolute(new_item, 2, e_minicard->height); + count++; + g_free(string); + } + g_list_free (emails); +} + static int get_left_width(EMinicard *e_minicard) { @@ -844,6 +919,7 @@ remodel( EMinicard *e_minicard ) char *file_as; int left_width = -1; gboolean is_list = FALSE; + gboolean email_rendered = FALSE; if (e_minicard->header_text) { file_as = e_contact_get (e_minicard->contact, E_CONTACT_FILE_AS); @@ -866,12 +942,19 @@ remodel( EMinicard *e_minicard ) for(field = E_CONTACT_FULL_NAME; field != (E_CONTACT_LAST_SIMPLE_STRING -1) && count < 5; field++) { EMinicardField *minicard_field = NULL; - + gboolean is_email=FALSE; + if (field == E_CONTACT_FAMILY_NAME || field == E_CONTACT_GIVEN_NAME) continue; if (field == E_CONTACT_FULL_NAME && is_list) continue; + if (field == E_CONTACT_EMAIL_1 || field == E_CONTACT_EMAIL_2 || field == E_CONTACT_EMAIL_3 || field == E_CONTACT_EMAIL_4) { + if (email_rendered) + continue; + email_rendered = TRUE; + is_email=TRUE; + } if (list) minicard_field = list->data; @@ -897,12 +980,27 @@ remodel( EMinicard *e_minicard ) left_width = get_left_width(e_minicard); } - string = e_contact_get(e_minicard->contact, field); - if (string && *string) { - add_field(e_minicard, field, left_width); - count++; + if (is_email) { + GList *email; + int limit; + + limit = 5 - count; + email = e_contact_get_attributes (e_minicard->contact, E_CONTACT_EMAIL); + add_email_field (e_minicard, email, left_width, limit); + if (count+limit >5) + count = 5; + else + count = count + g_list_length (email); + is_email=FALSE; + g_list_free (email); + } else { + string = e_contact_get(e_minicard->contact, field); + if (string && *string) { + add_field(e_minicard, field, left_width); + count++; + } + g_free(string); } - g_free(string); } } diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c index 0ce9f346d3..f9d85c9c7f 100644 --- a/addressbook/gui/widgets/eab-contact-display.c +++ b/addressbook/gui/widgets/eab-contact-display.c @@ -48,6 +48,16 @@ struct _EABContactDisplayPrivate { char *selection_uri; }; +static struct { + gchar *name; + gchar *pretty_name; +} +common_location [] = +{ + { "WORK", N_ ("Work") }, + { "HOME", N_ ("Home") }, + { "OTHER", N_ ("Other") } +}; #define HTML_HEADER "<!doctype html public \"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN\">\n<html>\n" \ "<head>\n<meta name=\"generator\" content=\"Evolution Addressbook Component\">\n</head>\n" @@ -289,7 +299,7 @@ render_address (GtkHTMLStream *html_stream, EContact *contact, const char *html_ gtk_html_stream_printf (html_stream, "<tr><td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\"></td><td valign=\"top\" width=\"100\"><font color=" HEADER_COLOR ">%s:</font><br><a href=\"http://www.mapquest.com/\">%s</a></td><td valign=\"top\">%s</td></tr>", html_label, _("(map)"), html); - g_free (html); +This shoul g_free (html); return; } @@ -406,6 +416,26 @@ accum_attribute (GString *gstr, EContact *contact, const char *html_label, ECont } static void +accum_time_attribute (GString *gstr, EContact *contact, const char *html_label, EContactField field, const char *icon, unsigned int html_flags) +{ + EContactDate *date; + struct tm tdate; + char sdate[100]; + + date = e_contact_get (contact, field); + memset (&tdate, 0, sizeof (struct tm)); + + if (date) { + tdate.tm_year = date->year-1900; + tdate.tm_mday = date->day; + tdate.tm_mon = date->month-1; + strftime (sdate, 100, "%x", &tdate); + accum_name_value (gstr, html_label, sdate, icon, html_flags); + e_contact_date_free (date); + } +} + +static void accum_multival_attribute (GString *gstr, EContact *contact, const char *html_label, EContactField field, const char *icon, unsigned int html_flags) { GList *val_list, *l; @@ -451,15 +481,28 @@ end_block (GtkHTMLStream *html_stream) gtk_html_stream_printf (html_stream, "<tr><td height=\"20\"> </td></tr>"); } +static const char * +get_email_location (EVCardAttribute *attr) +{ + gint i; + + for (i = 0; i < G_N_ELEMENTS (common_location); i++) { + if (e_vcard_attribute_has_type (attr, common_location [i].name)) + return common_location [i].pretty_name; + } + + return NULL; +} + static void render_contact (GtkHTMLStream *html_stream, EContact *contact) { GString *accum; - GList *email_list, *l; + GList *email_list, *l, *email_attr_list, *al; #ifdef HANDLE_MAILTO_INTERNALLY int email_num = 0; #endif - char *nl; + char *nl, *nick=NULL; gtk_html_stream_printf (html_stream, "<table border=\"0\">"); @@ -469,16 +512,18 @@ render_contact (GtkHTMLStream *html_stream, EContact *contact) start_block (html_stream, ""); email_list = e_contact_get (contact, E_CONTACT_EMAIL); - for (l = email_list; l; l = l->next) { + email_attr_list = e_contact_get_attributes (contact, E_CONTACT_EMAIL); + + for (l = email_list, al=email_attr_list; l && al; l = l->next, al = al->next) { #ifdef HANDLE_MAILTO_INTERNALLY char *html = e_text_to_html (l->data, 0); - g_string_append_printf (accum, "%s<a href=\"internal-mailto:%d\">%s</a>", nl, email_num, html); + g_string_append_printf (accum, "%s<a href=\"internal-mailto:%d\">%s</a> <font color=" HEADER_COLOR ">(%s)</font>", nl, email_num, html, get_email_location ((EVCardAttribute *) al->data)); email_num ++; g_free (html); nl = "<br>"; #else - g_string_append_printf (accum, "%s%s", nl, (char*)l->data); + g_string_append_printf (accum, "%s%s <font color=" HEADER_COLOR ">(%s)</font>", nl, (char*)l->data, get_email_location ((EVCardAttribute *) al->data)); nl = "\n"; #endif } @@ -499,7 +544,14 @@ render_contact (GtkHTMLStream *html_stream, EContact *contact) } g_string_assign (accum, ""); - + nick = e_contact_get (contact, E_CONTACT_NICKNAME); + if (nick && *nick) { + accum_name_value (accum, _("Nickname"), nick, NULL, 0); + if (accum->len > 0) + gtk_html_stream_printf (html_stream, "%s", accum->str); + } + + g_string_assign (accum, ""); accum_multival_attribute (accum, contact, _("AIM"), E_CONTACT_IM_AIM, AIM_ICON, 0); accum_multival_attribute (accum, contact, _("GroupWise"), E_CONTACT_IM_GROUPWISE, GROUPWISE_ICON, 0); accum_multival_attribute (accum, contact, _("ICQ"), E_CONTACT_IM_ICQ, ICQ_ICON, 0); @@ -515,14 +567,20 @@ render_contact (GtkHTMLStream *html_stream, EContact *contact) g_string_assign (accum, ""); accum_attribute (accum, contact, _("Organization"), E_CONTACT_ORG, NULL, 0); + accum_attribute (accum, contact, _("Department"), E_CONTACT_ORG_UNIT, NULL, 0); + accum_attribute (accum, contact, _("Profession"), E_CONTACT_ROLE, NULL, 0); accum_attribute (accum, contact, _("Position"), E_CONTACT_TITLE, NULL, 0); + accum_attribute (accum, contact, _("Manager"), E_CONTACT_MANAGER, NULL, 0); + accum_attribute (accum, contact, _("Assistant"), E_CONTACT_ASSISTANT, NULL, 0); accum_attribute (accum, contact, _("Video Chat"), E_CONTACT_VIDEO_URL, VIDEOCONF_ICON, E_TEXT_TO_HTML_CONVERT_URLS); + accum_attribute (accum, contact, _("Calendar"), E_CONTACT_CALENDAR_URI, NULL, E_TEXT_TO_HTML_CONVERT_URLS); + accum_attribute (accum, contact, _("Free/Busy"), E_CONTACT_FREEBUSY_URL, NULL, E_TEXT_TO_HTML_CONVERT_URLS); accum_attribute (accum, contact, _("Phone"), E_CONTACT_PHONE_BUSINESS, NULL, 0); accum_attribute (accum, contact, _("Fax"), E_CONTACT_PHONE_BUSINESS_FAX, NULL, 0); accum_address (accum, contact, _("Address"), E_CONTACT_ADDRESS_WORK, E_CONTACT_ADDRESS_LABEL_WORK); if (accum->len > 0) { - start_block (html_stream, _("work")); + start_block (html_stream, _("Work")); gtk_html_stream_printf (html_stream, "%s", accum->str); end_block (html_stream); } @@ -535,9 +593,11 @@ render_contact (GtkHTMLStream *html_stream, EContact *contact) accum_attribute (accum, contact, _("Phone"), E_CONTACT_PHONE_HOME, NULL, 0); accum_attribute (accum, contact, _("Mobile Phone"), E_CONTACT_PHONE_MOBILE, NULL, 0); accum_address (accum, contact, _("Address"), E_CONTACT_ADDRESS_HOME, E_CONTACT_ADDRESS_LABEL_HOME); - + accum_time_attribute (accum, contact, _("Birthday"), E_CONTACT_BIRTH_DATE, NULL, 0); + accum_time_attribute (accum, contact, _("Anniversary"), E_CONTACT_ANNIVERSARY, NULL, 0); + accum_attribute (accum, contact, _("Spouse"), E_CONTACT_SPOUSE, NULL, 0); if (accum->len > 0) { - start_block (html_stream, _("personal")); + start_block (html_stream, _("Personal")); gtk_html_stream_printf (html_stream, "%s", accum->str); end_block (html_stream); } |