X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=libdocument%2Fev-document-factory.c;h=1f1eb0dbcfb080e5ca34af58fa51384b9e47d240;hb=9c92e571cc1a334816b2fef568c1bed1bdc0e080;hp=3173d029f191352213cbc7d4dad0ea358675f2a3;hpb=643fcd30fb4848b599bb690caaef144a09ecfe85;p=evince.git diff --git a/libdocument/ev-document-factory.c b/libdocument/ev-document-factory.c index 3173d029..1f1eb0db 100644 --- a/libdocument/ev-document-factory.c +++ b/libdocument/ev-document-factory.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ @@ -33,58 +33,6 @@ #include "ev-document-factory.h" #include "ev-file-helpers.h" -#ifdef ENABLE_PIXBUF -static GList* -gdk_pixbuf_mime_type_list () -{ - GSList *formats, *list; - GList *result = NULL; - - formats = gdk_pixbuf_get_formats (); - for (list = formats; list != NULL; list = list->next) { - GdkPixbufFormat *format = list->data; - gchar **mime_types; - - if (gdk_pixbuf_format_is_disabled (format)) - continue; - - mime_types = gdk_pixbuf_format_get_mime_types (format); - result = g_list_prepend (result, mime_types); - } - g_slist_free (formats); - - return result; -} - -/* Would be nice to have this in gdk-pixbuf */ -static gboolean -mime_type_supported_by_gdk_pixbuf (const gchar *mime_type) -{ - GList *mime_types; - GList *list; - gboolean retval = FALSE; - - mime_types = gdk_pixbuf_mime_type_list (); - for (list = mime_types; list; list = list->next) { - gchar **mtypes = (gchar **)list->data; - const gchar *mtype; - gint i = 0; - - while ((mtype = mtypes[i++])) { - if (strcmp (mtype, mime_type) == 0) { - retval = TRUE; - break; - } - } - } - - g_list_foreach (mime_types, (GFunc)g_strfreev, NULL); - g_list_free (mime_types); - - return retval; -} -#endif /* ENABLE_PIXBUF */ - static EvCompressionType get_compression_from_mime_type (const gchar *mime_type) { @@ -99,6 +47,8 @@ get_compression_from_mime_type (const gchar *mime_type) return EV_COMPRESSION_GZIP; else if (g_ascii_strcasecmp (type, "bz") == 0) return EV_COMPRESSION_BZIP2; + else if (g_ascii_strcasecmp (type, "xz") == 0) + return EV_COMPRESSION_LZMA; } return EV_COMPRESSION_NONE; @@ -149,12 +99,6 @@ get_document_from_uri (const char *uri, } document = ev_backends_manager_get_document (mime_type); - -#ifdef ENABLE_PIXBUF - if (!document && mime_type_supported_by_gdk_pixbuf (mime_type)) - document = ev_backends_manager_get_document ("image/*"); -#endif /* ENABLE_PIXBUF */ - if (document == NULL) { gchar *content_type, *mime_desc = NULL; @@ -199,6 +143,8 @@ free_uncompressed_uri (gchar *uri_unc) * Creates a #EvDocument for the document at @uri; or, if no backend handling * the document's type is found, or an error occurred on opening the document, * returns %NULL and fills in @error. + * If the document is encrypted, it is returned but also @error is set to + * %EV_DOCUMENT_ERROR_ENCRYPTED. * * Returns: a new #EvDocument, or %NULL. */ @@ -235,7 +181,7 @@ ev_document_factory_get_document (const char *uri, GError **error) if (result == FALSE || err) { if (err && g_error_matches (err, EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_ENCRYPTED)) { - g_error_free (err); + g_propagate_error (error, err); return document; } /* else fall through to slow mime code section below */ @@ -283,7 +229,7 @@ ev_document_factory_get_document (const char *uri, GError **error) EV_DOCUMENT_ERROR_INVALID, _("Unknown MIME Type")); } else if (g_error_matches (err, EV_DOCUMENT_ERROR, EV_DOCUMENT_ERROR_ENCRYPTED)) { - g_error_free (err); + g_propagate_error (error, err); return document; } @@ -302,26 +248,6 @@ file_filter_add_mime_types (EvTypeInfo *info, GtkFileFilter *filter) const gchar *mime_type; gint i = 0; -#ifdef ENABLE_PIXBUF - if (g_ascii_strcasecmp (info->mime_types[0], "image/*") == 0) { - GList *pixbuf_types, *l; - - pixbuf_types = gdk_pixbuf_mime_type_list (); - for (l = pixbuf_types; l; l = g_list_next (l)) { - gchar **mime_types = (gchar **)l->data; - gint j = 0; - - while ((mime_type = mime_types[j++])) - gtk_file_filter_add_mime_type (filter, mime_type); - - g_strfreev (mime_types); - } - g_list_free (pixbuf_types); - - return; - } -#endif /* ENABLE_PIXBUF */ - while ((mime_type = info->mime_types[i++])) gtk_file_filter_add_mime_type (filter, mime_type); }