Index: goffice/utils/go-file.c
===================================================================
--- goffice/utils/go-file.c	(révision 2165)
+++ goffice/utils/go-file.c	(copie de travail)
@@ -29,6 +29,7 @@
 #include <gsf/gsf-output-stdio.h>
 #include <glib/gstdio.h>
 #include <glib/gi18n-lib.h>
+#include <gio/gio.h>
 #ifdef GOFFICE_WITH_GNOME
 #include <libgnomevfs/gnome-vfs-utils.h>
 #include <libgnomevfs/gnome-vfs-mime-utils.h>
@@ -1287,9 +1288,8 @@
 gchar *
 go_get_mime_type (gchar const *uri)
 {
-#ifdef GOFFICE_WITH_GNOME
-	return gnome_vfs_get_mime_type (uri);
-#elif defined(G_OS_WIN32)
+#if defined(G_OS_WIN32)
+	/* Do we really need that? */
 	LPWSTR wuri, mime_type;
 
 	wuri = g_utf8_to_utf16 (uri, -1, NULL, NULL, NULL);
@@ -1311,6 +1311,27 @@
 	 */
 	return g_strdup ("text/plain");
 #else
+	GFile *file = g_vfs_get_file_for_uri (g_vfs_get_default (), uri);
+	GError *error = NULL;
+	gchar *content_type = NULL, *mime_type = NULL;
+	GFileInfo *info = g_file_query_info (file,
+					     G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+					     G_FILE_QUERY_INFO_NONE,
+					     NULL, &error);
+	g_object_unref (file);
+	if (error) {
+		g_error_free (error);
+		/* on failure, try to guess from the file name */
+		content_type = g_content_type_guess (uri, NULL, 0, NULL);
+	} else
+		content_type = g_strdup (g_file_info_get_content_type (info));
+	if (content_type) {
+		mime_type = g_content_type_get_mime_type (content_type);
+		g_free (content_type);
+	}
+	g_object_unref (info);
+	if (mime_type)
+		return mime_type;
 	return g_strdup ("application/octet-stream");
 #endif
 }
@@ -1318,9 +1339,8 @@
 gchar *
 go_get_mime_type_for_data (gconstpointer data, int data_size)
 {
-#ifdef GOFFICE_WITH_GNOME
-	return g_strdup (gnome_vfs_get_mime_type_for_data (data, data_size));
-#elif defined(G_OS_WIN32)
+#if defined(G_OS_WIN32)
+	/* Do we really need that? */
 	LPWSTR mime_type;
 
 	if (FindMimeFromData (NULL, NULL,
@@ -1336,18 +1356,34 @@
 	 * "text/plain" */
 	return g_strdup ("text/plain");
 #else
+	gchar *content_type = g_content_type_guess (NULL, data, data_size, NULL);
+	gchar *mime_type = NULL;
+	if (content_type) {
+		mime_type = g_content_type_get_mime_type (content_type);
+		g_free (content_type);
+	}
+	if (mime_type)
+		return mime_type;
 	return g_strdup ("application/octet-stream");
 #endif
 }
 
-gchar const *
+gchar *
 go_mime_type_get_description (gchar const *mime_type)
 {
-#ifdef GOFFICE_WITH_GNOME
-	return gnome_vfs_mime_get_description (mime_type);
+#ifdef HAVE_G_CONTENT_TYPE_FROM_MIME_TYPE
+	char *content_type = g_content_type_from_mime_type (mime_type);
+	char *description = NULL;
+	if (content_type)
+		descrition = g_content_type_get_description (content_type);
+	return (description)? description: g_strdup (mime_type);
 #else
-	return mime_type;
+#if defined(G_OS_WIN32)
+	return g_strdup (mime_type);
+#else
+	return g_content_type_get_description (mime_type);
 #endif
+#endif
 }
 
 /* ------------------------------------------------------------------------- */
