diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2011-11-02 06:27:05 +0800 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2011-11-02 06:27:05 +0800 |
commit | 02cbe55123aa9ee218ee6a33ffb19f7644110123 (patch) | |
tree | 92c1da67ecff0a8a74316011dcfc6101631dc4cb | |
parent | ea8d9ff8f57c331b13afbea59160540f21fdca28 (diff) | |
download | gsoc2013-evolution-02cbe55123aa9ee218ee6a33ffb19f7644110123.tar gsoc2013-evolution-02cbe55123aa9ee218ee6a33ffb19f7644110123.tar.gz gsoc2013-evolution-02cbe55123aa9ee218ee6a33ffb19f7644110123.tar.bz2 gsoc2013-evolution-02cbe55123aa9ee218ee6a33ffb19f7644110123.tar.lz gsoc2013-evolution-02cbe55123aa9ee218ee6a33ffb19f7644110123.tar.xz gsoc2013-evolution-02cbe55123aa9ee218ee6a33ffb19f7644110123.tar.zst gsoc2013-evolution-02cbe55123aa9ee218ee6a33ffb19f7644110123.zip |
Teach Evolution about Photo/Logo EContact fields stored as URIs
Committing Milan Crha's patch here at his request (bug 652178).
-rw-r--r-- | addressbook/gui/widgets/eab-contact-display.c | 43 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-gui-util.c | 1 | ||||
-rw-r--r-- | addressbook/util/eab-book-util.c | 1 |
3 files changed, 36 insertions, 9 deletions
diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c index da558352bb..d428f8ed77 100644 --- a/addressbook/gui/widgets/eab-contact-display.c +++ b/addressbook/gui/widgets/eab-contact-display.c @@ -427,6 +427,8 @@ render_title_block (GString *buffer, /* Only handle inlined photos for now */ if (photo && photo->type == E_CONTACT_PHOTO_TYPE_INLINED) { g_string_append (buffer, "<img border=\"1\" src=\"internal-contact-photo:\">"); + } else if (photo && photo->type == E_CONTACT_PHOTO_TYPE_URI && photo->data.uri && *photo->data.uri) { + g_string_append_printf (buffer, "<img border=\"1\" src=\"%s\">", photo->data.uri); } if (photo) e_contact_photo_free (photo); @@ -929,7 +931,22 @@ eab_contact_display_render_compact (EABContactDisplay *display, * image here. we don't scale the pixbuf * itself, just insert width/height tags in * the html */ - gdk_pixbuf_loader_write (loader, photo->data.inlined.data, photo->data.inlined.length, NULL); + if (photo->type == E_CONTACT_PHOTO_TYPE_INLINED) { + gdk_pixbuf_loader_write (loader, photo->data.inlined.data, photo->data.inlined.length, NULL); + } else if (photo->type == E_CONTACT_PHOTO_TYPE_URI && photo->data.uri && + g_ascii_strncasecmp (photo->data.uri, "file://", 7) == 0) { + gchar *filename, *contents = NULL; + gsize length; + + filename = g_filename_from_uri (photo->data.uri, NULL, NULL); + if (filename) { + if (g_file_get_contents (filename, &contents, &length, NULL)) { + gdk_pixbuf_loader_write (loader, (const guchar *) contents, length, NULL); + g_free (contents); + } + g_free (filename); + } + } gdk_pixbuf_loader_close (loader, NULL); pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); if (pixbuf) @@ -949,13 +966,20 @@ eab_contact_display_render_compact (EABContactDisplay *display, calced_width *= ((gfloat) MAX_COMPACT_IMAGE_DIMENSION / max_dimension); calced_height *= ((gfloat) MAX_COMPACT_IMAGE_DIMENSION / max_dimension); } + g_object_unref (pixbuf); } - g_object_unref (pixbuf); - g_string_append_printf ( - buffer, - "<img width=\"%d\" height=\"%d\" src=\"internal-contact-photo:\">", - calced_width, calced_height); + if (photo->type == E_CONTACT_PHOTO_TYPE_URI && photo->data.uri && *photo->data.uri) + g_string_append_printf ( + buffer, + "<img width=\"%d\" height=\"%d\" src=\"%s\">", + calced_width, calced_height, photo->data.uri); + else + g_string_append_printf ( + buffer, + "<img width=\"%d\" height=\"%d\" src=\"internal-contact-photo:\">", + calced_width, calced_height); + e_contact_photo_free (photo); } @@ -1174,9 +1198,10 @@ contact_display_url_requested (GtkHTML *html, if (photo == NULL) photo = e_contact_get (contact, E_CONTACT_LOGO); - gtk_html_stream_write ( - handle, (gchar *) photo->data.inlined.data, - photo->data.inlined.length); + if (photo->type == E_CONTACT_PHOTO_TYPE_INLINED) + gtk_html_stream_write ( + handle, (gchar *) photo->data.inlined.data, + photo->data.inlined.length); gtk_html_end (html, handle, GTK_HTML_STREAM_OK); diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c index eb98676169..befc8836ca 100644 --- a/addressbook/gui/widgets/eab-gui-util.c +++ b/addressbook/gui/widgets/eab-gui-util.c @@ -495,6 +495,7 @@ do_copy (gpointer data, contact = data; book_client = process->destination; + e_contact_inline_local_photos (contact, NULL); process->count++; eab_merging_book_add_contact ( diff --git a/addressbook/util/eab-book-util.c b/addressbook/util/eab-book-util.c index eff5fc1058..30cd2acb96 100644 --- a/addressbook/util/eab-book-util.c +++ b/addressbook/util/eab-book-util.c @@ -136,6 +136,7 @@ eab_contact_list_to_string (const GSList *contacts) EContact *contact = l->data; gchar *vcard_str; + e_contact_inline_local_photos (contact, NULL); vcard_str = e_vcard_to_string ( E_VCARD (contact), EVC_FORMAT_VCARD_30); |