[sushi] evince: fetch mimetypes from Evince instead of hardcoding PDF
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sushi] evince: fetch mimetypes from Evince instead of hardcoding PDF
- Date: Wed, 27 Apr 2011 19:12:38 +0000 (UTC)
commit f8da0fea30f34fc2181e7492743bc4bb7bba92ff
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Apr 27 12:15:44 2011 -0400
evince: fetch mimetypes from Evince instead of hardcoding PDF
src/js/viewers/evince.js | 5 ++++-
src/libsushi/sushi-utils.c | 33 +++++++++++++++++++++++++++++++++
src/libsushi/sushi-utils.h | 1 +
3 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/src/js/viewers/evince.js b/src/js/viewers/evince.js
index ff5b72d..23de0e4 100644
--- a/src/js/viewers/evince.js
+++ b/src/js/viewers/evince.js
@@ -121,7 +121,10 @@ EvinceRenderer.prototype = {
let handler = new MimeHandler.MimeHandler();
let renderer = new EvinceRenderer();
-handler.registerMime("application/pdf", renderer);
+let mimeTypes = Sushi.query_supported_document_types();
+for (mime in mimeTypes) {
+ handler.registerMime(mimeTypes[mime]);
+}
if (Features.HAVE_UNOCONV) {
handler.registerMime("application/vnd.oasis.opendocument.text", renderer);
diff --git a/src/libsushi/sushi-utils.c b/src/libsushi/sushi-utils.c
index ea5950e..4af8229 100644
--- a/src/libsushi/sushi-utils.c
+++ b/src/libsushi/sushi-utils.c
@@ -84,3 +84,36 @@ sushi_create_foreign_window (guint xid)
return retval;
}
+/**
+ * sushi_query_supported_document_types:
+ *
+ * Returns: (transfer full):
+ */
+gchar **
+sushi_query_supported_document_types (void)
+{
+ GList *infos, *l;
+ gchar **retval = NULL;
+ GPtrArray *array;
+ EvTypeInfo *info;
+ gint idx;
+
+ infos = ev_backends_manager_get_all_types_info ();
+
+ if (infos == NULL)
+ return NULL;
+
+ array = g_ptr_array_new ();
+
+ for (l = infos; l != NULL; l = l->next) {
+ info = l->data;
+
+ for (idx = 0; info->mime_types[idx] != NULL; idx++)
+ g_ptr_array_add (array, g_strdup (info->mime_types[idx]));
+ }
+
+ g_ptr_array_add (array, NULL);
+ retval = (gchar **) g_ptr_array_free (array, FALSE);
+
+ return retval;
+}
diff --git a/src/libsushi/sushi-utils.h b/src/libsushi/sushi-utils.h
index 270418f..486fa55 100644
--- a/src/libsushi/sushi-utils.h
+++ b/src/libsushi/sushi-utils.h
@@ -9,6 +9,7 @@ G_BEGIN_DECLS
ClutterActor * sushi_create_rounded_background (void);
GdkWindow * sushi_create_foreign_window (guint xid);
+gchar ** sushi_query_supported_document_types (void);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]