fix printing HTML messages. Fixes #5298
This commit is contained in:
parent
b954492bc2
commit
ca127b8d31
2 changed files with 16 additions and 10 deletions
|
@ -1119,8 +1119,11 @@ class ConversationTextview(gobject.GObject):
|
||||||
# It's nothing special
|
# It's nothing special
|
||||||
if use_other_tags:
|
if use_other_tags:
|
||||||
end_iter = buffer_.get_end_iter()
|
end_iter = buffer_.get_end_iter()
|
||||||
buffer_.insert_with_tags_by_name(end_iter, special_text,
|
insert_tags_func = buffer_.insert_with_tags_by_name
|
||||||
*other_tags)
|
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:
|
if len(tags) > 0:
|
||||||
end_iter = buffer_.get_end_iter()
|
end_iter = buffer_.get_end_iter()
|
||||||
|
@ -1290,14 +1293,14 @@ class ConversationTextview(gobject.GObject):
|
||||||
graphics=True):
|
graphics=True):
|
||||||
'''this adds normal and special text. call this to add text'''
|
'''this adds normal and special text. call this to add text'''
|
||||||
if xhtml:
|
if xhtml:
|
||||||
try:
|
# try:
|
||||||
if name and (text.startswith('/me ') or text.startswith('/me\n')):
|
if name and (text.startswith('/me ') or text.startswith('/me\n')):
|
||||||
xhtml = xhtml.replace('/me', '<i>* %s</i>' % (name,), 1)
|
xhtml = xhtml.replace('/me', '<i>* %s</i>' % (name,), 1)
|
||||||
self.tv.display_html(xhtml.encode('utf-8'), self)
|
self.tv.display_html(xhtml.encode('utf-8'), self)
|
||||||
return
|
return
|
||||||
except Exception, e:
|
# except Exception, e:
|
||||||
gajim.log.debug(str('Error processing xhtml') + str(e))
|
# gajim.log.debug(str('Error processing xhtml') + str(e))
|
||||||
gajim.log.debug(str('with |' + xhtml + '|'))
|
# gajim.log.debug(str('with |' + xhtml + '|'))
|
||||||
|
|
||||||
# /me is replaced by name if name is given
|
# /me is replaced by name if name is given
|
||||||
if name and (text.startswith('/me ') or text.startswith('/me\n')):
|
if name and (text.startswith('/me ') or text.startswith('/me\n')):
|
||||||
|
|
|
@ -951,12 +951,15 @@ if __name__ == '__main__':
|
||||||
' <span style="font-size: 500%; font-family: serif">World</span>\n'
|
' <span style="font-size: 500%; font-family: serif">World</span>\n'
|
||||||
'</div>\n')
|
'</div>\n')
|
||||||
htmlview.print_real_text(None, xhtml='<hr />')
|
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='''
|
htmlview.print_real_text(None, xhtml='''
|
||||||
|
<body xmlns='http://www.w3.org/1999/xhtml'>
|
||||||
<p style='font-size:large'>
|
<p style='font-size:large'>
|
||||||
<span style='font-style: italic'>O<span style='font-size:larger'>M</span>G</span>,
|
<span style='font-style: italic'>O<span style='font-size:larger'>M</span>G</span>,
|
||||||
I'm <span style='color:green'>green</span>
|
I'm <span style='color:green'>green</span>
|
||||||
with <span style='font-weight: bold'>envy</span>!
|
with <span style='font-weight: bold'>envy</span>!
|
||||||
</p>
|
</p>
|
||||||
|
</body>
|
||||||
''')
|
''')
|
||||||
htmlview.print_real_text(None, xhtml='<hr />')
|
htmlview.print_real_text(None, xhtml='<hr />')
|
||||||
htmlview.print_real_text(None, xhtml='''
|
htmlview.print_real_text(None, xhtml='''
|
||||||
|
|
Loading…
Add table
Reference in a new issue