diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-02-02 10:20:48 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-02-02 10:20:48 +0800 |
commit | 3238b44d77cf9c75f09ccc6739af7fcb29dc39f8 (patch) | |
tree | 7456fe451f59a958984484f05793abf345f263f5 /composer | |
parent | 852e2f5ef255841ad9dc0637abe84714d2d51fc3 (diff) | |
download | gsoc2013-evolution-3238b44d77cf9c75f09ccc6739af7fcb29dc39f8.tar.gz gsoc2013-evolution-3238b44d77cf9c75f09ccc6739af7fcb29dc39f8.tar.zst gsoc2013-evolution-3238b44d77cf9c75f09ccc6739af7fcb29dc39f8.zip |
Give gnome_vfs_get_uri_from_local_path a full path.
2003-02-01 Jeffrey Stedfast <fejj@ximian.com>
* e-msg-composer-attachment.c (update_mime_type): Give
gnome_vfs_get_uri_from_local_path a full path.
svn path=/trunk/; revision=19702
Diffstat (limited to 'composer')
-rw-r--r-- | composer/ChangeLog | 5 | ||||
-rw-r--r-- | composer/e-msg-composer-attachment.c | 36 |
2 files changed, 31 insertions, 10 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index 360e6146e1..e40e83e2a0 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,8 @@ +2003-02-01 Jeffrey Stedfast <fejj@ximian.com> + + * e-msg-composer-attachment.c (update_mime_type): Give + gnome_vfs_get_uri_from_local_path a full path. + 2003-01-27 Jeffrey Stedfast <fejj@ximian.com> * e-msg-composer.c (e_msg_composer_new_from_url): If the subject diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c index 64daad1164..45b8a86c8e 100644 --- a/composer/e-msg-composer-attachment.c +++ b/composer/e-msg-composer-attachment.c @@ -37,6 +37,8 @@ #include <libgnomevfs/gnome-vfs-utils.h> #include <libgnomevfs/gnome-vfs-mime-utils.h> +#include "e-util/e-mktemp.h" + #include "e-msg-composer.h" #include "e-msg-composer-attachment.h" @@ -302,21 +304,35 @@ destroy_dialog_data (DialogData *data) static void update_mime_type (DialogData *data) { - const char *filename; - char *mime_type, *uri; + const char *filename, *tmpdir; + char *mime_type, *path, *uri; if (!data->attachment->guessed_type) return; filename = gtk_entry_get_text (data->file_name_entry); - - uri = gnome_vfs_get_uri_from_local_path (filename); - mime_type = gnome_vfs_get_mime_type (uri); - g_free (uri); - - if (mime_type) { - gtk_entry_set_text (data->mime_type_entry, mime_type); - g_free (mime_type); + if (filename) { + /* gnome_vfs_get_mime_type() might try to access the + * file and read it to 'sniff' the mime-type if it is + * there (and gnome-vfs can't determine the mime-type + * based on filename extension?), so we need to make + * sure the file doesn't exist yet we want to keep the + * filename intact so that gnome-vfs can try and + * determine the mime-type by the filename. This is + * kinda nasty. + */ + + tmpdir = e_mkdtemp ("mime-identify-XXXXXX"); + path = g_strdup_printf ("%s/%s", tmpdir, filename); + uri = gnome_vfs_get_uri_from_local_path (path); + mime_type = gnome_vfs_get_mime_type (uri); + g_free (path); + g_free (uri); + + if (mime_type) { + gtk_entry_set_text (data->mime_type_entry, mime_type); + g_free (mime_type); + } } } |