[sushi] mimehandler: add a method to register an array of mimetypes
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sushi] mimehandler: add a method to register an array of mimetypes
- Date: Wed, 11 May 2011 19:01:23 +0000 (UTC)
commit 613007f07dda92292cf3b12c3338d7a312fc0dd0
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed May 11 11:46:57 2011 -0400
mimehandler: add a method to register an array of mimetypes
Instead of letting each plugin do the loop.
src/js/ui/mimeHandler.js | 5 +++++
src/js/viewers/audio.js | 3 +--
src/js/viewers/evince.js | 22 ++++++++++++----------
src/js/viewers/font.js | 3 +--
src/js/viewers/gst.js | 3 +--
src/js/viewers/image.js | 6 ++----
6 files changed, 22 insertions(+), 20 deletions(-)
---
diff --git a/src/js/ui/mimeHandler.js b/src/js/ui/mimeHandler.js
index 61d0d27..4330ca4 100644
--- a/src/js/ui/mimeHandler.js
+++ b/src/js/ui/mimeHandler.js
@@ -28,6 +28,11 @@ MimeHandler.prototype = {
log ("Register mimetype " + mime);
},
+ registerMimeTypes: function(mimeTypes, obj) {
+ for (idx in mimeTypes)
+ this.registerMime(mimeTypes[idx], obj);
+ },
+
getObject: function(mime) {
if (this._mimeTypes[mime])
return this._mimeTypes[mime];
diff --git a/src/js/viewers/audio.js b/src/js/viewers/audio.js
index bb47253..8eda041 100644
--- a/src/js/viewers/audio.js
+++ b/src/js/viewers/audio.js
@@ -347,5 +347,4 @@ let audioTypes = [
"audio/x-xm",
];
-for (idx in audioTypes)
- handler.registerMime(audioTypes[idx], renderer);
+handler.registerMimeTypes(audioTypes, renderer);
diff --git a/src/js/viewers/evince.js b/src/js/viewers/evince.js
index 8f4ec8c..6f64dd0 100644
--- a/src/js/viewers/evince.js
+++ b/src/js/viewers/evince.js
@@ -182,16 +182,18 @@ let handler = new MimeHandler.MimeHandler();
let renderer = new EvinceRenderer();
let mimeTypes = Sushi.query_supported_document_types();
-for (mime in mimeTypes) {
- handler.registerMime(mimeTypes[mime], renderer);
-}
+handler.registerMimeTypes(mimeTypes, renderer);
if (Features.HAVE_UNOCONV) {
- handler.registerMime("application/vnd.oasis.opendocument.text", renderer);
- handler.registerMime("application/vnd.oasis.opendocument.presentation", renderer);
- handler.registerMime("application/vnd.oasis.opendocument.spreadsheet", renderer);
- handler.registerMime("application/msword", renderer);
- handler.registerMime("application/vnd.ms-excel", renderer);
- handler.registerMime("application/vnd.ms-powerpoint", renderer);
- handler.registerMime("application/rtf", renderer);
+ let officeTypes = [
+ "application/vnd.oasis.opendocument.text",
+ "application/vnd.oasis.opendocument.presentation",
+ "application/vnd.oasis.opendocument.spreadsheet",
+ "application/msword",
+ "application/vnd.ms-excel",
+ "application/vnd.ms-powerpoint",
+ "application/rtf"
+ ];
+
+ handler.registerMimeTypes(officeTypes, renderer);
}
diff --git a/src/js/viewers/font.js b/src/js/viewers/font.js
index 59c7db8..11ad24b 100644
--- a/src/js/viewers/font.js
+++ b/src/js/viewers/font.js
@@ -60,5 +60,4 @@ let mimeTypes = [
"application/x-font-type1"
];
-for (idx in mimeTypes)
- handler.registerMime(mimeTypes[idx], renderer);
+handler.registerMimeTypes(mimeTypes, renderer);
diff --git a/src/js/viewers/gst.js b/src/js/viewers/gst.js
index 6ea8ec8..57c7205 100644
--- a/src/js/viewers/gst.js
+++ b/src/js/viewers/gst.js
@@ -274,5 +274,4 @@ let videoTypes = [
"video/x-totem-stream"
];
-for (idx in videoTypes)
- handler.registerMime(videoTypes[idx], renderer);
+handler.registerMimeTypes(videoTypes, renderer);
diff --git a/src/js/viewers/image.js b/src/js/viewers/image.js
index 0c6105b..dfb7926 100644
--- a/src/js/viewers/image.js
+++ b/src/js/viewers/image.js
@@ -137,8 +137,6 @@ let renderer = new ImageRenderer();
let formats = GdkPixbuf.Pixbuf.get_formats();
for (idx in formats) {
- let mimetypes = formats[idx].get_mime_types();
- for (mime in mimetypes) {
- handler.registerMime(mimetypes[mime], renderer);
- }
+ let mimeTypes = formats[idx].get_mime_types();
+ handler.registerMimeTypes(mimeTypes, renderer);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]