from unittest.mock import MagicMock import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk from gajim.common import app from gajim.common import configpaths configpaths.init() from gajim.common import caps_cache from gajim.conversation_textview import ConversationTextview from gajim.gui_interface import Interface caps_cache.capscache = MagicMock() app.plugin_manager = MagicMock() app.logger = MagicMock() app.interface = Interface() XHTML = [ '''

rexxnor: i nimes chum a...

''', '''
Hello
\n
\n World\n
\n ''', '''
''', '''

a:b Google


''', '''

O MG , I'm greenwith envy!

''', '''
''', ''' http://test.com/ testing links autolinkifying ''', '''
''', '''

As Emerson said in his essay Self-Reliance:

"A foolish consistency is the hobgoblin of little minds."

''', '''
''', '''

Hey, are you licensed to Jabber?

A License to Jabber

''', '''
''', '''
def fac(n):
        def faciter(n,acc):
        if n==0: return acc
        return faciter(n-1, acc*n)
        if n<0: raise ValueError('Must be non-negative')
        return faciter(n,1)
''', '''
''', '''
  1. One
  2. Two is nested:
  3. Three
''', '''
''', '''

xmpp link :

examples@example.org wrote:

this cite - bla bla bla, smile- :-) …

some text

#232/1

''', '''
''', '''
Larry ''', ] class TextviewWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="Textview Test") self.set_default_size(600, 600) self._textview = ConversationTextview(None) scrolled = Gtk.ScrolledWindow() scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolled.add(self._textview.tv) self.add(scrolled) self.show() self._print_xhtml() def _print_xhtml(self): for xhtml in XHTML: self._textview.print_real_text(None, xhtml=xhtml) win = TextviewWindow() win.connect("destroy", Gtk.main_quit) win.show_all() Gtk.main()