]> www.fi.muni.cz Git - evince.git/blobdiff - backend/comics/comics-document.c
Fix several compile warnings in the dvi backend.
[evince.git] / backend / comics / comics-document.c
index 27c28008cb95e0bfec54bfb6bf44fc969b987977..b2f7b7ac728ff838e5cd1fd263f5dc752adf5411 100644 (file)
@@ -23,7 +23,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
+#include <gio/gio.h>
 
 #include "comics-document.h"
 #include "ev-document-misc.h"
@@ -64,8 +64,8 @@ static char**     extract_argv                   (EvDocument *document,
 
 EV_BACKEND_REGISTER_WITH_CODE (ComicsDocument, comics_document,
        {
-               G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
-                                      comics_document_document_thumbnails_iface_init);
+               EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
+                                               comics_document_document_thumbnails_iface_init);
        } );
 
 static char *
@@ -85,6 +85,8 @@ comics_regex_quote (const char *s)
        case ']':
        case '*':
        case '\\':
+           *d++ = '\\';
+           break;
        case '\'':
            *d++ = '\'';
            *d++ = '\\';
@@ -107,7 +109,10 @@ comics_document_load (EvDocument *document,
 {
        ComicsDocument *comics_document = COMICS_DOCUMENT (document);
        GSList *supported_extensions;
-       gchar *list_files_command = NULL, *std_out, *quoted_file, *mime_type;
+       GFile *file;
+       GFileInfo *file_info;
+       gchar *list_files_command = NULL, *std_out, *quoted_file;
+       const gchar *mime_type = NULL;
        gchar **cbr_files;
        gboolean success;
        int i, retval;
@@ -116,7 +121,14 @@ comics_document_load (EvDocument *document,
        g_return_val_if_fail (comics_document->archive != NULL, FALSE);
 
        quoted_file = g_shell_quote (comics_document->archive);
-       mime_type = gnome_vfs_get_mime_type (uri);
+       file = g_file_new_for_uri (uri);
+       file_info = g_file_query_info (file,
+                                      G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+                                      0, NULL, NULL);
+       if (file_info != NULL) {
+               mime_type = g_file_info_get_content_type (file_info);
+       }
+       g_object_unref (file);
 
        /* FIXME, use proper cbr/cbz mime types once they're
         * included in shared-mime-info */
@@ -132,8 +144,15 @@ comics_document_load (EvDocument *document,
                list_files_command = 
                        g_strdup_printf ("zipinfo -1 -- %s", quoted_file);
                comics_document->regex_arg = TRUE;
+       } else if (!strcmp (mime_type, "application/x-cb7")) {
+               comics_document->extract_command =
+                       g_strdup ("7zr x -so");
+               list_files_command = 
+                       g_strdup_printf ("7zr l -- %s", quoted_file);
+               comics_document->regex_arg = TRUE;
        }
 
+       g_object_unref (file_info);
        g_free (quoted_file);
 
        /* Get list of files in archive */
@@ -142,14 +161,12 @@ comics_document_load (EvDocument *document,
        g_free (list_files_command);
 
        if (!success) {
-               g_free (mime_type);
                return FALSE;
        } else if (retval != 0) {
                g_set_error (error,
                             EV_DOCUMENT_ERROR,
                             EV_DOCUMENT_ERROR_INVALID,
                             _("File corrupted."));
-               g_free (mime_type);
                return FALSE;
        }
 
@@ -175,7 +192,6 @@ comics_document_load (EvDocument *document,
        }
 
        g_free (std_out);
-       g_free (mime_type);
        g_strfreev (cbr_files);
        g_slist_foreach (supported_extensions, (GFunc) g_free, NULL);
        g_slist_free (supported_extensions);
@@ -211,7 +227,7 @@ comics_document_get_n_pages (EvDocument *document)
 
 static void
 comics_document_get_page_size (EvDocument *document,
-                              int         page,
+                              EvPage     *page,
                               double     *width,
                               double     *height)
 {
@@ -222,7 +238,7 @@ comics_document_get_page_size (EvDocument *document,
        gint outpipe = -1;
        GPid child_pid = -1;
 
-       argv = extract_argv (document, page);
+       argv = extract_argv (document, page->index);
        success = g_spawn_async_with_pipes (NULL, argv, NULL,
                                            G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL,
                                            NULL, NULL,
@@ -280,7 +296,7 @@ comics_document_render_pixbuf (EvDocument      *document,
        gint outpipe = -1;
        GPid child_pid = -1;
 
-       argv = extract_argv (document, rc->page);
+       argv = extract_argv (document, rc->page->index);
        success = g_spawn_async_with_pipes (NULL, argv, NULL,
                                            G_SPAWN_SEARCH_PATH
                                            | G_SPAWN_STDERR_TO_DEV_NULL,