[gthumb/ext] guess the mime type from the filename if no info is available



commit b7e343131581aea8bbc39291f85b887a1de53796
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Thu Sep 10 12:26:42 2009 +0200

    guess the mime type from the filename if no info is available
    
    [bug #594632]

 gthumb/gth-file-data.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/gthumb/gth-file-data.c b/gthumb/gth-file-data.c
index 1731c15..a3ba5e0 100644
--- a/gthumb/gth-file-data.c
+++ b/gthumb/gth-file-data.c
@@ -220,6 +220,12 @@ gth_file_data_get_mime_type (GthFileData *self)
 	content_type = g_file_info_get_attribute_string (self->info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
 	if (content_type == NULL)
 		content_type = g_file_info_get_attribute_string (self->info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
+	if (content_type == NULL) {
+		char *filename = g_file_get_basename (self->file);
+
+		content_type = g_content_type_guess (filename, NULL, 0, NULL);
+		g_free (filename);
+	}
 
 	return get_static_string (content_type);
 }



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