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 import gui gui.init('gtk') from gajim.common.helpers import AdditionalDataDict from gajim.conversation_textview import ConversationTextview from gajim.gui_interface import Interface app.settings = MagicMock() app.plugin_manager = MagicMock() app.logger = MagicMock() app.cert_store = MagicMock() app.storage = MagicMock() app.interface = Interface() XHTML = [ '''
Hello
\n
\n World\n
''', '''
''', '''

Look here Google


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

O MG , I'm green with envy!

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

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: additional_data = AdditionalDataDict() additional_data.set_value('gajim', 'xhtml', xhtml) self._textview.print_real_text(None, additional_data=additional_data) self._textview.print_real_text('\n') win = TextviewWindow() win.connect("destroy", Gtk.main_quit) win.show_all() Gtk.main()