From ca127b8d31f365b71dca6547ac0e6f7dc54cbba9 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 2 Oct 2009 17:57:17 +0200 Subject: [PATCH] fix printing HTML messages. Fixes #5298 --- src/conversation_textview.py | 23 +++++++++++++---------- src/htmltextview.py | 3 +++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/conversation_textview.py b/src/conversation_textview.py index 87b455260..b216b6ea1 100644 --- a/src/conversation_textview.py +++ b/src/conversation_textview.py @@ -1119,8 +1119,11 @@ class ConversationTextview(gobject.GObject): # It's nothing special if use_other_tags: end_iter = buffer_.get_end_iter() - buffer_.insert_with_tags_by_name(end_iter, special_text, - *other_tags) + insert_tags_func = buffer_.insert_with_tags_by_name + if len(other_tags) > 0 and isinstance(other_tags[0], gtk.TextTag): + insert_tags_func = buffer_.insert_with_tags + + insert_tags_func(end_iter, special_text, *other_tags) if len(tags) > 0: end_iter = buffer_.get_end_iter() @@ -1290,14 +1293,14 @@ class ConversationTextview(gobject.GObject): graphics=True): '''this adds normal and special text. call this to add text''' if xhtml: - try: - if name and (text.startswith('/me ') or text.startswith('/me\n')): - xhtml = xhtml.replace('/me', '* %s' % (name,), 1) - self.tv.display_html(xhtml.encode('utf-8'), self) - return - except Exception, e: - gajim.log.debug(str('Error processing xhtml') + str(e)) - gajim.log.debug(str('with |' + xhtml + '|')) +# try: + if name and (text.startswith('/me ') or text.startswith('/me\n')): + xhtml = xhtml.replace('/me', '* %s' % (name,), 1) + self.tv.display_html(xhtml.encode('utf-8'), self) + return +# except Exception, e: +# gajim.log.debug(str('Error processing xhtml') + str(e)) +# gajim.log.debug(str('with |' + xhtml + '|')) # /me is replaced by name if name is given if name and (text.startswith('/me ') or text.startswith('/me\n')): diff --git a/src/htmltextview.py b/src/htmltextview.py index 89082855a..1a25548a6 100644 --- a/src/htmltextview.py +++ b/src/htmltextview.py @@ -951,12 +951,15 @@ if __name__ == '__main__': ' World\n' '\n') htmlview.print_real_text(None, xhtml='
') + htmlview.print_real_text(None, xhtml='''

a:bGoogle


''') htmlview.print_real_text(None, xhtml=''' +

OMG, I'm green with envy!

+ ''') htmlview.print_real_text(None, xhtml='
') htmlview.print_real_text(None, xhtml='''