From 8ac67fef090a21f05f997123c27f7ad5db848ae6 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Sat, 18 Jun 2005 15:57:06 +0000
Subject: [PATCH] we can now have animations in textview

---
 src/chat.py   | 15 ++++++++++-----
 src/config.py |  8 ++++++--
 src/gajim.py  | 10 +++++-----
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/src/chat.py b/src/chat.py
index a543a09ae1..5a0e245031 100644
--- a/src/chat.py
+++ b/src/chat.py
@@ -612,22 +612,27 @@ class Chat:
 			index = end # update index
 			
 			#now print it
-			self.print_special_text(special_text, other_tags,
-								buffer)
+			self.print_special_text(special_text, other_tags, textview)
 					
 		return index
 		
-	def print_special_text(self, special_text, other_tags, buffer):
+	def print_special_text(self, special_text, other_tags, textview):
 		tags = []
 		use_other_tags = True
+		buffer = textview.get_buffer()
 
 		possible_emot_ascii_caps = special_text.upper() # emoticons keys are CAPS
 		if possible_emot_ascii_caps in self.plugin.emoticons.keys():
 			#it's an emoticon
 			emot_ascii = possible_emot_ascii_caps
 			end_iter = buffer.get_end_iter()
-			buffer.insert_pixbuf(end_iter,
-					self.plugin.emoticons[emot_ascii])
+			anchor = buffer.create_child_anchor(end_iter)
+			w = gtk.Image()
+			w.set_from_file(self.plugin.emoticons[emot_ascii])
+			w.show()
+			textview.add_child_at_anchor(w, anchor)
+#			buffer.insert_pixbuf(end_iter,
+#					self.plugin.emoticons[emot_ascii])
 		elif special_text.startswith('mailto:'):
 			#it's a mail
 			tags.append('mail')
diff --git a/src/config.py b/src/config.py
index 9877684a29..2ecbc7428e 100644
--- a/src/config.py
+++ b/src/config.py
@@ -1691,9 +1691,13 @@ class ManageEmoticonsWindow:
 			img.set_from_file(image)
 		except:
 			return False
-		if img.get_storage_type() != gtk.IMAGE_PIXBUF:
+		t = img.get_storage_type()
+		if t == gtk.IMAGE_PIXBUF:
+			pix = img.get_pixbuf()
+		elif t == gtk.IMAGE_ANIMATION:
+			pix = img.get_animation().get_static_image()
+		else:
 			return False
-		pix = img.get_pixbuf()
 
 		if pix.get_width() > 24 or pix.get_height() > 24:
 			dialogs.ErrorDialog(_('Image is too big'), _('Image for emoticon has to be less than or equal to 24 pixels in width and 24 in height.')).get_response()
diff --git a/src/gajim.py b/src/gajim.py
index 75b56e2100..6c8d322a10 100755
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -664,9 +664,8 @@ class Interface:
 			img.set_from_file(image)
 		except:
 			return False
-		if img.get_storage_type() == gtk.IMAGE_PIXBUF:
-			pix = img.get_pixbuf()
-		else:
+		t = img.get_storage_type()
+		if t != gtk.IMAGE_PIXBUF and t != gtk.IMAGE_ANIMATION:
 			return False
 		return True
 		
@@ -727,8 +726,9 @@ class Interface:
 			emot_file = gajim.config.get_per('emoticons', emot, 'path')
 			if not self.image_is_ok(emot_file):
 				continue
-			pix = gtk.gdk.pixbuf_new_from_file(emot_file)
-			self.emoticons[emot] = pix
+			img = gtk.Image()
+			img.set_from_file(emot_file)
+			self.emoticons[emot] = emot_file
 		
 		# update regular expressions
 		self.make_regexps()
-- 
GitLab