[sushi] pdf-loader: query native types from Evince



commit 2c53306585fc2dd0bdc1493001e09693cb344135
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Apr 27 15:55:27 2011 -0400

    pdf-loader: query native types from Evince

 src/libsushi/sushi-pdf-loader.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/src/libsushi/sushi-pdf-loader.c b/src/libsushi/sushi-pdf-loader.c
index 4580478..88292e0 100644
--- a/src/libsushi/sushi-pdf-loader.c
+++ b/src/libsushi/sushi-pdf-loader.c
@@ -1,4 +1,6 @@
 #include "sushi-pdf-loader.h"
+
+#include "sushi-utils.h"
 #include <evince-document.h>
 #include <evince-view.h>
 
@@ -121,6 +123,26 @@ load_openoffice (SushiPdfLoader *self)
   g_child_watch_add (pid, unoconv_child_watch_cb, self);
 }
 
+static gboolean
+content_type_is_native (const gchar *content_type)
+{
+  gchar **native_types;
+  gint idx;
+  gboolean found = FALSE;
+
+  native_types = sushi_query_supported_document_types ();
+
+  for (idx = 0; native_types[idx] != NULL; idx++) {
+    found = g_content_type_is_a (content_type, native_types[idx]);
+    if (found)
+      break;
+  }
+
+  g_strfreev (native_types);
+
+  return found;
+}
+
 static void
 query_info_ready_cb (GObject *obj,
                      GAsyncResult *res,
@@ -145,7 +167,7 @@ query_info_ready_cb (GObject *obj,
   content_type = g_file_info_get_content_type (info);
   g_object_unref (info);
 
-  if (g_content_type_is_a (content_type, "application/pdf"))
+  if (content_type_is_native (content_type))
     load_pdf (self, self->priv->uri);
   else
     load_openoffice (self);



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