[smuxi: 12/15] [Frontend-GNOME] Set the emoji size to the line height



commit 1e7ccad59119b788ebf74ad56d7d689f13dbe71e
Author: Carlos Martín Nieto <cmn dwim me>
Date:   Mon Feb 2 14:54:11 2015 +0100

    [Frontend-GNOME] Set the emoji size to the line height
    
    We can't show the pixbuf pixel-by-pixel on the line, as the image will
    typically be much larger than the text size. Constrain the pixbuf height
    to the current line height.

 src/Frontend-GNOME/Views/MessageTextView.cs |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/Frontend-GNOME/Views/MessageTextView.cs b/src/Frontend-GNOME/Views/MessageTextView.cs
index a87febf..87015ae 100644
--- a/src/Frontend-GNOME/Views/MessageTextView.cs
+++ b/src/Frontend-GNOME/Views/MessageTextView.cs
@@ -258,12 +258,17 @@ namespace Smuxi.Frontend.Gnome
                 return;
             }
 
+            int width, height;
+            using (var layout = CreatePangoLayout(null)) {
+                layout.GetPixelSize(out width, out height);
+            }
+
             var emojiName = unicode + ".png";
             string emojiPath;
             if (_EmojiCache.TryGetIcon("emojione", emojiName, out emojiPath)) {
                 var emojiFile = new FileInfo(emojiPath);
                 if (emojiFile.Exists && emojiFile.Length > 0) {
-                    var pix = new Gdk.Pixbuf(emojiPath);
+                    var pix = new Gdk.Pixbuf(emojiPath, -1, height);
                     buffer.InsertPixbuf(ref iter, pix);
                 } else {
                     AddAlternativeText(buffer, ref iter, imgPart);
@@ -282,7 +287,7 @@ namespace Smuxi.Frontend.Gnome
                 (path) => {
                     GLib.Idle.Add(delegate {
                         var markIter = buffer.GetIterAtMark(mark);
-                        buffer.InsertPixbuf(ref markIter, new Gdk.Pixbuf(path));
+                        buffer.InsertPixbuf(ref markIter, new Gdk.Pixbuf(path, -1, height));
                         return false;
                     });
                 },


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