[smuxi: 4/15] [Frontend-GNOME] Check for the existence of the emoji file
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi: 4/15] [Frontend-GNOME] Check for the existence of the emoji file
- Date: Tue, 3 Feb 2015 01:07:18 +0000 (UTC)
commit cdac332696ebf098f65287cba7e563a8b82ff524
Author: Carlos MartÃn Nieto <cmn dwim me>
Date: Sat Jan 31 00:35:25 2015 +0100
[Frontend-GNOME] Check for the existence of the emoji file
Use 'smuxi-emoji' as the scheme to indicate that we want to look at a
local file with an emoji in it.
If it does not exist (or it's an external image), we instead show the
alt text.
src/Frontend-GNOME/Views/MessageTextView.cs | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/src/Frontend-GNOME/Views/MessageTextView.cs b/src/Frontend-GNOME/Views/MessageTextView.cs
index 984462c..bcd1ed1 100644
--- a/src/Frontend-GNOME/Views/MessageTextView.cs
+++ b/src/Frontend-GNOME/Views/MessageTextView.cs
@@ -21,6 +21,7 @@
*/
using System;
+using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using System.Collections.Generic;
@@ -409,13 +410,22 @@ namespace Smuxi.Frontend.Gnome
} 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 uri = new Uri(imgpart.ImageFileName);
+ if (uri.Scheme == "smuxi-emoji") {
+ var emojiPath = System.IO.Path.Combine("/tmp/emoji/assets/images", uri.Host +
".png");
+ var emojiFile = new FileInfo(emojiPath);
+ if (emojiFile.Exists && emojiFile.Length > 0) {
+ var pix = new Gdk.Pixbuf(emojiPath);
+ buffer.InsertPixbuf(ref iter, pix);
+ continue;
+ }
+ }
+ } catch (UriFormatException) {
+ // we want to simply continue, using the alt text
}
+
+ 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]