From ca127b8d31f365b71dca6547ac0e6f7dc54cbba9 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger <asterix@lagaule.org> 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 87b455260e..b216b6ea1b 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', '<i>* %s</i>' % (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', '<i>* %s</i>' % (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 89082855a1..1a25548a67 100644 --- a/src/htmltextview.py +++ b/src/htmltextview.py @@ -951,12 +951,15 @@ if __name__ == '__main__': ' <span style="font-size: 500%; font-family: serif">World</span>\n' '</div>\n') htmlview.print_real_text(None, xhtml='<hr />') + htmlview.print_real_text(None, xhtml='''<body xmlns='http://www.w3.org/1999/xhtml'><p xmlns='http://www.w3.org/1999/xhtml'>a:b<a href='http://google.com/' xmlns='http://www.w3.org/1999/xhtml'>Google</a></p><br/></body>''') htmlview.print_real_text(None, xhtml=''' + <body xmlns='http://www.w3.org/1999/xhtml'> <p style='font-size:large'> <span style='font-style: italic'>O<span style='font-size:larger'>M</span>G</span>, I'm <span style='color:green'>green</span> with <span style='font-weight: bold'>envy</span>! </p> + </body> ''') htmlview.print_real_text(None, xhtml='<hr />') htmlview.print_real_text(None, xhtml=''' -- GitLab