evince r3021 - in trunk: . libdocument



Author: nshmyrev
Date: Wed Apr 23 21:45:05 2008
New Revision: 3021
URL: http://svn.gnome.org/viewvc/evince?rev=3021&view=rev

Log:
2008-04-24   Jean Baptiste Lallement  <jeanbaptiste lallement gmail com>

	* libdocument/ev-document-factory.c (get_mime_type_from_uri),
	(get_mime_type_from_data), (get_document_from_uri),
	(ev_document_factory_get_document):
	Improved error message about file opening failture.
	Bug #529129.



Modified:
   trunk/ChangeLog
   trunk/libdocument/ev-document-factory.c

Modified: trunk/libdocument/ev-document-factory.c
==============================================================================
--- trunk/libdocument/ev-document-factory.c	(original)
+++ trunk/libdocument/ev-document-factory.c	Wed Apr 23 21:45:05 2008
@@ -104,7 +104,7 @@
 }
 
 static gchar *
-get_mime_type_from_uri (const gchar *uri)
+get_mime_type_from_uri (const gchar *uri, GError **error)
 {
 	GFile     *file;
 	GFileInfo *file_info;
@@ -113,7 +113,7 @@
 	file = g_file_new_for_uri (uri);
 	file_info = g_file_query_info (file,
 				       G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
-				       0, NULL, NULL);
+				       0, NULL, error);
 	g_object_unref (file);
 
 	if (file_info == NULL)
@@ -126,7 +126,7 @@
 }
 
 static gchar *
-get_mime_type_from_data (const gchar *uri)
+get_mime_type_from_data (const gchar *uri, GError **error)
 {
 	GFile            *file;
 	GFileInputStream *input_stream;
@@ -135,7 +135,7 @@
 
 	file = g_file_new_for_uri (uri);
 	
-	input_stream = g_file_read (file, NULL, NULL);
+	input_stream = g_file_read (file, NULL, error);
 	if (!input_stream) {
 		g_object_unref (file);
 		return NULL;
@@ -167,14 +167,10 @@
 	*compression = EV_COMPRESSION_NONE;
 
 	mime_type = slow ?
-		get_mime_type_from_data (uri) :
-		get_mime_type_from_uri (uri);
+		get_mime_type_from_data (uri, error) :
+		get_mime_type_from_uri (uri, error);
 
 	if (mime_type == NULL) {
-		g_set_error (error,
-			     EV_DOCUMENT_ERROR,	
-    			     0,
-			     _("Unknown MIME Type"));
 		g_free (mime_type);
 		
 		return NULL;
@@ -191,9 +187,11 @@
 		g_set_error (error,
 			     EV_DOCUMENT_ERROR,	
 			     0,
-			     _("Unhandled MIME type: â%sâ"), mime_type);
+			     _("File type %s (%s) is not supported"),
+			     g_content_type_get_description (mime_type),
+			     mime_type);
 		g_free (mime_type);
-		
+
 		return NULL;
 	}
 



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