[evolution] Display local contact photos in EContactEditor's EImageChooser



commit f77a83e8759912bc74029e29effe1f0d20876965
Author: Dan VrÃtil <dvratil redhat com>
Date:   Wed Jun 27 14:08:03 2012 +0200

    Display local contact photos in EContactEditor's EImageChooser
    
    Some contacts have photos stored locally as files. Until now
    EContactEditor displayed thumbnail of contact photo in EImageChooser
    only if the photo was embedded in the vCard as data. This patch
    adds support for dispalying thumbnails of photos stored in local files
    to indicate that the contact has a picture set.

 addressbook/gui/contact-editor/e-contact-editor.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 16ee869..44fd081 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -2612,14 +2612,25 @@ fill_in_simple_field (EContactEditor *editor,
 
 	} else if (E_IS_IMAGE_CHOOSER (widget)) {
 		EContactPhoto *photo = e_contact_get (contact, field_id);
+		editor->image_set = FALSE;
 		if (photo && photo->type == E_CONTACT_PHOTO_TYPE_INLINED) {
 			e_image_chooser_set_image_data (
 				E_IMAGE_CHOOSER (widget),
 				(gchar *) photo->data.inlined.data,
 				photo->data.inlined.length);
 			editor->image_set = TRUE;
+		} else if (photo && photo->type == E_CONTACT_PHOTO_TYPE_URI) {
+			gchar *file_name = g_filename_from_uri (photo->data.uri, NULL, NULL);
+			if (file_name) {
+				e_image_chooser_set_from_file (
+					E_IMAGE_CHOOSER (widget),
+					file_name);
+				editor->image_set = TRUE;
+				g_free (file_name);
+			}
 		}
-		else {
+
+		if (!editor->image_set) {
 			gchar *file_name;
 
 			file_name = e_icon_factory_get_icon_filename (
@@ -2629,6 +2640,7 @@ fill_in_simple_field (EContactEditor *editor,
 			editor->image_set = FALSE;
 			g_free (file_name);
 		}
+
 		editor->image_changed = FALSE;
 		e_contact_photo_free (photo);
 



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