commit b3e934fe6b39a87d06762df94e6dd886535239e2
Author: Prince781 <princetonf@optonline.net>
Date:   Mon Jul 31 18:13:16 2017 +0100

    Fix for rendering GIFs.

diff --git a/src/js/viewers/image.js b/src/js/viewers/image.js
index 383f0c2..1ec943b 100644
--- a/src/js/viewers/image.js
+++ b/src/js/viewers/image.js
@@ -31,6 +31,7 @@ const GLib = imports.gi.GLib;
 const Gettext = imports.gettext.domain('sushi');
 const _ = Gettext.gettext;
 const Lang = imports.lang;
+const Mainloop = imports.mainloop;
 
 const MimeHandler = imports.ui.mimeHandler;
 const Utils = imports.ui.utils;
@@ -39,8 +40,10 @@ const ImageRenderer = new Lang.Class({
     Name: 'ImageRenderer',
 
     _init : function(args) {
+        this._timeoutId = 0;
         this.moveOnClick = true;
         this.canFullScreen = true;
+        this._ending = false;
     },
 
     prepare : function(file, mainWindow, callback) {
@@ -69,15 +72,20 @@ const ImageRenderer = new Lang.Class({
     },
 
     _textureFromStream : function(stream) {
-        GdkPixbuf.Pixbuf.new_from_stream_async
+        GdkPixbuf.PixbufAnimation.new_from_stream_async
         (stream, null,
          Lang.bind(this, function(obj, res) {
-             let pix = GdkPixbuf.Pixbuf.new_from_stream_finish(res);
-             pix = pix.apply_embedded_orientation();
+             let anim = GdkPixbuf.PixbufAnimation.new_from_stream_finish(res);
+
+             this._iter = anim.get_iter(null);
+             let pix = this._iter.get_pixbuf().apply_embedded_orientation();
 
              this._texture = new GtkClutter.Texture({ keep_aspect_ratio: true });
              this._texture.set_from_pixbuf(pix);
 
+             if (!anim.is_static_image())
+                 this._startTimeout();
+
              /* we're ready now */
              this._callback();
 
@@ -97,6 +105,15 @@ const ImageRenderer = new Lang.Class({
         return Utils.getScaledSize(baseSize, allocation, fullScreen);
     },
 
+    _startTimeout : function() {
+        if (this._timeoutId)
+            return;
+
+        this._timeoutId = Mainloop.timeout_add(this._iter.get_delay_time(),
+                                               Lang.bind(this,
+                                                         this._advanceImage));
+    },
+
     createToolbar : function() {
         this._mainToolbar = new Gtk.Toolbar({ icon_size: Gtk.IconSize.MENU });
         this._mainToolbar.get_style_context().add_class('osd');
@@ -110,6 +127,23 @@ const ImageRenderer = new Lang.Class({
 
         return this._toolbarActor;
     },
+
+    destroy : function () {
+        if (this._timeoutId) {
+            Mainloop.source_remove(this._timeoutId);
+            this._timeoutId = 0;
+        }
+    },
+
+    _advanceImage : function () {
+        if (this._timeoutId) {
+            this._iter.advance(null);
+            let pix = this._iter.get_pixbuf().apply_embedded_orientation();
+            this._texture.set_from_pixbuf(pix);
+            return true;
+        }
+        return false;
+    },
 });
 
 let handler = new MimeHandler.MimeHandler();
