]> www.fi.muni.cz Git - evince.git/blobdiff - libdocument/ev-document-factory.c
Use the content type to get the description, not the MIME type.
[evince.git] / libdocument / ev-document-factory.c
index 09baef24683cf66412f633b39633db642088ba8c..f0172ff8f4a4db86edd9ec32af2de5cab8e89a91 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <gio/gio.h>
 #include <glib/gstdio.h>
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 
 #include "ev-backends-manager.h"
@@ -121,10 +121,10 @@ get_document_from_uri (const char        *uri,
                g_free (mime_type);
 
                if (*error == NULL) {
-                       g_set_error (error,
-                                    EV_DOCUMENT_ERROR,
-                                    0,
-                                    _("Unknown MIME Type"));
+                       g_set_error_literal (error,
+                                             EV_DOCUMENT_ERROR,
+                                             EV_DOCUMENT_ERROR_INVALID,
+                                             _("Unknown MIME Type"));
                }
                
                return NULL;
@@ -138,15 +138,19 @@ get_document_from_uri (const char        *uri,
 #endif /* ENABLE_PIXBUF */
 
        if (document == NULL) {
-               gchar *mime_desc;
+               gchar *content_type, *mime_desc = NULL;
+
+               content_type = g_content_type_from_mime_type (mime_type);
+               if (content_type)
+                       mime_desc = g_content_type_get_description (content_type);
 
-               mime_desc = g_content_type_get_description (mime_type);
                g_set_error (error,
                             EV_DOCUMENT_ERROR, 
-                            0,
+                            EV_DOCUMENT_ERROR_INVALID,
                             _("File type %s (%s) is not supported"),
-                            mime_desc, mime_type);
+                            mime_desc ? mime_desc : "-", mime_type);
                g_free (mime_desc);
+               g_free (content_type);
                g_free (mime_type);
 
                return NULL;
@@ -242,10 +246,10 @@ ev_document_factory_get_document (const char *uri, GError **error)
 
        if (result == FALSE) {
                if (*error == NULL) {
-                       g_set_error (error,
-                                    EV_DOCUMENT_ERROR,
-                                    0,
-                                    _("Unknown MIME Type"));
+                       g_set_error_literal (error,
+                                             EV_DOCUMENT_ERROR,
+                                             EV_DOCUMENT_ERROR_INVALID,
+                                             _("Unknown MIME Type"));
                } else if ((*error)->domain == EV_DOCUMENT_ERROR &&
                           (*error)->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
                        return document;