Beispiel #1
0
        void ResizeEmoji()
        {
            var buffer = Buffer;

            int width, height;
            int descent;

            using (var layout = CreatePangoLayout(null)) {
                layout.GetPixelSize(out width, out height);
                descent = layout.Context.GetMetrics(layout.FontDescription, null).Descent;
            }

            _MessageTextTagTable.Foreach((tag) => {
                if (!(tag is EmojiTag))
                {
                    return;
                }

                var emojiTag = tag as EmojiTag;
                tag.Rise     = -descent;
                var pix      = new Gdk.Pixbuf(emojiTag.Path, -1, height);

                var beforeIter = buffer.GetIterAtMark(emojiTag.Mark);
                var afterIter  = beforeIter;
                afterIter.ForwardToTagToggle(tag);
                buffer.RemoveTag(tag, beforeIter, afterIter);
                buffer.Delete(ref beforeIter, ref afterIter);
                buffer.InsertPixbuf(ref beforeIter, pix);
                // after all that, we need to re-apply the tag to the buffer
                afterIter  = beforeIter;
                beforeIter = Buffer.GetIterAtMark(emojiTag.Mark);
                buffer.ApplyTag(tag, beforeIter, afterIter);
            });
        }
Beispiel #2
0
 public override void Dispose()
 {
     // HACK: this shouldn't be needed but GTK# keeps GC handles
     // these callbacks for some reason and thus leaks :(
     _MessageTextTagTable.Foreach(tag => {
         if (tag is LinkTag)
         {
             tag.TextEvent -= OnLinkTagTextEvent;
         }
         else if (tag is PersonTag)
         {
             tag.TextEvent -= OnPersonTagTextEvent;
         }
     });
     _MessageTextTagTable.Dispose();
     base.Dispose();
 }