From 86ad3e544e48530873357a1c112669b734ab988a Mon Sep 17 00:00:00 2001 From: Jean Baptiste Lallement Date: Wed, 23 Apr 2008 21:45:05 +0000 Subject: [PATCH] Improved error message about file opening failture. Bug #529129. 2008-04-24 Jean Baptiste Lallement * 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. svn path=/trunk/; revision=3021 --- ChangeLog | 8 ++++++++ libdocument/ev-document-factory.c | 22 ++++++++++------------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5dd139da..20b0030e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-04-24 Jean Baptiste Lallement + + * 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. + 2008-04-24 Abhishek Mukherjee * data/evince-toolbar.xml: diff --git a/libdocument/ev-document-factory.c b/libdocument/ev-document-factory.c index c7732d8b..328ff743 100644 --- a/libdocument/ev-document-factory.c +++ b/libdocument/ev-document-factory.c @@ -104,7 +104,7 @@ get_compression_from_mime_type (const gchar *mime_type) } 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 @@ get_mime_type_from_uri (const gchar *uri) 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 @@ get_mime_type_from_uri (const gchar *uri) } 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 @@ get_mime_type_from_data (const gchar *uri) 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 @@ get_document_from_uri (const char *uri, *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 @@ get_document_from_uri (const char *uri, 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; } -- 2.43.5