[evolution-patches] patch for bug 320168



 please review it and let me know if I can optimize it.


Yahoo! DSL Something to write home about. Just $16.99/mo. or less
Index: e-minicard.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-minicard.c,v
retrieving revision 1.126
diff -u -p -r1.126 e-minicard.c
--- e-minicard.c	24 Aug 2005 03:06:51 -0000	1.126
+++ e-minicard.c	7 Jan 2006 14:28:12 -0000
@@ -65,7 +65,7 @@ static GnomeCanvasGroupClass *parent_cla
 #define d(x)
 
 #define LIST_ICON_NAME "stock_contact-list"
-
+#define EMAIL_SLOTS 4
 static void
 e_minicard_field_destroy(EMinicardField *field)
 {
@@ -94,6 +94,31 @@ enum {
 
 static guint e_minicard_signals [LAST_SIGNAL] = {0, };
 
+
+static struct {
+	gchar *name;
+	gchar *pretty_name;
+}
+loc [] =
+{
+	{ "WORK", "Work Email"  },
+	{ "HOME",  "Home Email"  },
+	{ "OTHER", "Other Email" }
+};	
+
+static gint
+get_email_location (EVCardAttribute *attr)
+{
+	gint i;
+
+	for (i = 0; i < G_N_ELEMENTS (loc); i++) {
+		if (e_vcard_attribute_has_type (attr,loc[i].name))
+			return i;
+	}
+
+	return -1;
+}
+
 GType
 e_minicard_get_type (void)
 {
@@ -760,7 +785,7 @@ e_minicard_resize_children( EMinicard *e
 }
 
 static void
-add_field (EMinicard *e_minicard, EContactField field, gdouble left_width)
+add_field (EMinicard *e_minicard, EContactField field, gdouble left_width,gint location)
 {
 	GnomeCanvasItem *new_item;
 	GnomeCanvasGroup *group;
@@ -768,9 +793,14 @@ add_field (EMinicard *e_minicard, EConta
 	char *name;
 	char *string;
 	
-	group = GNOME_CANVAS_GROUP( e_minicard );
 	
-	name = g_strdup_printf("%s:", e_contact_pretty_name (field));
+	group = GNOME_CANVAS_GROUP( e_minicard );
+		if(location>=0){
+			name = g_strdup_printf("%s:",loc[location].pretty_name);
+		}
+		else{
+			name=g_strdup_printf("%s:",e_contact_pretty_name(field));
+		}
 	string = e_contact_get (e_minicard->contact, field);
 
 	new_item = e_minicard_label_new(group);
@@ -847,9 +877,12 @@ remodel( EMinicard *e_minicard )
 	if (e_minicard->contact) {
 		EContactField field;
 		GList *list;
-		char *file_as;
+		char *file_as,*location;
 		int left_width = -1;
 		gboolean is_list = FALSE;
+		GList *email_attr_list,*l;
+		gint record_n,i=0;
+		gint email_location[EMAIL_SLOTS];
 
 		if (e_minicard->header_text) {
 			file_as = e_contact_get (e_minicard->contact, E_CONTACT_FILE_AS);
@@ -869,7 +902,14 @@ remodel( EMinicard *e_minicard )
 
 		list = e_minicard->fields;
 		e_minicard->fields = NULL;
+				
+		email_attr_list = e_contact_get_attributes (e_minicard->contact, E_CONTACT_EMAIL);
+		for (record_n = 1, l = email_attr_list; l && record_n <= EMAIL_SLOTS; l = g_list_next (l),record_n++) {
+		EVCardAttribute *attr = l->data;
+		email_location[record_n-1]=get_email_location(attr);
+		}
 
+		
 		for(field = E_CONTACT_FULL_NAME; field != (E_CONTACT_LAST_SIMPLE_STRING -1) && count < 5; field++) {
 			EMinicardField *minicard_field = NULL;
 
@@ -906,7 +946,13 @@ remodel( EMinicard *e_minicard )
 
 				string = e_contact_get(e_minicard->contact, field);
 				if (string && *string) {
-					add_field(e_minicard, field, left_width);
+					if(!g_ascii_strcasecmp(e_contact_vcard_attribute(field),"EMAIL")) {
+						location=email_location[i++];
+						}
+					else{
+						 location=-1;
+					}
+					add_field(e_minicard, field, left_width,location);
 					count++;
 				}
 				g_free(string);
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.2026
diff -u -p -r1.2026 ChangeLog
--- ChangeLog	22 Dec 2005 07:55:15 -0000	1.2026
+++ ChangeLog	7 Jan 2006 14:29:37 -0000
@@ -1,3 +1,6 @@
+2005-01-07 Oswald Rodrigues <ozzy_rodrigues yahoo com>
+	*gui/widgets/e-minicard.c:modified the minicard e-mail fields to work e-        mail,etc ie according to type of email.
+	
 2005-12-22  Srinivasa Ragavan <sragavan novell com>
 
 	* gui/search/addresstypes.xml: Modified the categories to option menu


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]