From e58a0e749818ebb5719afd03843d066d1aaa723d Mon Sep 17 00:00:00 2001 From: Srinivasa Ragavan Date: Fri, 24 Feb 2006 08:15:43 +0000 Subject: Committing Rohini's patch for bug #324742. svn path=/trunk/; revision=31576 --- composer/ChangeLog | 8 ++++++++ composer/e-msg-composer.c | 36 +++++++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 7 deletions(-) (limited to 'composer') diff --git a/composer/ChangeLog b/composer/ChangeLog index 268fa641bc..e786c66347 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,11 @@ +2006-02-16 Rohini S + + ** Fixes bug #324742 + + * e-msg-composer.c (drop_action) (attachment_guess_mime_type): + Modified to add images in plain text mode and other files in both + html and plain text mode as attachment during DnD. + 2006-02-16 Tor Lillqvist * e-msg-composer-hdrs.c (e_msg_composer_hdrs_get_to) diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 008c583b00..5d9c6bc4f4 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -2884,10 +2884,30 @@ e_msg_composer_get_remote_download_count (EMsgComposer *composer) (E_ATTACHMENT_BAR (p->attachment_bar)); } +static char * +attachment_guess_mime_type (const char *file_name) +{ + GnomeVFSFileInfo *info; + GnomeVFSResult result; + char *type = NULL; + + info = gnome_vfs_file_info_new (); + result = gnome_vfs_get_file_info (file_name, info, + GNOME_VFS_FILE_INFO_GET_MIME_TYPE | + GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE | + GNOME_VFS_FILE_INFO_FOLLOW_LINKS); + if (result == GNOME_VFS_OK) + type = g_strdup (gnome_vfs_file_info_get_mime_type (info)); + + gnome_vfs_file_info_unref (info); + + return type; +} + static void drop_action(EMsgComposer *composer, GdkDragContext *context, guint32 action, GtkSelectionData *selection, guint info, guint time) { - char *tmp, *str, **urls; + char *tmp, *str, **urls, *type; CamelMimePart *mime_part; CamelStream *stream; CamelURL *url; @@ -2939,12 +2959,14 @@ drop_action(EMsgComposer *composer, GdkDragContext *context, guint32 action, Gtk continue; } - if (!g_ascii_strcasecmp (url->protocol, "file")) - e_attachment_bar_attach - (E_ATTACHMENT_BAR (p->attachment_bar), - url->path, - "attachment"); - else { + if (!g_ascii_strcasecmp (url->protocol, "file")) { + type=attachment_guess_mime_type (str); + if (strncmp (type, "image", 5) || (!p->send_html && !strncmp (type, "image", 5))) + e_attachment_bar_attach + (E_ATTACHMENT_BAR (p->attachment_bar), + url->path, + "attachment"); + } else { e_attachment_bar_attach_remote_file (E_ATTACHMENT_BAR (p->attachment_bar), str); -- cgit