[smuxi: 1/15] [Frontend-GNOME] Show an image message part



commit 74261f63abff0b836f3d9c5b5af5e7b13c6c7e0b
Author: Carlos Martín Nieto <cmn dwim me>
Date:   Tue May 13 12:39:40 2014 +0200

    [Frontend-GNOME] Show an image message part
    
    Handle an ImageMessagePartModel by showing it as a pixbuf on the
    TextView. If we cannot find the file, we show the alt text instead.
    
    This is based on the emoji work by jamesaxl.

 src/Frontend-GNOME/Views/MessageTextView.cs |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/src/Frontend-GNOME/Views/MessageTextView.cs b/src/Frontend-GNOME/Views/MessageTextView.cs
index 2305ea8..984462c 100644
--- a/src/Frontend-GNOME/Views/MessageTextView.cs
+++ b/src/Frontend-GNOME/Views/MessageTextView.cs
@@ -406,6 +406,16 @@ namespace Smuxi.Frontend.Gnome
                     } else {
                         buffer.Insert(ref iter, fmsgti.Text);
                     }
+                } else if (msgPart is ImageMessagePartModel) {
+                    var imgpart = (ImageMessagePartModel) msgPart;
+                    try {
+                        var pix = new Gdk.Pixbuf(imgpart.ImageFileName);
+                        buffer.InsertPixbuf(ref iter, pix);
+                    } catch (GLib.GException) {
+                        // use the alt text if we can't find the file
+                        if (!String.IsNullOrEmpty(imgpart.AlternativeText))
+                            buffer.Insert(ref iter, imgpart.AlternativeText);
+                    }
                 }
             }
             var startIter = buffer.GetIterAtMark(startMark);


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